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

@shikijs/twoslash does not work on rehype pretty code transformers option #231

Open
udohjeremiah opened this issue Jul 9, 2024 · 4 comments

Comments

@udohjeremiah
Copy link

@shikijs/twoslash does not work on rehype-pretty-code transformers options, which the docs say here that it should work.

However, so far, it is not working. This is a sample of the code:

import { rendererRich, transformerTwoslash } from "@shikijs/twoslash";
import rehypePrettyCode from "rehype-pretty-code";
// ...

const rehypePrettyCodeOptions = {
  theme: moonlightTheme,
  keepBackground: false,
  transformers: [transformerTwoslash({ renderer: rendererRich() })],
  onVisitLine(node) {
    if (node.children.length === 0) {
      node.children = [{ type: "text", value: " " }];
    }
  },
};

// ...

const source = makeSource({
  contentDirPath: "./src/content",
  documentTypes: [Blog],
  mdx: {
    remarkPlugins: [remarkGfm],
    rehypePlugins: [
      rehypeAccessibleEmojis,
      rehypeSlug,
      [rehypePrettyCode, rehypePrettyCodeOptions],
      [rehypeAutolinkHeadings, rehypeAutolinkHeadingsOptions],
      rehypePresetMinify,
    ],
  },
});
@lishaduck
Copy link

lishaduck commented Jul 11, 2024

Not at all a minimal reproduction (I'll try to write one sometime), but at least a full project: Effect-TS/website#770.

@lishaduck
Copy link

@udohjeremiah
Copy link
Author

udohjeremiah commented Jul 20, 2024

Thanks for your suggestion @lishaduck but it doesn't work. Turns out that after applying all your new suggestions, what I get is a <pre> code block that just loses all its styling from the theme: "one-dark-pro" in the rehypePrettyCodeOptions?

@lishaduck
Copy link

Thanks for your suggestion @lishaduck but it doesn't work. Turns out that after applying all your new suggestions, what I get is a \<pre\> code block that just loses all its styling from the theme: "one-dark-pro" in the rehypePrettyCodeOptions?

Yeah. I ran into that as well. I don't know what plugins you're using, but some orders work, and some lose styling, and some work but without twoslash. I don't really know why, just that's what I'm experiencing.

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

2 participants