From 19a087d08d6024a59ad943bfee3086a6710b9278 Mon Sep 17 00:00:00 2001 From: SavagePeanut Date: Tue, 15 Aug 2023 15:02:07 -0500 Subject: replace newlines --- src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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) -> 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::().replace("\n", &new_tags.get(&"\n".to_string()).unwrap().0) + } else { + chars.into_iter().collect::() + }; + + Ok(remove_non_escaped_backslashes(text)) } fn remove_non_escaped_backslashes(text: String) -> String { @@ -100,9 +106,8 @@ fn parse_with_limits(chars: &Vec, 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 => () } -- cgit v1.2.3