Skip to content

Return every stacked block's properties from ExtractFrontmatter [patch] - #201

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/169-extract-stacked-blocks
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/169-extract-stacked-blocks

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

ExtractBody, RemoveFrontmatter and AddFrontmatter already treat consecutive frontmatter blocks as one header (#138 / #166). ExtractFrontmatter, though, still returned only the first block. So in ---\ntitle: Hello\n---\n---\nauthor: Jane\n---\n# Body, author: Jane showed up in neither the extracted frontmatter nor the body.

ExtractFrontmatter now folds every block through CombineAllFrontmatterObjects, the same fold AddFrontmatter uses, so the first block to define a key wins. It still returns null when nothing parses. Single-block documents are unaffected.

Tests in StackedBlockPreservationTests:

  • The issue's repro returns both title and author, and its body is # Body.
  • When stacked blocks repeat a key, the first block's value wins, mirroring AddFrontmatter_StackedBlocksRepeatAKey_FirstBlockWins.

Without the fix, both new tests fail. With it, the full suite passes (299/299).

Fixes #169

🤖 Generated with Claude Code

https://claude.ai/code/session_019MupvoiQ9WM1vUJoCzYJ6W


Generated by Claude Code

ExtractBody, RemoveFrontmatter and AddFrontmatter treat consecutive
frontmatter blocks as one header, but ExtractFrontmatter returned only the
first block, so a later block's properties were in neither the extracted
frontmatter nor the body. Fold every block the way AddFrontmatter does, so
the first block to define a key wins.

Fixes #169

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MupvoiQ9WM1vUJoCzYJ6W
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

1 participant