Update MD054/link-image-style to split reference parameter into full/collapsed/shortcut parameters (fixes #918).

This commit is contained in:
David Anson 2023-11-11 22:12:50 -08:00
parent 4390715f4b
commit 063310e51a
21 changed files with 2583 additions and 80 deletions

View file

@ -29,8 +29,10 @@ module.exports = {
const { parsers, config } = params;
const autolink = (config.autolink === undefined) || !!config.autolink;
const inline = (config.inline === undefined) || !!config.inline;
const reference = (config.reference === undefined) || !!config.reference;
if (autolink && inline && reference) {
const full = (config.full === undefined) || !!config.full;
const collapsed = (config.collapsed === undefined) || !!config.collapsed;
const shortcut = (config.shortcut === undefined) || !!config.shortcut;
if (autolink && inline && full && collapsed && shortcut) {
// Everything allowed, nothing to check
return;
}
@ -62,12 +64,14 @@ module.exports = {
// link kind is an inline link
isError = !inline;
} else {
// link kind is a reference link
const referenceLabel =
getTokenTextByType(descendents, "referenceString") || label;
const definition = definitions.get(referenceLabel);
// link kind is a full/collapsed/shortcut reference link
const isShortcut = !children.some((t) => t.type === "reference");
const referenceString = getTokenTextByType(descendents, "referenceString");
const isCollapsed = (referenceString === null);
const definition = definitions.get(referenceString || label);
destination = definition && definition[1];
isError = !reference && destination;
isError = destination &&
(isShortcut ? !shortcut : (isCollapsed ? !collapsed : !full));
}
}
if (isError) {