-
marp has this nice |
Beta Was this translation helpful? Give feedback.
Answered by
yhatt
Feb 13, 2025
Replies: 1 comment
-
It brings because // engine.mjs
import markdownItHighlightLines from 'markdown-it-highlight-lines'
const fixMarkdownItHighlightLinesPlugin = (md) => {
// Store the original fence renderer
const { fence } = md.renderer.rules
// Overload the fence renderer to add Marp Core compatible attributes
md.renderer.rules.fence = (...args) => {
// Call the original renderer
const rendered = fence(...args)
// Add Marp Core compatible attributes to the rendered code block
if (rendered.startsWith('<pre')) {
return `<pre is="marp-pre" data-auto-scaling="downscale-only"${rendered.slice(4)}`
}
return rendered
}
}
export default ({ marp }) =>
marp.use(markdownItHighlightLines).use(fixMarkdownItHighlightLinesPlugin) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yhatt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It brings because
markdown-it-highlight-lines
plugin will overload the code block renderer provided by Marp Core. You can write a markdown-it plugin to fix the renderer.