Expand description
docling’s item tree, for a backend that knows the exact shape upstream gives a document and wants the JSON export to reproduce it.
DoclingDocument::nodes is a flat,
reading-order stream tuned for Markdown / DocLang / LaTeX; the JSON export
rebuilds docling’s parent/child structure from it with generic rules (runs
of list items become list groups, a heading is a flat sibling of the text
that follows it). Upstream’s backends do not all agree on that structure:
the HTML backend nests everything after a heading under the heading,
splits a paragraph of mixed formatting into an inline group of one text
item per formatting run, parents a rich table cell’s content to a group
under the table, keeps site chrome on the furniture layer… and numbers
every item in the order it creates them. A backend that ports those
rules call-for-call (HTML’s html_tree.rs, DOCX’s docx_tree.rs) records
the result here — an arena of items in
creation order, each with its parent and children — and the JSON export
(DoclingDocument::export_to_json)
serializes this tree instead of deriving one from the nodes. Every other
serializer keeps reading the flat nodes, so their output is unaffected.
Structs§
- Formatting
- docling-core’s
Formatting: the inline styles an item carries in JSON. - Item
Tree - docling’s item tree in creation order (see the module docs).
- List
Meta - A
list_item’s docling fields. - Source
Block - A block of the source document (#903, #904): the original element an item was made from — or one that produced no item, with the reason — so a caller can tie converted items back to the source, tell two identical texts apart, and read a block’s text on its own terms, free of any serializer’s separators.
- Source
Element - An element of the source that is not a block but carries an
idor aclass(#910): a container — the<div id="art_23">an article’s paragraphs sit in — so an excerpt selected by a container’s identity resolves to a path and, throughItemTree::blocks_under, to the blocks inside it. A block’s own identity is on the block. - Source
Inline - An inline element inside a
SourceBlock(#911): where its text sits in the block’s, so a caller can select or leave out the text of one element — not a whole block — by what the source says about it. - Source
Text Builder - Builds a
SourceBlock’s normalized text while recording the inline elements’ ranges in it (#911) — for a backend walking its source: text nodes throughpush_text, a line break as whitespace, an inline element betweenopen_inlineandclose_inline. Whitespace runs collapse to one space, the text is trimmed, and a range never starts with the space that separates it from what precedes. - Tree
Item - One item of an
ItemTree. - Tree
Note - A note call inside a text item (
TreeItem::notes). - Tree
Prov - docling’s
ProvenanceItemfor a tree item, written verbatim: the backend’s own geometry in the page’s units — a PPTX shape’s EMU box, whosepagesentry is the slide size in EMU — rather than the 0–511 DocLang grid the flatNode::Locatedcarries (which cannot round-trip those integers). - Tree
Track - docling’s
TrackSource— where in a time-based track (a WebVTT cue) a text item came from. Written as the item’ssource: [{"kind": "track", …}].
Enums§
- Block
Omission - Why a
SourceBlockproduced no item. - Tree
Kind - What an item in the tree is. Mirrors the docling-core item classes the
JSON
texts/groups/tables/pictures/field_regionsbuckets hold.