Compare commits

...

2 commits

Author SHA1 Message Date
91dc938fb1
french quotes 2024-09-14 20:32:26 +02:00
fb44c25e47
clippy 2024-09-14 20:17:11 +02:00

View file

@ -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;
@ -178,7 +178,7 @@ fn custom_img_size(html: &str) -> String {
RewriteStrSettings {
element_content_handlers: vec![element!("img[alt]", |el| {
let alt = el.get_attribute("alt").unwrap();
let possible_piece = alt.split(|c| c == '|').collect::<Vec<&str>>();
let possible_piece = alt.split('|').collect::<Vec<&str>>();
if possible_piece.len() > 1 {
let data = possible_piece.last().unwrap().trim();
@ -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));