mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD023, MD024, MD025 with tests.
This commit is contained in:
parent
2b289ab5f3
commit
1112ac729d
5 changed files with 80 additions and 0 deletions
53
lib/rules.js
53
lib/rules.js
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue