mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10: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 || [];
|
var names = params.options.names || [];
|
||||||
names.forEach(function forName(name) {
|
names.forEach(function forName(name) {
|
||||||
var escapedName = escapeForRegExp(name);
|
var escapedName = escapeForRegExp(name);
|
||||||
var namePattern = "\\b" + escapedName + "\\b";
|
var namePattern = "\\S*\\b(" + escapedName + ")\\b\\S*";
|
||||||
var anyNameRe = new RegExp(namePattern, "gi");
|
var anyNameRe = new RegExp(namePattern, "gi");
|
||||||
function forToken(token) {
|
function forToken(token) {
|
||||||
var fenceOffset = (token.type === "fence") ? 1 : 0;
|
var fenceOffset = (token.type === "fence") ? 1 : 0;
|
||||||
token.content.split(shared.newLineRe)
|
token.content.split(shared.newLineRe)
|
||||||
.forEach(function forLine(line, index) {
|
.forEach(function forLine(line, index) {
|
||||||
var matches = line.match(anyNameRe) || [];
|
var match = null;
|
||||||
matches.forEach(function forMatch(match) {
|
while ((match = anyNameRe.exec(line)) !== null) {
|
||||||
var lineNumber = token.lineNumber + index + fenceOffset;
|
if (!bareUrlRe.test(match[0])) {
|
||||||
errors.addDetailIf(lineNumber, name, match);
|
var lineNumber = token.lineNumber + index + fenceOffset;
|
||||||
});
|
errors.addDetailIf(lineNumber, name, match[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
forEachInlineChild(params, "text", forToken);
|
forEachInlineChild(params, "text", forToken);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ Link to [GitHub](https://github.com/).
|
||||||
|
|
||||||
Link to [markdownlint](https://github.com/DavidAnson/MARKDOWNLINT).
|
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
|
A short paragraph
|
||||||
about node.js and {MD044}
|
about node.js and {MD044}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue