Expand description
Document tree (AST) types: nodes, spans and metadata.
A Document is what a parser produces and what transformers and
renderers consume. Every type here crosses process boundaries, so the
serialized shape is part of the public API:
- Nodes are tagged by a
typefield, e.g.{"type": "heading", "level": 1, "children": [...]}. - Field names are
snake_case. - Optional fields are omitted when empty, and unknown fields are ignored when reading, so new fields can be added without breaking older plugins.
Formats without a core node kind use Node::Custom.
§The shape every parser produces
Parsers for any source format hand transformers the same shape:
- Sections nest. Content under a title is wrapped in a
Node::Sectionwhose first child is the titleHeading, with subsections nested inside it. A section’s anchor id isSection::id;Heading::idis only for headings outside the section tree (e.g. inside a block quote). Content before the first title stays at the top level. - Ids are explicit or left out. Parsers set ids the author wrote
(e.g.
{#id}in Markdown, labels in reStructuredText). The host gives every other section a unique id derived from its title after parsing. - Cross-document links carry a
LinkTarget. The host fills it in for relative links to other documents; parsers set it for references that are not paths, such as labels.
Structs§
- Admonition
- See
Node::Admonition. - Anchor
- See
Node::Anchor. - Block
Quote - See
Node::BlockQuote. - Caption
- See
Node::Caption. - Code
Block - See
Node::CodeBlock. - Custom
- See
Node::Custom. - Definition
Description - See
Node::DefinitionDescription. - Definition
List - See
Node::DefinitionList. - Definition
Term - See
Node::DefinitionTerm. - Descendants
- Depth-first iterator returned by
Document::descendantsandNode::descendants. - Document
- A parsed source document.
- Emphasis
- See
Node::Emphasis. - Figure
- See
Node::Figure. - Footnote
Definition - See
Node::FootnoteDefinition. - Footnote
Reference - See
Node::FootnoteReference. - Heading
- See
Node::Heading. - Image
- See
Node::Image. - Inline
Code - See
Node::InlineCode. - Line
Break - See
Node::LineBreak. - Link
- See
Node::Link. - Link
Target - The site-internal destination of a
Link. - List
- See
Node::List. - List
Item - See
Node::ListItem. - Math
- See
Node::Math. - Paragraph
- See
Node::Paragraph. - Raw
- See
Node::Raw. - Section
- See
Node::Section. - Span
- A byte range within the document’s source text.
- Strong
- See
Node::Strong. - Table
- See
Node::Table. - Table
Cell - See
Node::TableCell. - Table
Row - See
Node::TableRow. - Text
- See
Node::Text. - Thematic
Break - See
Node::ThematicBreak.
Enums§
Functions§
- plain_
text - The text of
nodeswithout markup: text, inline code and image alt text, in order. - text
- Shorthand for a
Textnode.