feat(web): color the file viewer with highlight.js
ci / checks (push) Successful in 50s
ci / test (push) Successful in 55s
ci / chart (push) Successful in 6s
ci / web (push) Successful in 19s
ci / docker (push) Successful in 14s
ci / publish-edge-image (push) Successful in 9s
ci / publish-edge-chart (push) Successful in 4s

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

+75
View File
@@ -41,6 +41,15 @@
--member-7: #7a6a2f;
--member-8: #5a6a3f;
--syntax-keyword: #6a5a8f;
--syntax-string: #3f6f5a;
--syntax-number: #8a5a2b;
--syntax-def: #2f6f6f;
--syntax-type: #4f5f8f;
--syntax-tag: #8f4f5a;
--syntax-attr: var(--syntax-type);
--syntax-comment: var(--faint);
--font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
--font-mono: "FiraCode Nerd Font Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
@@ -89,6 +98,13 @@
--ok: #58a58c;
--on-accent: #12110f;
--overlay: rgba(0, 0, 0, 0.62);
--syntax-keyword: #b9a8dd;
--syntax-string: #8cc4aa;
--syntax-number: #d9b37c;
--syntax-def: #7fc4c4;
--syntax-type: #a3b1e0;
--syntax-tag: #d99aa5;
}
}
@@ -1912,6 +1928,65 @@ body.files-resizing-y * {
min-width: max-content;
}
.viewer-code .hljs-comment,
.viewer-code .hljs-quote {
color: var(--syntax-comment);
}
.viewer-code .hljs-keyword,
.viewer-code .hljs-selector-tag,
.viewer-code .hljs-literal,
.viewer-code .hljs-section,
.viewer-code .hljs-doctag,
.viewer-code .hljs-meta {
color: var(--syntax-keyword);
}
.viewer-code .hljs-string,
.viewer-code .hljs-regexp,
.viewer-code .hljs-symbol,
.viewer-code .hljs-bullet,
.viewer-code .hljs-template-tag,
.viewer-code .hljs-template-variable,
.viewer-code .hljs-addition,
.viewer-code .hljs-link {
color: var(--syntax-string);
}
.viewer-code .hljs-number {
color: var(--syntax-number);
}
.viewer-code .hljs-title,
.viewer-code .hljs-title.function_,
.viewer-code .hljs-title.class_ {
color: var(--syntax-def);
}
.viewer-code .hljs-type,
.viewer-code .hljs-built_in,
.viewer-code .hljs-class .hljs-title {
color: var(--syntax-type);
}
.viewer-code .hljs-tag,
.viewer-code .hljs-name,
.viewer-code .hljs-selector-id,
.viewer-code .hljs-selector-class,
.viewer-code .hljs-selector-attr,
.viewer-code .hljs-selector-pseudo,
.viewer-code .hljs-deletion {
color: var(--syntax-tag);
}
.viewer-code .hljs-attr,
.viewer-code .hljs-attribute,
.viewer-code .hljs-variable,
.viewer-code .hljs-property,
.viewer-code .hljs-params {
color: var(--syntax-attr);
}
.git-strip {
flex: 0 0 auto;
border-top: 1px solid var(--border);