Copy to clipboard button with rehype-shiki
and mdx
#785
Unanswered
nikolailehbrink
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @antfu,
in a recent
remix
project I tried out usingmdx
with mdx-js/rollup and@shikijs/rehype
.I wanted to incorporate a copy to clipboard button for all my code blocks but I have a hard time doing that. Now I searched the docs on how to do that and only found out about the
preprocess
step mentioned in https://shiki.style/guide/transformers. I could log the initial code with that function but don't know how to proceed there.A different solution was mentioned in this blog article and doing it with traversing the tree, but I didn't want to install yet another package (
unist-util-visit
) to make it work. Would be nice to get a detailed explanation on how one would tackle that problem, since it is a pretty common use case I guess.Beta Was this translation helpful? Give feedback.
All reactions