Skip to content

Commit 7ec2b26

Browse files
committed
Fix identical background for code and text
Resolves TypeStrong#1836
1 parent 4597587 commit 7ec2b26

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
### Features
44

55
- `ReferenceType`s which reference an external symbol will now include `qualifiedName` and `package` in their serialized JSON.
6+
- Added new `cname` option for GitHub Pages custom domain support, #1803
67

78
### Bug Fixes
89

910
- Fixed line height of `h1` and `h2` elements being too low, #1796.
10-
- Symbol names passed to `addUnknownSymbolResolver` will now be correctly given the qualified name to the symbol being referenced.
11-
12-
### Features
13-
14-
- Added new `cname` option for GitHub Pages custom domain support, #1803
11+
- Code blocks in the light theme will no longer have the same background as the rest of the page, #1836.
12+
- Symbol names passed to `addUnknownSymbolResolver` will now be correctly given the qualified name to the symbol being referenced, #1832.
1513

1614
## v0.22.10 (2021-11-25)
1715

src/lib/utils/highlighter.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ class DoubleHighlighter {
8888
i++;
8989
}
9090

91-
style.push(` --light-code-background: ${this.highlighter.getTheme(this.light).bg};`);
91+
// GH#1836, our page background is white, but it would be nice to be able to see
92+
// a difference between the code blocks and the background of the page. There's
93+
// probably a better solution to this... revisit once #1794 is merged.
94+
let lightBackground = this.highlighter.getTheme(this.light).bg;
95+
if (isWhite(lightBackground)) {
96+
lightBackground = "#F5F5F5";
97+
}
98+
99+
style.push(` --light-code-background: ${lightBackground};`);
92100
style.push(` --dark-code-background: ${this.highlighter.getTheme(this.dark).bg};`);
93101
lightRules.push(` --code-background: var(--light-code-background);`);
94102
darkRules.push(` --code-background: var(--dark-code-background);`);
@@ -163,3 +171,8 @@ export function getStyles(): string {
163171
assert(highlighter, "Tried to highlight with an uninitialized highlighter");
164172
return highlighter.getStyles();
165173
}
174+
175+
function isWhite(color: string) {
176+
const colors = new Set(color.toLowerCase().replace(/[^a-f0-9]/g, ""));
177+
return colors.size === 1 && colors.has("f");
178+
}

0 commit comments

Comments
 (0)