From 7a63b10d76bc553366dcc2545a84a5c470d330d8 Mon Sep 17 00:00:00 2001 From: wonjang <48057918+wonjangcloud9@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:11:38 +0000 Subject: [PATCH] fix(check): a number with a separator counts as one word in line reading time (#8084) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "1,080" and "3.5%" were split at the separator and counted as two words, so a two-word line such as "1,080억 달러" was timed as three and its shortest allowed hold went from 0.4 s to 1.05 s. Co-authored-by: Claude Fable 5.2 --- packages/cli/src/utils/craftAudit.test.ts | 10 ++++++++++ packages/cli/src/utils/craftAudit.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/utils/craftAudit.test.ts b/packages/cli/src/utils/craftAudit.test.ts index c913686fcf..348fbe286c 100644 --- a/packages/cli/src/utils/craftAudit.test.ts +++ b/packages/cli/src/utils/craftAudit.test.ts @@ -111,6 +111,16 @@ describe("readingWords", () => { expect(readingWords("a tooth can’t get in")).toBe(5); expect(readingWords("it's 'quoted'")).toBe(2); }); + + it("counts a number with a thousands separator or a decimal point as one word", () => { + expect(readingWords("1,080")).toBe(1); + expect(readingWords("3.5%")).toBe(1); + expect(readingWords("$1,200.50 saved")).toBe(2); + expect(readingWords("1,080억 달러")).toBe(2); + expect(readingWords("one, two. 3 left")).toBe(4); + expect(readingWords("12/40")).toBe(2); + expect(readingWords("売上1,080億")).toBe(3); + }); }); describe("lineFloorSec", () => { diff --git a/packages/cli/src/utils/craftAudit.ts b/packages/cli/src/utils/craftAudit.ts index 9f335cf5a7..32e4a19343 100644 --- a/packages/cli/src/utils/craftAudit.ts +++ b/packages/cli/src/utils/craftAudit.ts @@ -29,7 +29,10 @@ const CRAFT_THRESHOLDS = { const T = CRAFT_THRESHOLDS; const ZERO_BBOX: CheckBbox = { x: 0, y: 0, width: 0, height: 0 }; -const WORD_RUNS = /[\p{L}\p{M}\p{N}%$]+(?:['’][\p{L}\p{M}\p{N}]+)*/gu; +const WORD_CHARS = "[\\p{L}\\p{M}\\p{N}%$]+"; +const CONTRACTION_TAIL = "['’][\\p{L}\\p{M}\\p{N}]+"; +const DIGIT_SEPARATOR_TAIL = `(?<=\\p{N})[.,](?=\\p{N})${WORD_CHARS}`; +const WORD_RUNS = new RegExp(`${WORD_CHARS}(?:${CONTRACTION_TAIL}|${DIGIT_SEPARATOR_TAIL})*`, "gu"); // Chinese and Japanese have no spaces; a dictionary segmenter counts their words like an English line's. const WORD_SEGMENTER = new Intl.Segmenter("ja", { granularity: "word" }); const UNSPACED_SCRIPT =