Improve handling of nested tags and blocks by MD033/no-inline-html (fixes #179).

This commit is contained in:
David Anson 2019-04-29 22:09:03 -07:00
parent 44fac78721
commit 4c7ffdd335
7 changed files with 372 additions and 18 deletions

View file

@ -115,6 +115,19 @@ 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;
});
};
// Returns the indent for a token
function indentFor(token) {
const line = token.line.replace(/^[\s>]*(> |>)/, "");