pub struct ParsedDocument {
pub frontmatter: HashMap<String, Value>,
pub body: String,
pub frontmatter_range: Option<(usize, usize)>,
pub frontmatter_error: Option<String>,
}Expand description
A parsed markdown document with frontmatter separated from body.
Fields§
§frontmatter: HashMap<String, Value>Parsed frontmatter key-value pairs.
body: StringThe markdown body (everything after the closing ---).
frontmatter_range: Option<(usize, usize)>Byte offsets of the frontmatter block: (start_of_opening_delimiter, end_of_closing_delimiter).
None if no frontmatter was found.
frontmatter_error: Option<String>serde_yaml error message when a delimited ---...--- block failed to
parse as YAML. None when the block parsed cleanly or there was no
delimited block. When Some, frontmatter is empty and body still
holds the WHOLE document (so the editor can show/repair the bad block);
use render_body() for the HTML-render view that excludes it.
#[serde(default)] is defensive: the type derives Deserialize but is
transient (no code deserializes INTO it).
Implementations§
Source§impl ParsedDocument
impl ParsedDocument
Sourcepub fn render_body(&self) -> &str
pub fn render_body(&self) -> &str
Body suitable for RENDERING to HTML (build pipeline): excludes a
delimited frontmatter block that FAILED to parse, so malformed YAML never
leaks verbatim into output. Equal to body when the frontmatter parsed
cleanly or there was no block.
The EDITOR must NOT use this — it needs the raw body so the author can
see/repair the bad block and a full-reserialize save preserves it.
Trait Implementations§
Source§impl Clone for ParsedDocument
impl Clone for ParsedDocument
Source§fn clone(&self) -> ParsedDocument
fn clone(&self) -> ParsedDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more