diff --git a/CHANGELOG.md b/CHANGELOG.md index c0afe8aa..0acf3548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ into their typographic forms content - Update some highlighting syntaxes and the TS syntax will now be used instead of JS due to issues with it - Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore +- Update clojure syntax +- Prefer extra syntaxes to the default ones if we have a match for language ## 0.12.2 (2020-09-28) diff --git a/components/config/src/highlighting.rs b/components/config/src/highlighting.rs index 9d73d4da..2612d6ae 100644 --- a/components/config/src/highlighting.rs +++ b/components/config/src/highlighting.rs @@ -22,26 +22,20 @@ pub fn get_highlighter(language: Option<&str>, config: &Config) -> (HighlightLin let mut in_extra = false; if let Some(ref lang) = language { - // The JS syntax hangs a lot... the TS syntax is probably better anyway. - // https://github.com/getzola/zola/issues/1241 - // https://github.com/getzola/zola/issues/1211 - // https://github.com/getzola/zola/issues/1174 - let hacked_lang = if *lang == "js" || *lang == "javascript" { "ts" } else { lang }; - let syntax = SYNTAX_SET - .find_syntax_by_token(hacked_lang) - .or_else(|| { - if let Some(ref extra) = config.markdown.extra_syntax_set { - let s = extra.find_syntax_by_token(hacked_lang); - if s.is_some() { - in_extra = true; - println!("Found extra syntax"); - } - s - } else { - None - } - }) - .unwrap_or_else(|| SYNTAX_SET.find_syntax_plain_text()); + let syntax = if let Some(ref extra) = config.markdown.extra_syntax_set { + let s = extra.find_syntax_by_token(lang); + if s.is_some() { + in_extra = true; + } + s + } else { + // The JS syntax hangs a lot... the TS syntax is probably better anyway. + // https://github.com/getzola/zola/issues/1241 + // https://github.com/getzola/zola/issues/1211 + // https://github.com/getzola/zola/issues/1174 + let hacked_lang = if *lang == "js" || *lang == "javascript" { "ts" } else { lang }; + SYNTAX_SET.find_syntax_by_token(hacked_lang) + }.unwrap_or_else(|| SYNTAX_SET.find_syntax_plain_text()); (HighlightLines::new(syntax, theme), in_extra) } else { (HighlightLines::new(SYNTAX_SET.find_syntax_plain_text(), theme), false) diff --git a/docs/content/documentation/content/syntax-highlighting.md b/docs/content/documentation/content/syntax-highlighting.md index 43e7a625..1dde1c32 100644 --- a/docs/content/documentation/content/syntax-highlighting.md +++ b/docs/content/documentation/content/syntax-highlighting.md @@ -35,7 +35,6 @@ Here is a full list of supported languages and their short names: - C -> ["c", "h"] - C# -> ["cs", "csx"] - C++ -> ["C", "c++", "cc", "cp", "cpp", "cxx", "h", "h++", "hh", "hpp", "hxx", "inl", "ipp"] -- Clojure -> ["clj", "cljc", "cljs", "edn"] - ClojureC -> ["boot", "clj", "cljc", "cljs", "cljx"] - CMake -> ["CMakeLists.txt", "cmake"] - CMake C Header -> ["h.in"]