aboutsummaryrefslogtreecommitdiff
path: root/code/src/markdown
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-09-26 14:14:58 +0200
committermetamuffin <metamuffin@disroot.org>2022-09-26 14:14:58 +0200
commit15d78464ba9a717a71e1dc47a4101c8b13ec6581 (patch)
tree43def89ffd6e9c2ff80e7f7eeecec6fcf18c4e92 /code/src/markdown
parent0a18eae178a23e7f7bfd88c37502e5e8c1fdf64a (diff)
downloadmetamuffin-blog-15d78464ba9a717a71e1dc47a4101c8b13ec6581.tar
metamuffin-blog-15d78464ba9a717a71e1dc47a4101c8b13ec6581.tar.bz2
metamuffin-blog-15d78464ba9a717a71e1dc47a4101c8b13ec6581.tar.zst
syntax highlighting with syntect
Diffstat (limited to 'code/src/markdown')
-rw-r--r--code/src/markdown/render.rs10
1 files changed, 5 insertions, 5 deletions
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<Block>) -> String {
Block::Paragraph(p) => format!("<p>{}</p>", span_to_html(p)),
Block::Blockquote(q) => format!("<quote>{}</quote>", blocks_to_html(q)),
Block::CodeBlock(syntax, content) => {
- if let Some(s) = &syntax {
- format!("<pre>{}</pre>", syntax_highlight(s, &content))
- } else {
- format!("<pre>{}</pre>", escape(&content))
- }
+ format!(
+ "<pre>{}</pre>",
+ syntax_highlight(&syntax.unwrap_or(String::from("")), &content)
+ .unwrap_or_else(|| escape(&content))
+ )
}
Block::OrderedList(els) => format!(
"<ol>{}</ol>",