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
ExtractFrontmatter returns only the first of stacked frontmatter blocks, while ExtractBody and RemoveFrontmatter strip all of them, so later blocks' properties are lost to readers #169
The library treats consecutive frontmatter blocks as one header. PR #166 (fixing #138) made AddFrontmatter and CombineFrontmatter fold all of the blocks together, and ExtractBody, RemoveFrontmatter and ReplaceFrontmatter also treat every block as header. ExtractFrontmatter, however, still returns frontmatterObjects.First() (Frontmatter/Frontmatter.cs:139). As a result, properties in the second and later blocks appear in neither the extracted frontmatter nor the extracted body.
ExtractFrontmatter: { title: Hello } <- author missing
ExtractBody: # Body <- author block stripped as header
RemoveFrontmatter: # Body\n
AddFrontmatter(x=1): ---\ntitle: Hello\nauthor: Jane\nx: 1\n---\n# Body\n <- author IS part of the header here
Why it matters
A static-site or indexing tool that reads a page with ExtractFrontmatter plus ExtractBody loses author: Jane entirely: it is in neither the metadata nor the body. The same library's AddFrontmatter and CombineFrontmatter do count it as frontmatter, so the API gives different answers depending on which method is called.
Suggested fix / acceptance criteria
ExtractFrontmatter returns CombineAllFrontmatterObjects(ExtractFrontmatterObjects(input, out _)), the same first-block-wins fold that AddFrontmatter uses. It returns null when the result is empty.
Test: for the document above, ExtractFrontmatter returns both title and author.
Test: when stacked blocks repeat a key, the first block's value wins, matching AddFrontmatter_StackedBlocksRepeatAKey_FirstBlockWins.
Category: Bug (API inconsistency / data lost to readers)
Priority: Medium. Stacked frontmatter blocks are uncommon, but when they occur, ExtractFrontmatter + ExtractBody drops the later blocks' properties from both results. The fix is one line that reuses CombineAllFrontmatterObjects.
Activity
matt-edmondson commentedon Sep 29, 2026
Triage
ExtractFrontmatter+ExtractBodydrops the later blocks' properties from both results. The fix is one line that reusesCombineAllFrontmatterObjects.ExtractFrontmatterinFrontmatter/Frontmatter.cs:139. It is a leftover from AddFrontmatter deletes every frontmatter block after the first #138 / PR Keep every frontmatter block when adding or combining properties [patch] #166.Generated by Claude Code