Skip to content

Commit cab87f8

Browse files
nlopesclaude
andcommitted
feat(terminal): honor highlight-style and default to the github themes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3a857b0 commit cab87f8

26 files changed

Lines changed: 294 additions & 149 deletions

‎converters/html/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
- With `:highlight-css: class`, highlighted lines (`highlight=`) use the
4040
`syntax-hl` class. The generated CSS sets their background, not an inline
4141
style. Regenerate the CSS with the HTML.
42+
- Source blocks in terminal previews use `highlight-style`, and default to
43+
`github-light` or `github-dark`, like the page's code.
4244

4345
### Fixed
4446

‎converters/html/src/terminal.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,9 @@ mod tests {
16371637
HtmlVariant::Standard,
16381638
)?;
16391639

1640-
// Prompt lines keep their shell colors.
1640+
// Prompt lines keep their shell colors: github-light's command color.
16411641
assert!(
1642-
html.contains("$</span> <span style=\"color:#268bd2\">acdc</span>"),
1642+
html.contains("$</span> <span style=\"color:#6f42c1\">acdc</span>"),
16431643
"command not highlighted: {html}"
16441644
);
16451645
// Program output starts at the line start, outside any colored span.

‎converters/terminal/CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
a file show the alternative text.
2929
- Links are clickable in Rex, and in Ghostty and kitty when `TERM` is
3030
generic, such as `xterm-256color`.
31+
- `highlight-style` chooses the code theme, as in HTML. A light and dark pair,
32+
such as `github-light,github-dark`, uses the side for the terminal's background.
33+
34+
### Changed
35+
36+
- Code uses `github-light` or `github-dark` by default, as in HTML, instead of
37+
the Solarized themes. `$` and `#` prompts take the theme's command color.
3138

3239
### Fixed
3340

‎converters/terminal/README.adoc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ fn main() {
108108

109109
The highlighted code will display with appropriate colors for your terminal. If a language isn't recognized or no language is specified, the code block renders as plain text.
110110

111+
Code uses `github-dark` on a dark terminal and `github-light` on a light one.
112+
acdc reads the background from `COLORFGBG`, and assumes dark without it. Set
113+
`highlight-style` to choose another giallo theme, such as `solarized-dark`.
114+
A light and dark pair, such as `github-light,github-dark`, uses the side for
115+
the terminal's background. `dark-mode` doesn't change it: that attribute
116+
describes HTML pages, and the terminal's own background decides what reads well.
117+
111118
Source blocks honor `linenums`, `start`, and `highlight`. Callout comment guards
112119
are removed and the visible callout marker is emphasized. Source substitutions,
113120
Unicode text, and long lines are preserved. PHP `%mixed` highlighting falls back

‎converters/terminal/src/appearance/theme.rs‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ impl Theme {
3030
Self::Dark
3131
}
3232

33-
/// Get the appropriate syntax highlighting theme name (giallo theme)
33+
/// The color scheme that picks syntax highlighting themes.
3434
#[cfg(feature = "highlighting")]
3535
#[must_use]
36-
pub(crate) const fn highlight_theme(self) -> &'static str {
36+
pub(crate) const fn color_scheme(self) -> acdc_converters_core::ColorScheme {
3737
match self {
38-
Self::Dark => "solarized-dark",
39-
Self::Light => "solarized-light",
38+
Self::Dark => acdc_converters_core::ColorScheme::Dark,
39+
Self::Light => acdc_converters_core::ColorScheme::Light,
4040
}
4141
}
4242
}
@@ -168,13 +168,6 @@ mod tests {
168168
let _theme = Theme::detect();
169169
}
170170

171-
#[cfg(feature = "highlighting")]
172-
#[test]
173-
fn test_highlight_theme_names() {
174-
assert_eq!(Theme::Dark.highlight_theme(), "solarized-dark");
175-
assert_eq!(Theme::Light.highlight_theme(), "solarized-light");
176-
}
177-
178171
#[test]
179172
fn test_color_scheme_creation() {
180173
let dark = ColorScheme::dark();

0 commit comments

Comments
 (0)