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.
Rust Document Engineering · v0.0.15 · Open Source
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.
--- via noyalib), TOML 1.1 (+++), and JSON ({ ... }) enabled by default.extract_raw_frontmatter borrows (&str, &str) slices directly from your input buffer.cargo-llvm-cov, proptest, Miri Tree Borrows, and 4 fuzz targets.max_depth, max_keys, and required-key validation via ParseOptions.
Content Pipeline Automation
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 BlueprintsEngine Architecture
Every module in frontmatter-gen separates zero-copy borrowing from heap allocation so callers pay only for the work they request.
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.
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.
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
Strip optional UTF-8 BOM (\u{FEFF}) and split the leading frontmatter block from the Markdown body without copying either half.
Inspect fence delimiters or leading structural tokens to classify the header as Format::Yaml, Format::Toml, or Format::Json.
Deserialize into Frontmatter while enforcing optional ParseOptions limits on nesting depth, total keys, and required fields.
Serialize back to any format via parser::to_string, emit escaped HTML <meta> tags, or render static pages via fmg.
High-Assurance Pipeline
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 BlueprintDeveloper Quickstart
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.
Formal & Empirical Assurance
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.
Clear Answers
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.
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.
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.
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
Get started in seconds with the Rust library crate or the standalone fmg CLI across Linux, macOS, and Windows.