summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src-tauri/src/markdown.rs
blob: a2a53b2224c4fa9a8794c82e58809fc5f45c4036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use comrak::{markdown_to_html, Options};

pub fn parse_markdown(input: &str) -> String {
    let mut options = Options::default();
    options.extension.strikethrough = true;
    options.extension.table = true;
    options.extension.tasklist = true;
    options.extension.autolink = true;
    options.render.r#unsafe = true;

    markdown_to_html(input, &options)
}

#[tauri::command]
pub async fn parse_markdown_command(markdown: String) -> Result<String, String> {
    Ok(parse_markdown(&markdown))
}