refactor(desktop): move markdown rendering to rust (#10000)
This commit is contained in:
@@ -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();
|
||||
|
||||
17
packages/desktop/src-tauri/src/markdown.rs
Normal file
17
packages/desktop/src-tauri/src/markdown.rs
Normal file
@@ -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<String, String> {
|
||||
Ok(parse_markdown(&markdown))
|
||||
}
|
||||
Reference in New Issue
Block a user