Update MD037/no-space-in-emphasis to ignore emphasis markers in link text/destination (refs #286).

This commit is contained in:
David Anson 2020-05-08 16:01:42 -07:00
parent 0cea489e18
commit 37f1d6b64b
3 changed files with 38 additions and 8 deletions

View file

@ -2,8 +2,8 @@
"use strict";
const { addErrorContext, emphasisMarkersInCodeSpans, forEachLine,
includesSorted, isBlankLine } = require("../helpers");
const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine } =
require("../helpers");
const { lineMetadata } = require("./cache");
const emphasisRe = /(^|[^\\])(?:(\*\*?\*?)|(__?_?))/g;
@ -66,7 +66,7 @@ module.exports = {
return null;
}
// Initialize
const ignoreMarkersByLine = emphasisMarkersInCodeSpans(params);
const ignoreMarkersByLine = emphasisMarkersInContent(params);
resetRunTracking();
forEachLine(
lineMetadata(),
@ -89,8 +89,8 @@ module.exports = {
while ((match = emphasisRe.exec(line))) {
const ignoreMarkersForLine = ignoreMarkersByLine[lineIndex] || [];
const matchIndex = match.index + match[1].length;
if (includesSorted(ignoreMarkersForLine, matchIndex)) {
// Ignore emphasis markers inside code spans
if (ignoreMarkersForLine.includes(matchIndex)) {
// Ignore emphasis markers inside code spans and links
continue;
}
const matchLength = match[0].length - match[1].length;