pub fn parse<T: DeserializeOwned>(content: &str) -> Result<(T, &str), Error>Available on crate features
json or toml or yaml only.Expand description
Parses frontmatter from a markdown string, deserializing it into a given type and returning the parsed frontmatter and the body of the document.
§Arguments
content- The content of the document to parse.
§Examples
use markdown_frontmatter::parse;
use serde::Deserialize;
#[derive(Deserialize)]
struct MyFrontmatter {
title: String,
}
let doc = r#"---
title: Hello
---
World
"#;
let (frontmatter, body) = parse::<MyFrontmatter>(doc).unwrap();
assert_eq!(frontmatter.title, "Hello");
assert_eq!(body, "World\n");