Skip to content

fix(ui): parse nested frontmatter maps and arrays of maps - #1548

Merged
backnotprop merged 4 commits into
backnotprop:mainfrom
FNDEVVE:fix/1485-frontmatter-nested
Sep 21, 2026
Merged

backnotprop merged 4 commits into
backnotprop:mainfrom
FNDEVVE:fix/1485-frontmatter-nested

Conversation

@FNDEVVE

@FNDEVVE FNDEVVE commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

extractFrontmatter trimmed every line, so indented child keys (generated:/by:/at:, verified:/sources: arrays of maps) hoisted to the document root, where same-named keys clobbered each other and the card rendered wrong-but-complete-looking values.

The parser is now indentation-aware: nested maps stay grouped, arrays of maps group per item, and flat scalars, string arrays, block scalars (|/>), and CRLF all behave as before. FrontmatterCard renders nested structures recursively (flat frontmatter renders exactly as today).

Testing: bun test packages/ui/utils/parser.test.ts (197 pass, incl. 6 new nested-structure tests + regressions), full bun run typecheck clean.

Closes #1485.

FNDEVVE and others added 4 commits September 16, 2026 13:16
extractFrontmatter hoisted indented child keys to the root, clobbering same-named keys and rendering wrong values.

Parse nested maps and arrays of maps; flat frontmatter renders byte-identically.

Closes backnotprop#1485.
A line starting and ending with a quote was rejected wholesale, so
`"title": "Doc"` parsed to {} and the row disappeared from the
frontmatter card. Accept a quoted KEY followed by `:` (plus the same
space-after-colon rule the unquoted branch applies); a line that is only
a quoted scalar is still not an entry.

Also record an array item's pending key at the key's own column
(lineIndent + 2) rather than the dash's, so a nested map used as an
item's first key no longer swallows the item's later sibling keys.
@backnotprop
backnotprop merged commit d82db6e into backnotprop:main Sep 21, 2026
24 checks passed
@backnotprop

Copy link
Copy Markdown
Owner

Merged, thanks @FNDEVVE. Two small parser additions went in on top of your branch before merge: quoted keys ("title": "Doc") parse as a mapping instead of vanishing from the card, and a nested map as an array item's first key no longer swallows its siblings. Fixes #1485. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotate: frontmatter card shows wrong values when the YAML has nested keys

2 participants