shikijs / twoslash

You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
https://shikijs.github.io/twoslash/
MIT License
1.06k stars 51 forks source link

unexpected rendered more than one code block #192

Closed jellli closed 9 months ago

jellli commented 9 months ago

Greetings,

I'm trying to figure out this plugin. when I set more than one theme, the plugin will render two code blocks like the following:

image

here is my code

import type { Root } from 'mdast'
import { highlightersFromSettings, remarkVisitor } from 'remark-shiki-twoslash'
import type { Plugin } from 'unified'
import { visit } from 'unist-util-visit'

export const remarkShikiTwoSlash: Plugin<[], Root> = () => async (ast: any) => {
  const settings = {
    themes: ['github-light', 'github-dark']
  }
  const highlighters = await highlightersFromSettings(settings)

  visit(ast, 'code', remarkVisitor(highlighters, settings))
}

Any help will be appreciated! Jellli

jellli commented 9 months ago

my mistake, solution is here