Repository navigation
v1.9.6 — frontmatter is metadata, not body content, on every extractor
Frontmatter is document metadata, not body content — on every extractor (#58).
#57 fixed the two renderers (md_to_text, md_to_html) and deliberately left the extractors alone, because whether an extractor should see frontmatter is an API question rather than an obvious defect. This settles it: body only, everywhere.
What changes
For any document that has a frontmatter block, these now read the body and skip the metadata:
| surface | before | after |
|---|---|---|
md_extract_links, md_extract_images, md_extract_wikilinks, md_extract_tags |
included metadata rows | body rows only |
md_extract_code_blocks, md_extract_tables_json, md_extract_table_rows |
parsed the whole document | body only |
md_stats — word_count, char_count, line_count, reading_time_minutes |
counted the metadata block as prose | body only |
read_markdown — wikilinks, tags, stats columns |
same leak, via the same primitives | body only |
Concretely: a document whose frontmatter carries title: [Doc](http://example.com) no longer reports that as a document link, and md_stats on a one-word body with a three-line metadata block reports one word rather than eleven.
line_number still refers to the original document, not to the body's own numbering, so positions reported by the extractors still locate the text in the file as written.
Scope was wider than the issue described
#58 listed five functions, enumerated from cmark_parser_feed call sites. md_extract_wikilinks and md_extract_tags are linear scanners that never touch cmark, so that method structurally could not see them — and they leaked identically. Seven surfaces, not five. Grepping one mechanism to enumerate surfaces misses the ones built on another.
Nothing is discarded
The competing design was to keep the metadata rows and label them, on the principle that a visible leak beats a silent discard — the canonical OG image being the case a strip would lose. Measured, there is no discard: the frontmatter stays reachable on its own and composes.
-- body images only
SELECT md_extract_images(content) FROM read_markdown('posts/*.md');
-- the frontmatter's image, on purpose
SELECT md_extract_images(md_extract_frontmatter(content)::MARKDOWN)
FROM read_markdown('posts/*.md');
-- or as flat metadata
SELECT md_extract_metadata(content)['image'] FROM read_markdown('posts/*.md');That composability is pinned in the test suite: if it ever stops working, the reasoning behind stripping is void rather than quietly wrong.
If you relied on the old behaviour
Queries that counted links, images, tags, wikilinks or words across documents with frontmatter will return different numbers after this upgrade. To get the previous result for a given document, ask for the metadata explicitly with md_extract_frontmatter(content)::MARKDOWN as shown above, or md_extract_metadata(content) for a flat MAP.
Why this is a patch release
md_stats reporting twenty-one words for an eleven-word body, and a "link" that exists only in a metadata block, were defects rather than features. This is a bug fix that changes behaviour, not a new capability.
Tests
test/sql/frontmatter_extractors.test, 34 assertions, plus two fixtures.
Prior coverage was zero — nothing anywhere fed document-initial frontmatter to any of the seven and asserted a value, which is why this shipped for so long and why the suite passed unchanged when the behaviour was fixed. Each surface is compared against the same document minus its frontmatter (a control, rather than a hardcoded count that drifts with the fixture), and the absolute values are pinned too, so an equality that held because both sides broke the same way still fails.
Verified discriminating rather than merely passing: with the source fix reverted and the tests left in place, the file fails; restored, all 34 pass.
Suite: 2007 assertions across 57 files.