mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD054/link-image-style to split reference parameter into full/collapsed/shortcut parameters (fixes #918).
This commit is contained in:
parent
4390715f4b
commit
063310e51a
21 changed files with 2583 additions and 80 deletions
18
lib/md054.js
18
lib/md054.js
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue