From 91dc938fb1ed930615e783f033297e0e7d616cf8 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 14 Sep 2024 20:32:26 +0200 Subject: [PATCH] french quotes --- src/misc/markdown.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index 702ac82..c3f31e0 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -146,7 +146,7 @@ pub fn get_options<'a>() -> ComrakOptions<'a> { options.extension.greentext = false; // Parser - options.parse.smart = true; // could be boring + options.parse.smart = false; // could be boring options.parse.default_info_string = Some("plaintext".into()); options.parse.relaxed_tasklist_matching = true; options.parse.relaxed_autolinks = true; @@ -289,6 +289,8 @@ pub fn read_md( let mermaid_name = "mermaid"; hljs_replace(root, mermaid_name); + replace_quotes(root); + // Convert to HTML let mut html = vec![]; format_html(root, &opt, &mut html).unwrap(); @@ -434,6 +436,20 @@ fn hljs_replace<'a>(root: &'a AstNode<'a>, mermaid_str: &str) { }); } +/// TODO +fn replace_quotes<'a>(node: &'a AstNode<'a>) { + match &mut node.data.borrow_mut().value { + NodeValue::Text(text) => { + *text = text.replacen('"', "«", 1).replacen('"', "»", 1); + } + _ => { + for c in node.children() { + replace_quotes(c); + } + } + } +} + /// Obfuscate email if email found fn mail_obfuscation(html: &str) -> (String, bool) { let modified = Arc::new(AtomicBool::new(false));