mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
parent
410da18a2c
commit
fb31bb5f35
4 changed files with 71 additions and 3 deletions
23
lib/rules.js
23
lib/rules.js
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue