You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
4 years ago | |
---|---|---|
src | 4 years ago | |
.gitignore | 4 years ago | |
Cargo.toml | 4 years ago | |
README.md | 4 years ago |
README.md
frontmatter
A library to parse TOML & YAML frontmatter either naively (as a serde_json::Map<String,serde_json::Value>) or to a native struct via serde.
This is very early stages software, just an experiment to learn how types work in Rust.
Example:
use frontmatter::GenericFrontmatter;
struct PageFrontMatter {
title: Option<String>,
date: Option<String>
}
let body = "test: lol\ntest2: lol\nextra:\n extra_key: value";
let frontmatter = GenericFrontmatter::from_yaml(&body).expect("FAIL");
let special: PageFrontMatter = serde_json::from_value(frontmatter.into()).expect("FAIL2");
println!("{:?}", special);
TODO
- JSON support
- file splitting: String -> (frontmatter, String)
- date parsing