shikijs / shiki

A beautiful yet powerful syntax highlighter
http://shiki.style/
MIT License
10.3k stars 374 forks source link

Unable to use Color Replacements option in the `Rehype` plugin #724

Closed fwqaaq closed 3 months ago

fwqaaq commented 3 months ago

Hey, bro:

I've encountered an issue while using rehypeShiki. Although the plugin's TypeScript definitions include a CodeToHastOptions type with a Replacements option, I'm unable to utilize the Replacements option in practice.

See: https://shiki.style/guide/theme-colors#color-replacements

https://github.com/shikijs/shiki/blob/4111b033c398aa0937a75d0fa66c202a55c74782/packages/rehype/src/core.ts#L120-L128

// Don't replace bg `#23262E` to `#48458A`
    .use(rehypeShiki, {
      theme: "andromeeda",
      defaultColor: false,
      addLanguageClass: true,
      colorReplacements: {
        "andromeeda": {
          "#23262E": "#48458A"
        }
      }
    })