A tree representation of a linear markdown-it token stream.
- class markdown_it.tree.SyntaxTreeNode(tokens: Sequence[Token] = (), *, create_root: bool = True)#
A Markdown syntax tree node.
A class that can be used to construct a tree representation of a linear markdown-it-py token stream.
- Each node in the tree represents either:
root of the Markdown document
a single unnested Token
- a Token “_open” and “_close” token pair, and the tokens nested in
- attrGet(name: str) None | str | int | float #
Get the value of attribute name, or null if it does not exist.
- property content: str#
In a case of self-closing tag (code, html, fence, etc.), it has contents of this tag.
If it’s true, ignore this element when rendering. Used for tight lists to hide paragraphs.
- property is_nested: bool#
Is this node nested?.
Returns True if the node represents a Token pair and tokens in the sequence between them, where Token.nesting of the first Token in the pair is 1 and nesting of the other Token is -1.
- property next_sibling: _NodeType | None#
Get the next node in the sequence of siblings.
Returns None if this is the last sibling.
- pretty(*, indent: int = 2, show_text: bool = False, _current: int = 0) str #
Create an XML style string of the tree.
- property previous_sibling: _NodeType | None#
Get the previous node in the sequence of siblings.
Returns None if this is the first sibling.
- property siblings: Sequence[_NodeType]#
Get siblings of the node.
Gets the whole group of siblings, including self.
- property type: str#
Get a string type of the represented syntax.
“root” for root nodes
Token.type if the node represents an unnested token
- Token.type of the opening token, with “_open” suffix stripped, if
the node represents a nester token pair