Simplify solution for #2279
This commit is contained in:
parent
67acaa17e4
commit
d294fff882
@ -73,13 +73,12 @@ fn tokenize(mut text: &str) -> impl Iterator<Item = Token> {
|
|||||||
nom::error::ErrorKind::Eof,
|
nom::error::ErrorKind::Eof,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let mut index = 0;
|
|
||||||
let mut other_token = alt((open_cloze, close_cloze));
|
let mut other_token = alt((open_cloze, close_cloze));
|
||||||
while other_token(&text[index..]).is_err() && index < text.len() {
|
// start with the no-match case
|
||||||
if let Some(next_char) = text[index..].chars().next() {
|
let mut index = text.len();
|
||||||
// advance index by one scalar char
|
for (idx, _) in text.char_indices() {
|
||||||
index += next_char.len_utf8();
|
if other_token(&text[idx..]).is_ok() {
|
||||||
} else {
|
index = idx;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user