Expand description
Core data model for docling.rs.
This crate is the Rust counterpart of the docling-core Python package: it
owns the unified DoclingDocument representation that every backend
produces and every serializer consumes. Keeping it dependency-light and
separate from the conversion logic mirrors the Python split between
docling-core (the schema) and docling (the converters).
Phase 0 models a simplified, linear node tree that is enough to round-trip
through Markdown. The faithful, $ref-based schema that matches
docling-core’s JSON wire format lands in Phase 1 (see docs/MIGRATION.md).
Modules§
- base64
- Minimal standard-alphabet Base64 codec (RFC 4648):
encodefor embedding image bytes asdata:URIs,decodefor reading them back out — avoids a dependency for the two things we need. - chunker
- Document chunking for RAG pipelines — the Rust port of docling-core’s
docling_core.transforms.chunker.
Structs§
- Docling
Document - The unified, format-agnostic document produced by every backend.
- Field
Item - One entry of a
Node::FieldRegion: a marker/key/value triple, any of which may be absent. Mirrors docling’sfield_itemwith itsmarker/field_key/field_valuechild texts. - Inline
Run - One styled segment of a
Node::InlineGroup— the docling.rs analogue of aTextIteminside anInlineGroup, carrying the ancestor formatting docling tracks.textis already whitespace-normalized/trimmed (one segment per source text node). A hyperlink is intentionally not stored: DocLang drops the target inside inline scope, keeping only the anchor text. - List
Item Dclx - DocLang-only content for a
Node::ListItemwhose DocLang form differs from its flat Markdowntext(seeNode::ListItem::dclx).orderedpicks the enclosing<list>kind,markerthe<ldiv><marker>; content isruns(structured equations/formatting) when non-empty, elsetextre-parsed for inline markers. - Markdown
Streamer - Incremental Markdown serializer: feed finalized, in-document-order batches of
Nodes and receive Markdown chunks whose concatenation is byte-identical to [to_markdown_images] over the same nodes. This is the streaming counterpart of the buffered serializer — used to emit a document’s Markdown in chunks (e.g. page by page, as the parallel PDF pipeline finishes pages) instead of building the whole string up front. - Picture
Class - One DocumentPictureClassifier prediction — docling-core’s
PictureClassificationClass(class_name+confidence). - Picture
Image - An extracted picture’s raw encoded bytes plus its mimetype and pixel size —
the docling.rs analogue of docling-core’s
ImageRef. - Table
- A simple row-major table. By default
rows[0]is the header row; aTableStructureoverlay overrides that and adds column spans. - Table
Structure - OTSL structure overlay for a
Table, parallel toTable::rows.
Enums§
- Content
Layer - A DocLang content layer other than the default
body(seeNode::Furniture). - DocItem
Label - Semantic role of a document item, mirroring docling-core’s
DocItemLabel. - Image
Mode - How pictures are rendered (mirrors docling-core’s
ImageRefMode). - Node
- A single piece of document content.
- Script
- Vertical text position of an
InlineRun— docling’sScript.
Functions§
- inline_
paragraph_ node - Build the
Nodefor a paragraph of inline content from its structuredrunsand Markdown text, applying docling’sInlineGroupboundary: - inline_
runs_ from_ markdown - Parse a docling-legacy Markdown string into structured
InlineRuns for aNode::InlineGroup. Handles the marker set docling emits —***,**,*,~~,`,[t](u)— recursively so nested markers combine formatting, and splits plain text on newlines (docling’s<br>/ text-node boundaries become separate runs). Underline and sub/superscript have no Markdown representation and therefore never appear via this path.