Add MD029 with tests.

This commit is contained in:
David Anson 2015-03-07 22:46:45 -08:00
parent 35067149c9
commit 5591cf4587
5 changed files with 58 additions and 1 deletions

View file

@ -333,6 +333,30 @@ module.exports = [
}
},
{
"name": "MD029",
"desc": "Ordered list item prefix",
"func": function MD029(params, errors) {
var style = params.options.style || "one";
var number = 0;
params.tokens.forEach(function forToken(token) {
if (token.type === "ordered_list_open") {
number = 1;
} else if (token.type === "ordered_list_close") {
number = 0;
} else if ((token.type === "list_item_open") && number) {
var regex = new RegExp("^\\s*" + String(number) + "\\. ");
if (!regex.test(token.line)) {
errors.push(token.lineNumber);
}
if (style === "ordered") {
number++;
}
}
});
}
},
{
"name": "MD031",
"desc": "Fenced code blocks should be surrounded by blank lines",