diff --git a/app/public/app.js b/app/public/app.js index 1596389..ebe8480 100644 --- a/app/public/app.js +++ b/app/public/app.js @@ -321,15 +321,30 @@ globalThis.toggle_metadata_css = (e) => { // reset colored text for (const element of Array.from( - document.querySelectorAll(".color_block"), + document.querySelectorAll("#content_rect .color_block"), )) { element.removeAttribute("style"); element.classList.remove("color_block"); } // strikethrough auto theme since it's disabled - document.getElementById("auto_theme").style.textDecoration = - "line-through"; + if (document.getElementById("auto_theme")) { + document.getElementById("auto_theme").style.textDecoration = + "line-through"; + } + + // remove styles + for (const element of Array.from( + document.querySelectorAll("#content_rect style"), + )) { + element.remove(); + } + + for (const element of Array.from( + document.querySelectorAll("#content_rect [style]"), + )) { + element.removeAttribute("style"); + } } else { window.location.reload(); } diff --git a/app/templates_src/view.lisp b/app/templates_src/view.lisp index f81eafa..1f63ccf 100644 --- a/app/templates_src/view.lisp +++ b/app/templates_src/view.lisp @@ -18,6 +18,7 @@ ("class" "flex flex-col gap-2") (div ("class" "card container") + ("id" "content_rect") ("style" "min-height: 15rem") (text "{{ entry.content|markdown|safe }}")) (div diff --git a/src/markdown.rs b/src/markdown.rs index 41acd9a..fd97113 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -5,7 +5,8 @@ pub fn render_markdown(input: &str) -> String { &parse_highlight(&parse_link(&parse_image(&parse_image_size( &parse_underline(&parse_comment(&input.replace("[/]", "
"))), )))), - )); + )) + .replace("$per", "%"); let mut allowed_attributes = HashSet::new(); allowed_attributes.insert("id"); @@ -475,7 +476,8 @@ fn parse_image_line(output: &mut String, buffer: &mut String, line: &str) { if in_image { // end output.push_str(&format!( - "\"{alt}\"", + "\"{alt}\"", + buffer.replace(" ", "$per20"), if buffer.ends_with("#left") { "left" } else if buffer.ends_with("#right") { @@ -605,7 +607,7 @@ macro_rules! parser_ignores_pre { let mut buffer = String::new(); for line in $input.split("\n") { - if line.starts_with("```") { + if line.starts_with("```") | (line == "") { in_pre_block = !in_pre_block; output.push_str(&format!("{line}\n")); continue;