dustinknopoff / frontmatter

Separating front matter from text since 2020

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:Other


Languages

Language:Rust 100.0%