Skip to content

Commit 801da48

Browse files
committed
sphinx-gp-theme(pygments[light]): give Generic.Prompt + Generic.Output distinctive light-mode colours
why: User noted the light Pygments style lacks the visual distinction dark mode (monokai) has for shell prompts (`$`, `>>>`, etc.) and command-output samples. Dark gives: body[data-theme="dark"] .highlight .gp → #FF4689 (pink, bold) body[data-theme="dark"] .highlight .go → #66D9EF (cyan) Light's gp-sphinx-light style mapped both tokens to plain `#475569` (slate-600) — the same colour `Name.Label` and `Generic.Subheading` already use. Net effect: in light mode, prompts and output were visually indistinguishable from surrounding `bold` subheadings, losing the "prompt vs. output" cue that dark delivers via pink-vs-cyan contrast. User asked specifically for purple on `.gp`. Audit of every other dark-mode override against light's mapping confirmed the same asymmetry on `.go` (cyan in dark, generic slate in light); fixing both to honour the broader directive: "for any dark-mode override, ensure light has a specialized override too." what: - packages/sphinx-gp-theme/src/sphinx_gp_theme/pygments_styles.py: two `styles[…]` map entries change, with an 8-line comment block explaining the asymmetry that motivated the picks: Generic.Output: "#475569" → "#0891b2" (cyan-600) Generic.Prompt: "bold #475569" → "bold #a855f7" (purple-500, bold) Colour rationale: - #a855f7 (Tailwind purple-500) is already in the palette for `Name.Decorator`, `Name.Function.Magic`, `Name.Variable.Magic` — keeps the palette tight at 11 distinct colours rather than introducing a 12th. It's clearly distinct from `#7c3aed` (violet-600) used for keywords, so prompts read as their own visual class. - #0891b2 (Tailwind cyan-600) is the natural light-mode mirror of dark's `#66D9EF` cyan choice for the same token — same "this is sample output, not your code" semantic cue, just at a luminance suited to the slate-50 background. - tests/test_pygments_style.py: +2 TokenColorCase entries in `_TOKEN_COLOR_FIXTURES` so future drift on either token fails the parametrized `test_gp_sphinx_light_token_palette` rather than waiting for a user to notice in rendered output: test_id="generic-prompt-purple" → expected_substring="#a855f7" test_id="generic-output-cyan" → expected_substring="#0891b2" - tests/__snapshots__/test_pygments_style.ambr: syrupy snapshot regenerated via `pytest --snapshot-update`. Diff is exactly the two intended lines (gp + go); no other token rules drifted. The other 9 token classes the audit checked (`.k*`, `.c*`, `.s*`, `.mi`, `.gd`, `.gi`, `.gs`, `.gh`, `.gr`) all already specialize in BOTH modes; only `.gp` and `.go` had the gap. Pre-commit gate: ruff/mypy/pytest 1315 passed (was 1313, +2 new parametrized cases)/159 skipped/just build-docs all green.
1 parent c319f9c commit 801da48

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

packages/sphinx-gp-theme/src/sphinx_gp_theme/pygments_styles.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,17 @@ class GpSphinxLightStyle(style.Style):
132132
token.Generic.Error: "#dc2626",
133133
token.Generic.Heading: "bold #0f172a",
134134
token.Generic.Inserted: "#16a34a",
135-
token.Generic.Output: "#475569",
136-
token.Generic.Prompt: "bold #475569",
135+
# Light-mode override for `Generic.Output` and `Generic.Prompt`
136+
# so they read as distinctively as their dark-mode (monokai)
137+
# counterparts (cyan #66D9EF and pink #FF4689 respectively).
138+
# Without these, both tokens fall through to the same `#475569`
139+
# slate-600 the palette uses for `Name.Label` + `Generic.Subheading`,
140+
# leaving shell prompts (`$`, `>>>`, etc.) and command output
141+
# visually indistinguishable from the surrounding `bold #475569`
142+
# subheadings — losing the same "this is a prompt vs. its output"
143+
# cue dark mode delivers via pink-vs-cyan contrast.
144+
token.Generic.Output: "#0891b2",
145+
token.Generic.Prompt: "bold #a855f7",
137146
token.Generic.Strong: "bold",
138147
token.Generic.EmphStrong: "bold italic",
139148
token.Generic.Subheading: "bold #475569",

tests/__snapshots__/test_pygments_style.ambr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
.highlight .gr { color: #DC2626 } /* Generic.Error */
3030
.highlight .gh { color: #0F172A; font-weight: bold } /* Generic.Heading */
3131
.highlight .gi { color: #16A34A } /* Generic.Inserted */
32-
.highlight .go { color: #475569 } /* Generic.Output */
33-
.highlight .gp { color: #475569; font-weight: bold } /* Generic.Prompt */
32+
.highlight .go { color: #0891B2 } /* Generic.Output */
33+
.highlight .gp { color: #A855F7; font-weight: bold } /* Generic.Prompt */
3434
.highlight .gs { color: #0F172A; font-weight: bold } /* Generic.Strong */
3535
.highlight .gu { color: #475569; font-weight: bold } /* Generic.Subheading */
3636
.highlight .gt { color: #DC2626 } /* Generic.Traceback */

tests/test_pygments_style.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ class TokenColorCase(t.NamedTuple):
107107
token=token.Generic.Deleted,
108108
expected_substring="#dc2626",
109109
),
110+
# Distinctive purple + cyan for Generic.Prompt and Generic.Output —
111+
# mirrors the dark-mode (monokai) treatment which uses pink + cyan
112+
# for these tokens. Pre-2026-05-01 both fell through to a generic
113+
# slate-600, leaving shell prompts and command output visually
114+
# indistinguishable from `Generic.Subheading`.
115+
TokenColorCase(
116+
test_id="generic-prompt-purple",
117+
token=token.Generic.Prompt,
118+
expected_substring="#a855f7",
119+
),
120+
TokenColorCase(
121+
test_id="generic-output-cyan",
122+
token=token.Generic.Output,
123+
expected_substring="#0891b2",
124+
),
110125
]
111126

112127

0 commit comments

Comments
 (0)