Skip to content

Commit eaa04fc

Browse files
committed
fix(web): keep inline abbreviations in direction votes
1 parent 6408c79 commit eaa04fc

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎apps/web/src/textDirection.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ describe("textDirection", () => {
2626
"Run the migration first. ثم شغّل الاختبارات كلها. Then deploy to staging.",
2727
"ltr",
2828
],
29+
[
30+
"Arabic with inline abbreviations",
31+
"هذه جملة عربية تتحدث عن e.g. React i.e. TypeScript JavaScript",
32+
"rtl",
33+
],
34+
[
35+
"an abbreviation at a sentence boundary",
36+
"This long English sentence describes the technology sector in the U.S. هذه جملة عربية. وهذه جملة عربية أخرى.",
37+
"rtl",
38+
],
2939
])("reads %s", (_, text, direction) => {
3040
expect(textDirection(text)).toBe(direction);
3141
});

‎apps/web/src/textDirection.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type TextDirection = "ltr" | "rtl";
44
// supplementary right-to-left blocks.
55
const RTL_LETTER = /[֐-ࣿיִ-﷿ﹰ-\u{10800}-\u{10FFF}\u{1E800}-\u{1EFFF}]/u;
66
const LETTER = /\p{L}/u;
7-
const SENTENCE_END = /(?<=[.!?؟])\s+|\n+/;
7+
const SENTENCE_END = /(?<=[.!?؟])(?<!\b(?:e\.g|i\.e)\.)\s+|\n+/i;
88

99
function majority(units: Iterable<TextDirection | undefined>): TextDirection | undefined {
1010
let rtl = 0;

0 commit comments

Comments
 (0)