From aa03a7fec59c13f645179acc8d47ed0c5eed2476 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Thu, 7 Jan 2021 11:34:23 +0100 Subject: [PATCH] Fix highlighting Closes #1291 --- components/config/src/config/mod.rs | 4 ++-- components/config/src/highlighting.rs | 2 +- components/rendering/src/markdown/codeblock.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index b0ab5426..415f215b 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -56,10 +56,10 @@ pub struct Config { translations: HashMap, /// Whether to highlight all code blocks found in markdown files. Defaults to false - pub highlight_code: bool, + highlight_code: bool, /// Which themes to use for code highlighting. See Readme for supported themes /// Defaults to "base16-ocean-dark" - pub highlight_theme: String, + highlight_theme: String, /// Whether to generate a feed. Defaults to false. pub generate_feed: bool, diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index b1a16353..2d733d10 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -18,7 +18,7 @@ lazy_static! { /// Returns the highlighter and whether it was found in the extra or not pub fn get_highlighter(language: Option<&str>, config: &Config) -> (HighlightLines<'static>, bool) { - let theme = &THEME_SET.themes[&config.highlight_theme]; + let theme = &THEME_SET.themes[config.highlight_theme()]; let mut in_extra = false; if let Some(ref lang) = language { diff --git a/components/rendering/src/markdown/codeblock.rs b/components/rendering/src/markdown/codeblock.rs index b273664f..b5120c7b 100644 --- a/components/rendering/src/markdown/codeblock.rs +++ b/components/rendering/src/markdown/codeblock.rs @@ -24,7 +24,7 @@ pub struct CodeBlock<'config> { impl<'config> CodeBlock<'config> { pub fn new(fence_info: &str, config: &'config Config, background: IncludeBackground) -> Self { let fence_info = FenceSettings::new(fence_info); - let theme = &THEME_SET.themes[&config.highlight_theme]; + let theme = &THEME_SET.themes[config.highlight_theme()]; let (highlighter, in_extra) = get_highlighter(fence_info.language, config); Self { highlighter,