From 1b5d0d8b2495cb66354705234679e938be9bf5d6 Mon Sep 17 00:00:00 2001 From: Justin Donaldson Date: Tue, 24 Feb 2026 19:56:53 -0800 Subject: [PATCH] Fix dark highlighting themes missing base text color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues prevented dark syntax highlighting themes (zenburn, espresso, etc.) from setting a base text color when paired with a light theme: 1. In format-html-scss.ts, the $code-block-color SCSS variable extraction was gated by !isAdaptive. When users specify separate light/dark themes ({light: kate, dark: zenburn}), isAdaptive returns true (because both keys exist), so $code-block-color was never emitted. Move the text-color extraction outside the isAdaptive guard — adaptive themes handle their own background, but text-color still needs to propagate. 2. In _bootstrap-rules.scss, $code-block-color was only applied to container elements (div.sourceCode, pre.sourceCode), but the light theme's syntax highlighting CSS generates span-level rules (code.sourceCode > span { color: #1f1c1b }) that override container inheritance. Add matching span-level selectors. Fixes #14099 --- src/format/html/format-html-scss.ts | 6 ++++++ .../formats/html/bootstrap/_bootstrap-rules.scss | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/format/html/format-html-scss.ts b/src/format/html/format-html-scss.ts index 5516df9fd3c..36b2d977e1e 100644 --- a/src/format/html/format-html-scss.ts +++ b/src/format/html/format-html-scss.ts @@ -314,7 +314,13 @@ export function resolveTextHighlightingLayer( true, ); } + } + // Inject a text color regardless of adaptive status. Adaptive themes + // handle their own bg, but when separate light/dark themes are paired + // (e.g. kate + zenburn), the dark theme still needs its text-color + // emitted as $code-block-color so Bootstrap rules can apply it. + if (themeDescriptor) { const textColor = themeDescriptor.json["text-color"] as string; if (textColor) { layer.defaults = layer.defaults + "\n" + outputVariable( diff --git a/src/resources/formats/html/bootstrap/_bootstrap-rules.scss b/src/resources/formats/html/bootstrap/_bootstrap-rules.scss index 8c041fd8c71..a593047159b 100644 --- a/src/resources/formats/html/bootstrap/_bootstrap-rules.scss +++ b/src/resources/formats/html/bootstrap/_bootstrap-rules.scss @@ -863,6 +863,14 @@ div.sourceCode { div.sourceCode pre.sourceCode { color: $code-block-color; } + // Themes that omit "Normal" from text-styles (e.g. zenburn, espresso) + // don't generate a span-level color rule in the syntax highlighting CSS. + // When layered with a light theme that does, the light theme's near-black + // span color persists in dark mode. This ensures a base span color is set. + pre > code.sourceCode > span, + code.sourceCode > span { + color: $code-block-color; + } } pre.sourceCode {