web: chroma line numbers use the site gutter colour !90

merged merged by cmc on 2026-08-26 23:09 UTC · krz/gitbay:gutter-contrast into main

2 files changed, +9 −6

Layout: unified · split

internal/httpd/palette_test.go +3 −3
@@ -34,9 +34,9 @@ func contrast(a, b chroma.Colour) float64 {
3434// two diff tints. The chroma default (friendly) put 61 token/ground pairs
3535// under the floor, which is why the styles are chosen rather than assumed.
3636//
37// Two tokens are exempted because the stylesheet overrides them after
38// writing the palette, which this test cannot see: NameAttribute in light
39// (#6f5a21) and the line-number tokens in dark (#8b949e).
37// Tokens the stylesheet overrides after writing the palette are exempt,
38// since this test cannot see those rules: NameAttribute in light
39// (#6f5a21) and the line-number tokens in both (var(--muted)).
4040func TestSyntaxPaletteContrast(t *testing.T) {
4141 const floor = 4.5
4242 // chroma's own line-number gutter renders on blob pages only — the diff
internal/httpd/web.go +6 −3
@@ -853,10 +853,13 @@ var chromaCSS = func() []byte {
853853 buf.WriteString(".chroma .na { color: #6f5a21 }\n")
854854 buf.WriteString("}\n@media (prefers-color-scheme: dark) {\n")
855855 chromaFormatter.WriteCSS(&buf, styles.Get(darkStyle))
856 // github-dark's line numbers are #6e7681, 4.31:1 on the page; lifted to
857 // the same grey its comments use, which clears the floor.
858 buf.WriteString(".chroma .lnt, .chroma .ln { color: #8b949e }\n")
859856 buf.WriteString("}\n.chroma, .bg { background: transparent !important; }\n")
857 // Line numbers take the site's own gutter colour in both schemes. Left
858 // alone they are github-dark's #6e7681 (4.31:1 on the page) in dark and
859 // chroma's built-in #7f7f7f (3.67:1 on a code block) in light — the
860 // latter is a formatter fallback, not a style entry, so no palette test
861 // can see it.
862 buf.WriteString(".chroma .lnt, .chroma .ln { color: var(--muted) }\n")
860863 return buf.Bytes()
861864}()
862865