mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01: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 line = params.lines[lineNumber - 1];
|
||||||
const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
|
const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
|
||||||
const length = reversedLink.length;
|
const length = reversedLink.length;
|
||||||
|
const range = column ? [ column, length ] : null;
|
||||||
|
const fixInfo = column ?
|
||||||
|
{
|
||||||
|
"editColumn": column,
|
||||||
|
"deleteCount": length,
|
||||||
|
"insertText": `[${linkText}](${linkDestination})`
|
||||||
|
} :
|
||||||
|
null;
|
||||||
addError(
|
addError(
|
||||||
onError,
|
onError,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
reversedLink,
|
reversedLink,
|
||||||
null,
|
null,
|
||||||
[ column, length ],
|
range,
|
||||||
{
|
fixInfo
|
||||||
"editColumn": column,
|
|
||||||
"deleteCount": length,
|
|
||||||
"insertText": `[${linkText}](${linkDestination})`
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,13 @@ begin: /\B(([\/.])[\w\-.\/=]+)+/, {MD011}
|
||||||
{begin: '%r\\(', end: '\\)[a-z]*'} {MD011}
|
{begin: '%r\\(', end: '\\)[a-z]*'} {MD011}
|
||||||
|
|
||||||
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str); {MD011}
|
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str); {MD011}
|
||||||
|
|
||||||
|
## Escaped Parens
|
||||||
|
|
||||||
|
(reversed)[link] {MD011}
|
||||||
|
|
||||||
|
a ) a ( a )[a]~ {MD011}
|
||||||
|
|
||||||
|
<!-- markdownlint-disable no-inline-html-->
|
||||||
|
|
||||||
|
a<pre>) a ( a )[a]~</pre> {MD011}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue