Files
skillshare/internal
Willie aeaa8337bc refactor(utils): locate frontmatter in one place under a named policy
Each reader in internal/utils found the --- delimiters with its own
loop, under four different rules that were only visible by reading all
of them, and the list reader existed twice with a path copy and a bytes
copy that had drifted apart. A fix to one reader, like the mcp serve
fixes to the strict one, did not reach the others, and nobody could say
which rule an entry point followed without tracing it.

locateFrontmatter now does the locating for every reader, and the rule
is a frontmatterPolicy value: strictBlock, lenientBlock, bodyBlock and
rewriteBlock name the rules that exist and the entry points that use
them. The rules themselves are not unified; every entry point returns
what it returned before, including the bufio.Scanner quirks of the
readers that take a path (a line of 64 KiB or more ends the content,
one \r is dropped per line), which now live in scannable. The strict
reader still walks only to the closing delimiter and copies nothing.

Two more cases found by comparing old and new code on random input are
pinned: a block scalar on the last frontmatter line, and \r\r\n endings.

Refs #449
2026-10-07 00:09:14 +08:00
..