Update MD044/proper-names to ignore violations in bare URLs (fixes #50).

This commit is contained in:
David Anson 2017-03-17 20:08:57 -07:00
parent 5e710e31c8
commit 15fe91ba38
2 changed files with 9 additions and 7 deletions

View file

@ -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);

View file

@ -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}