Skip to content

Strip punctuation from spoken alerts - #508

Open
nedtwigg wants to merge 2 commits into
mainfrom
speak-punctuation
Open

Strip punctuation from spoken alerts#508
nedtwigg wants to merge 2 commits into
mainfrom
speak-punctuation

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Sep 1, 2026

Copy link
Copy Markdown
Member

Summary

  • strip Unicode punctuation, symbols, and controls before alert labels reach speech synthesis
  • preserve letters, numbers, and combining marks across writing systems
  • document and test the speech sanitization contract

Verification

  • full dormouse-lib test suite (1,835 tests)
  • focused alert-speech tests (26 tests)
  • dormouse-lib TypeScript build
  • spec lint

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7788350
Status: ✅  Deploy successful!
Preview URL: https://1da081f3.mouseterm.pages.dev
Branch Preview URL: https://speak-punctuation.mouseterm.pages.dev

View logs

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things on the widened strip set. The regex itself is right — Cc fully covers the \u0000-\u001f\u007f-\u009f range it replaces, and </>/+/= are Sm while &/* are Po, so no guard was dropped — and nothing else in the repo carries a copy of the old [<>&*] pattern to keep in sync.

Apostrophes now orphan the letter after them. toSpokenText("build didn’t finish") returns build didn t finish, and a terminal-supplied OSC 0/2 title is exactly where English prose reaches speech. That works against the bullet’s own goal: the reason * is substituted is so eight * is not announced as "eight asterisk", but didn t hands the engine a bare t to announce for the same reason. Eliding rather than space-substituting the apostrophe fixes it in one line and leaves every existing case alone (I checked "'''"terminal and the combined punctuation case both still hold).

The spec understates \p{C}. It is General_Category=Other, not just control characters — it also strips the bidi and zero-width format characters. That is worth naming rather than losing, because the toPushText bullet a few lines down documents stripping exactly that class as a named security control ("can visually reorder or hide text in an OS notification"); as written, a reader asking whether a bidi override reaches the speech engine gets "yes" from the spec and "no" from the code. The suggested wording is sized to the word budget — alert.md is at 7333 of 7350, and it lands at 7342.

If you take both, the bullet needs the apostrophe carve-out too — appending , except apostrophes, which are elided so contractions survive after become spaces lands alert.md at exactly 7350 words, which the ratchet still passes (words > budget is the failure test).

Comment thread lib/src/lib/alert-speech.ts
Comment thread docs/specs/alert.md Outdated
Comment thread lib/src/lib/alert-speech.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants