Keep a thematic break directly under the header in the body - #145
Merged
Merged
Conversation
The splitter consumed another frontmatter block whenever a delimiter line followed the one that closed the header, so a "---" rule placed straight under the header opened a block that ran to the next rule. Body text in between was either deleted (when it was not YAML) or moved into the header (when it was). Only the first block is now taken on trust. A follow-on block must hold a non-empty YAML mapping and must not open or close with a blank line; otherwise it and everything after it stay in the body. Tight stacked headers, which are supported on purpose, are unaffected. Fixes #140 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KMqfUfzWj2Gmdz1EqYdnLe
This was referenced Sep 27, 2026
…-stays-in-body # Conflicts: # Frontmatter.Test/DelimiterLineTests.cs
|
This was referenced Sep 27, 2026
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #140
What was wrong
TrySplitFrontmatterBlockskept consuming blocks for as long as a delimiter line followed the one that had just closed. A---rule placed straight under the header therefore opened a second "block" that ran to the next rule anywhere in the document.ExtractBody,RemoveFrontmatterand every rewriting API.Change
Only the first block is taken on trust. A follow-on block is accepted only when
IsFollowOnBlockholds, which requires all of the following:---/---pair under the header), andOtherwise splitting stops, and that block and everything after it stay in the body.
Decision to review: the triage asked for an owner call on the Case B rule. I used the example rule from the issue: a follow-on block whose content opens or closes with a blank line is body text. Stacked headers written tight against their delimiters, such as
---\ntitle: A\n---\n---\nauthor: B\n---, still combine as before, and the existingCombineFrontmatter_TwoConsecutiveBlocks_…test still passes. If you'd rather drop stacked-block support entirely, that is a one-line change inIsFollowOnBlock.Tests
DelimiterLineTestsgains four tests:ExtractBodyandRemoveFrontmatterreturn the whole body, both rules included.AddFrontmattermerges into the header and keeps the whole body.CombineFrontmatterleaves the document unchanged, and the YAML-like paragraph is not merged into the header.With the fix reverted, all 4 new tests fail. With the fix, the full suite passes: 157/157.
Note: #143 (for #141) also appends tests to the end of
DelimiterLineTests.cs, so whichever of the two merges second will need a trivial merge at the end of that file.🤖 Generated with Claude Code
https://claude.ai/code/session_01KMqfUfzWj2Gmdz1EqYdnLe
Generated by Claude Code