summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSavagePeanut <sourcehut@lazytapir.com>2023-07-31 10:31:54 -0500
committerSavagePeanut <sourcehut@lazytapir.com>2023-07-31 10:32:12 -0500
commitdb5bd2e6e42bed5204788f006d241b618671b94b (patch)
tree1bcb1a377565ea228bcb2ddbc85e3009825f5975 /src
parentabd8ad5fd2c1e014633ccd83fd0f4de01b5e7a28 (diff)
non-compliant Conversations style formatting for *bold*still bold*
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 35ebc12..532fec7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -154,6 +154,37 @@ fn seek_end(chars: &Vec<char>, keyword: char, start: usize, end: usize) -> Optio
&& !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<char>, keyword: char, start: usize, end: usize) -> Option<usize> {
+ 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);
}
}