Skip to content

Keep every frontmatter block when adding or combining properties [patch] - #166

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/keep-every-frontmatter-block-138-139
Sep 29, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/keep-every-frontmatter-block-138-139

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #138
Fixes #139

Both issues had the same cause: the header was rebuilt from only some of the blocks, but the body still started after all of them. Per the triage on #138, they are fixed together here.

Changes

Note on the #139 repro

The repro in the issue (an unparseable second block) no longer loses data on main. TrySplitFrontmatterBlocks only accepts a follow-on block that parses, so that block already stays verbatim in the body. The data loss still happens when the first block is unparseable and a later one parses: the first block is always taken as frontmatter, and it was being dropped. The tests cover that case, and a guard test keeps the second-block case in the body.

Tests

  • New file StackedBlockPreservationTests. With Frontmatter.cs reverted, 5 of its tests fail. With the fix, the full suite passes (204/204).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RpyD4tJtfe5diTxv8UEw2x


Generated by Claude Code

AddFrontmatter merged the new properties into the first block only, then
rebuilt the document from the body after all blocks, so properties in
later blocks were deleted. It now folds every block in first.

CombineFrontmatter skipped a block it could not parse but still started
the body after it, so an unreadable first block was deleted whenever a
later block parsed. It now returns the input unchanged in that case,
matching AddFrontmatter's guard.

Fixes #138
Fixes #139

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

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

2 participants