-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plans on doing the other way (editting the front matter) #3
Comments
More detail in your description please? |
Something like extracting the front matter, editing it, then writing back to the file |
Got it. I think add an api such as For example: use gray_matter::Matter;
use gray_matter::engine::YAML;
use serde::Deserialize;
const INPUT: &str = r#"---
title: gray-matter-rs
tags:
- gray-matter
- rust
---
Some excerpt
---
Other stuff
"#;
fn main() {
#[derive(Deserialize, Debug)]
struct FrontMatter {
title: String,
tags: Vec<String>
}
let mut result_with_struct = matter.parse_with_struct::<FrontMatter>(INPUT).unwrap();
result_with_struct.data.title = "gray-matter-rs-modified".to_owned();
let output = matter.compose(result_with_struct);
println!("{:?}", output)
// ---
// title: gray-matter-rs-modified
// tags:
// - gray-matter
// - rust
// ---
// Some excerpt
// ---
// Other stuff
} |
i think that's a good api. I dont have any better idea |
We could implement the |
That's great! |
I've set a new requirement for the This requirement means every engine will need to define how the front matter they've parsed shall be output, e.g.: This is in turn is used in the I was not able to implement |
Since now we can deserialized |
Very useful library btw
The text was updated successfully, but these errors were encountered: