Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.15 KB

README.md

File metadata and controls

54 lines (43 loc) · 1.15 KB

Frontmatter

build-and-check LICENSE no_std

Inspired by matter

A simple, no-dependency library for separating YAML or TOML frontmatter from some text.

For example, Let's say you have a markdown document:

+++
title = "TOML Frontmatter"
list = [
    "Of",
    "Things",
]
[[assets]]
contentType = "audio/mpeg"
+++

This is some content.
use frontmatter::split_matter;

fn main() {
    let example_text = r#"+++
title = "TOML Frontmatter"
list = [
    "Of",
    "Things",
]
[[assets]]
contentType = "audio/mpeg"
+++"#;
    if let Some((frontmatter, content)) = split_matter(&content) {
        // Do something, probably deserializing the frontmatter in to YAML/TOML
        assert_ne!(f.len(), 0);
        assert_eq!(c, "This is some content.");
    }
}

Installation

Add the following to your Cargo.toml

frontmatter = { git="https://github.com/dustinknopoff/frontmatter", branch="master"}