Commit 20b06b791b
20b06b791bf4bdd23b633bbfde819d5d8564751a
parent: 0e719f049c
Verified · cmc ci/build: success
cmc <hello@cleberg.net> · 2026-08-26T23:09:16Z
web: chroma line numbers use the site gutter colour
They were github-dark's #6e7681 (4.31:1 on the page) in dark and, in
light, chroma's built-in #7f7f7f fallback at 3.67:1 on a code block. The
light one is a formatter default rather than a style entry, so the
palette test could not see it.
internal/httpd/palette_test.go
+3 −3
| @@ -34,9 +34,9 @@ func contrast(a, b chroma.Colour) float64 { |
| 34 | 34 | // two diff tints. The chroma default (friendly) put 61 token/ground pairs |
| 35 | 35 | // under the floor, which is why the styles are chosen rather than assumed. |
| 36 | 36 | // |
| 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)). |
| 40 | 40 | func TestSyntaxPaletteContrast(t *testing.T) { |
| 41 | 41 | const floor = 4.5 |
| 42 | 42 | // 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 { |
| 853 | 853 | buf.WriteString(".chroma .na { color: #6f5a21 }\n") |
| 854 | 854 | buf.WriteString("}\n@media (prefers-color-scheme: dark) {\n") |
| 855 | 855 | 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") |
| 859 | 856 | 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") |
| 860 | 863 | return buf.Bytes() |
| 861 | 864 | }() |
| 862 | 865 | |