Reimplement MD033/no-inline-html using micromark tokens.

This commit is contained in:
David Anson 2023-01-21 15:41:03 -08:00
parent 08b31da0aa
commit 48a92d41a4
6 changed files with 171 additions and 200 deletions

View file

@ -193,19 +193,6 @@ module.exports.escapeForRegExp = function escapeForRegExp(str) {
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
};
// Un-escapes Markdown content (simple algorithm; not a parser)
const escapedMarkdownRe = /\\./g;
module.exports.unescapeMarkdown =
function unescapeMarkdown(markdown, replacement) {
return markdown.replace(escapedMarkdownRe, (match) => {
const char = match[1];
if ("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".includes(char)) {
return replacement || char;
}
return match;
});
};
/**
* Return the string representation of a fence markup character.
*