Add MD034 with tests, improve validation of README and Rules.

This commit is contained in:
David Anson 2015-04-14 00:01:57 -07:00
parent 495fbac6fd
commit 0e24df7cf7
7 changed files with 104 additions and 34 deletions

View file

@ -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++;
}
});
});
}
}
];