Add markdown rendering for recipe descriptions using comrak

This commit is contained in:
Greg Burri 2025-04-02 18:19:06 +02:00
parent 9b89117a66
commit 0c2e4b7624
3 changed files with 12 additions and 1 deletions

View file

@ -18,6 +18,16 @@ impl Recipes {
}
}
mod filters {
use askama::filters::Safe;
pub fn markdown<T: std::fmt::Display>(s: T) -> askama::Result<Safe<String>> {
Ok(Safe(comrak::markdown_to_html(
&s.to_string(),
&comrak::ComrakOptions::default(),
)))
}
}
#[derive(Template)]
#[template(path = "home.html")]
pub struct HomeTemplate {