fix: preamble-hoist's section splitter closes a fence only on a bare delimiter (ship Step 11)

Inside an open fence, a line such as "```bash" is content in CommonMark,
but splitSections treated it as the closing fence, so a later "## " line in
the same block could split a section mid-code-block and hoist half of it.
A closing delimiter now needs nothing but whitespace after it. Every host's
render is unchanged (gen-skill-docs --dry-run FRESH on all twelve hosts).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-26 13:22:04 +00:00
1 parent e13bee1490
commit 066fe1954c
1 file changed
+2 -2
+2 -2
View File
@@ -35,10 +35,10 @@ function splitSections(text: string, marker = '## '): string[] {
let current: string[] = [];
let fence: string | null = null;
for (const line of text.split('\n')) {
const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
const [, delimiter, info] = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line) ?? [];
if (delimiter) {
if (!fence) fence = delimiter;
else if (delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = null;
else if (delimiter[0] === fence[0] && delimiter.length >= fence.length && !info.trim()) fence = null;
} else if (!fence && line.startsWith(marker) && current.some(l => l.trim())) {
sections.push(current.join('\n').trim());
current = [];