Format fixes
This commit is contained in:
parent
70d5aa194b
commit
2edc3082d3
1 changed files with 5 additions and 0 deletions
|
@ -97,14 +97,19 @@ fn format_attachments(depth: usize, attachments: &[Attachment]) -> String {
|
|||
// line, breaking the desired formatting
|
||||
fn apply_block_quote<S: AsRef<str>>(depth: usize, content: S) -> String {
|
||||
let prefix = quote_prefix(depth);
|
||||
// TODO use OnceLock
|
||||
let empty = Regex::new("\n\\s").expect("Failed to compiled regex for nested empty lines!");
|
||||
let non_empty =
|
||||
Regex::new("\n(?P<initial>[^>\\s])").expect("Failed to compile regex for nested lines!");
|
||||
// TODO break into separate function
|
||||
// parsing some multiline content adds paragraph tags, convert those back to new lines to apply
|
||||
// the block quote level to each line
|
||||
let content = content.as_ref().replace("</p><p>", "\n\n");
|
||||
let content = content.replace("<p>", "");
|
||||
let content = content.replace("</p>", "");
|
||||
// TODO refactor into separate function
|
||||
let content = content.replace("\\*", "*");
|
||||
let content = content.replace(":totoro:", "\\:totoro\\:");
|
||||
// replace separately to avoid trailing spaces when replacing empty lines with the prefix
|
||||
let content = empty.replace_all(content.as_ref(), format!("\n{}\n", prefix.trim()));
|
||||
let content = non_empty.replace_all(&content, |c: &Captures| {
|
||||
|
|
Loading…
Reference in a new issue