Motivation
The frontmatter mark's body is opaque text today (raw YAML/TOML). Consumers that want structured metadata — querying a key, transforming values, rendering metadata visibly — must parse the YAML themselves. Since the library's identity is semantic-event-stream tooling, frontmatter should optionally be expressible as events, queryable and transformable with the same machinery (transform DSL, matchers) instead of via a side-channel string.
Design sketch
An opt-in downstream operator (Flow<SemanticEvent>.parseFrontmatter() or similar), NOT parser behavior:
- The raw text body stays the canonical representation inside the
frontmatter mark. This preserves the round-trip fixpoint (comments, key order, |/> block scalars, quoting quirks survive verbatim) and the "parser never throws" guarantee (malformed YAML degrades gracefully as text). The operator replaces the body with structured events only for consumers that ask for it.
- Vocabulary:
dl/dt/dd for mappings, ul/li for sequences, nested recursively. This is the HTML-idiomatic encoding of a property tree, consistent with the parser's existing style of untagged marks carrying HTML names (p, em, table), and it means the existing HTML renderer displays frontmatter meaningfully with zero new rendering code.
- Scalar type info (booleans, numbers, dates), if ever needed, can ride on an attribute (e.g.
dd type="int"); plain text is fine for LLM-facing output.
- Pragmatic YAML subset: scalars, flat and nested block mappings, block sequences, quoted strings. Anchors, aliases, flow syntax, and multi-line scalars fall back to emitting the unparsed text verbatim — a full multiplatform YAML parser in
commonMain is out of scope.
- The expansion is lossy by design (comments and formatting die), so it belongs strictly on the consuming side of pipelines, never on any path that later hits
renderMarkdown() expecting a fixpoint.
- TOML support can follow the same shape later; YAML first.
Context
Emerged from designing the frontmatter title operator (ensureFrontmatterTitle): title detection/injection is a line-level operation on the raw body, so the two features are decoupled — this issue tracks the structural parsing for when a real consumer materializes.
Motivation
The
frontmattermark's body is opaque text today (raw YAML/TOML). Consumers that want structured metadata — querying a key, transforming values, rendering metadata visibly — must parse the YAML themselves. Since the library's identity is semantic-event-stream tooling, frontmatter should optionally be expressible as events, queryable and transformable with the same machinery (transform DSL, matchers) instead of via a side-channel string.Design sketch
An opt-in downstream operator (
Flow<SemanticEvent>.parseFrontmatter()or similar), NOT parser behavior:frontmattermark. This preserves the round-trip fixpoint (comments, key order,|/>block scalars, quoting quirks survive verbatim) and the "parser never throws" guarantee (malformed YAML degrades gracefully as text). The operator replaces the body with structured events only for consumers that ask for it.dl/dt/ddfor mappings,ul/lifor sequences, nested recursively. This is the HTML-idiomatic encoding of a property tree, consistent with the parser's existing style of untagged marks carrying HTML names (p,em,table), and it means the existing HTML renderer displays frontmatter meaningfully with zero new rendering code.dd type="int"); plain text is fine for LLM-facing output.commonMainis out of scope.renderMarkdown()expecting a fixpoint.Context
Emerged from designing the frontmatter title operator (
ensureFrontmatterTitle): title detection/injection is a line-level operation on the raw body, so the two features are decoupled — this issue tracks the structural parsing for when a real consumer materializes.