mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add MD002 with test, incorporate markdown-it parser.
This commit is contained in:
parent
5d35b8dfea
commit
82caaa9407
6 changed files with 29 additions and 5 deletions
20
lib/rules.js
20
lib/rules.js
|
|
@ -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 = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue