Frontmatter: leading YAML run is one pinned block; example renders a Properties card
Frontmatter: leading YAML run is one pinned block; example renders a Properties card
#10 in Riparion/riparion-editor — merged 2026-06-05
Summary
Ergonomic YAML frontmatter handling, end to end:
Core (src/lib.rs)
split_blocksconsumes a leading---…---run (byte offset 0 only) as the outermost rule — before fences,is_atomic, and blank-line breaks — so its interior can never be split. The blank separator after the closing delimiter attaches to the block, same as every other block's trailing blank.- New
Block::frontmatterflag and publicfrontmatter_len()helper. rejoin_normalizedpreserves the YAML verbatim, so normalize-on-blur can't restructure it.- Pinned in arrange mode: the block renders above the
DragDropAreawith no ⠿ handle and no drop slot, plus a defensive guard inon_drop— reordering can't move it or land anything above it. - Unclosed
---stays an ordinary thematic break (doesn't swallow the doc);...closes per YAML; CRLF-safe; byte-for-byte round-trip invariant holds.
Markdown example
- Obsidian-style Properties card: scalar
key: valuerows edit inline (click value; Enter/blur commits, Esc cancels), per-row remove,+ Add property. - Non-scalar values (
tags: [a, b], nested blocks, comments) render read-only; the{}YAML button bubbles to the block's normal activate — the raw textarea is the escape hatch, for free. - Commits are line-targeted YAML rewrites, so comments, ordering, and the body survive untouched (no serializer round-trip).
File ▸ Add propertiesprepends starter frontmatter when missing; SEED shows the card off.
Test plan
- 14 new unit tests: one-block splitting, hostile interiors (embeds/fence chars inside YAML), offset-0-only detection, leading-blank/unclosed/empty/CRLF/
...-closed runs, frontmatter-only docs, normalization (38 total pass) -
cargo clippy --all-targets --features webclean;cargo fmt --checkclean -
cargo check --example markdown --features web --target wasm32-unknown-unknown - Manual:
dx serve --example markdown --features web— card pinned at top, inline edits persist, drag can't displace it, Save round-trips
🤖 Generated with Claude Code
Last updated 2026-06-05
Links to this note
Credits
Merged pull requests, newest first.