mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Fix bug in MD039 where links with markup could trigger incorrectly.
This commit is contained in:
parent
1906214b07
commit
31ae415dbe
2 changed files with 30 additions and 4 deletions
19
lib/rules.js
19
lib/rules.js
|
|
@ -742,15 +742,26 @@ module.exports = [
|
|||
filterTokens(params.tokens, "inline")
|
||||
.forEach(function forToken(token) {
|
||||
var inLink = false;
|
||||
var index = 0;
|
||||
var lastChildRightSpaceLineNumber = 0;
|
||||
token.children.forEach(function forChild(child) {
|
||||
if (child.type === "link_open") {
|
||||
inLink = true;
|
||||
index = 0;
|
||||
} else if (child.type === "link_close") {
|
||||
inLink = false;
|
||||
} else if ((child.type === "text") &&
|
||||
inLink &&
|
||||
(child.content.trim().length !== child.content.length)) {
|
||||
errors.push(child.lineNumber);
|
||||
if (lastChildRightSpaceLineNumber) {
|
||||
errors.push(lastChildRightSpaceLineNumber);
|
||||
}
|
||||
} else if (inLink) {
|
||||
if ((index === 0) &&
|
||||
(child.content.trimLeft().length !== child.content.length)) {
|
||||
errors.push(child.lineNumber);
|
||||
}
|
||||
lastChildRightSpaceLineNumber =
|
||||
(child.content.trimRight().length !== child.content.length) ?
|
||||
child.lineNumber : 0;
|
||||
index++;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue