rehype-pretty-code icon indicating copy to clipboard operation
rehype-pretty-code copied to clipboard

Support for rendering inside a custom component

Open manvydasu opened this issue 1 year ago • 1 comments

Goal

I'd like to write MDX file, which contains code examples for multiple languages. In order to reduce amount of space taken by code examples, it would be nice to have dropdown/switch component for toggling between languages. Example screenshot taken from geeksforgeeks

image

Problem

As far as I understand, rehype-pretty-code can't currently be used to achieve that as it only exposes a function, which is a a rehype plugin and it can't be used inside a react component.

manvydasu avatar Jun 14 '23 20:06 manvydasu

Problem

As far as I understand, rehype-pretty-code can't currently be used to achieve that as it only exposes a function, which is a a rehype plugin and it can't be used inside a react component.

Hi2885 avatar Jan 08 '24 07:01 Hi2885

Goal

I'd like to write MDX file, which contains code examples for multiple languages. In order to reduce amount of space taken by code examples, it would be nice to have dropdown/switch component for toggling between languages. Example screenshot taken from geeksforgeeks

image

Problem

As far as I understand, rehype-pretty-code can't currently be used to achieve that as it only exposes a function, which is a a rehype plugin and it can't be used inside a react component.

You should be able to do this with Astro Starlight using tabs https://starlight.astro.build/guides/components/#tabs

rehype-pretty-code works well with Astro in general https://github.com/atomiks/rehype-pretty-code/tree/master/examples/astro

o-az avatar Jan 21 '24 09:01 o-az