treeprocessors
Markdown Treeprocessors.
Classes
Treeprocessor(markdown_instance=None)
Bases: Processor
Treeprocessors are run on the ElementTree object before serialization.
Each Treeprocessor implements a "run" method that takes a pointer to an ElementTree, modifies it as necessary and returns an ElementTree object.
Treeprocessors must extend markdown.Treeprocessor.
Source code in pyrevitlib/pyrevit/coreutils/markdown/util.py
Attributes
markdown = markdown_instance
instance-attribute
Functions
run(root)
Main treeprocessor method.
Subclasses of Treeprocessor should implement a run
method, which
takes a root ElementTree. This method can return another ElementTree
object, and the existing root ElementTree will be replaced, or it can
modify the current tree and return None.
Source code in pyrevitlib/pyrevit/coreutils/markdown/treeprocessors.py
InlineProcessor(md)
Bases: Treeprocessor
A Treeprocessor that traverses a tree, applying inline patterns.
Source code in pyrevitlib/pyrevit/coreutils/markdown/treeprocessors.py
Attributes
markdown = md
instance-attribute
inlinePatterns = md.inlinePatterns
instance-attribute
Functions
run(tree)
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 paterns, instead of normal string, use subclass AtomicString:
node.text = markdown.AtomicString("This will not be processed.")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
ElementTree
|
Markdown tree. |
required |
Returns:
Type | Description |
---|---|
ElementTree
|
Tree with applied inline patterns. |
Source code in pyrevitlib/pyrevit/coreutils/markdown/treeprocessors.py
PrettifyTreeprocessor(markdown_instance=None)
Bases: Treeprocessor
Add linebreaks to the html document.
Source code in pyrevitlib/pyrevit/coreutils/markdown/util.py
Attributes
markdown = markdown_instance
instance-attribute
Functions
run(root)
Add linebreaks to ElementTree root object.
Source code in pyrevitlib/pyrevit/coreutils/markdown/treeprocessors.py
Functions
build_treeprocessors(md_instance, **kwargs)
Build the default treeprocessors for Markdown.