mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD034 with tests, improve validation of README and Rules.
This commit is contained in:
parent
495fbac6fd
commit
0e24df7cf7
7 changed files with 104 additions and 34 deletions
27
lib/rules.js
27
lib/rules.js
|
@ -619,5 +619,32 @@ module.exports = [
|
|||
errors.push(token.lineNumber);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD034",
|
||||
"desc": "Bare URL used",
|
||||
"tags": [ "links", "url" ],
|
||||
"func": function MD034(params, errors) {
|
||||
filterTokens(params.tokens, "inline")
|
||||
.forEach(function forToken(token) {
|
||||
var lineNumber = token.lineNumber;
|
||||
var inLink = false;
|
||||
token.children.forEach(function forChild(child) {
|
||||
if (child.type === "link_open") {
|
||||
inLink = true;
|
||||
} else if (child.type === "link_close") {
|
||||
inLink = false;
|
||||
} else if ((child.type === "text") &&
|
||||
!inLink &&
|
||||
/https?:\/\//.test(child.content)) {
|
||||
errors.push(lineNumber);
|
||||
} else if ((child.type === "softbreak") ||
|
||||
(child.type === "hardbreak")) {
|
||||
lineNumber++;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue