blob: 9798876c45ef051884b7557d212b3d9f301c73fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
use color_eyre::{Result, eyre::Context};
use comrak::{ComrakOptions, Arena, parse_document, format_html};
pub fn render(inp: &str) -> Result<String> {
let mut options = ComrakOptions::default();
options.extension.autolink = true;
options.extension.table = true;
options.extension.superscript = true;
options.extension.footnotes = true;
options.render.unsafe_ = true;
let arena = Arena::new();
let root = parse_document(&arena, inp, &options);
let mut html = vec![];
format_html(root, &options, &mut html).unwrap();
String::from_utf8(html).wrap_err("this is somehow not UTF-8")
}
|