rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
18.44k stars 1.65k forks source link

Better syntax highlighting support - consider switchting from HighlightJS to Prism #2313

Open joepio opened 9 months ago

joepio commented 9 months ago

Problem

The current highlighter (powered by highlight.ts) does not support .tsx.

Proposed Solution

Switch to Prism

Notes

Some related discussions:

https://github.com/highlightjs/highlight.js/issues/3625

toastal commented 5 months ago

Only if the switch is moving from client-side highlight.js to build-side Prism.

Client-side highlight.js & Prism both are incredibly wasteful for documentation. For the most part, your documentation’s code samples aren’t changing so why is mdBook shipping client-side parsing libraries at all & making all downstream users parse & highlight the exact same unchanging content when this tool should be doing the syntax highlighting at build time to save energy, data, & time for users. See also: https://github.com/rust-lang/mdBook/issues/1383

uncenter commented 2 weeks ago

Prism is currently unmaintained and the documentation isn't great. I'd definitely like mdBook to switch to some sort of build-time syntax highlighting (client-side syntax highlighting for static code in 2024 😔) - but Prism isn't it. Shiki is the most powerful and maintained syntax highlighter right now, might be worth a look though I'm not sure how it would integrate into the build system.

toastal commented 1 week ago

Where does it say Prism is unmaintained? Last I heard they were working on v2.

uncenter commented 1 week ago

The main branch hasn't been updated in 2 years and the v2 branch hasn't had a commit for 9 months. Seems to have stalled. I don't see any benefits of Prism over Highlight.js but especially compared to Shiki.

toastal commented 1 week ago

9 months. Single-maintainer project dead. Lol.

uncenter commented 1 week ago

9 months. Single-maintainer project dead. Lol.

I don't mean to criticize the maintainer but the project only having a single maintainer is yet another reason not to switch to it. And 9 months is a long time! Do you have any thoughts about Shiki?