web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.37k stars 120 forks source link

[Feature]: Add shiki syntax highlighting plugin support #211

Closed hustcer closed 10 months ago

hustcer commented 11 months ago

What problem does this feature solve?

rspress seems to support PL syntax highlighting by prismjs at the moment, hopefully the Shiki plugin can be added as well. The advantage of supporting shiki is that prism may can't support syntax highlighting for some less common programming languages in the short term, but if it supports the shiki plugin, the corresponding syntax highlighting grammar can be applied to shiki as long as it has a VSCode extension. And the Nushell official site is currently using this solution!

What does the proposed API look like?

Something like this: https://vuepress.github.io/reference/plugin/shiki.html

hustcer commented 11 months ago

Hey, any thoughts on this issue? We may move away from VuePress and use rspress instead someday: https://github.com/nushell/nushell.github.io/issues/1126 And this is the most important thing we care about. Thanks

sanyuan0704 commented 11 months ago

Thanks for feedback. I think it's important to ensure the flexibility in code highlight solution. Currently the most difficult thing is that rspress does code highlight in runtime instead of compiled-time, in the meanwhile, shiki only supports compiled-time code highlight in most cases. So i'm going to solve the problem and add a @rspress/plugin-shiki to support shiki highlight in rspress.

hustcer commented 11 months ago

That’s great, very appreciated !

sanyuan0704 commented 11 months ago

I will support the plugin this week and notify you after finishing it.

hustcer commented 11 months ago

Take it easy, no rush at all

sanyuan0704 commented 10 months ago

https://rspress.dev/zh/plugin/official-plugins/shiki.html

hustcer commented 10 months ago

@sanyuan0704 Great, Thanks