Better syntax highlighting for rust code
The syntax highlighting we're using in code examples doesn't clearly distinguish many of the syntax elements of rust code. This makes it far less readable.
For example, this is our docs:
And this is vscode:
Ah yeah, I see what you're saying; this is kinda sad. But it's leagues better than Prism.js, which we'd been using before. I recently learned about another highlighting library; I'll see if I can remember where I filed it.
I'm guessing it's the theme used by the syntax highlighting library that just needs to have different colors for more code elements. Some themes may not colorize all elements.
could be -- although it may be that highlight.js doesn't have an expressive enough grammar for this. Here are two promising candidates, which both pride themselves on high-quality highlighting. I think they both take TextMate grammars, which means they could ostensibly mimic what VSCode does.
- https://github.com/wooorm/starry-night
- https://github.com/shikijs/shiki
Criteria:
- JS
- Easy to integrate with 11ty (ideal situation is a sync function that takes a code block string and a language and returns HTML)
Testing: Here's Shiki, which claims it keeps parity with VSCode but can be used server-side. Using Dark Plus theme. A dead ringer for your VSCode screenshot.
Might be addressed by #574 . It looks like Docusaurus hard-codes Prism.js and there's little to no documentation on how to extend Docusaurus to, say, integrate other code highlighters. But either we were using the wrong Prism theme, or it didn't do really well one of the languages we use a lot of (probably Svelte). Anyhow, it'll be interesting to see what that spike uncovers.