From 2a88ed30e27f25bed0b72bf5b31aa59b83f2b1d7 Mon Sep 17 00:00:00 2001 From: SavagePeanut Date: Thu, 24 Aug 2023 16:09:16 -0500 Subject: fix codeblocks, again --- src/lib.rs | 2 +- tests/test_style_parser.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 89387b0..8de599a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -295,7 +295,7 @@ fn seek_end_block(chars: &Vec, keyword: char, start: usize, end: usize, de if i + 1 + depth > end { return Some(i); } - if i + 4 + depth > end + if seek_end_of_line(chars, i + 1, end) == i + depth + 4 && chars[i + 1..i + 1 + depth].iter().all(|&c| QUOTE_KEYWORDS.contains(&c)) && chars[i + 1 + depth] == keyword && is_char_repeating(chars, keyword, 2, i + 1 + depth, end) diff --git a/tests/test_style_parser.py b/tests/test_style_parser.py index 86a7eff..8f39580 100644 --- a/tests/test_style_parser.py +++ b/tests/test_style_parser.py @@ -90,6 +90,10 @@ def test_code_blocks(): formatted_body = "
hacker code
" assert(format_body(test, MATRIX_FORMATS) == formatted_body) + test = "```python\nhacker code\n```\nnormal text" + formatted_body = "
hacker code

normal text" + assert(format_body(test, MATRIX_FORMATS) == formatted_body) + test = ">```java\n>why are you quoting a code block\n>```" formatted_body = "
why are you quoting a code block
" assert(format_body(test, MATRIX_FORMATS) == formatted_body) -- cgit v1.2.3