Rust Document Engineering · v0.0.15 · Open Source

Front matter in, typed values out.
Zero-copy slicing. Zero unsafe code.

A pure-Rust library and CLI for extracting and parsing YAML 1.2, TOML 1.1, and JSON frontmatter from Markdown and text documents. Built for static site generators, documentation engines, and content pipelines with configurable DoS budgets, HTML meta tag synthesis, Miri Tree Borrows verification, and 100% unit test coverage.

  • YAML 1.2, TOML 1.1 & JSON
  • Zero-Copy Body Slicing
  • #![forbid(unsafe_code)] + Miri Verified
  • 3 Native Formats YAML 1.2 (--- via noyalib), TOML 1.1 (+++), and JSON ({ ... }) enabled by default.
  • 0 B Copy Slice extract_raw_frontmatter borrows (&str, &str) slices directly from your input buffer.
  • 100% Coverage Every module verified by cargo-llvm-cov, proptest, Miri Tree Borrows, and 4 fuzz targets.
  • DoS Guardrails Configurable max_depth, max_keys, and required-key validation via ParseOptions.
High-throughput content engineering and static site compilation dashboard

Content Pipeline Automation

Unified Metadata for Static Sites & Content Engines

Replace brittle regular expressions and archived YAML 1.1 parsers with a single deterministic crate. Ingest Markdown with YAML, TOML, or JSON headers and emit typed Rust structures or escaped HTML5 meta tags in microseconds.

View Production Blueprints

Engine Architecture

Engineered for predictable latency and untrusted input safety.

Every module in frontmatter-gen separates zero-copy borrowing from heap allocation so callers pay only for the work they request.

01

Zero-Copy Fence Splitting

extractor::extract_raw_frontmatter locates YAML (---), TOML (+++), or JSON ({ ... }) boundaries in a single forward scan and returns borrowed (&str, &str) slices with zero heap allocation.

02

YAML 1.2, TOML 1.1 & JSON

Powered by pure-Rust noyalib (YAML 1.2 with explicit Value::Tagged preservation and no Norway boolean coercion), toml 1.1, and serde_json, unified behind a single recursive Frontmatter model.

03

HTML Meta & Template Engine

meta::generate_metatags transforms frontmatter maps into entity-escaped HTML <meta>, Open Graph (og:*), and Twitter Card tags, while the optional ssg feature drives static site builds.

The Processing Pipeline

One pass from raw Markdown document to verified output.

1

Slice

Strip optional UTF-8 BOM (\u{FEFF}) and split the leading frontmatter block from the Markdown body without copying either half.

extract_raw_frontmatter(&str)
2

Detect

Inspect fence delimiters or leading structural tokens to classify the header as Format::Yaml, Format::Toml, or Format::Json.

detect_format(&str)
3

Parse & Guard

Deserialize into Frontmatter while enforcing optional ParseOptions limits on nesting depth, total keys, and required fields.

parse_with_options(&str, Format, &ParseOptions)
4

Emit

Serialize back to any format via parser::to_string, emit escaped HTML <meta> tags, or render static pages via fmg.

generate_metatags(&Frontmatter)
Architectural view of London at night representing deterministic Rust parsing infrastructure

High-Assurance Pipeline

Deterministic Execution at Scale

Designed for static site compilers, documentation servers, and CI linters requiring sub-microsecond slice extraction, bounded recursion depth, and strict YAML 1.2 fidelity.

View Architecture Blueprint

Developer Quickstart

Add the Rust Crate or Install the CLI in Seconds

Embed frontmatter_gen::extract directly in your Rust library, or install the standalone fmg binary to extract frontmatter and build static sites from your terminal.

rust & bash — frontmatter-gen v0.0.15
# 1. Add library crate or install CLI binary
$cargo add frontmatter-gen
$cargo install frontmatter-gen --features cli
 
# 2. Extract and parse YAML 1.2, TOML, or JSON in Rust
let (fm, body) = frontmatter_gen::extract(markdown)?;
let meta_html = frontmatter_gen::meta::generate_metatags(&fm)?;
 
# 3. Extract frontmatter to JSON from the terminal
$fmg extract content/post.md --format json --output meta.json

Formal & Empirical Assurance

Zero unsafe code. Proven under Miri Tree Borrows.

Every crate boundary enforces #![forbid(unsafe_code)]. Continuous verification runs Miri with -Zmiri-strict-provenance -Zmiri-tree-borrows across both default and minimal feature sets, backed by 4 structure-aware cargo-fuzz harnesses and cargo-vet supply-chain audits.

Read Security & Verification Architecture

Clear Answers

Frequently Asked Questions

Why does frontmatter-gen use noyalib instead of serde_yaml?

serde_yaml was archived upstream in March 2024 and implements YAML 1.1, where unquoted scalars like no or off coerce to booleans. frontmatter-gen uses noyalib, an actively maintained, pure-Rust YAML 1.2 parser with zero unsafe code and explicit tag support.

Does extract_raw_frontmatter allocate on the heap?

No. extractor::extract_raw_frontmatter returns Result<(&str, &str), ParseError> borrowed directly from your input &str. You only allocate when you parse the raw slice into a Frontmatter map.

How do I protect my server against deeply nested frontmatter payloads?

Use parser::parse_with_options with a ParseOptions struct setting max_depth (for example, Some(16)) and max_keys (for example, Some(128)). Payloads exceeding either threshold return ParseError::InvalidFrontmatter immediately.

Are the CLI and SSG engine mandatory dependencies?

No. The default build includes only the core extractor, YAML/TOML/JSON parsers, and HTML meta tag generator. The cli feature (fmg binary) and ssg feature (static site engine) are strictly opt-in.

Developer Quickstart

Document metadata is foundational.
Your frontmatter parser should be deterministic.

Get started in seconds with the Rust library crate or the standalone fmg CLI across Linux, macOS, and Windows.

Install Frontmatter Gen