pub struct FrontmatterParser;Expand description
Parses YAML frontmatter from markdown files.
Implementations§
Source§impl FrontmatterParser
impl FrontmatterParser
Sourcepub fn extract(content: &str) -> Option<&str>
pub fn extract(content: &str) -> Option<&str>
Extract frontmatter content from a markdown file.
Frontmatter is delimited by --- at the start and end.
Returns None if no valid frontmatter is found.
§Example
use cc_audit::parser::FrontmatterParser;
let content = "---\nname: test\n---\n# Content";
let frontmatter = FrontmatterParser::extract(content);
assert_eq!(frontmatter, Some("\nname: test\n"));Sourcepub fn parse_yaml(content: &str) -> Option<Value>
pub fn parse_yaml(content: &str) -> Option<Value>
Parse frontmatter as a YAML value.
Returns None if no frontmatter exists or parsing fails.
Sourcepub fn parse_json(content: &str) -> Option<Value>
pub fn parse_json(content: &str) -> Option<Value>
Parse frontmatter as a JSON value.
Returns None if no frontmatter exists or parsing fails.
Auto Trait Implementations§
impl Freeze for FrontmatterParser
impl RefUnwindSafe for FrontmatterParser
impl Send for FrontmatterParser
impl Sync for FrontmatterParser
impl Unpin for FrontmatterParser
impl UnwindSafe for FrontmatterParser
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
Mutably borrows from an owned value. Read more