mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Fix MD011/no-reversed-links to better handle escaped RegExp content in reversed links.
This commit is contained in:
parent
40ac584482
commit
6587ba7261
2 changed files with 13 additions and 2 deletions
|
@ -2,7 +2,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, forEachInlineChild } = require("../helpers");
|
||||
const { addError, forEachInlineChild, unescapeMarkdown } =
|
||||
require("../helpers");
|
||||
|
||||
const reversedLinkRe = /\(([^)]+)\)\[([^\]^][^\]]*)]/g;
|
||||
|
||||
|
@ -17,7 +18,7 @@ module.exports = {
|
|||
while ((match = reversedLinkRe.exec(content)) !== null) {
|
||||
const [ reversedLink, linkText, linkDestination ] = match;
|
||||
const line = params.lines[lineNumber - 1];
|
||||
const column = line.indexOf(reversedLink) + 1;
|
||||
const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
|
||||
const length = reversedLink.length;
|
||||
addError(
|
||||
onError,
|
||||
|
|
|
@ -22,3 +22,13 @@ code code
|
|||
code` text
|
||||
text
|
||||
text (reversed)[link] text {MD011}
|
||||
|
||||
## Escaped JavaScript Content
|
||||
|
||||
var IDENT_RE = '([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*'; {MD011}
|
||||
|
||||
begin: /\B(([\/.])[\w\-.\/=]+)+/, {MD011}
|
||||
|
||||
{begin: '%r\\(', end: '\\)[a-z]*'} {MD011}
|
||||
|
||||
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str); {MD011}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue