mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD011/no-reversed-links to remove RegExp negative lookbehind assertion which is not supported on Safari.
This commit is contained in:
parent
a8228ecd80
commit
e72b2ba985
2 changed files with 18 additions and 12 deletions
16
lib/md011.js
16
lib/md011.js
|
|
@ -6,7 +6,7 @@ const { addError, forEachLine, overlapsAnyRange } = require("../helpers");
|
|||
const { inlineCodeSpanRanges, lineMetadata } = require("./cache");
|
||||
|
||||
const reversedLinkRe =
|
||||
/(?<![\\\]])\(([^)]+)(?<!\\)\)\[([^\]^][^\]]*)(?<!\\)](?!\()/g;
|
||||
/(^|[^\\])\(([^)]+)\)\[([^\]^][^\]]*)](?!\()/g;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD011", "no-reversed-links" ],
|
||||
|
|
@ -18,14 +18,18 @@ module.exports = {
|
|||
if (!inCode && !onFence) {
|
||||
let match = null;
|
||||
while ((match = reversedLinkRe.exec(line)) !== null) {
|
||||
const [ reversedLink, linkText, linkDestination ] = match;
|
||||
const index = match.index;
|
||||
const length = match[0].length;
|
||||
if (!overlapsAnyRange(exclusions, lineIndex, index, length)) {
|
||||
const [ reversedLink, preChar, linkText, linkDestination ] = match;
|
||||
const index = match.index + preChar.length;
|
||||
const length = match[0].length - preChar.length;
|
||||
if (
|
||||
!linkText.endsWith("\\") &&
|
||||
!linkDestination.endsWith("\\") &&
|
||||
!overlapsAnyRange(exclusions, lineIndex, index, length)
|
||||
) {
|
||||
addError(
|
||||
onError,
|
||||
lineIndex + 1,
|
||||
reversedLink,
|
||||
reversedLink.slice(preChar.length),
|
||||
null,
|
||||
[ index + 1, length ],
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue