mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD044/proper-names to ignore non-text content like link targets.
This commit is contained in:
parent
1b44ed54e4
commit
935935b96c
2 changed files with 35 additions and 6 deletions
21
lib/rules.js
21
lib/rules.js
|
@ -1128,12 +1128,21 @@ module.exports = [
|
|||
var escapedName = escapeForRegExp(name);
|
||||
var namePattern = "\\b" + escapedName + "\\b";
|
||||
var anyNameRe = new RegExp(namePattern, "gi");
|
||||
forEachLine(params, function forLine(line, lineIndex) {
|
||||
var matches = line.match(anyNameRe) || [];
|
||||
matches.forEach(function forMatch(match) {
|
||||
errors.addDetailIf(lineIndex + 1, name, match);
|
||||
});
|
||||
});
|
||||
function forToken(token) {
|
||||
var fenceOffset = (token.type === "fence") ? 1 : 0;
|
||||
token.content.split(shared.newLineRe)
|
||||
.forEach(function forLine(line, index) {
|
||||
var matches = line.match(anyNameRe) || [];
|
||||
matches.forEach(function forMatch(match) {
|
||||
var lineNumber = token.lineNumber + index + fenceOffset;
|
||||
errors.addDetailIf(lineNumber, name, match);
|
||||
});
|
||||
});
|
||||
}
|
||||
forEachInlineChild(params, "text", forToken);
|
||||
forEachInlineChild(params, "code_inline", forToken);
|
||||
filterTokens(params, "code_block", forToken);
|
||||
filterTokens(params, "fence", forToken);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue