Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: tagName Lowercasing in @shikijs/twoslash renderer for custom popup #251

Open
Zih0 opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@Zih0
Copy link

Zih0 commented Oct 21, 2024

Problem Description

When using the @shikijs/twoslash transformer, I encountered an issue where the tagName provided in the renderer configuration is automatically converted to lowercase.

Example

Here is the configuration where the issue occurs:

transformers: [
  transformerTwoslash({
    explicitTrigger: true,
    renderer: rendererRich({
      hast: {
        hoverPopup: {
          tagName: 'Popup'
        },
        // additional configuration
      }
    }),
  }),
],

In this case, the expected behavior is that a Popup node is generated, which would correspond to the Popup component in MDX. However, the node is being converted to lowercase (popup).

image

I think that during the process where the HTML generated by highlighter.codeToHtml is converted back to hast, the tagName is being transformed to lowercase.

You can reproduce this issue by checking the following example:
StackBlitz Example

twoslash custom popup usage:
https://github.com/shikijs/shiki/blob/main/packages/vitepress-twoslash/src/renderer-floating-vue.ts
https://github.com/fuma-nama/fumadocs/blob/38e2b602d6c8e818cae8d01037c7c2245be93803/packages/twoslash/src/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant