Technical Knowledge Base
Frequently Asked Questions
Direct engineering answers covering format semantics, zero-copy lifetimes, security budgets, CLI usage, and licensing.
Formats Which frontmatter formats does frontmatter-gen support out of the box?
frontmatter-gen supports three formats out of the box with no feature flags required: YAML 1.2 (bounded by --- fences, parsed via noyalib), TOML 1.1 (bounded by +++ fences, parsed via toml), and JSON (a balanced leading { ... } object or fenced JSON block, parsed via serde_json).
YAML 1.2 Why did frontmatter-gen switch from serde_yml / serde_yaml to noyalib?
serde_yaml was archived upstream in March 2024 and implements YAML 1.1, which suffers from the Norway problem (unquoted NO, no, on, and off coerce to booleans). noyalib is an actively maintained, pure-Rust YAML 1.2 parser with zero unsafe code that keeps unquoted no and off as strings and preserves explicit YAML tags via Value::Tagged (ADR-0003).
Zero-Copy Is extract_raw_frontmatter truly zero-copy?
Yes. extractor::extract_raw_frontmatter(content: &str) -> Result<(&str, &str), ParseError> performs a single forward scan and returns two sub-slices borrowed directly from content. Neither the raw frontmatter slice nor the Markdown body slice is copied to the heap.
Encoding How are UTF-8 byte-order marks (BOM) and CRLF line endings handled?
If an input document starts with a UTF-8 BOM (\u{FEFF}), extract_raw_frontmatter strips the 3-byte prefix before checking for opening delimiters. Both Unix (\n) and Windows (\r\n) line endings are supported across YAML, TOML, and JSON extraction.
DoS Budgets How do I protect against deeply nested or oversized frontmatter payloads?
Pass a ParseOptions struct to parser::parse_with_options with max_depth (for example, Some(8)) and max_keys (for example, Some(64)). If the parsed frontmatter exceeds either limit, parse_with_options returns Err(ParseError::InvalidFrontmatter) immediately.
Memory Safety Does frontmatter-gen contain any unsafe Rust blocks?
No. Both the library crate (src/lib.rs) and binary crate (src/main.rs) declare #![forbid(unsafe_code)]. Any attempt to introduce an unsafe block fails compilation immediately.
Miri & Fuzzing How is memory safety verified beyond the Rust borrow checker?
Every pull request runs the unit test suite under Miri with -Zmiri-strict-provenance -Zmiri-tree-borrows -Zmiri-symbolic-alignment-check across both --no-default-features and default feature sets, alongside 4 structure-aware cargo-fuzz targets and proptest property suites.
XSS Prevention Does generate_metatags escape HTML special characters against XSS?
Yes. meta::generate_metatags escapes &, <, >, ", and ' in all attribute values so untrusted frontmatter strings cannot break out of content="..." attributes or inject script tags.
Rust Crate How do I integrate frontmatter-gen into an existing Rust application?
Add the dependency to your Cargo.toml:
[dependencies]
frontmatter-gen = "0.0.15" Then extract and parse any Markdown document in one call:
use frontmatter_gen::{extract, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (fm, body) = extract("---\ntitle: Hello\n---\n# Body")?;
assert_eq!(fm.get("title"), Some(&Value::String("Hello".into())));
assert_eq!(body.trim(), "# Body");
Ok(())
} Format Conversion Can I convert frontmatter from one format to another (e.g. YAML to TOML or JSON)?
Yes. Because YAML, TOML, and JSON all deserialize into the same Frontmatter type, you can parse a YAML header and call frontmatter_gen::parser::to_string(&fm, Format::Toml) or to_string(&fm, Format::Json) to serialize it into another format.
YAML Tags How does frontmatter-gen handle explicit YAML 1.2 tags like !custom?
Explicit YAML tags are preserved as Value::Tagged(String, Box<Value>) where the first element is the tag name without the leading ! and the second element is the inner Value. You can inspect them via val.as_tagged().
CLI & SSG What is the difference between the default library, the cli feature, and the ssg feature?
The default library provides extract, extractor, parser, meta, and error with minimal dependencies. Enabling --features cli builds the fmg binary with clap and tokio. Enabling --features ssg adds the static site builder module powered by tera and comrak.
MSRV What is the Minimum Supported Rust Version (MSRV)?
frontmatter-gen targets Rust 1.85.0 and Rust Edition 2024. The MSRV is verified in CI on every pull request.
Stability What constitutes a breaking change in frontmatter-gen?
In addition to Rust type and signature changes, any change to the observable output of extract_metadata or generate_metatags for existing inputs is treated as a breaking change under our stability policy.
Licensing Under what license is frontmatter-gen distributed?
frontmatter-gen is dual-licensed under the Apache License, Version 2.0 and the MIT License (Apache-2.0 OR MIT) at the recipient's option, and is 100% REUSE 3.3 compliant.
Support Where can I report bugs, request features, or ask integration questions?
Open an issue or discussion on GitHub, or reach out via our Contact Page. For security vulnerabilities, follow our Security Policy.
No matching questions found
Try searching for broader terms such as “YAML 1.2”, “TOML”, “Miri”, or “CLI”.
Have a question not listed here?
Explore the getting started guide and API reference, open an issue on GitHub, or contact us directly for architecture and integration support.