You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AddFrontmatter deletes every frontmatter block after the first #138
When a document has more than one frontmatter block, AddFrontmatter (Frontmatter/Frontmatter.cs:173-184) does the following:
It calls ExtractFrontmatter(input), which returns only frontmatterObjects.First() (:138).
It merges the new properties into that first block.
It calls ReplaceFrontmatter(input, combined), which rebuilds the document from the body that comes after all blocks (ExtractFrontmatterObjects(input, out string body), :208).
So the properties from the second and later blocks are neither merged nor preserved; they are simply removed from the document.
Actual: ---\ntitle: T\nauthor: Me\n---\nbody. The tags value is gone.
Expected: title, tags and author in the header, which is what CombineFrontmatter produces for the same input.
Why it matters
A call meant to add one property deletes existing properties, and nothing reports it. Multiple stacked blocks are exactly the input CombineFrontmatter exists to handle, and the recent hardening in AddFrontmatter ("frontmatter it cannot read is left alone", from the #132/#133 fix) shows the intent is never to lose data. This path still loses data the library can read.
Suggested fix
In AddFrontmatter, fold every parsed block together (ExtractFrontmatterObjects + CombineFrontmatterObjects, as CombineFrontmatter does at :87-91) before merging in the new properties. If any non-blank block fails to parse, return the input unchanged, matching the existing guard.
Acceptance: the repro keeps tags, with a regression test covering two stacked blocks.
Priority: High. A call meant to add one property silently deletes existing, perfectly parseable properties. It happens on ordinary input (stacked blocks, which CombineFrontmatter exists to handle) and nothing reports it.
Area / suggested owner:AddFrontmatter / ExtractFrontmatter / ReplaceFrontmatter in Frontmatter.cs.
Duplicates / in progress: None found. No open PR covers this.
Next step: In AddFrontmatter, fold all parsed blocks with ExtractFrontmatterObjects + CombineFrontmatterObjects before merging, and bail out unchanged if any non-blank block fails to parse. Add a two-stacked-blocks regression test.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
CombineFrontmatterexists to handle) and nothing reports it.AddFrontmatter/ExtractFrontmatter/ReplaceFrontmatterinFrontmatter.cs.AddFrontmatter, fold all parsed blocks withExtractFrontmatterObjects+CombineFrontmatterObjectsbefore merging, and bail out unchanged if any non-blank block fails to parse. Add a two-stacked-blocks regression test.Generated by Claude Code