Repository navigation
fix(registry): caption keywords, emoji and aftershock work for words outside a-z - #7804
Conversation
…outside a-z
caption-emoji-pop and caption-neon-accent look a word up in KEYWORDS and
WORD_EMOJI after stripping everything outside a-z, and caption-glitch-rgb
counts a word's \w characters to decide on the aftershock. A Korean, Cyrillic
or accented word comes out empty or cut, so a keyword written in that script
never matches and a long word never pulses.
The three components now strip by Unicode letter (\p{L}) instead, which is
the same set for a lowercased English transcript.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
miguel-heygen
left a comment
There was a problem hiding this comment.
Verified at 6a1f29c: all six strip sites (3 components + their demo.html) move from a-z / \w to Unicode classes with the u flag; input is lowercased first, so an a-z transcript normalises to the same string as before and the shipped English KEYWORDS/WORD_EMOJI still match. Test runs each inline script in happy-dom and pins Korean emoji/accents and Cyrillic aftershock counts. Required checks green. The one red job, Catalog payloads (not required), fails on caption-emoji-pop/caption-neon-accent with a 404 for caption-overrides.json: the caption runtime probes that optional file, hyperframes validate ignores that 404 by design (validate.ts shouldIgnoreHttpError), and the payload verifier does not. It runs only on changed components, so it surfaces here; the regex change cannot add or remove that request.
Nit, non-blocking: \p{L} also strips combining marks (\p{M}), so in scripts that use them (Devanagari, Thai, Arabic with harakat) a transcript word like नमस्ते loses its vowel signs and no longer equals the same keyword in KEYWORDS/WORD_EMOJI. [^\p{L}\p{M}] (and \p{M} in the glitch count) would cover those scripts. Fine as a follow-up.
What
caption-emoji-pop,caption-neon-accentandcaption-glitch-rgbnow treat a word in any script the way they treat an English one: a keyword inKEYWORDSgets its accent, a word inWORD_EMOJIgets its emoji, and a long word gets the glitch aftershock.Why
I make Korean captions with these components. After replacing
TRANSCRIPTand putting Korean words inKEYWORDS/WORD_EMOJI, nothing was accented and no emoji appeared, with no error.The cause is how the word is normalised before the lookup:
caption-emoji-popandcaption-neon-accent:text.toLowerCase().replace(/[^a-z]/g, "")."영상을"becomes"","información"becomes"informacin", soKEYWORDS.has(...)andWORD_EMOJI[...]can never match a word written outside a-z.caption-glitch-rgb:shouldAftershockcountsword.text.replace(/[^\w]/g, "").length >= 7."невероятно"counts as 0 letters, so it never pulses.Related work
How
In each component and its
demo.html, the strip pattern is now a Unicode property class with theuflag:/[^a-z]/g→/[^\p{L}]/gu(and/[^a-z']/g→/[^\p{L}']/gufor the transition-word lookup)/[^\w]/g→/[^\p{L}\p{N}_]/guThe input is lowercased first, so for an English transcript the result is the same string as before. Keywords are still matched as whole words, so a Korean keyword has to be written in the form the transcript uses (
영상을, not영상).Test plan
Unit: new
packages/cli/src/registry/captionNonLatinKeywords.test.tsruns each component's inline script in happy-dom (the approach of #7690's test).On main (
04ee926d) with the component changes stashed, all 4 fail (expected [] to deeply equal [ '📹' ],expected 16 to be 24, …). With the fix,vitest run src/registry/passes 327 tests.tsc --noEmit, oxlint, oxfmt andfallow auditare clean.Real CLI: each
demo.htmlwith a 10-word Korean transcript,KEYWORDS = ["영상을", "공개합니다", "감사합니다"]andWORD_EMOJI = { 영상을: "📹", 감사합니다: "🙏" }, thenhyperframes snapshot --at 1.5,2.7,5.7.Before
No emoji; the keywords "공개합니다." and "감사합니다." stay plain white in neon-accent.
After
The emoji sit above their words; the keywords take the accent colour and size.
🤖 Generated with Claude Code