15 lines
368 B
JavaScript
Raw Normal View History

2021-02-11 21:31:41 +08:00
module.exports = md => {
const RE = /^<(script|style)(?=(\s|>|$))/i
md.renderer.rules.html_block = (tokens, idx) => {
const content = tokens[idx].content
const hoistedTags = md.$data.hoistedTags || (md.$data.hoistedTags = [])
if (RE.test(content.trim())) {
hoistedTags.push(content)
return ''
} else {
return content
}
}
}