frontmatter-gen 0.0.6

A Rust library for generating and parsing frontmatter in various formats.
Documentation

Install

cargo add frontmatter-gen

Or add to Cargo.toml:

[dependencies]
frontmatter-gen = "0.0.6"

You need Rust 1.56.0 or later. Works on macOS, Linux, and Windows.


Overview

Frontmatter Gen extracts and generates frontmatter blocks from content files. It supports YAML, TOML, and JSON delimiters out of the box.

  • Auto-detection of frontmatter format from delimiters
  • Extraction of frontmatter and body content in a single pass
  • Generation of frontmatter blocks from Rust structs via Serde
  • Validation of required fields and structure

Features

Multi-format Parse and generate YAML, TOML, and JSON frontmatter
Extraction Extract frontmatter from Markdown and other content files
Validation Validate frontmatter structure and required fields
Fenced blocks Support for fenced (---, +++, {) delimiters
Serde integration Serialize/deserialize to Rust structs via Serde

Usage

use frontmatter_gen::extract;

fn main() {
    let content = r#"---
title: "My Post"
date: "2024-01-15"
---
# Hello World
This is the body."#;

    let (frontmatter, body) = extract(content).unwrap();
    println!("Title: {:?}", frontmatter.get("title"));
    println!("Body: {}", body);
}

Development

cargo build        # Build the project
cargo test         # Run all tests
cargo clippy       # Lint with Clippy
cargo fmt          # Format with rustfmt

See CONTRIBUTING.md for setup, signed commits, and PR guidelines.


THE ARCHITECT \u1d2b Sebastien Rousseau THE ENGINE \u1d5e EUXIS \u1d2b Enterprise Unified Execution Intelligence System


License

Dual-licensed under Apache 2.0 or MIT, at your option.