mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD036 with tests.
This commit is contained in:
parent
762d8425ca
commit
bd7e712728
5 changed files with 102 additions and 3 deletions
33
lib/rules.js
33
lib/rules.js
|
@ -667,5 +667,38 @@ module.exports = [
|
|||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD036",
|
||||
"desc": "Emphasis used instead of a header",
|
||||
"tags": [ "headers", "emphasis" ],
|
||||
"func": function MD036(params, errors) {
|
||||
var lineNumber = 0;
|
||||
function base(token) {
|
||||
lineNumber = token.lineNumber;
|
||||
if (token.type === "paragraph_open") {
|
||||
return function inParagraph(t) {
|
||||
if ((t.type === "inline") &&
|
||||
(t.children.length === 3) &&
|
||||
((t.children[0].type === "strong_open") ||
|
||||
(t.children[0].type === "em_open")) &&
|
||||
(t.children[1].type === "text")) {
|
||||
errors.push(lineNumber);
|
||||
}
|
||||
};
|
||||
} else if (token.type === "blockquote_open") {
|
||||
return function inBlockquote(t) {
|
||||
if (t.type !== "blockquote_close") {
|
||||
return inBlockquote;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
var state = base;
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
state = state(token) || base;
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue