summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSavagePeanut <sourcehut@lazytapir.com>2023-08-15 15:02:07 -0500
committerSavagePeanut <sourcehut@lazytapir.com>2023-08-15 15:02:07 -0500
commit19a087d08d6024a59ad943bfee3086a6710b9278 (patch)
tree65f34b81b116935599cb4536cd4462676c7055d6 /src
parent0f370ea91d78c7a0394417edbd9b0ea80ffed1c9 (diff)
replace newlines
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ceca3a1..89387b0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -42,7 +42,13 @@ fn format_body(body: String, new_tags: HashMap<String, (String, String)>) -> PyR
chars = [chars[..index].to_vec(), tag.chars().collect(), chars[end..].to_vec()].concat();
}
- Ok(remove_non_escaped_backslashes(chars.into_iter().collect()))
+ let text: String = if new_tags.contains_key("\n") {
+ chars.into_iter().collect::<String>().replace("\n", &new_tags.get(&"\n".to_string()).unwrap().0)
+ } else {
+ chars.into_iter().collect::<String>()
+ };
+
+ Ok(remove_non_escaped_backslashes(text))
}
fn remove_non_escaped_backslashes(text: String) -> String {
@@ -100,9 +106,8 @@ fn parse_with_limits(chars: &Vec<char>, start: usize, end: usize, depth: usize)
};
styles.push((keyword, index, end_of_line + 1, to, remove_end));
styles.append(&mut parse_quotes_in_code_block(chars, index + 3, to, depth));
+ index = to;
}
- index = to + 3;
- continue;
}
None => ()
}