From c737776958d45fbd30434d9aa49289a93acf72c8 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Thu, 22 Jan 2026 16:18:39 +0530 Subject: refactor(desktop): move markdown rendering to rust (#10000) --- packages/desktop/src-tauri/src/lib.rs | 4 +++- packages/desktop/src-tauri/src/markdown.rs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 packages/desktop/src-tauri/src/markdown.rs (limited to 'packages/desktop/src-tauri/src') diff --git a/packages/desktop/src-tauri/src/lib.rs b/packages/desktop/src-tauri/src/lib.rs index aea730926..6d601e9ee 100644 --- a/packages/desktop/src-tauri/src/lib.rs +++ b/packages/desktop/src-tauri/src/lib.rs @@ -1,6 +1,7 @@ mod cli; #[cfg(windows)] mod job_object; +mod markdown; mod window_customizer; use cli::{install_cli, sync_cli}; @@ -283,7 +284,8 @@ pub fn run() { install_cli, ensure_server_ready, get_default_server_url, - set_default_server_url + set_default_server_url, + markdown::parse_markdown_command ]) .setup(move |app| { let app = app.handle().clone(); diff --git a/packages/desktop/src-tauri/src/markdown.rs b/packages/desktop/src-tauri/src/markdown.rs new file mode 100644 index 000000000..a2a53b222 --- /dev/null +++ b/packages/desktop/src-tauri/src/markdown.rs @@ -0,0 +1,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 { + Ok(parse_markdown(&markdown)) +} -- cgit v1.2.3