Skip to content

Separating front matter from text since 2020

License

Notifications You must be signed in to change notification settings

dustinknopoff/frontmatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"}

About

Separating front matter from text since 2020

Topics

Resources

License

Stars

Watchers

Forks

Languages