Experimental multi-format frontmatter parsing library (YAML/TOML)
Go to file
user dd52f006a8 Initial commit 2019-08-10 20:33:44 +02:00
src Initial commit 2019-08-10 20:33:44 +02:00
.gitignore Initial commit 2019-08-10 20:33:44 +02:00
Cargo.toml Initial commit 2019-08-10 20:33:44 +02:00
README.md Initial commit 2019-08-10 20:33:44 +02:00

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