blob: bb285fa759889b83b7a5ed1ef1d03635024aa7ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use std::borrow::Cow;
use askama::Template;
use crate::state::State;
#[derive(Template)]
#[template(path = "index.html")]
pub struct Index<'a> {
pub state: &'a State,
}
#[derive(Template)]
#[template(path = "about.html")]
pub struct About<'a> {
pub path: &'a str,
pub readme: Cow<'a, str>,
}
mod filters {
pub fn markdown(s: &str) -> ::askama::Result<String> {
use pulldown_cmark::{Parser, Options, html};
let mut options = Options::empty();
options.insert(Options::ENABLE_STRIKETHROUGH);
options.insert(Options::ENABLE_SMART_PUNCTUATION);
let parser = Parser::new_ext(s, options);
let mut result = String::new();
html::push_html(&mut result, parser);
// TODO mark as safe automatically
Ok(result)
}
}
|