Fix MD039/no-space-in-links range for multiple issues on the same line.

This commit is contained in:
David Anson 2019-09-21 21:05:58 -07:00
parent 4843e277c0
commit a75f1ecf2a
4 changed files with 22 additions and 7 deletions

View file

@ -15,6 +15,7 @@ module.exports = {
const { line, lineNumber, children } = token;
let inLink = false;
let linkText = "";
let lineIndex = 0;
children.forEach((child) => {
if (child.type === "link_open") {
inLink = true;
@ -24,9 +25,10 @@ module.exports = {
const left = linkText.trimLeft().length !== linkText.length;
const right = linkText.trimRight().length !== linkText.length;
if (left || right) {
const match = line.match(spaceInLinkRe);
const column = match.index + 1;
const match = line.slice(lineIndex).match(spaceInLinkRe);
const column = match.index + lineIndex + 1;
const length = match[0].length;
lineIndex = column + length - 1;
addErrorContext(
onError,
lineNumber,