Re-implement MD011/no-reversed-links for better accuracy (range and fixInfo are now always valid) (fixes #398).

This commit is contained in:
David Anson 2021-06-17 21:50:03 -07:00
parent 646a67b8bd
commit 706f48bd25
6 changed files with 165 additions and 91 deletions

View file

@ -1,17 +1,26 @@
# reversed_link
Go to [this website](https://www.example.com)
Go to (this website)[https://www.example.com] {MD011}
Go to (this)[website](https://www.example.com)
However, this shouldn't trigger inside code blocks:
myObj.getFiles("test")[0]
Nor code fences:
```js
myObj.getFiles(test)[0];
```
Nor inline code: `myobj.getFiles("test")[0]`
Two (issues)[https://www.example.com/one] in {MD011}
the (same text)[https://www.example.com/two]. {MD011}
<!-- markdownlint-disable line-length -->
Two (issues)[https://www.example.com/three] on the (same line)[https://www.example.com/four]. {MD011}
`code code
@ -31,16 +40,40 @@ var IDENT_RE = '([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*'; {MD011}
begin: /\B(([\/.])[\w\-.\/=]+)+/, {MD011}
{begin: '%r\\(', end: '\\)[a-z]*'} {MD011}
{begin: '%r\\(', end: '\\)[a-z]*'}
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str); {MD011}
## Escaped Parens
&lpar;reversed&rpar;[link] {MD011}
&lpar;reversed&rpar;[link]
a &rpar; a &lpar; a &rpar;[a]~ {MD011}
a &rpar; a &lpar; a &rpar;[a]~
<!-- markdownlint-disable no-inline-html-->
a<pre>&rpar; a &lpar; a &rpar;[a]~</pre>
a<pre>&rpar; a &lpar; a &rpar;[a]~</pre> {MD011}
## Backslash Escapes
xxx(xxx)[xxx] {MD011}
xxx\(xxx)[xxx]
xxx(xxx\)[xxx]
xxx(xxx)\[xxx]
xxx(xxx)[xxx\]
## Consecutive Links
text [link](destination) text [link](destination) text
text [link](destination)[link](destination) text
text [link](destination)[link](destination)[link](destination) text
text (reversed)[link] text (reversed)[link] text {MD011}
<!-- markdownlint-configure-file {
"code-block-style": false,
"line-length": false,
"no-inline-html": false
} -->