Skip to content

data-auto-scaling not kicking in when using markdown-it-highlight-lines #566

Answered by yhatt
mil-ad asked this question in Q&A
Discussion options

You must be logged in to vote

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.

// 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 i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yhatt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants