Skip to content

fix(test): anchor docs fence-parity regex to line start#1319

Merged
tamirdresher merged 1 commit into
bradygaster:devfrom
tamirdresher:tamirdresher/fix-docs-fence-regex
Jun 15, 2026
Merged

fix(test): anchor docs fence-parity regex to line start#1319
tamirdresher merged 1 commit into
bradygaster:devfrom
tamirdresher:tamirdresher/fix-docs-fence-regex

Conversation

@tamirdresher

Copy link
Copy Markdown
Collaborator

Summary

The fence-parity check in est/docs-build.test.ts used /\/g which matched triple-backticks anywhere in file content — including inside table cells and inline code spans that document fence syntax itself. This caused false positives on legitimate documentation.

Root cause

docs/src/content/docs/features/skill-security-scanner.md line 69 contains a Markdown table cell that shows the fence-syntax escape using four-backtick quoting:

| Inside a fenced code block (`` ``) | Suppressed ... |
`

The old regex matched 3 triple-backtick occurrences from that single table cell (the two four-backtick spans each contain a triple-backtick match, plus the standalone ` in the middle), plus 2 from the real fenced bash block at L82/L91 = 5 total (odd) → failing parity check.

The second assertion (�lock.split('\n').length).toBeGreaterThan(1)) also failed as a cascade — the over-matching regex formed phantom single-line "code blocks" that failed the line-count check.

Fix

Anchor both regexes to line start with /^`/gm so only real fence delimiters (at column 0) are counted or matched:

  • Fence parity: //g /^/gm
  • Block extraction: /[\s\S]?/g /^[\s\S]?^/gm

Validation

Both failing tests now pass locally (
px vitest run test/docs-build.test.ts):

✓ Docs Structure Validation > Markdown Files > all code blocks are properly fenced (even count of)
✓ Docs Structure Validation > Code Example Validation > code blocks contain language specification or valid content
`

Impact

This unblocks PRs #1316, #1317, #1234 which are all blocked on the red CI on dev. The most recent failing CI run on dev: https://github.com/bradygaster/squad/actions/runs/27525511648

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 bradygaster#1316, bradygaster#1317, bradygaster#1234 which are all failing CI on dev.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 15, 2026 15:49
@github-actions

Copy link
Copy Markdown
Contributor

🟢 Impact Analysis — PR #1319

Risk tier: 🟢 LOW

📊 Summary

Metric Count
Files changed 1
Files added 0
Files modified 1
Files deleted 0
Modules touched 1

🎯 Risk Factors

  • 1 files changed (≤5 → LOW)
  • 1 module(s) touched (≤1 → LOW)

📦 Modules Affected

tests (1 file)
  • test/docs-build.test.ts

This report is generated automatically for every PR. See #733 for details.

@github-actions

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 9f11987

PR Scope: 🔧 Infrastructure

⚠️ 3 item(s) to address before review

Status Check Details
Single commit 1 commit — clean history
Not in draft Ready for review
Branch up to date dev is 1 commit(s) ahead — rebase recommended
Copilot review No Copilot review yet — it may still be processing
Changeset present No source files changed — changeset not required
Scope clean No .squad/ or docs/proposals/ files
No merge conflicts No merge conflicts
Copilot threads resolved No Copilot review threads
CI passing 7 check(s) still running

Files Changed (1 file, +6 −2)

File +/−
test/docs-build.test.ts +6 −2

Total: +6 −2


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the markdown fence-parity and code-block extraction logic in test/docs-build.test.ts to reduce false positives caused by matching triple backticks inside inline code/table cells.

Changes:

  • Anchors the fence-count regex to line start.
  • Anchors the code-block extraction regex to line start to avoid forming phantom single-line “blocks” from inline backticks.

Comment thread test/docs-build.test.ts
Comment on lines +155 to +157
// 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;
Comment thread test/docs-build.test.ts
Comment on lines +172 to +174
// 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) || [];
@tamirdresher tamirdresher merged commit ca3fdd6 into bradygaster:dev Jun 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants