From 15d78464ba9a717a71e1dc47a4101c8b13ec6581 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 26 Sep 2022 14:14:58 +0200 Subject: syntax highlighting with syntect --- code/src/markdown/render.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'code/src/markdown/render.rs') diff --git a/code/src/markdown/render.rs b/code/src/markdown/render.rs index f6b7686..7962561 100644 --- a/code/src/markdown/render.rs +++ b/code/src/markdown/render.rs @@ -34,11 +34,11 @@ pub fn blocks_to_html(blocks: Vec) -> String { Block::Paragraph(p) => format!("

{}

", span_to_html(p)), Block::Blockquote(q) => format!("{}", blocks_to_html(q)), Block::CodeBlock(syntax, content) => { - if let Some(s) = &syntax { - format!("
{}
", syntax_highlight(s, &content)) - } else { - format!("
{}
", escape(&content)) - } + format!( + "
{}
", + syntax_highlight(&syntax.unwrap_or(String::from("")), &content) + .unwrap_or_else(|| escape(&content)) + ) } Block::OrderedList(els) => format!( "
    {}
", -- cgit v1.2.3-70-g09d2