mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 15:00:13 +01:00
Everything under `lib/rules/*` is a rules file (with the name of the rule in camelCase), re-exported into an array in `lib/rules.js`. Moved the regular expressions from `lib/rules.js` to `lib/expressions.js`, and the rest of the variables into `lib/shared.js`.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
var expressions = require("../expressions");
|
|
var shared = require("../shared");
|
|
|
|
module.exports = {
|
|
"name": "MD033",
|
|
"desc": "Inline HTML",
|
|
"tags": [ "html" ],
|
|
"aliases": [ "no-inline-html" ],
|
|
"regexp": expressions.htmlRe,
|
|
"func": function MD033(params, errors) {
|
|
var allowedElements = (params.options.allowed_elements || [])
|
|
.map(function forElement(element) {
|
|
return element.toLowerCase();
|
|
});
|
|
function forToken(token) {
|
|
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();
|
|
})
|
|
.filter(function forElement(element) {
|
|
return allowedElements.indexOf(element) === -1;
|
|
});
|
|
if (allowed.length) {
|
|
errors.addDetail(token.lineNumber + offset,
|
|
"Element: " + allowed[0]);
|
|
}
|
|
});
|
|
}
|
|
shared.filterTokens(params, "html_block", forToken);
|
|
shared.forEachInlineChild(params, "html_inline", forToken);
|
|
}
|
|
};
|