Skip to content

Commit

Permalink
Merge pull request rust-lang#1199 from ehuss/preferred-dark-theme
Browse files Browse the repository at this point in the history
Change default preferred-dark-theme to `navy`.
  • Loading branch information
ehuss authored Jun 8, 2020
2 parents 649cad3 + d9a99f4 commit 7afbbca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion book-example/src/format/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ The following configuration options are available:
- **preferred-dark-theme:** The default dark theme. This theme will be used if
the browser requests the dark version of the site via the
['prefers-color-scheme'](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
CSS media query. Defaults to the same theme as `default-theme`.
CSS media query. Defaults to `navy`.
- **curly-quotes:** Convert straight quotes to curly quotes, except for those
that occur in code blocks and code spans. Defaults to `false`.
- **mathjax-support:** Adds support for [MathJax](mathjax.md). Defaults to
Expand Down
6 changes: 6 additions & 0 deletions book-example/src/format/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ functionality. Therefore I recommend to use the file from the default theme as
template and only add / modify what you need. You can copy the default theme
into your source directory automatically by using `mdbook init --theme` just
remove the files you don't want to override.

If you completely replace all built-in themes, be sure to also set
[`output.html.preferred-dark-theme`] in the config, which defaults to the
built-in `navy` theme.

[`output.html.preferred-dark-theme`]: ../config.md#html-renderer-options
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ pub struct HtmlConfig {
/// The default theme to use, defaults to 'light'
pub default_theme: Option<String>,
/// The theme to use if the browser requests the dark version of the site.
/// Defaults to the same as 'default_theme'
/// Defaults to 'navy'.
pub preferred_dark_theme: Option<String>,
/// Use "smart quotes" instead of the usual `"` character.
pub curly_quotes: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ fn make_data(

let preferred_dark_theme = match html_config.preferred_dark_theme {
Some(ref theme) => theme.to_lowercase(),
None => default_theme,
None => "navy".to_string(),
};
data.insert(
"preferred_dark_theme".to_owned(),
Expand Down

0 comments on commit 7afbbca

Please sign in to comment.