From 39c2993164fb5144b33a1b14aadea97a9bcd13e9 Mon Sep 17 00:00:00 2001 From: sotashimozono Date: Thu, 24 Sep 2026 12:22:38 +0000 Subject: [PATCH] Turn the lamp down on a figure, rather than take its paper away MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A figure carries its own white inside the SVG, where no stylesheet reaches it. On a dark page that is a lit rectangle, and after 0.1.7 it was the one thing left bright. Taking the white away is not the fix it looks like: the axes and labels are dark ink and would be left dark on dark. So the page dims it instead. `brightness(.85)` makes the paper #d9d9d9 — measured there, ink/paper 14.9, axis/paper 7.2, a plotted line 4.4 (a graphical object wants 3), and the figure still stands 12.3 off the card. Chosen by looking at 1.00 / 0.92 / 0.85 / 0.78 against a real figure: 0.92 barely helps, 0.78 muddies the data. The token check caught its own blind spot on the way in. It read `#d9d9d9` out of the comment explaining the choice and called it a hard-coded colour, because it scanned the sheet without stripping comments first. A colour named in a `/* … */` is not a colour the sheet draws with — Archeion's equivalent check already knew that, and this one now does too. A mitigation, not a fix. The fix is figures not drawn on white, which belongs to whoever writes the report. Archeion carries the same rule in the layer it derives for reports frozen before this existed. Co-Authored-By: Claude Opus 5 (1M context) --- Project.toml | 2 +- src/themes/gallery.jl | 19 +++++++++++++++++++ test/test_appearance.jl | 8 +++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index a90b049..c5f666f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Pinax" uuid = "e782a80a-1ac9-479e-ba2b-0f3433ef5b4f" -version = "0.1.7" +version = "0.1.8" authors = ["sota shimozono "] [deps] diff --git a/src/themes/gallery.jl b/src/themes/gallery.jl index 3b8087d..6ca96d1 100644 --- a/src/themes/gallery.jl +++ b/src/themes/gallery.jl @@ -125,6 +125,25 @@ const _GALLERY_CSS = """ } :root[data-theme="dark"]{$_DARK_TOKENS } + /* A figure carries its own white, inside the SVG, where no stylesheet can reach it — and it + should: the axes and labels are dark ink, and taking the paper away would leave them on a dark + page unreadable. So the page does not take it away, it turns the lamp down. `brightness(.85)` + makes the paper #d9d9d9, which still reads as paper and stops being a light source. + + Measured at that value: inside the figure, ink/paper 14.9, axis/paper 7.2, a plotted line + 4.4 — all still clear (a line is a graphical object, which wants 3). Against the card it sits + on, 12.3. It is a mitigation and not a fix; the fix would be figures that are not drawn on + white in the first place, and that is the report author's to choose. */ + @media (prefers-color-scheme:dark){ + :root:not([data-theme="light"]) figure img, + :root:not([data-theme="light"]) .card-thumb img, + :root:not([data-theme="light"]) iframe.pinax-pdf, + :root:not([data-theme="light"]) .card-thumb-pdf{filter:brightness(.85)} + } + :root[data-theme="dark"] figure img, + :root[data-theme="dark"] .card-thumb img, + :root[data-theme="dark"] iframe.pinax-pdf, + :root[data-theme="dark"] .card-thumb-pdf{filter:brightness(.85)} /* The control itself. Out of the flow, out of the way, and out of print. Measured, and the measurement changed it. The pill's fill is --card on a --bg page: 1.04:1 in diff --git a/test/test_appearance.jl b/test/test_appearance.jl index 841f670..9d824e1 100644 --- a/test/test_appearance.jl +++ b/test/test_appearance.jl @@ -139,7 +139,13 @@ end # # It is loaded into the same document as the theme's own stylesheet, in both asset modes, so # the tokens are in scope there. Nothing stopped it using them except that nobody had. - literals(css) = [m.match for m in eachmatch(r"#[0-9a-fA-F]{3,6}\b", css)] + # Comments first. A palette worth reading is a palette worth annotating, and a colour named in + # a `/* … */` — "brightness(.85) makes the paper #d9d9d9" — is not a colour the sheet draws + # with. Archeion's equivalent check learned this before this one did. + literals(css) = [ + m.match for + m in eachmatch(r"#[0-9a-fA-F]{3,6}\b", replace(css, r"/\*.*?\*/"s => "")) + ] @test isempty(literals(Pinax._asset("pinax.css")))