From fbd5eeb993b4a934b6cb2598adbb67485e74f16b Mon Sep 17 00:00:00 2001 From: SavagePeanut Date: Sun, 3 Sep 2023 21:27:07 -0500 Subject: add test case --- src/matrix.rs | 3 ++- tests/test_matrix.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/matrix.rs b/src/matrix.rs index 92d2eb8..963e569 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -46,7 +46,7 @@ pub fn format_for_matrix(body: String) -> PyResult { if tag == "" { // index is at \n, add 1 to skip that one let substring = chars[index + 1..replace_newlines_to].into_iter().collect::(); - chars = [&chars[..index + 1], &substring.replace('\n', "
").chars().collect::>()[..]].concat(); + chars = [&chars[..index + 1], &substring.replace('\n', "
").chars().collect::>()[..], &chars[replace_newlines_to..]].concat(); } else if tag == "
" {
             replace_newlines_to = index;
         }
@@ -60,6 +60,7 @@ pub fn format_for_matrix(body: String) -> PyResult {
         } else {
             replace_newlines_to - offset.abs() as usize
         };
+        println!("chars {:?}", chars.clone().into_iter().collect::());
     }
     let substring = chars[..replace_newlines_to].into_iter().collect::();
     let text = [substring.replace('\n', "
"), chars[replace_newlines_to..].into_iter().collect::()].concat(); diff --git a/tests/test_matrix.py b/tests/test_matrix.py index be33973..7dbafdc 100644 --- a/tests/test_matrix.py +++ b/tests/test_matrix.py @@ -227,6 +227,10 @@ def test_assorted(): formatted_body = "underline bold strikethrough >not quote spoiler
quote

nothing
nothing
another quote with ```four```
" assert(format_for_matrix(test) == formatted_body) + test = "```\nhacker\ncode\n```\n\n```\nhacker\ncode\n```" + formatted_body = "
hacker\ncode


hacker\ncode
" + assert(format_for_matrix(test) == formatted_body) + test = ">```\n>do be do be dooo ba do be do be do ba\n>>>" formatted_body = "
do be do be dooo ba do be do be do ba\n>>
" assert(format_for_matrix(test) == formatted_body) -- cgit v1.2.3