mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 15:00:13 +01:00
Moved rules into their own files
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`.
This commit is contained in:
parent
77e27cbe09
commit
b63647f6b1
43 changed files with 1283 additions and 1177 deletions
37
lib/rules/noInlineHtml.js
Normal file
37
lib/rules/noInlineHtml.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue