These tokens do not form part of the core CommonMark specification, but are commonly implemented extended syntax elements.
mistletoe.span_tokens_ext.
Strikethrough
Bases: mistletoe.base_elements.SpanToken
mistletoe.base_elements.SpanToken
Strikethrough tokens: ~~some text~~.
Must be parsed after CoreTokens.
find
Find all tokens, matching a pattern in the given string
Math
Dollar Math tokens (single or double): $a=1$.
mistletoe.block_tokens.
FrontMatter
Bases: mistletoe.base_elements.BlockToken
mistletoe.base_elements.BlockToken
Front matter YAML block, on the first line of the document.
--- a: b c: d ---
NOTE: The content of the block should be valid YAML, but its parsing (and hence syntax testing) is deferred to the renderers. This is so that, given ‘bad’ YAML, the rest of the of document will still be parsed, and then the renderers can apply there own error reporting.
Not included in the parsing process, but called by Document.read, if front_matter=True.
content (str) – Source text (should be valid YAML)
position (Tuple[int, int]) – Line position in source text (start, end)
start
Takes a line from the document as argument, and returns a boolean representing whether that line marks the start of the current token. Every subclass of BlockToken must define a start function (see block_tokenizer.tokenize_main).
read
takes the rest of the lines in the document as an iterator (including the start line), and consumes all the lines that should be read into this token.
The default is to stop at an empty line.
mistletoe.block_tokens_ext.
Table
Table token.
Note: header delimiters must be of at least length 3 (—)
Example:
| Left Align | Centered | Right Align | | :--- | :----: | ---: | | Header | Title | Here's this | | Paragraph | Text | And more |
children (List[mistletoe.block_tokens_ext.TableRow]) – Child tokens list
header (mistletoe.block_tokens_ext.TableRow, NoneType) – The header row
column_align (list) – align options for columns (left=None (default), center=0, right=1)
split_delimiter
Helper function; returns a list of align options.
delimiter – e.g.: | :— | :—: | —: |
a list of align options (None, 0 or 1).
parse_align
Helper function; returns align option from cell content.
None if align = left; 0 if align = center; 1 if align = right.
TableRow
Table row token.
children (List[mistletoe.block_tokens_ext.TableCell]) – Child tokens list
row_align (list) – align options for columns (left=None (default), center=0, right=1)
TableCell
Table cell token.
Boundary between span-level and block-level tokens.
children (List[mistletoe.base_elements.Token]) – Child tokens list
align (int, NoneType) – align options for the cell (left=None (default), center=0, right=1)