pub struct MarkdownStreamer { /* private fields */ }Expand description
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.
Only ImageMode::Placeholder and ImageMode::Embedded are streamable:
ImageMode::Referenced needs a side-channel for the image bytes, which only
the buffered [to_markdown_images] provides.
Each push must contain whole blocks in reading order: a caller
must not split a run of list items across two pushes (the run would render as
two separate lists). Finalized PDF page batches already satisfy this.
Implementations§
Source§impl MarkdownStreamer
impl MarkdownStreamer
Sourcepub fn new(strict: bool, images: ImageMode, compact_tables: bool) -> Self
pub fn new(strict: bool, images: ImageMode, compact_tables: bool) -> Self
Create a streamer. compact_tables mirrors DoclingDocument::compact_tables.
Sourcepub fn push(&mut self, nodes: &[Node], links: &[(String, String)]) -> String
pub fn push(&mut self, nodes: &[Node], links: &[(String, String)]) -> String
Render one finalized batch of nodes (plus any links recovered from the same span, in document order) into the next Markdown chunk. Returns an empty string when the batch produces no output (e.g. empty tables/pictures), in which case nothing should be written.