class documentation

class InlineProcessor(Treeprocessor): (source)

View In Hierarchy

A Treeprocessor that traverses a tree, applying inline patterns.

Method __init__ Undocumented
Method run Apply inline patterns to a parsed Markdown tree.
Instance Variable ancestors Undocumented
Instance Variable inlinePatterns Undocumented
Instance Variable md Undocumented
Instance Variable parent_map Undocumented
Instance Variable stashed_nodes Undocumented
Method __applyPattern Check if the line fits the pattern, create the necessary elements, add it to stashed_nodes.
Method __build_ancestors Build the ancestor list.
Method __findPlaceholder Extract id from data string, start from index
Method __handleInline Process string with inline patterns and replace it with placeholders
Method __makePlaceholder Generate a placeholder
Method __processElementText Process placeholders in Element.text or Element.tail of Elements popped from self.stashed_nodes.
Method __processPlaceholders Process string with placeholders and generate ElementTree tree.
Method __stashNode Add node to stash
Instance Variable __placeholder_length Undocumented
Instance Variable __placeholder_prefix Undocumented
Instance Variable __placeholder_re Undocumented
Instance Variable __placeholder_suffix Undocumented
def __init__(self, md): (source)

Undocumented

def run(self, tree, ancestors=None): (source)

Apply inline patterns to a parsed Markdown tree. Iterate over ElementTree, find elements with inline tag, apply inline patterns and append newly created Elements to tree. If you don't want to process your data with inline patterns, instead of normal string, use subclass AtomicString: node.text = markdown.AtomicString("This will not be processed.") Arguments: * tree: ElementTree object, representing Markdown tree. * ancestors: List of parent tag names that precede the tree node (if needed). Returns: ElementTree object with applied inline patterns.

ancestors = (source)

Undocumented

inlinePatterns = (source)

Undocumented

Undocumented

parent_map = (source)

Undocumented

stashed_nodes: dict = (source)

Undocumented

def __applyPattern(self, pattern, data, patternIndex, startIndex=0): (source)

Check if the line fits the pattern, create the necessary elements, add it to stashed_nodes. Keyword arguments: * data: the text to be processed * pattern: the pattern to be checked * patternIndex: index of current pattern * startIndex: string index, from which we start searching Returns: String with placeholders instead of ElementTree elements.

def __build_ancestors(self, parent, parents): (source)

Build the ancestor list.

def __findPlaceholder(self, data, index): (source)

Extract id from data string, start from index Keyword arguments: * data: string * index: index, from which we start search Returns: placeholder id and string index, after the found placeholder.

def __handleInline(self, data, patternIndex=0): (source)

Process string with inline patterns and replace it with placeholders Keyword arguments: * data: A line of Markdown text * patternIndex: The index of the inlinePattern to start with Returns: String with placeholders.

def __makePlaceholder(self, type): (source)

Generate a placeholder

def __processElementText(self, node, subnode, isText=True): (source)

Process placeholders in Element.text or Element.tail of Elements popped from self.stashed_nodes. Keywords arguments: * node: parent node * subnode: processing node * isText: bool variable, True - it's text, False - it's tail Returns: None

def __processPlaceholders(self, data, parent, isText=True): (source)

Process string with placeholders and generate ElementTree tree. Keyword arguments: * data: string with placeholders instead of ElementTree elements. * parent: Element, which contains processing inline data Returns: list with ElementTree elements with applied inline patterns.

def __stashNode(self, node, type): (source)

Add node to stash

__placeholder_length = (source)

Undocumented

__placeholder_prefix = (source)

Undocumented

__placeholder_re = (source)

Undocumented

__placeholder_suffix = (source)

Undocumented