Skip to content

Commit 1b5d0d8

Browse files
committed
Fix dark highlighting themes missing base text color
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
1 parent d1c3de0 commit 1b5d0d8

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/format/html/format-html-scss.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@ export function resolveTextHighlightingLayer(
314314
true,
315315
);
316316
}
317+
}
317318

319+
// Inject a text color regardless of adaptive status. Adaptive themes
320+
// handle their own bg, but when separate light/dark themes are paired
321+
// (e.g. kate + zenburn), the dark theme still needs its text-color
322+
// emitted as $code-block-color so Bootstrap rules can apply it.
323+
if (themeDescriptor) {
318324
const textColor = themeDescriptor.json["text-color"] as string;
319325
if (textColor) {
320326
layer.defaults = layer.defaults + "\n" + outputVariable(

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,14 @@ div.sourceCode {
863863
div.sourceCode pre.sourceCode {
864864
color: $code-block-color;
865865
}
866+
// Themes that omit "Normal" from text-styles (e.g. zenburn, espresso)
867+
// don't generate a span-level color rule in the syntax highlighting CSS.
868+
// When layered with a light theme that does, the light theme's near-black
869+
// span color persists in dark mode. This ensures a base span color is set.
870+
pre > code.sourceCode > span,
871+
code.sourceCode > span {
872+
color: $code-block-color;
873+
}
866874
}
867875

868876
pre.sourceCode {

0 commit comments

Comments
 (0)