import MarkdownIt from 'markdown-it' ; import { MarkdownRenderer } from '../markdown' ; export const hoistPlugin = ( md ) => { const RE = /^<(script|style)(?=(\s|>|$))/i ; md . renderer . rules . html_block = ( tokens , idx ) => { const content = tokens [ idx ] . content ; const data = ( md as MarkdownRenderer ) . __data ; const hoistedTags = data . hoistedTags || ( data . hoistedTags = [ ] ) ; if ( RE . test ( content . trim ( ) ) ) { hoistedTags . push ( content ) ; return '' ; } else { return content ; } } ; } ;