rehype-prism-plus icon indicating copy to clipboard operation
rehype-prism-plus copied to clipboard

Adding prism plugins

Open AlexanderZeilmann opened this issue 3 years ago • 5 comments

Is there a way to use prism plugins and especially the treeview plugin?

As far as I understand refractor does not allow prism plugins, but it should be possible to add support for the treeview plugin by registering its syntax definitions with refractor. For this to work rehype-prism-plus would need to allow registering new syntaxes with its refractor instance.

What do you think?

AlexanderZeilmann avatar Jan 07 '22 10:01 AlexanderZeilmann

I have refactored the code to export a rehypePrismGenerator that you can pass in any refractor object and customise your desired languages.

Unfortunately, the treeview plugin does some manipulation on the dom so it can't be simply imported. That section of the code probably needs to be ported over to rehype-prism-plus for everything to work as intended.

timlrx avatar Jan 08 '22 03:01 timlrx

Tried just initializing the plugin and commenting out the addition dom modifications. Here's how it looks. Top code block is without the plugin and the bottom one is with the plugin and CSS loaded. image

The modification actually looks pretty straightforward. Let me know if you want to help port it over? Or I will take a stab over the next few days.

timlrx avatar Jan 08 '22 03:01 timlrx

Ahh good to know that it works. I only got a nondescriptive error message. I will try it a again in the next few days.

AlexanderZeilmann avatar Jan 10 '22 09:01 AlexanderZeilmann

Hmm, sadly I did not figure out how to do it 🙁 Can you post your solution?

AlexanderZeilmann avatar Feb 01 '22 23:02 AlexanderZeilmann

Most certainly, will take a stab at it and let you know again when it is done.

timlrx avatar Feb 05 '22 15:02 timlrx