Allow exceptions for MD033 "Inline HTML" (fixes #3, fixes #4).

This commit is contained in:
David Anson 2015-12-15 21:30:37 -08:00
parent 410da18a2c
commit fb31bb5f35
4 changed files with 71 additions and 3 deletions

View file

@ -640,10 +640,27 @@ module.exports = [
"desc": "Inline HTML",
"tags": [ "html" ],
"func": function MD033(params, errors) {
var allowedElements = (params.options.allowed_elements || [])
.map(function forElement(element) {
return element.toLowerCase();
});
function forToken(token) {
if (token.content.search(shared.inlineCommentRe) === -1) {
errors.push(token.lineNumber);
}
token.content.split(shared.newLineRe)
.forEach(function forLine(line, offset) {
var allowed = (line.match(/<[^/\s>!]*/g) || [])
.filter(function forElement(element) {
return element.length > 1;
})
.map(function forElement(element) {
return element.slice(1).toLowerCase();
})
.every(function forElement(element) {
return allowedElements.indexOf(element) !== -1;
});
if (!allowed) {
errors.push(token.lineNumber + offset);
}
});
}
filterTokens(params, "html_block", forToken);
forEachInlineChild(params, "html_inline", forToken);