Skip to main content

normalize_fields

Function normalize_fields 

Source
pub fn normalize_fields(
    fields: IndexMap<String, QuillValue>,
) -> IndexMap<String, QuillValue>
Expand description

Normalizes document frontmatter fields per the Quillmark §7 spec.

This is an internal helper used by normalize_document. It operates on the typed IndexMap<String, QuillValue> frontmatter; it does not touch body or cards (those are normalized separately by the caller).

Field names at the top level are NFC-normalized (see normalize_field_name). Only body regions receive content normalization (bidi stripping + HTML comment fence repair). All other field values pass through verbatim.

§Examples

use quillmark_core::normalize::normalize_fields;
use quillmark_core::QuillValue;
use indexmap::IndexMap;

let mut fields = IndexMap::new();
fields.insert("title".to_string(), QuillValue::from_json(serde_json::json!("<<hello>>")));

let result = normalize_fields(fields);

// Title passes through verbatim
assert_eq!(result.get("title").unwrap().as_str().unwrap(), "<<hello>>");