Skip to content
lsdocs

The document tree #

A document is a map with its source path (relative to the source directory, with /), its metadata (front matter) and its children. Nodes are maps with a type and that type's fields; every node may have a span, the byte range (start, end exclusive) of the source it came from. The JSON Schema is schema/doctree/document.json in the repository.

Blocks #

TypeFieldsChildren
sectionidA heading, then the section's content and subsections.
headinglevel (1 to 6), id (only outside a section title)Inlines.
paragraphInlines.
listordered, startlist_items.
list_itemchecked (task lists)Blocks.
block_quoteBlocks.
code_blocklanguage, info, value
tablealign (per column: none, left, center, right)table_rows.
table_rowheadertable_cells.
table_cellInlines or blocks.
thematic_break
admonitionkind (note, warning, ...), titleBlocks.
definition_listdefinition_terms, each followed by definition_descriptions.
footnote_definitionlabelBlocks.
figureidAn image (or other content), then an optional caption.
mathvalue, display
rawformat (html), value

Inlines #

TypeFieldsChildren
textvalue
emphasis, strongInlines.
inline_codevalue
linkurl, title, targetInlines (none: the target's title is filled in).
imageurl, alt, title
line_break
footnote_referencelabel
anchorid

math and raw are also inlines.

Custom nodes #

custom nodes have a kind, free-form attrs and children: plugin-defined content, such as diagrams, that other plugins turn into core nodes or render. Transformers select them as custom:<kind>.

Parsers make some by convention:

  • A directive (.. name:: in reStructuredText, a ```{name} fence in Markdown) is a custom node of its name, with the attributes argument, options and content. For directives a plugin declares, content that is markup is parsed into the children instead, and an argument that is markup is parsed into a first child of kind directive_argument.
  • A role a plugin declares (:name:`text`, or {name}`text` in Markdown) is a custom node of kind role with the attributes name and text, and the text as its child.

Renderers draw a custom node they don't know as a block holding its children, or, if its attribute inline is true, as an inline element (render-html uses a span, or the element html_tag names, with title as its title). render-html shows a block one with a text content attribute (a directive nobody declared) in a warning, with its argument, options and content, so they are not lost.

Ids #

Parsers set only the ids authors wrote. lsdocs then gives every other section, and every heading outside a section title, the slug of its title: lowercase, letters and digits kept, every other run of characters one -, made unique in the document with -1, -2, ...