Add MD023, MD024, MD025 with tests.

This commit is contained in:
David Anson 2015-03-11 09:30:34 -07:00
parent 2b289ab5f3
commit 1112ac729d
5 changed files with 80 additions and 0 deletions

View file

@ -375,6 +375,59 @@ module.exports = [
}
},
{
"name": "MD023",
"desc": "Headers must start at the beginning of the line",
"func": function MD023(params, errors) {
filterTokens(params.tokens, "heading_open")
.forEach(function forToken(token) {
if (/^\s/.test(token.line)) {
errors.push(token.lineNumber);
}
});
}
},
{
"name": "MD024",
"desc": "Multiple headers with the same content",
"func": function MD024(params, errors) {
var content = [];
var inHeading = false;
params.tokens.forEach(function forToken(token) {
if (token.type === "heading_open") {
inHeading = true;
} else if (token.type === "heading_close") {
inHeading = false;
} else if ((token.type === "inline") && inHeading) {
if (content.indexOf(token.content) === -1) {
content.push(token.content);
} else {
errors.push(token.lineNumber);
}
}
});
}
},
{
"name": "MD025",
"desc": "Multiple top level headers in the same document",
"func": function MD025(params, errors) {
var hasTopLevelHeading = false;
filterTokens(params.tokens, "heading_open")
.forEach(function forToken(token) {
if (token.hLevel === 1) {
if (hasTopLevelHeading) {
errors.push(token.lineNumber);
} else if (token.lineNumber === 1) {
hasTopLevelHeading = true;
}
}
});
}
},
{
"name": "MD028",
"desc": "Blank line inside blockquote",

View file

@ -0,0 +1,11 @@
# Header 1
## Header 2
## Header 1
### Header 2
## Header 3
{MD024:5} {MD024:7}

View file

@ -0,0 +1,3 @@
# Heading 1
# Heading 2 {MD025}

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD003": false
}

View file

@ -0,0 +1,9 @@
Some text
# Header 1 {MD023}
Setext style fully indented {MD023}
===================================
Setext style title only indented {MD023}
=========================================