Repository navigation
Close a frontmatter block at YAML's ... document end marker [patch] - #182
Merged
Merged
Conversation
A block opened by `---` and closed by Pandoc's `...` was not closed, so the scan ran on to the next `---` anywhere in the document (usually a markdown horizontal rule). RemoveFrontmatter, ReplaceFrontmatter and ExtractBody then deleted the body up to that rule, and with no later rule the block was not recognised at all. `...` now closes a block but never opens one, and an indented `...` inside a value is left alone. Rewritten documents close their frontmatter with `---`. Fixes #152 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N47Hdpq8iSMutiKdDS81pa
|
This was referenced Oct 6, 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 #152
Problem
TrySplitFrontmatterBlocksonly accepted---as a closing delimiter. If a block was opened by---and closed by Pandoc's...document end marker, the block never closed. The scan carried on to the next---in the document, which is usually a markdown horizontal rule. As a result:RemoveFrontmatterandReplaceFrontmatterdeleted the body up to that rule.ExtractBodyreturned only what came after the rule.---, the document was treated as having no frontmatter at all.Change
TrimEnd()is..., through a newIsClosingDelimiterLine....never opens a block. Openers still go throughIsDelimiterLineandHasFrontmatter....inside a block scalar does not close the block, because only a whole line equal to...counts.---. TheTrySplitFrontmatterBlocksremarks now say so.Tests
DelimiterLineTestshas seven new tests:ExtractFrontmatter,ExtractBody,RemoveFrontmatterandReplaceFrontmatter....with trailing whitespace and no later rule....on the first line is not an opener....inside a|value does not close the block.With the fix reverted, the first five fail. The two guard tests pass either way, by design. The full suite passes: 237/237.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N47Hdpq8iSMutiKdDS81pa
Generated by Claude Code