From 773da2820a68db7e3d08a9e6e9918f6b5f55801b Mon Sep 17 00:00:00 2001 From: Michael Pursifull Date: Sat, 31 Jan 2026 14:30:48 -0600 Subject: [PATCH] fix: correct verbose [OK]/[BROKEN] overlap and line number drift Broken refs no longer print [OK] before [BROKEN] in --verbose mode. Code block stripping now preserves newlines so offsetToLine() reports accurate line numbers when code blocks precede broken references. --- tools/validate-file-refs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/validate-file-refs.js b/tools/validate-file-refs.js index 747b92ec..6c9b7e8e 100644 --- a/tools/validate-file-refs.js +++ b/tools/validate-file-refs.js @@ -124,13 +124,13 @@ function getSourceFiles(dir) { // --- Code Block Stripping --- function stripCodeBlocks(content) { - return content.replaceAll(/```[\s\S]*?```/g, ''); + return content.replaceAll(/```[\s\S]*?```/g, (m) => m.replaceAll(/[^\n]/g, '')); } function stripJsonExampleBlocks(content) { // Strip bare JSON example blocks: { and } each on their own line. // These are example/template data (not real file references). - return content.replaceAll(/^\{\s*\n(?:.*\n)*?^\}\s*$/gm, ''); + return content.replaceAll(/^\{\s*\n(?:.*\n)*?^\}\s*$/gm, (m) => m.replaceAll(/[^\n]/g, '')); } // --- Path Mapping --- @@ -368,6 +368,7 @@ for (const filePath of files) { } broken.push({ ref, resolved: path.relative(PROJECT_ROOT, resolved) }); brokenRefs++; + continue; } if (VERBOSE && resolved) {