These block tokens are defined in the CommonMark specification.
mistletoe.block_tokens.
Document
Bases: mistletoe.base_elements.BlockToken
mistletoe.base_elements.BlockToken
Document container.
children (List[mistletoe.base_elements.Token]) – Child tokens list
link_definitions (dict) – Mapping of keys to (url, title)
front_matter (mistletoe.block_tokens.FrontMatter, NoneType) – Front matter YAML block (default: None)
read
Read a document
lines – Lines or string to parse
start_line – The initial line (used for nested parsing)
reset_definitions – remove any previously stored link_definitions
store_definitions – store LinkDefinitions or ignore them
front_matter – search for an initial YAML block front matter block (note this is not strictly CommonMark compliant)
Heading
Heading token. ([“### some heading ###n”])
Boundary between span-level and block-level tokens.
level (int) – Heading level
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).
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.
SetextHeading
Setext headings.
Not included in the parsing process, but returned by Paragraph.read.
Paragraph
Paragraph token. ([“somen”, “continuousn”, “linesn”])
Quote
Quote token. ([“> # headingn”, “> paragraphn”]).
BlockCode
Indented code.
language (str) – The code language (for sytax highlighting) (default: “”)
CodeFence
Code fence. ([“`sh\n", "rm -rf /", ..., "`”])
`sh\n", "rm -rf /", ..., "`
arguments (str) – Any string occuring after the language (default: “”)
List
List token (unordered or ordered)
loose (bool) – Whether list items are separated by blank lines
start_at (int, NoneType) – None if unordered, starting number if ordered.
ListItem
List items.
Not included in the parsing process, but called by List.
leader (str) – The prefix number or bullet point.
prepend (Any) –
next_marker (Any) –
parse_marker
Returns a pair (prepend, leader) if the line has a valid leader.
LinkDefinition
LinkDefinition token: [ref]: url “title”
definitions (list) – list of (label, dest, title)
ThematicBreak
Thematic break token (a.k.a. horizontal rule.)
HTMLBlock
Block-level HTML token.
content (str) – literal strings rendered as-is