Filter out prohibited line breaks in par (#2376)

This commit is contained in:
tingerrr 2023-10-17 11:26:34 +02:00 committed by GitHub
parent 5f1ea5c48c
commit 80175db397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1189,18 +1189,25 @@ impl Iterator for Breakpoints<'_> {
let lb = LINEBREAK_DATA.as_borrowed(); let lb = LINEBREAK_DATA.as_borrowed();
loop {
// Get the next "word". // Get the next "word".
self.end = self.linebreaks.next()?; self.end = self.linebreaks.next()?;
self.mandatory = self.mandatory = false;
self.p.bidi.text[..self.end].chars().next_back().map_or(false, |c| {
matches!( // Fix for: https://github.com/unicode-org/icu4x/issues/4146
lb.get(c), if let Some(c) = self.p.bidi.text[..self.end].chars().next_back() {
self.mandatory = match lb.get(c) {
LineBreak::Glue | LineBreak::WordJoiner | LineBreak::ZWJ => continue,
LineBreak::MandatoryBreak LineBreak::MandatoryBreak
| LineBreak::CarriageReturn | LineBreak::CarriageReturn
| LineBreak::LineFeed | LineBreak::LineFeed
| LineBreak::NextLine | LineBreak::NextLine => true,
) || self.end == self.p.bidi.text.len() _ => self.end == self.p.bidi.text.len(),
}); };
};
break;
}
// Hyphenate the next word. // Hyphenate the next word.
if self.p.hyphenate != Some(false) { if self.p.hyphenate != Some(false) {