Skip to content

Commit

Permalink
fix whitespace around embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
hry-gh committed Nov 13, 2024
1 parent a8ab8a8 commit b445c5b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tools/od_ref_bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,24 @@ fn format_body(body: &str, data: &Data) -> String {

new_body = tag_cleaner_regex.replace_all(&new_body, "").to_string();
new_body = new_body.replace("```dm", "```js");
new_body.replace("\n\n\n", "\n")

let mut whitespaced_body = new_body.clone();

let whitespace_cleaner = Regex::new(r"(\n{3,}```)|(```\n{2,})").unwrap();
for capture in whitespace_cleaner.captures_iter(&new_body) {
let original = capture.get(0).unwrap().as_str();

if let Some(_) = capture.get(1) {
whitespaced_body = whitespaced_body.replace(original, "\n\n```");
break;
}

if let Some(_) = capture.get(2) {
whitespaced_body = whitespaced_body.replace(original, "```\n")
}
}

whitespaced_body
}

/// Converts the internal Zola page structure into something we can link to.
Expand Down

0 comments on commit b445c5b

Please sign in to comment.