TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Syntax highlighting on the web

50 pointsby joelgalmost 3 years ago

5 comments

eyelidlessnessalmost 3 years ago
This is a good reminder that I need to extract and open source the Shiki integration stuff from my personal site. I doubt I fully addressed the limitations in the linked issue, as my usage is fully static (both build and runtime), but there are other parts people might find useful: mapping inline styles to unique generated class names for more generalized styling (currently depends on Fela for atomic classes, but can be generalized further), which also enables support for light&#x2F;dark mode without JS. Shiki is <i>fantastic</i>, but unfortunately still fairly obscure. Hopefully making it easier to adopt for more use cases will help.<p>I also agree that tree-sitter is a pain to use in web projects, but I’ll be open sourcing my solutions for that too (either as direct contributions to web-tree-sitter where appropriate, or as plugins for ecosystem tooling where I had to do additional work to support specific tools) as it’s part of ongoing, already open source project work.
alpaca128almost 3 years ago
&gt; Also it&#x27;s written in Rust<p>The core library is in C.
ezekgalmost 3 years ago
I use Torchlight (<a href="https:&#x2F;&#x2F;torchlight.dev" rel="nofollow">https:&#x2F;&#x2F;torchlight.dev</a>) for syntax highlighting on a static site (<a href="https:&#x2F;&#x2F;keygen.sh" rel="nofollow">https:&#x2F;&#x2F;keygen.sh</a>) and it’s been great. I use Torchlight’s CLI to precompile the code snippets during the build step. Much better than highlighting client-side with JS.
nyanpasu64almost 3 years ago
Out of curiosity, since this post discusses syntax highlighting on the web and supports code syntax highlighting, what blog engine does this site use? Does it support giving headings their own id (I use headings and like being able to refer to them with anchor URLs, but I didn&#x27;t see any headings on the entire blog)?
mklein994almost 3 years ago
Seems similar to twoslash:<p><a href="https:&#x2F;&#x2F;shikijs.github.io&#x2F;twoslash&#x2F;" rel="nofollow">https:&#x2F;&#x2F;shikijs.github.io&#x2F;twoslash&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;shikijs&#x2F;twoslash" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shikijs&#x2F;twoslash</a>