pub struct Document {
pub blocks: Vec<Block>,
pub block_meta: Vec<BlockMeta>,
pub slot_only: bool,
pub warnings: Vec<String>,
}Expand description
A parsed markdown document body.
Wraps Vec<Block> with document-level flags. The frontmatter sits in
crate::frontmatter::ParsedDocument; this struct is body-only.
Higher-level code combines the two as needed.
Fields§
§blocks: Vec<Block>Body content as a flat list of block-level nodes.
block_meta: Vec<BlockMeta>Parallel-to-blocks metadata. Invariant: block_meta.len() == blocks.len(). The renderer asserts this in debug builds and
gracefully degrades (treats missing entries as BlockMeta::default())
in release builds.
Defaults to an all-BlockMeta::default() vec sized to match
blocks when constructed via Document::from_blocks; only the
parser populates source_line (under
crate::ast::ParseConfig::emit_source_lines).
slot_only: boolTrue if this document is a slot file (e.g. footer.md) — its
content fills a layout slot rather than being rendered as an
article. The renderer suppresses auto-injected article chrome
(<h1 class="moss-article-title">) when this is set.
Replaces the heading: false YAML synthesis hack at
src-tauri/src/build/footer.rs:160. Lands in Phase A.5 of the
typed-AST migration; in Phase A it’s available but not yet
consumed by src-tauri.
warnings: Vec<String>Non-fatal problems found while parsing this body — today, every
:::name fence whose name is not a registered shortcode.
The extractor has collected these since the unknown-name fallback
landed, but nothing carried them out of the parse, so the only trace
a misspelling left was a moss-unknown-shortcode div in the built
HTML. An author (or an agent) got a page that had silently lost its
gallery and a build that said nothing. This field is that missing
hop; build::markdown::pipeline prints each entry against the file.
Scope, precisely: top-level fences, fences nested inside an
unknown fence (that branch recurses through extract_with_state,
threading one collection), AND fences nested inside a valid
shortcode’s body — grid cells (parse_cell_to_blocks) and the hero
overlay (parse_overlay_to_blocks) each re-parse their body as an
independent fragment via parse_fragment_with_config; both now
return that fragment Document’s warnings alongside its blocks,
and parse_shortcode_block merges them into the Vec<String> it
already threads into extract_with_state’s shared collection. So a
misspelling inside :::grid or :::hero warns exactly like a
top-level one; see unknown_shortcode_inside_a_valid_shortcode_warns
and unknown_shortcode_inside_a_hero_overlay_warns.
Implementations§
Source§impl Document
impl Document
Sourcepub fn from_blocks(blocks: Vec<Block>) -> Self
pub fn from_blocks(blocks: Vec<Block>) -> Self
Construct a document from a list of blocks. All block_meta entries
are default (no source-line tracking). Use
Document::from_blocks_with_meta when meta is known.
Sourcepub fn from_blocks_with_meta(
blocks: Vec<Block>,
block_meta: Vec<BlockMeta>,
) -> Self
pub fn from_blocks_with_meta( blocks: Vec<Block>, block_meta: Vec<BlockMeta>, ) -> Self
Construct a document from blocks + parallel meta. Panics in debug if the two slices have different lengths.
Sourcepub fn has_shortcode(&self, kind: ShortcodeKind) -> bool
pub fn has_shortcode(&self, kind: ShortcodeKind) -> bool
True if any top-level block is a shortcode of the given kind.
Shallow check: does NOT descend into nested blocks (e.g. a
:::subscribe inside a :::grid cell would not be found by this
query alone). Phase A models the shallow case; deeper
has_shortcode_recursive lands when nested-shortcode AST queries
are first needed.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.