Add MD036 with tests.

This commit is contained in:
David Anson 2015-04-14 22:37:56 -07:00
parent 762d8425ca
commit bd7e712728
5 changed files with 102 additions and 3 deletions

View file

@ -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;
});
}
}
];