From 35b357b1e1f6bf9af8297e46e2934d2f65bc3b59 Mon Sep 17 00:00:00 2001 From: gered Date: Fri, 30 Jun 2023 21:13:12 -0400 Subject: [PATCH] add some css classes to syntax highlighted code block container tags --- src/markdown.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/markdown.rs b/src/markdown.rs index f5991d3..cf7fb4c 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -55,7 +55,15 @@ impl MarkdownRenderer { for line in LinesWithEndings::from(code) { html_generator.parse_html_for_line_which_includes_newline(line)?; } - Ok(format!("
{}
", html_generator.finalize())) + // the "sh-code" css class is what syntect will generate for the top-level code container that includes + // things like the background color and default text foreground color. + // the inner classname we're generating with the language included in it is not used for anything. it's + // just a marker that includes the name of the language syntax used + Ok(format!( + "
{}
", + if !language.is_empty() { format!("syntax-{}", language) } else { String::new() }, + html_generator.finalize() + )) } fn highlight_codeblocks<'input>(