mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 06:50:12 +01:00
Merge aa733719b0 into 071bba88fc
This commit is contained in:
commit
1c2241fc62
2 changed files with 27 additions and 7 deletions
|
|
@ -133,7 +133,7 @@ function lintContent(content, config, frontMatter) {
|
||||||
// Configure rule
|
// Configure rule
|
||||||
params.options = mergedRules[rule.name];
|
params.options = mergedRules[rule.name];
|
||||||
var errors = [];
|
var errors = [];
|
||||||
rule.func(params, errors);
|
rule.func(params, errors, config);
|
||||||
// Record any errors
|
// Record any errors
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
errors.sort(numberComparison);
|
errors.sort(numberComparison);
|
||||||
|
|
|
||||||
32
lib/rules.js
32
lib/rules.js
|
|
@ -639,13 +639,33 @@ module.exports = [
|
||||||
"name": "MD033",
|
"name": "MD033",
|
||||||
"desc": "Inline HTML",
|
"desc": "Inline HTML",
|
||||||
"tags": [ "html" ],
|
"tags": [ "html" ],
|
||||||
"func": function MD033(params, errors) {
|
"func": function MD033(params, errors, config) {
|
||||||
filterTokens(params, "html_block", function forToken(token) {
|
// map allowed tags
|
||||||
errors.push(token.lineNumber);
|
var allowed = {};
|
||||||
});
|
(config.MD033 || []).forEach(function mapTagName(tagName) {
|
||||||
forEachInlineChild(params, "html_inline", function forToken(token) {
|
allowed[tagName.toLowerCase()] = true;
|
||||||
errors.push(token.lineNumber);
|
|
||||||
});
|
});
|
||||||
|
// expression to extract tag names
|
||||||
|
// (closing tags are coming in from the tokens as well)
|
||||||
|
var tagNamePattern = /<\/?([^ >]+)/ig;
|
||||||
|
function forToken(token) {
|
||||||
|
// abusing replace because we then don't
|
||||||
|
// have to deal with the .lastIndex mess
|
||||||
|
/*eslint-disable max-len */
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec#Finding_successive_matches
|
||||||
|
/*eslint-enable max-len */
|
||||||
|
var badHtml = false;
|
||||||
|
token.content.replace(tagNamePattern, function forTagName(m, tagName) {
|
||||||
|
badHtml = badHtml || !allowed[tagName.toLowerCase()];
|
||||||
|
return m;
|
||||||
|
});
|
||||||
|
if (badHtml) {
|
||||||
|
errors.push(token.lineNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filterTokens(params, "html_block", forToken);
|
||||||
|
forEachInlineChild(params, "html_inline", forToken);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue