Closed iamskok closed 5 years ago
What do you want to do? Create a unified plugin? Use syntax highlighting in React? Use refractor?
I want to use refractor clientside with other unified plugins.
Why not use @mapbox/rehype-prism
?
If there are reasons to not use rehype-prism (such as a lower browser footprint), you could copy the plugin and take away the things you don’t need.
Alternatively, a PR to rehype-prism to include a “light” build/plugin instead may be a good way to go?
Yes, my main goal is to lower browser footprint. So refractor can't be used directly with other unified plugins?
PR looks like a good idea :+1:
Is there any way to pass the required languages to rehype-prism
options or they have to be declared only inside of the package?
Correct, refractor is not a unified plugin.
Is there any way to pass the required languages to rehype-prism options or they have to be declared only inside of the package?
That depends on what the people of rehype-prism would like, it’s an issue there, and will result in API changes there!
Gotcha, thanks for the clarification!
Thanks a lot for making this plugin, I previously used rehype-prism and it was working like a charm.
For my current project, I'm implementing syntax highlighting which has to work client side, so I was following this documentation sections, though I have some difficulties injecting it in unified pipeline:
Code:
String:
Error: Expected usable value, not
<span class="token template-string"><span class="token string">``</span></span><span class="token template-string"><span class="token string">
js alert('xxx')</span></span><span class="token template-string"><span class="token string">``</span></span>
▼ 3 stack frames were expanded. add node_modules/unified/index.js:209 addList node_modules/unified/index.js:224 Function.use node_modules/unified/index.js:177