Single-binary self-hosted Markdown blog on Rust axum: no database, live search, Typst PDF export, and strong SEO.
axumblogdockermarkdownminijinjarustself-hostedtypstvite
1use comrak::plugins::syntect::SyntectAdapter;
2use comrak::{markdown_to_html_with_plugins, Options, Plugins};
3use once_cell::sync::Lazy;
4
5static HIGHLIGHTER: Lazy<SyntectAdapter> =
6 Lazy::new(|| SyntectAdapter::new(Some("base16-ocean.dark")));
7
8pub fn render(md: &str) -> String {
9 let mut options = Options::default();
10 options.extension.strikethrough = true;
11 options.extension.table = true;
12 options.render.unsafe_ = true;
13
14 let mut plugins = Plugins::default();
15 plugins.render.codefence_syntax_highlighter = Some(&*HIGHLIGHTER);
16
17 markdown_to_html_with_plugins(md, &options, &plugins)
18}