Expand description
The block model as a Docling DoclingDocument (#629).
A pipeline built on Docling reads its documents through docling-core’s
DoclingDocument: it walks body, filters on label, cites prov and
asks the table for its grid. This writes that document from our blocks,
so such a pipeline can swap the converter and keep every line downstream of
it. crates/pdf-python/tests/test_docling_document.py loads what this
writes with docling-core’s own model and checks it comes back unchanged.
THE SCHEMA IS PINNED: DoclingDocument version SCHEMA_VERSION, as
docling-core DOCLING_CORE_VERSION writes it (MIT, the Docling project).
The test above installs exactly that version, so a schema that moves is a
decision somebody makes here and not a surprise in a customer’s pipeline.
WHAT MAPS, block kind by block kind:
- a paragraph is a
textitem; - a heading is a
section_headerwith the block’s level (1 to 3); - a list item is a
list_iteminside alistgroup,enumeratedwhere the document numbered it and with the marker written asN.or-. A nested item opens a group under the item above it, which is where Docling puts a sub-list; - a run of table cells is one
table, its cells with their spans andcolumn_headerfrom the header row, and thegridDocling derives from them written out as Docling would derive it; - a running head and a running footer are
page_headerandpage_footerunderfurniture, in thefurniturecontent layer, so every Docling export that leaves the furniture out leaves them out too; - the half of a paragraph a page break cut off is not an item of its own: it
is joined onto the paragraph it continues, which then carries one
proventry per page, each with thecharspanof its own half.
PROVENANCE: page_no is 1-BASED, because Docling’s is – the one place this
output disagrees with Block::page and with the page markers of
crate::markdown, which count from zero. The box is Block::bbox as it is:
the page as it is displayed, /Rotate applied, in points from the bottom
left corner of the crop box with y up (BOTTOMLEFT). pages gives each
page’s size in that same frame, which is what makes the box relative to a
page and not to a sheet of paper nobody sees.
WHAT HAS NO MAPPING, stated so nobody looks for it:
Block::confidence:DoclingDocumenthas no per-item confidence;Block::spans: Docling items carry no runs, fonts or sizes. The caller that needs them readscrate::to_json;- the document’s own list marker:
c)andiv.come out as3.and4., because the block keeps the number and not the glyphs; title,caption,footnote,picture,formula,code, key-value and form items: the block model has no such kind, so nothing is written under those labels, andpictures,key_value_itemsandform_itemsare always empty;origin: the serializer does not see the file, so it isnull.
DETERMINISTIC, like the other two serializers: keys in a fixed order, every
number through crate::json::number, two spaces per level.
Structs§
- Docling
Page - One page of the document as
DoclingDocument.pageslists it.
Constants§
- DOCLING_
CORE_ VERSION - The
docling-corerelease whose model definesSCHEMA_VERSION, and the one the round-trip test loads the output with. - SCHEMA_
VERSION - The
DoclingDocumentschema version this writes.
Functions§
- to_
docling_ json - The blocks as a
DoclingDocument, pinned toSCHEMA_VERSION.