From 9f1198707b8d275956da37b01d2c522f2f00f88f Mon Sep 17 00:00:00 2001 From: Tamir Dresher Date: Mon, 15 Jun 2026 18:48:13 +0300 Subject: [PATCH] fix(test): anchor docs fence-parity regex to line start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fence-parity check used /\\\/g which matched triple-backticks anywhere in file content — including inside table cells and inline code spans that document fence syntax itself. Reproducer: docs/src/content/docs/features/skill-security-scanner.md L69 contains a table cell that shows the fence-syntax escape with four-backtick quoting (\\\\ \\\ \\\\). The old regex matched 3 backtick-triples from that one cell plus 2 from the real fenced bash block at L82/L91 = 5 total (odd) → failing parity check. Fix: anchor both regexes to line start with /^\\\/gm so only real fence delimiters (at column 0) are counted or matched. - Line-count check: /\\\/g → /^\\\/gm - Block-extraction regex: /\\\[\s\S]*?\\\/g → /^\\\[\s\S]*?^\\\/gm This unblocks PRs #1316, #1317, #1234 which are all failing CI on dev. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- test/docs-build.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/docs-build.test.ts b/test/docs-build.test.ts index 832d868d5..b3f080d67 100644 --- a/test/docs-build.test.ts +++ b/test/docs-build.test.ts @@ -152,7 +152,9 @@ describe('Docs Structure Validation', () => { it('all code blocks are properly fenced (even count of ```)', () => { for (const file of getAllMarkdownFiles()) { const content = readFile(file); - const fenceCount = (content.match(/```/g) || []).length; + // Anchor to line-start so inline/table backticks (e.g. documenting fence syntax) + // are not counted as real fence delimiters. + const fenceCount = (content.match(/^```/gm) || []).length; expect(fenceCount % 2, `${basename(file)} has mismatched fences`).toBe(0); } }); @@ -167,7 +169,9 @@ describe('Docs Structure Validation', () => { describe('Code Example Validation', () => { it('code blocks contain language specification or valid content', () => { for (const file of getAllMarkdownFiles()) { - const codeBlocks = readFile(file).match(/```[\s\S]*?```/g) || []; + // Anchor both opening and closing fences to line-start so inline + // backtick usage inside table cells or prose does not form phantom blocks. + const codeBlocks = readFile(file).match(/^```[\s\S]*?^```/gm) || []; for (const block of codeBlocks) { expect(block.split('\n').length).toBeGreaterThan(1); }