[EasyMark] Fix incorrect handling of non-ASCII characters

This commit is contained in:
Emil Ernerfeldt 2021-02-06 15:19:39 +01:00
parent 8189a78284
commit b106d10202

View file

@ -299,12 +299,14 @@ impl<'a> Iterator for Parser<'a> {
}
// Swallow everything up to the next special character:
let special = self.s[1..]
let end = self
.s
.find(&['*', '`', '~', '_', '/', '\\', '<', '[', '\n'][..])
.map(|i| i + 1)
.map(|special| special.max(1)) // make sure we swallow at least one character
.unwrap_or_else(|| self.s.len());
let item = Item::Text(self.style, &self.s[..special]);
self.s = &self.s[special..];
let item = Item::Text(self.style, &self.s[..end]);
self.s = &self.s[end..];
self.start_of_line = false;
return Some(item);
}