Skip to main content

Crate docling_core

Crate docling_core 

Source
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): encode for embedding image bytes as data: URIs, decode for 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§

DoclingDocument
The unified, format-agnostic document produced by every backend.
FieldItem
One entry of a Node::FieldRegion: a marker/key/value triple, any of which may be absent. Mirrors docling’s field_item with its marker / field_key / field_value child texts.
InlineRun
One styled segment of a Node::InlineGroup — the docling.rs analogue of a TextItem inside an InlineGroup, carrying the ancestor formatting docling tracks. text is 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.
ListItemDclx
DocLang-only content for a Node::ListItem whose DocLang form differs from its flat Markdown text (see Node::ListItem::dclx). ordered picks the enclosing <list> kind, marker the <ldiv><marker>; content is runs (structured equations/formatting) when non-empty, else text re-parsed for inline markers.
MarkdownStreamer
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.
PictureClass
One DocumentPictureClassifier prediction — docling-core’s PictureClassificationClass (class_name + confidence).
PictureImage
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; a TableStructure overlay overrides that and adds column spans.
TableStructure
OTSL structure overlay for a Table, parallel to Table::rows.

Enums§

ContentLayer
A DocLang content layer other than the default body (see Node::Furniture).
DocItemLabel
Semantic role of a document item, mirroring docling-core’s DocItemLabel.
ImageMode
How pictures are rendered (mirrors docling-core’s ImageRefMode).
Node
A single piece of document content.
Script
Vertical text position of an InlineRun — docling’s Script.

Functions§

inline_paragraph_node
Build the Node for a paragraph of inline content from its structured runs and Markdown text, applying docling’s InlineGroup boundary:
inline_runs_from_markdown
Parse a docling-legacy Markdown string into structured InlineRuns for a Node::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.