pub struct Document<'src> { /* private fields */ }Expand description
A document represents the top-level block element in AsciiDoc. It consists of an optional document header and either a) one or more sections preceded by an optional preamble or b) a sequence of top-level blocks only.
The document can be configured using a document header. The header is not a block itself, but contributes metadata to the document, such as the document title and document attributes.
The Document structure is a self-contained package of the original content
that was parsed and the data structures that describe that parsed content.
The API functions on this struct can be used to understand the parse
results.
Implementations§
Source§impl<'src> Document<'src>
impl<'src> Document<'src>
Sourcepub fn doctitle(&self) -> Option<&str>
pub fn doctitle(&self) -> Option<&str>
Return the document title (the level-0 = Title), if there was one.
Sourcepub fn show_doctitle(&self) -> bool
pub fn show_doctitle(&self) -> bool
Return whether the document title should be displayed (as an <h1>).
This reflects the effective showtitle/notitle attribute state: an
embedded document shows its title only when showtitle is set.
Sourcepub fn toc_mode(&self) -> TocMode
pub fn toc_mode(&self) -> TocMode
Return where (and whether) this document’s table of contents is
generated, resolved from the toc attribute.
Sourcepub fn toc_levels(&self) -> usize
pub fn toc_levels(&self) -> usize
Return the depth of section levels included in this document’s table of
contents, resolved from the toclevels attribute (default 2).
Sourcepub fn toc_title(&self) -> &str
pub fn toc_title(&self) -> &str
Return the title of this document’s table of contents, resolved from the
toc-title attribute (default Table of Contents).
Sourcepub fn toc_class(&self) -> &str
pub fn toc_class(&self) -> &str
Return the CSS class applied to this document’s table of contents
container, resolved from the toc-class attribute (default toc).
Sourcepub fn warnings(&self) -> Iter<'_, Warning<'_>>
pub fn warnings(&self) -> Iter<'_, Warning<'_>>
Return an iterator over any warnings found during parsing.
Sourcepub fn source_map(&self) -> &SourceMap
pub fn source_map(&self) -> &SourceMap
Return the source map that tracks original file locations.
Sourcepub fn catalog(&self) -> &Catalog
pub fn catalog(&self) -> &Catalog
Return the document catalog for accessing referenceable elements.
Sourcepub fn resolve_references(
&mut self,
resolver: &dyn ReferenceResolver,
renderer: &dyn InlineSubstitutionRenderer,
) -> Vec<ReferenceWarning>
pub fn resolve_references( &mut self, resolver: &dyn ReferenceResolver, renderer: &dyn InlineSubstitutionRenderer, ) -> Vec<ReferenceWarning>
Resolve the document’s deferred cross-references using a caller-supplied
ReferenceResolver and InlineSubstitutionRenderer.
This is the entry point for multi-document workflows: parse each
document with Parser::parse_deferred, then call this with a
resolver that resolves targets against whatever combined index the
caller has built (this crate does not merge catalogs). The resolver
binds the “from” document, so a single shared resolver can be
parametrized per call site.
Resolution is non-destructive and may be repeated (e.g. for incremental builds or multiple output targets): the original target text is retained, so re-resolving is always possible.
Each call is a full, independent resolution sweep. Every
cross-reference is re-resolved against resolver, overwriting any
result from a previous pass, and the returned ReferenceWarnings
reflect only what this resolver could not resolve — a prior pass
having resolved a target does not suppress a warning here.
Consequently, resolving with a resolver that knows fewer targets
than an earlier pass (for example, calling this after
Parser::parse has already auto-resolved against the document’s
own catalog) will re-report those now-unknown targets as unresolved.
Multi-document pipelines should therefore start from
Parser::parse_deferred, which does not auto-resolve.
Trait Implementations§
impl<'src> Eq for Document<'src>
Source§impl<'src> IsBlock<'src> for Document<'src>
impl<'src> IsBlock<'src> for Document<'src>
Source§fn content_model(&self) -> ContentModel
fn content_model(&self) -> ContentModel
ContentModel for this block.Source§fn raw_context(&self) -> CowStr<'src>
fn raw_context(&self) -> CowStr<'src>
Source§fn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
fn nested_blocks(&'src self) -> Iter<'src, Block<'src>>
Source§fn title_source(&'src self) -> Option<Span<'src>>
fn title_source(&'src self) -> Option<Span<'src>>
Source§fn anchor_reftext(&'src self) -> Option<Span<'src>>
fn anchor_reftext(&'src self) -> Option<Span<'src>>
Source§fn attrlist(&'src self) -> Option<&'src Attrlist<'src>>
fn attrlist(&'src self) -> Option<&'src Attrlist<'src>>
Source§fn rendered_content(&'src self) -> Option<&'src str>
fn rendered_content(&'src self) -> Option<&'src str>
Source§fn resolved_context(&'src self) -> CowStr<'src>
fn resolved_context(&'src self) -> CowStr<'src>
Source§fn declared_style(&'src self) -> Option<&'src str>
fn declared_style(&'src self) -> Option<&'src str>
Source§fn nested_blocks_mut(&mut self) -> &mut [Block<'src>]
fn nested_blocks_mut(&mut self) -> &mut [Block<'src>]
Source§fn content_mut(&mut self) -> Option<&mut Content<'src>>
fn content_mut(&mut self) -> Option<&mut Content<'src>>
Source§fn options(&'src self) -> Vec<&'src str>
fn options(&'src self) -> Vec<&'src str>
Source§fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
true if this block has the named option. Read more