Add MD002 with test, incorporate markdown-it parser.

This commit is contained in:
David Anson 2015-02-25 18:00:08 -08:00
parent 5d35b8dfea
commit 82caaa9407
6 changed files with 29 additions and 5 deletions

View file

@ -10,10 +10,26 @@ function padAndTrim(lines) {
}
module.exports = [
{
"name": "MD002",
"desc": "First header should be a h1 header",
"func": function MD002(tokens) {
var errors = [];
tokens.every(function forToken(token) {
if ((token.type === "heading_open") && (token.hLevel !== 1)) {
errors.push(token.lines[0] + 1);
return false;
}
return true;
});
return errors;
}
},
{
"name": "MD031",
"desc": "Fenced code blocks should be surrounded by blank lines",
"func": function MD031(lines) {
"func": function MD031(tokens, lines) {
// Some parsers have trouble detecting fenced code blocks without
// surrounding whitespace, so examine the lines directly.
lines = padAndTrim(lines);
@ -35,7 +51,7 @@ module.exports = [
{
"name": "MD032",
"desc": "Lists should be surrounded by blank lines",
"func": function MD032(lines) {
"func": function MD032(tokens, lines) {
// Some parsers have trouble detecting lists without surrounding
// whitespace, so examine the lines directly.
var errors = [];