mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 13:26:08 +10:00
20 lines
692 B
JavaScript
20 lines
692 B
JavaScript
// markdown-it plugin for wrapping <pre> ... </pre>.
|
|
//
|
|
// If your plugin was chained before preWrapper, you can add additional eleemnt directly.
|
|
// If your plugin was chained after preWrapper, you can use these slots:
|
|
// 1. <!--beforebegin-->
|
|
// 2. <!--afterbegin-->
|
|
// 3. <!--beforeend-->
|
|
// 4. <!--afterend-->
|
|
|
|
module.exports = md => {
|
|
const fence = md.renderer.rules.fence
|
|
md.renderer.rules.fence = (...args) => {
|
|
const [tokens, idx] = args
|
|
const token = tokens[idx]
|
|
const rawCode = fence(...args)
|
|
return `<!--beforebegin--><div class="language-${token.info.trim()} extra-class">` +
|
|
`<!--afterbegin-->${rawCode}<!--beforeend--></div><!--afterend-->`
|
|
}
|
|
}
|