Classes
Node
1
▼
Base class for all AST nodes.
All nodes track their source location for error messages and debuggi…
Node
1
▼
Base class for all AST nodes.
All nodes track their source location for error messages and debugging.
Attributes
| Name | Type | Description |
|---|---|---|
location |
SourceLocation
|
— |
Text
1
▼
Plain text content.
The most common inline node, representing literal text.
Text
1
▼
Plain text content.
The most common inline node, representing literal text.
Attributes
| Name | Type | Description |
|---|---|---|
content |
str
|
— |
Emphasis
1
▼
Emphasized (italic) text.
Markdown: *text* or _text_
HTML: <em>text</em>
Emphasis
1
▼
Emphasized (italic) text.
Markdown: text or text HTML: text
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Inline, ...]
|
— |
Strong
1
▼
Strong (bold) text.
Markdown: **text** or __text__
HTML: <strong>text</strong>
Strong
1
▼
Strong (bold) text.
Markdown: text or text HTML: text
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Inline, ...]
|
— |
Link
3
▼
Hyperlink.
Markdown: [text](url "title") or [text][ref]
HTML: <a href="url" title="title">text</a>
Link
3
▼
Image
3
▼
Image.
Markdown: 
HTML: <img src="url" alt="alt" title="title">
Image
3
▼
Image.
Markdown:
HTML:
Attributes
| Name | Type | Description |
|---|---|---|
url |
str
|
— |
alt |
str
|
— |
title |
str | None
|
— |
CodeSpan
1
▼
Inline code.
Markdown: `code`
HTML: <code>code</code>
CodeSpan
1
▼
Inline code.
Markdown:code
HTML:code
Attributes
| Name | Type | Description |
|---|---|---|
code |
str
|
— |
LineBreak
0
▼
Hard line break.
Markdown: ``\`` at end of line or two trailing spaces
HTML: <br />
LineBreak
0
▼
Hard line break.
Markdown:\at end of line or two trailing spaces
HTML:
SoftBreak
0
▼
Soft line break (single newline in paragraph).
Typically rendered as a space or newline depending …
SoftBreak
0
▼
Soft line break (single newline in paragraph).
Typically rendered as a space or newline depending on renderer settings.
HtmlInline
1
▼
Inline raw HTML.
Markdown: <span>text</span>
HTML: passed through unchanged
HtmlInline
1
▼
Inline raw HTML.
Markdown: text HTML: passed through unchanged
Attributes
| Name | Type | Description |
|---|---|---|
html |
str
|
— |
Role
3
▼
Inline role (MyST syntax).
Markdown: {role}`content`
Example: {ref}`target`, {kbd}`Ctrl+C`
Role
3
▼
Inline role (MyST syntax).
Markdown: content Example: target, Ctrl+C
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
content |
str
|
— |
target |
str | None
|
— |
Strikethrough
1
▼
Strikethrough (deleted) text.
Markdown: ~~deleted~~
HTML: <del>deleted</del>
Strikethrough
1
▼
Strikethrough (deleted) text.
Markdown: deleted
HTML: deleted
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Inline, ...]
|
— |
Math
1
▼
Inline math expression.
Markdown: $E = mc^2$
HTML: <span class="math">E = mc^2</span>
Math
1
▼
Inline math expression.
Markdown: $E = mc^2$ HTML: E = mc^2
Attributes
| Name | Type | Description |
|---|---|---|
content |
str
|
— |
FootnoteRef
1
▼
Footnote reference.
Markdown: [^1] or [^note]
HTML: <sup><a href="#fn-1">1</a></sup>
FootnoteRef
1
▼
Footnote reference.
Markdown: [^1] or [^note] HTML: 1
Attributes
| Name | Type | Description |
|---|---|---|
identifier |
str
|
— |
Heading
4
▼
ATX or setext heading.
Markdown: # Heading or Heading
======
HTML: <h1>Heading</h1>
S…
Heading
4
▼
ATX or setext heading.
Markdown: # Heading or Heading
====== HTML:
Heading
Supports MyST-compatible explicit anchor syntax: ## Title {#custom-id}
The {#id} is parsed during lexing and stored in explicit_id.
Attributes
| Name | Type | Description |
|---|---|---|
level |
Literal[1, 2, 3, 4, 5, 6]
|
— |
children |
tuple[Inline, ...]
|
— |
style |
Literal['atx', 'setext']
|
— |
explicit_id |
str | None
|
— |
Paragraph
1
▼
Paragraph block.
Markdown: Text separated by blank lines
HTML: <p>text</p>
Paragraph
1
▼
Paragraph block.
Markdown: Text separated by blank lines HTML:
text
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Inline, ...]
|
— |
FencedCode
8
▼
Fenced code block with zero-copy source reference.
BREAKING CHANGE (v0.4.0):
Previous: code: s…
FencedCode
8
▼
Fenced code block with zero-copy source reference.
BREAKING CHANGE (v0.4.0): Previous: code: str (extracted content) Current: source_start/source_end indices into original source
Migration:
Old: block.code
New: block.get_code(source)
For nested contexts (e.g., fenced code inside block quotes), the content_override field stores the actual code content directly since the source offsets would be relative to a sub-parser's source.
Attributes
| Name | Type | Description |
|---|---|---|
source_start |
int
|
— |
source_end |
int
|
— |
info |
str | None
|
— |
marker |
Literal['`', '~']
|
— |
fence_indent |
int
|
— |
content_override |
str | None
|
— |
Methods
get_code
1
str
▼
Extract code content (creates new string).
CommonMark: strips up to fence_inde…
get_code
1
str
▼
def get_code(self, source: str) -> str
Extract code content (creates new string).
CommonMark: strips up to fence_indent spaces from each content line.
Parameters
| Name | Type | Description |
|---|---|---|
source |
— |
Returns
str
code_length
0
int
▼
Length of code content without allocation.
code_length
0
int
▼
def code_length(self) -> int
Returns
int
IndentedCode
1
▼
Indented code block (4+ spaces).
Markdown: ····code
HTML: <pre><code>code</code></pre>
IndentedCode
1
▼
Indented code block (4+ spaces).
Markdown: ····code HTML:
code
Attributes
| Name | Type | Description |
|---|---|---|
code |
str
|
— |
BlockQuote
1
▼
Block quote.
Markdown: > quoted text
HTML: <blockquote>text</blockquote>
BlockQuote
1
▼
Block quote.
Markdown: > quoted text HTML:
text
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Block, ...]
|
— |
ListItem
2
▼
List item.
Markdown: - item or 1. item
HTML: <li>item</li>
ListItem
2
▼
List item.
Markdown: - item or 1. item HTML:
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Block, ...]
|
— |
checked |
bool | None
|
— |
List
4
▼
Ordered or unordered list.
Markdown: - item or 1. item
HTML: <ul>/<ol> with <li> children
List
4
▼
Ordered or unordered list.
Markdown: - item or 1. item HTML:
- /
- children
- with
Attributes
| Name | Type | Description |
|---|---|---|
items |
tuple[ListItem, ...]
|
— |
ordered |
bool
|
— |
start |
int
|
— |
tight |
bool
|
— |
ThematicBreak
0
▼
Thematic break (horizontal rule).
Markdown: --- or *** or ___
HTML: <hr />
ThematicBreak
0
▼
Thematic break (horizontal rule).
Markdown: --- or *** or ___ HTML:
HtmlBlock
1
▼
Raw HTML block.
Markdown: HTML that starts a block
HTML: passed through unchanged
HtmlBlock
1
▼
Raw HTML block.
Markdown: HTML that starts a block HTML: passed through unchanged
Attributes
| Name | Type | Description |
|---|---|---|
html |
str
|
— |
Directive
5
▼
Block directive (MyST syntax).
Markdown: :::{name} title
:option: value
content
:::
Gener…
Directive
5
▼
Block directive (MyST syntax).
Markdown: :::{name} title
:option: value content :::
Generic over options type for full type safety. Use Directive[YourOptions]
to get typed options access in handlers.
PEP 695 Note:
Uses Python 3.12+ type parameter syntax: `class Directive[TOptions: DirectiveOptions]`
instead of the older `class Directive(Node, Generic[TOptions])` with TypeVar.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
title |
str | None
|
— |
options |
TOptions
|
— |
children |
tuple[Block, ...]
|
— |
raw_content |
str | None
|
— |
Document
1
▼
Root document node.
Contains all top-level blocks in the document.
Document
1
▼
Root document node.
Contains all top-level blocks in the document.
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Block, ...]
|
— |
TableCell
3
▼
Table cell (th or td).
Markdown: | cell content |
HTML: <td>cell content</td> or <th>cell content<…
TableCell
3
▼
Table cell (th or td).
Markdown: | cell content | HTML:
Attributes
| Name | Type | Description |
|---|---|---|
children |
tuple[Inline, ...]
|
— |
is_header |
bool
|
— |
align |
Literal['left', 'center', 'right'] | None
|
— |
TableRow
2
▼
Table row.
Markdown: | cell1 | cell2 |
HTML: <tr><td>cell1</td><td>cell2</td></tr>
TableRow
2
▼
Table row.
Markdown: | cell1 | cell2 | HTML:
Attributes
| Name | Type | Description |
|---|---|---|
cells |
tuple[TableCell, ...]
|
— |
is_header |
bool
|
— |
Table
3
▼
Table (GFM-style).
Markdown:
| A | B |
|---|---|
| 1 | 2 |
HTML: <table>...</table>
Table
3
▼
Table (GFM-style).
Markdown:
| A | B |
|---|---|
| 1 | 2 |
HTML:
Attributes
| Name | Type | Description |
|---|---|---|
head |
tuple[TableRow, ...]
|
— |
body |
tuple[TableRow, ...]
|
— |
alignments |
tuple[Literal['left', 'center', 'right'] | None, ...]
|
— |
MathBlock
1
▼
Block math expression.
Markdown:
$$
E = mc^2
$$
HTML: <div class="math-block">E = mc^…
MathBlock
1
▼
Block math expression.
Markdown:
$$
E = mc^2
$$
HTML:
Attributes
| Name | Type | Description |
|---|---|---|
content |
str
|
— |
FootnoteDef
2
▼
Footnote definition.
Markdown: [^1]: Footnote content here.
HTML: (rendered in footnotes section)
FootnoteDef
2
▼
Footnote definition.
Markdown: [^1]: Footnote content here. HTML: (rendered in footnotes section)
Attributes
| Name | Type | Description |
|---|---|---|
identifier |
str
|
— |
children |
tuple[Block, ...]
|
— |