Update MD052/reference-links-images to add ignored_labels parameter and default to ignoring GFM task list items (fixes #1524).

This commit is contained in:
David Anson 2025-04-27 22:36:07 -07:00
parent c413ac9a88
commit 328506e6c8
19 changed files with 357 additions and 12 deletions

View file

@ -996,6 +996,10 @@ export interface ConfigurationStrict {
MD052?:
| boolean
| {
/**
* Ignored link labels
*/
ignored_labels?: string[];
/**
* Include shortcut syntax
*/
@ -1007,6 +1011,10 @@ export interface ConfigurationStrict {
"reference-links-images"?:
| boolean
| {
/**
* Ignored link labels
*/
ignored_labels?: string[];
/**
* Include shortcut syntax
*/

View file

@ -13,6 +13,7 @@ export default {
"function": function MD052(params, onError) {
const { config, lines } = params;
const shortcutSyntax = config.shortcut_syntax || false;
const ignoredLabels = new Set(config.ignored_labels || [ "x" ]);
const { definitions, references, shortcuts } = getReferenceLinkImageData();
const entries = shortcutSyntax ?
[ ...references.entries(), ...shortcuts.entries() ] :
@ -20,7 +21,7 @@ export default {
// Look for links/images that use an undefined link reference
for (const reference of entries) {
const [ label, datas ] = reference;
if (!definitions.has(label)) {
if (!definitions.has(label) && !ignoredLabels.has(label)) {
for (const data of datas) {
const [ lineIndex, index, length ] = data;
// Context will be incomplete if reporting for a multi-line link