Skip to main content

Crate lsdocs_doctree

Crate lsdocs_doctree 

Source
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 type field, 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::Section whose first child is the title Heading, with subsections nested inside it. A section’s anchor id is Section::id; Heading::id is 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.
BlockQuote
See Node::BlockQuote.
Caption
See Node::Caption.
CodeBlock
See Node::CodeBlock.
Custom
See Node::Custom.
DefinitionDescription
See Node::DefinitionDescription.
DefinitionList
See Node::DefinitionList.
DefinitionTerm
See Node::DefinitionTerm.
Descendants
Depth-first iterator returned by Document::descendants and Node::descendants.
Document
A parsed source document.
Emphasis
See Node::Emphasis.
Figure
See Node::Figure.
FootnoteDefinition
See Node::FootnoteDefinition.
FootnoteReference
See Node::FootnoteReference.
Heading
See Node::Heading.
Image
See Node::Image.
InlineCode
See Node::InlineCode.
LineBreak
See Node::LineBreak.
Link
See Node::Link.
LinkTarget
The site-internal destination of a Link.
List
See Node::List.
ListItem
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.
TableCell
See Node::TableCell.
TableRow
See Node::TableRow.
Text
See Node::Text.
ThematicBreak
See Node::ThematicBreak.

Enums§

Align
Horizontal alignment of a table column.
Node
A node in the document tree.

Functions§

plain_text
The text of nodes without markup: text, inline code and image alt text, in order.
text
Shorthand for a Text node.

Type Aliases§

Metadata
Document-level metadata, such as front matter.
Value
An arbitrary structured value, as found in front matter or plugin data.