Update MD039/no-space-in-links to handle hardbreaks (fixes #222).

This commit is contained in:
David Anson 2019-09-28 22:50:33 -07:00
parent fa9e08cf53
commit 1edb3f0a78
2 changed files with 9 additions and 4 deletions

View file

@ -18,10 +18,11 @@ module.exports = {
let linkText = "";
let lineIndex = 0;
children.forEach((child) => {
if (child.type === "link_open") {
const { content, type } = child;
if (type === "link_open") {
inLink = true;
linkText = "";
} else if (child.type === "link_close") {
} else if (type === "link_close") {
inLink = false;
const left = linkText.trimLeft().length !== linkText.length;
const right = linkText.trimRight().length !== linkText.length;
@ -45,11 +46,11 @@ module.exports = {
}
);
}
} else if (child.type === "softbreak") {
} else if ((type === "softbreak") || (type === "hardbreak")) {
lineNumber++;
lineIndex = 0;
} else if (inLink) {
linkText += child.content;
linkText += content;
}
});
});

View file

@ -41,3 +41,7 @@ function MoreCodeButNotCode(input) {
input = input.replace(/[- ]([a-z])/g, "three"); // {MD039}
return input;
}
[Links](ending)
[with](spaces)
[error ]({MD039})