Installation & Guide
Getting Started with Frontmatter Gen
Install the library crate or standalone CLI, extract YAML 1.2, TOML 1.1, and JSON headers, and synthesize HTML meta tags.
Frontmatter Gen (frontmatter-gen) is an open-source, pure-Rust library and CLI for extracting and parsing YAML 1.2, TOML 1.1, and JSON frontmatter from Markdown and text documents. Follow this guide to add the crate, run the fmg binary, or enforce DoS limits on untrusted inputs.
Core Library
Crate v0.0.15Zero-copy extractor, YAML 1.2 / TOML 1.1 / JSON parsers, and HTML meta tag generator with minimal dependencies.
cargo add frontmatter-gen Standalone CLI
Binary (fmg)Install the standalone fmg command-line binary with clap and tokio for terminal and CI workflows.
cargo install frontmatter-gen --features cli SSG Engine
Feature FlagEnable the static site generation engine powered by tera templates and comrak Markdown rendering.
cargo add frontmatter-gen --features ssg Rust Toolchain
MSRV 1.85.0+Requires Rust 1.85.0 or newer (Edition 2024) and compiles cleanly across Linux, macOS, and Windows with zero unsafe code.
rustup update stable Extract & Parse Frontmatter in One Call
The top-level frontmatter_gen::extract function detects the frontmatter format automatically, parses the header into a Frontmatter map, and returns the remaining Markdown body as a borrowed &str slice:
Zero-Copy Raw Slicing & DoS Budget Guardrails
When processing untrusted Markdown uploads or inspecting raw slices before allocation, pair extractor::extract_raw_frontmatter with parser::parse_with_options:
Generate Escaped HTML Meta Tags & Use the CLI
Convert parsed frontmatter into HTML <meta>, Open Graph, and Twitter Card tags, or invoke the fmg binary directly from your shell:
Memory-Safe Execution Guarantees
Every extraction and parsing pass executes strictly in local memory with #![forbid(unsafe_code)], verified under Miri Tree Borrows and continuous fuzzing: