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.
This commit is contained in:
Michael Pursifull 2026-01-31 13:10:14 -06:00
parent 8a91b32315
commit 1b863ee9c7
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -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;