From db5bd2e6e42bed5204788f006d241b618671b94b Mon Sep 17 00:00:00 2001 From: SavagePeanut Date: Mon, 31 Jul 2023 10:31:54 -0500 Subject: non-compliant Conversations style formatting for *bold*still bold* --- src/lib.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 35ebc12..532fec7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,6 +153,37 @@ fn seek_end(chars: &Vec, keyword: char, start: usize, end: usize) -> Optio if c == keyword && !chars[i - 1].is_whitespace() && !preceeded_by_backslash(chars, i, start) + { + match seek_higher_order_end(chars, c, i + 1, end) { + Some(higher_order_index) => { + return Some(higher_order_index); + } + None => { + return Some(i); + } + } + } + } + None +} + +fn seek_higher_order_end(chars: &Vec, keyword: char, start: usize, end: usize) -> Option { + for i in start..=end { + let c = chars[i]; + if c == '\n' { + return None; + } + if c == keyword + && chars[i - 1].is_whitespace() + && !followed_by_whitespace(chars, i, end) + && !preceeded_by_backslash(chars, i, start) + { + return None; // "*bold* *<--- beginning of new bold>*" + } + if c == keyword + && !chars[i - 1].is_whitespace() + && followed_by_whitespace(chars, i, end) + && !preceeded_by_backslash(chars, i, start) { return Some(i); } -- cgit v1.2.3