Make MD033/no-inline-html slightly more efficient.

This commit is contained in:
David Anson 2019-06-06 22:02:10 -07:00
parent 73e70b76f3
commit fa40084994

View file

@ -30,11 +30,13 @@ module.exports = {
!tag.endsWith("\\>") && !bareUrlRe.test(content) && !tag.endsWith("\\>") && !bareUrlRe.test(content) &&
!emailAddressRe.test(content)) { !emailAddressRe.test(content)) {
const prefix = line.substring(0, match.index); const prefix = line.substring(0, match.index);
if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix) && if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix)) {
!unescapeMarkdown(prefix + "<", "_").endsWith("_") && const unescaped = unescapeMarkdown(prefix + "<", "_");
(unescapeMarkdown(prefix + "`", "_").match(/`/g).length % 2)) { if (!unescaped.endsWith("_") &&
addError(onError, lineIndex + 1, "Element: " + element, ((unescaped + "`").match(/`/g).length % 2)) {
null, [ match.index + 1, tag.length ]); addError(onError, lineIndex + 1, "Element: " + element,
null, [ match.index + 1, tag.length ]);
}
} }
} }
} }