fix(md)!: warn if region not found

when a region is not in the source file,
instead of including the whole file,
warn that the #region was not found in it.

fix #4625
Miroma 4 months ago
parent cb83272074
commit 6e8827146e
No known key found for this signature in database

@ -218,6 +218,10 @@ export const snippetPlugin = (md: MarkdownItAsync, srcDir: string) => {
)
.join('\n')
)
} else {
token.content = `No region #${region} found in path: ${src}`
token.info = ''
return fence(...args)
}
}

@ -70,9 +70,13 @@ export function processIncludes(
}
}
content = regions
.flatMap((region) => lines.slice(region.start, region.end))
.join('\n')
if (regions.length > 0) {
content = regions
.flatMap((region) => lines.slice(region.start, region.end))
.join('\n')
} else {
content = `No region or heading #${region} found in path: ${includePath}`
}
}
if (range) {

Loading…
Cancel
Save