pub struct Document { /* private fields */ }Expand description
An owned, immutable Markdown document and its navigation indexes.
Construct a document with Document::parse or
Document::parse_with_limits. Blocks, headings, and links all refer to
the same parse, so renderers can share heading and link identities without
rebuilding indexes. Cloning a document performs a deep clone; use
std::sync::Arc when several consumers should share one allocation.
Implementations§
Source§impl Document
impl Document
Sourcepub fn blocks(&self) -> &[Block]
pub fn blocks(&self) -> &[Block]
Returns the top-level semantic blocks in source order.
Blocks nested inside quotations and list items are available through
BlockKind::Quote and ListItem::blocks.
Source§impl Document
impl Document
Sourcepub fn parse(source: &str) -> Result<Self, ParseError>
pub fn parse(source: &str) -> Result<Self, ParseError>
Parses CommonMark with tables, task lists, and strikethrough enabled.
Parsing is synchronous, performs no I/O, and returns an owned document
that does not borrow source. Incomplete syntax follows
pulldown-cmark’s literal fallback rules.
§Errors
Returns ParseError if the default resource limits are exceeded.
Sourcepub fn parse_with_limits(
source: &str,
limits: ParseLimits,
) -> Result<Self, ParseError>
pub fn parse_with_limits( source: &str, limits: ParseLimits, ) -> Result<Self, ParseError>
Parses with caller-supplied resource bounds.
The same Markdown extensions and ownership rules as Document::parse
apply. See ParseLimits for boundary semantics.
§Errors
Returns ParseError when any bound is exceeded.