Skip to content

Commit c38241a

Browse files
default background and foreground for inline code in dark mode
fixes #8568 this minimal and defensive change (found and iterated with Claude) changes inline code to use the same default background and foreground colors as the block code, when in dark mode.
1 parent a4f5185 commit c38241a

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

news/changelog-1.8.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All changes included in 1.8:
2020
- ([#726](https://github.com/quarto-dev/quarto-cli/issues/726)): a11y - Provide `.screen-reader-only` callout type when callout text doesn't naturally include the type.
2121
- ([#5538](https://github.com/quarto-dev/quarto-cli/issues/5538)): Fix code-copy button style so that scrolling behaves properly.
2222
- ([#5879](https://github.com/quarto-dev/quarto-cli/issues/5879)): Improve font rendering of `kbd` shortcode on macOS. `kbd` will now also be stricter in converting keyboard shortcuts to macOS icons.
23+
- ([#8568](https://github.com/quarto-dev/quarto-cli/issues/8568)) Default inline code background color is the same as default code block background color; foreground color is `$pre-color` in dark mode and (remains) purple in light mode.
2324
- ([#10983](https://github.com/quarto-dev/quarto-cli/issues/10983)): Fix spacing inconsistency between paras and first section headings.
2425
- ([#12259](https://github.com/quarto-dev/quarto-cli/issues/12259)): Fix conflict between `html-math-method: katex` and crossref popups (author: @benkeks).
2526
- ([#12341](https://github.com/quarto-dev/quarto-cli/issues/12341)): Enable light and dark logos for html formats (sidebar, navbar, dashboard).
@@ -101,7 +102,7 @@ All changes included in 1.8:
101102

102103
- ([#12753](https://github.com/quarto-dev/quarto-cli/issues/12753)): Support change in IPython 9+ and import `set_matplotlib_formats` from `matplotlib_inline.backend_inline` in the internal `setup.py` script used to initialize rendering with Jupyter engine.
103104
- ([#12839](https://github.com/quarto-dev/quarto-cli/issues/12839)): Support for `plotly.py` 6+ which now loads plotly.js using a cdn in script as a module.
104-
- ([#13026](https://github.com/quarto-dev/quarto-cli/pulls/13026), [#13151](https://github.com/quarto-dev/quarto-cli/pulls/13151)): Use `jsdelivr` CDN for jupyter widgets dependencies.
105+
- ([#13026](https://github.com/quarto-dev/quarto-cli/pulls/13026), [#13151](https://github.com/quarto-dev/quarto-cli/pulls/13151)): Use `jsdelivr` CDN for jupyter widgets dependencies.
105106

106107
### `knitr`
107108

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,20 @@ pre code:not(.sourceCode) {
946946
p code:not(.sourceCode),
947947
li code:not(.sourceCode),
948948
td code:not(.sourceCode) {
949+
$calculated-bg: if(
950+
variable-exists(code-bg),
951+
if(
952+
$code-bg == $gray-100 and variable-exists(code-block-bg-color),
953+
$code-block-bg-color,
954+
$code-bg
955+
),
956+
null
957+
);
958+
949959
@if variable-exists(mono-background-color) {
950960
background-color: $mono-background-color;
951-
} @else if variable-exists(code-bg) {
952-
background-color: $code-bg;
961+
} @else if variable-exists(calculated-bg) {
962+
background-color: $calculated-bg;
953963
}
954964

955965
@if variable-exists(code-padding) {
@@ -2197,12 +2207,12 @@ a {
21972207

21982208
// screen-reader-only, cf https://github.com/quarto-dev/quarto-cli/issues/726#issuecomment-1112486100
21992209
.screen-reader-only {
2200-
position: absolute;
2201-
clip: rect(0 0 0 0);
2202-
border: 0;
2203-
height: 1px;
2204-
margin: -1px;
2205-
overflow: hidden;
2206-
padding: 0;
2207-
width: 1px;
2208-
}
2210+
position: absolute;
2211+
clip: rect(0 0 0 0);
2212+
border: 0;
2213+
height: 1px;
2214+
margin: -1px;
2215+
overflow: hidden;
2216+
padding: 0;
2217+
width: 1px;
2218+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ $code-block-theme-dark-threshhold: 40% !default;
3838

3939
/* Inline Code Formatting */
4040
// $code-bg, $code-color, $code-padding
41-
$code-color: #7d12ba !default;
41+
$code-color: if(
42+
variable-exists(pre-color) and $pre-color != null,
43+
$pre-color,
44+
#7d12ba
45+
) !default;
46+
// or $code-color: inherit !default;
4247

4348
// Set a default body emphasis color
4449
$code-bg: $gray-100 !default;

0 commit comments

Comments
 (0)