class documentation

class Rule(object): (source)

View In Hierarchy

Class that defines a single parser rule. Typically used to define a regex pattern for one specific wiki format string and the processing to be done when this formatting is encountered in the text.
Method __init__ No summary
Method __or__ Allow new parsers to be constructed by combining parser objects with the "|" operator.
Method __repr__ Undocumented
Instance Variable decent optional function (or object) to recursively parse the text matched by this rule. Called in the same way as process.
Instance Variable descent Undocumented
Instance Variable pattern the regular expression for this parser as string
Instance Variable process function (or object) to process matched text, or None The function should take a Builder object as first argument, followed by one or more parameters for matched groups in the regular expression. If the regex pattern has no capturing groups this function is called with the whole match. The default function will use the tag and descent attributes
Instance Variable tag Builder tag for result of this rule. Used by the default process method.
Method _process Undocumented
Instance Variable _re Undocumented
def __init__(self, tag, pattern, process=None, descent=None): (source)
Constructor
Parameters
tagBuilder tag for result of this rule. Used by the default process method.
patternregex pattern as string
processoptional function to process matched text
descentoptional function to recursively parse matched text
def __or__(self, other): (source)
Allow new parsers to be constructed by combining parser objects with the "|" operator.
def __repr__(self): (source)

Undocumented

decent = (source)
optional function (or object) to recursively parse the text matched by this rule. Called in the same way as process.
descent = (source)

Undocumented

pattern = (source)
the regular expression for this parser as string
process = (source)
function (or object) to process matched text, or None The function should take a Builder object as first argument, followed by one or more parameters for matched groups in the regular expression. If the regex pattern has no capturing groups this function is called with the whole match. The default function will use the tag and descent attributes
Builder tag for result of this rule. Used by the default process method.
def _process(self, builder, text): (source)

Undocumented

Undocumented