mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD044/proper-names to ignore violations in bare URLs (fixes #50).
This commit is contained in:
parent
5e710e31c8
commit
15fe91ba38
2 changed files with 9 additions and 7 deletions
14
lib/rules.js
14
lib/rules.js
|
|
@ -1126,17 +1126,19 @@ module.exports = [
|
|||
var names = params.options.names || [];
|
||||
names.forEach(function forName(name) {
|
||||
var escapedName = escapeForRegExp(name);
|
||||
var namePattern = "\\b" + escapedName + "\\b";
|
||||
var namePattern = "\\S*\\b(" + escapedName + ")\\b\\S*";
|
||||
var anyNameRe = new RegExp(namePattern, "gi");
|
||||
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);
|
||||
});
|
||||
var match = null;
|
||||
while ((match = anyNameRe.exec(line)) !== null) {
|
||||
if (!bareUrlRe.test(match[0])) {
|
||||
var lineNumber = token.lineNumber + index + fenceOffset;
|
||||
errors.addDetailIf(lineNumber, name, match[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
forEachInlineChild(params, "text", forToken);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Link to [GitHub](https://github.com/).
|
|||
|
||||
Link to [markdownlint](https://github.com/DavidAnson/MARKDOWNLINT).
|
||||
|
||||
Bare URL https://github.com/DavidAnson/markdownlint {MD034} {MD044}
|
||||
Bare URL exempt https://github.com/DavidAnson/MARKDOWNLINT {MD034}
|
||||
|
||||
A short paragraph
|
||||
about node.js and {MD044}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue