fix: honor Arabic Letter Mark in paragraph direction detection (#2149)

Recognize U+061C alongside RLM before the alphabetic-character check. Extend directional-mark coverage to preserve first-strong precedence.
This commit is contained in:
Mex authored and GitHub committed 2026-11-15 14:12:23 +00:00
1 parent 9f7d1c426f
commit 1ff3b87f5a
1 file changed
+6 -2
+6 -2
View File
@@ -10,8 +10,8 @@
/// Cyrillic, CJK…) give `false`. Neutral, weak, and whitespace characters are skipped.
pub fn first_strong_is_rtl(text: &str) -> bool {
for c in text.chars() {
if c == '\u{200F}' {
// Right-to-Left Mark (RLM)
if c == '\u{200F}' || c == '\u{061C}' {
// RLM and ALM are strong RTL controls, although neither is alphabetic.
return true;
}
if c == '\u{200E}' {
@@ -76,6 +76,10 @@ mod tests {
#[test]
fn honours_directional_marks() {
assert!(first_strong_is_rtl("\u{200F}Hello"));
assert!(first_strong_is_rtl("\u{061C}Hello"));
assert!(first_strong_is_rtl("\u{061C}"));
assert!(!first_strong_is_rtl("Hello\u{061C}"));
assert!(!first_strong_is_rtl("\u{200E}\u{061C}"));
assert!(!first_strong_is_rtl("\u{200E}مرحبا"));
}
}