class documentation

class AbbrPreprocessor(BlockProcessor): (source)

View In Hierarchy

Abbreviation Preprocessor - parse text for abbr references.

Method run Find and remove all Abbreviation references from the text. Each reference is set as a new AbbrPattern in the markdown instance.
Method test Test for block type. Must be overridden by subclasses.
Constant RE Undocumented
Method _generate_pattern Given a string, returns an regex pattern to match that string.

Inherited from BlockProcessor:

Method __init__ Undocumented
Method detab Remove a tab from the front of each line of the given text.
Method lastChild Return the last child of an etree element.
Method looseDetab Remove a tab from front of lines but allowing dedented lines.
Instance Variable parser Undocumented
Instance Variable tab_length Undocumented
def run(self, parent, blocks): (source)

Find and remove all Abbreviation references from the text. Each reference is set as a new AbbrPattern in the markdown instance.

def test(self, parent, block): (source)

Test for block type. Must be overridden by subclasses. As the parser loops through processors, it will call the ``test`` method on each to determine if the given block of text is of that type. This method must return a boolean ``True`` or ``False``. The actual method of testing is left to the needs of that particular block type. It could be as simple as ``block.startswith(some_string)`` or a complex regular expression. As the block type may be different depending on the parent of the block (i.e. inside a list), the parent etree element is also provided and may be used as part of the test. Keywords: * ``parent``: A etree element which will be the parent of the block. * ``block``: A block of text from the source which has been split at blank lines.

Undocumented

Value
re.compile(r'^\*\[(?P<abbr>[^\]]*)\] ?: *\n? *(?P<title>.*)$',
           re.MULTILINE)
def _generate_pattern(self, text): (source)

Given a string, returns an regex pattern to match that string. 'HTML' -> r'(?P<abbr>[H][T][M][L])' Note: we force each char as a literal match (in brackets) as we don't know what they will be beforehand.