UNPKG

368 BJavaScriptView Raw
1module.exports = md => {
2 const RE = /^<(script|style)(?=(\s|>|$))/i
3
4 md.renderer.rules.html_block = (tokens, idx) => {
5 const content = tokens[idx].content
6 const hoistedTags = md.$data.hoistedTags || (md.$data.hoistedTags = [])
7 if (RE.test(content.trim())) {
8 hoistedTags.push(content)
9 return ''
10 } else {
11 return content
12 }
13 }
14}