fix: spaces in images

This commit is contained in:
trisua 2025-07-25 22:26:06 -04:00
parent 0c43a48349
commit 5d1a49ab06
3 changed files with 24 additions and 6 deletions

View file

@ -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
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();
}

View file

@ -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

View file

@ -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("[/]", "<br />"))),
)))),
));
))
.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!(
"<img loading=\"lazy\" alt=\"{alt}\" src=\"{buffer}\" style=\"float: {}\" />",
"<img loading=\"lazy\" alt=\"{alt}\" src=\"{}\" style=\"float: {}\" />",
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 == "<style>") | (line == "</style>") {
in_pre_block = !in_pre_block;
output.push_str(&format!("{line}\n"));
continue;