feat(web): color the file viewer with highlight.js

The viewer rendered every file as plain text, so keywords, strings, and
comments in Rust, TypeScript, and the rest read as one color. Replace
the hand-written scanner explored for this with highlight.js, pinned to
the seventeen languages the viewer can open, so the client bundle stays
near 28KB gzip and unknown files still render as escaped text.

The output is class names only. The .hljs-* classes map onto the
--syntax-* tokens from the palette, so light and dark follow the
existing media query and no color bypasses the stylesheet.
This commit is contained in:
vhaudiquet committed 2026-12-01 19:33:16 +01:00
1 parent 880f4e2d87
commit acc545ede7
5 files changed
+222 -1

No files matched your search

+9
View File
@@ -14,6 +14,9 @@ importers:
'@xterm/xterm':
specifier: ^6.0.0
version: 6.0.0
highlight.js:
specifier: ^11.12.0
version: 11.12.0
lucide-vue-next:
specifier: ^1.0.0
version: 1.0.0(vue@3.5.46(typescript@5.9.3))
@@ -1731,6 +1734,10 @@ packages:
resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
hasBin: true
highlight.js@11.12.0:
resolution: {integrity: sha512-nbfWpyRMcMrPMmDwJB+dhX/eiaPKtc2RB+0QZskqJ3WjRA/FDS0e9hZrx8EC/lbEv8gXy98FcDbNa/dspAaJMg==}
engines: {node: '>=12.0.0'}
hookable@5.5.3:
resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
@@ -4664,6 +4671,8 @@ snapshots:
he@1.2.0: {}
highlight.js@11.12.0: {}
hookable@5.5.3: {}
hookable@6.1.2: {}