mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Avoid exception when MD011/no-reversed-links is not able to report column/length (fixes #339).
This commit is contained in:
parent
aa7fbce2dd
commit
9afd4e1ab5
2 changed files with 20 additions and 6 deletions
16
lib/md011.js
16
lib/md011.js
|
@ -20,17 +20,21 @@ module.exports = {
|
|||
const line = params.lines[lineNumber - 1];
|
||||
const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
|
||||
const length = reversedLink.length;
|
||||
const range = column ? [ column, length ] : null;
|
||||
const fixInfo = column ?
|
||||
{
|
||||
"editColumn": column,
|
||||
"deleteCount": length,
|
||||
"insertText": `[${linkText}](${linkDestination})`
|
||||
} :
|
||||
null;
|
||||
addError(
|
||||
onError,
|
||||
lineNumber,
|
||||
reversedLink,
|
||||
null,
|
||||
[ column, length ],
|
||||
{
|
||||
"editColumn": column,
|
||||
"deleteCount": length,
|
||||
"insertText": `[${linkText}](${linkDestination})`
|
||||
}
|
||||
range,
|
||||
fixInfo
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue