pub struct DoclingDocument {
pub name: String,
pub nodes: Vec<Node>,
pub strict_markdown: bool,
}Expand description
The unified, format-agnostic document produced by every backend.
This is the heart of docling: backends parse their source format into a
DoclingDocument, and serializers turn it back into Markdown, HTML, JSON,
etc. Phase 0 uses a flat sequence of Nodes; the production schema will
match docling-core’s body-tree-with-references layout.
Fields§
§name: StringLogical document name (usually the input file stem).
nodes: Vec<Node>Top-level content, in reading order.
strict_markdown: boolDefault Markdown export mode for Self::export_to_markdown. false
(the default) reproduces docling’s legacy output byte-for-byte; true
emits cleaner, more conformant Markdown. Set by DocumentConverter.
Implementations§
Source§impl DoclingDocument
impl DoclingDocument
Sourcepub fn add_heading(&mut self, level: u8, text: impl Into<String>)
pub fn add_heading(&mut self, level: u8, text: impl Into<String>)
Convenience: append a heading.
Sourcepub fn add_paragraph(&mut self, text: impl Into<String>)
pub fn add_paragraph(&mut self, text: impl Into<String>)
Convenience: append a paragraph.
Sourcepub fn export_to_markdown(&self) -> String
pub fn export_to_markdown(&self) -> String
Serialize the document to Markdown.
The Rust equivalent of docling-core’s
DoclingDocument.export_to_markdown(). Uses Self::strict_markdown to
pick between docling-legacy output (default) and the cleaner, more
conformant variant.
Sourcepub fn export_to_markdown_with(&self, strict: bool) -> String
pub fn export_to_markdown_with(&self, strict: bool) -> String
Serialize to Markdown, explicitly choosing the mode regardless of
Self::strict_markdown. strict = true produces cleaner, more
conformant Markdown (code-fence languages preserved, no inline-run
spacing artifacts); strict = false reproduces docling’s legacy output.
Sourcepub fn export_to_json(&self) -> String
pub fn export_to_json(&self) -> String
Serialize to docling-core’s native JSON wire format (DoclingDocument
schema), pretty-printed — the Rust equivalent of
DoclingDocument.export_to_dict() / save_as_json(). The output loads
back into Python docling-core and round-trips to the same Markdown.
Sourcepub fn export_to_markdown_with_images(
&self,
image_mode: ImageMode,
artifacts_dir: &str,
) -> (String, Vec<(String, Vec<u8>)>)
pub fn export_to_markdown_with_images( &self, image_mode: ImageMode, artifacts_dir: &str, ) -> (String, Vec<(String, Vec<u8>)>)
Serialize to Markdown with an explicit picture ImageMode (mirrors
docling’s image_mode). Returns the Markdown and, for
ImageMode::Referenced, the (relative-path, bytes) of each image the
caller should write next to the Markdown file. artifacts_dir is the
directory name used in referenced links.
Trait Implementations§
Source§impl Clone for DoclingDocument
impl Clone for DoclingDocument
Source§fn clone(&self) -> DoclingDocument
fn clone(&self) -> DoclingDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DoclingDocument
impl Debug for DoclingDocument
Source§impl PartialEq for DoclingDocument
impl PartialEq for DoclingDocument
Source§fn eq(&self, other: &DoclingDocument) -> bool
fn eq(&self, other: &DoclingDocument) -> bool
self and other values to be equal, and is used by ==.