From 1b863ee9c793705b998eb1f096276075cbfba8e5 Mon Sep 17 00:00:00 2001 From: Michael Pursifull Date: Sat, 31 Jan 2026 13:10:14 -0600 Subject: [PATCH] feat: strip JSON example blocks to reduce false-positive broken refs Add stripJsonExampleBlocks() to the markdown reference extractor so bare JSON example/template blocks (braces on their own lines) are removed before pattern matching. This prevents paths inside example data from being flagged as broken references. --- tools/validate-file-refs.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/validate-file-refs.js b/tools/validate-file-refs.js index d00e27b5..175427b4 100644 --- a/tools/validate-file-refs.js +++ b/tools/validate-file-refs.js @@ -127,6 +127,12 @@ function stripCodeBlocks(content) { return content.replaceAll(/```[\s\S]*?```/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, ''); +} + // --- Path Mapping --- function mapInstalledToSource(refPath) { @@ -218,7 +224,7 @@ function extractYamlRefs(filePath, content) { function extractMarkdownRefs(filePath, content) { const refs = []; - const stripped = stripCodeBlocks(content); + const stripped = stripJsonExampleBlocks(stripCodeBlocks(content)); function runPattern(regex, type) { regex.lastIndex = 0;