Module

parsing.ast.types

Type definitions for markdown AST nodes (mistune-compatible).

Classes

BaseNode 2
Common fields for all AST nodes.

Common fields for all AST nodes.

Attributes

Name Type Description
children list[ASTNode]
attrs dict[str, str]
TextNode 2
Plain text content.

Plain text content.

Attributes

Name Type Description
type Literal['text']
raw str
CodeSpanNode 2
Inline code.

Inline code.

Attributes

Name Type Description
type Literal['codespan']
raw str
HeadingNode 4
Heading (h1-h6).

Heading (h1-h6).

Attributes

Name Type Description
type Literal['heading']
level int
children list[ASTNode]
attrs NotRequired[dict[str, str]]
ParagraphNode 2
Paragraph block.

Paragraph block.

Attributes

Name Type Description
type Literal['paragraph']
children list[ASTNode]
CodeBlockNode 3
Fenced code block.

Fenced code block.

Attributes

Name Type Description
type Literal['block_code']
raw str
info str | None
ListNode 3
Ordered or unordered list.

Ordered or unordered list.

Attributes

Name Type Description
type Literal['list']
ordered bool
children list[ListItemNode]
ListItemNode 2
List item.

List item.

Attributes

Name Type Description
type Literal['list_item']
children list[ASTNode]
BlockquoteNode 2
Blockquote.

Blockquote.

Attributes

Name Type Description
type Literal['block_quote']
children list[ASTNode]
LinkNode 4
Hyperlink.

Hyperlink.

Attributes

Name Type Description
type Literal['link']
url str
title str | None
children list[ASTNode]
ImageNode 4
Image.

Image.

Attributes

Name Type Description
type Literal['image']
src str
alt str
title str | None
EmphasisNode 2
Emphasis (italic).

Emphasis (italic).

Attributes

Name Type Description
type Literal['emphasis']
children list[ASTNode]
StrongNode 2
Strong (bold).

Strong (bold).

Attributes

Name Type Description
type Literal['strong']
children list[ASTNode]
ThematicBreakNode 1
Horizontal rule / thematic break.

Horizontal rule / thematic break.

Attributes

Name Type Description
type Literal['thematic_break']
SoftBreakNode 1
Soft line break.

Soft line break.

Attributes

Name Type Description
type Literal['softbreak']
HardBreakNode 1
Hard line break.

Hard line break.

Attributes

Name Type Description
type Literal['linebreak']
RawHTMLNode 2
Pre-rendered HTML block. Used for: - Directive output (code blocks, admonitions, tabs) - Virtual p…

Pre-rendered HTML block.

Used for:

  • Directive output (code blocks, admonitions, tabs)
  • Virtual page content (page._prerendered_html)
  • External embeds
  • Any content that bypasses markdown parsing

Attributes

Name Type Description
type Literal['raw_html']
content str

Functions

is_heading 1 bool
Type guard for heading nodes.
def is_heading(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
is_text 1 bool
Type guard for text nodes.
def is_text(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
is_code_block 1 bool
Type guard for code block nodes.
def is_code_block(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
is_link 1 bool
Type guard for link nodes.
def is_link(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
is_image 1 bool
Type guard for image nodes.
def is_image(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
is_raw_html 1 bool
Type guard for raw HTML nodes.
def is_raw_html(node: ASTNode) -> bool
Parameters
Name Type Description
node ASTNode
Returns
bool
get_heading_level 1 int | None
Get heading level if node is a heading.
def get_heading_level(node: ASTNode) -> int | None
Parameters
Name Type Description
node ASTNode
Returns
int | None
get_node_text 1 str
Extract text content from a node.
def get_node_text(node: ASTNode) -> str
Parameters
Name Type Description
node ASTNode
Returns
str