Batch r2-1 review: U+2007 glues beside ideographs too

This commit is contained in:
bflatastic
2026-10-24 10:31:29 +07:00
parent d0db758684
commit 8af2efd1b9
+6 -2
View File
@@ -19,6 +19,8 @@ enum Class {
Hyphen,
/// Everything else (letters, digits, other symbols): no break inside a run of them.
Other,
/// The figure space: glues what's on either side, ideographs included.
Glue,
}
/// Opening brackets and quotes (line-end prohibited).
@@ -40,6 +42,7 @@ fn class(c: char) -> Class {
}
match c {
' ' | '\t' | '\u{3000}' | '\u{2002}'..='\u{2006}' | '\u{2008}'..='\u{200B}' => Class::Space,
'\u{2007}' => Class::Glue,
'-' | '/' | '\u{2010}' | '\u{2013}' | '\u{2014}' => Class::Hyphen,
'\u{2E80}'..='\u{2FFF}'
| '\u{3003}'..='\u{33FF}'
@@ -60,8 +63,8 @@ pub(crate) fn break_between(a: char, b: char) -> bool {
use Class::*;
match (class(a), class(b)) {
// Spaces hang at the end of the line before them; kinsoku: no closing mark starts a line,
// no opening mark ends one.
(_, Space | Close) | (Open, _) => false,
// no opening mark ends one; glue holds on both sides.
(_, Space | Close | Glue) | (Open | Glue, _) => false,
(Space | Hyphen | Ideo, _) | (_, Ideo) => true,
_ => false,
}
@@ -107,6 +110,7 @@ mod tests {
fn figure_space_is_non_breaking() {
assert!(!break_between('\u{2007}', '0'));
assert!(!break_between('1', '\u{2007}'));
assert!(!break_between('日', '\u{2007}') && !break_between('\u{2007}', '日'), "nor beside ideographs");
assert!(!is_space('\u{2007}'));
}
}