Fix highlighting of MD011/no-reversed-links when preceeded by decorated text.

This commit is contained in:
David Anson 2019-09-26 22:29:01 -07:00
parent a5f03d02d0
commit 3632ce28b9
4 changed files with 15 additions and 1 deletions

View file

@ -16,7 +16,8 @@ module.exports = {
let match = null;
while ((match = reversedLinkRe.exec(content)) !== null) {
const [ reversedLink, linkText, linkDestination ] = match;
const column = match.index + 1;
const line = params.lines[lineNumber - 1];
const column = line.indexOf(reversedLink) + 1;
const length = reversedLink.length;
addError(
onError,

View file

@ -22,3 +22,5 @@ A (reversed)[link] example.
## Multiple spaces E ##
## Multiple spaces F ##
*Another* (reversed)[link] example.

View file

@ -21,3 +21,5 @@ A [reversed](link) example.
## Multiple spaces E ##
## Multiple spaces F ##
*Another* [reversed](link) example.

View file

@ -8,6 +8,15 @@
"errorContext": null,
"errorRange": [3, 16]
},
{
"lineNumber": 26,
"ruleNames": [ "MD011", "no-reversed-links" ],
"ruleDescription": "Reversed link syntax",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md011",
"errorDetail": "(reversed)[link]",
"errorContext": null,
"errorRange": [11, 16]
},
{
"lineNumber": 7,
"ruleNames": [ "MD012", "no-multiple-blanks" ],