Add MD041 with tests.

This commit is contained in:
David Anson 2015-07-20 22:06:48 -07:00
parent eabe2387bc
commit 7f5dd9ab6b
17 changed files with 113 additions and 18 deletions

View file

@ -779,5 +779,28 @@ module.exports = [
}
});
}
},
{
"name": "MD041",
"desc": "First line in file should be a top level header",
"tags": [ "headers" ],
"func": function MD041(params, errors) {
var firstHeader = null;
params.tokens.every(function forToken(token) {
if (token.type === "heading_open") {
firstHeader = token;
return false;
} else if (token.lineNumber > 1) {
return false;
}
return true;
});
if (!firstHeader ||
(firstHeader.lineNumber !== 1) ||
(firstHeader.tag !== "h1")) {
errors.push(1);
}
}
}
];