Repository navigation
fix(markdown): render CJK bold that ends in punctuation in desktop and phone chats - #32020
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⛔ Files ignored due to path filters: 1
⚙️ Run configuration
⛔ Files ignored due to path filters: 1
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
fd69b8a to
afce523
Compare
The editor preview already used the CJK-friendly emphasis rule; chat markdown on desktop and phone did not. Fixes #31368
afce523 to
451f0a1
Compare
ELI5
When Chinese or Japanese bold text ended in punctuation and the next sentence started right after it, chats showed the raw
**instead of bold. Chats now use the same CJK rule the markdown preview already uses.What Changed
Before:
**单算 Runtime 执行引擎,平均每题 29.78 秒。**边界是开始执行到产出结果。showed literal asterisks in desktop native chat and in the phone chat.After: the first sentence is bold, including its
。, and the next sentence is normal text. This applies to both surfaces, and to the user's own messages too.CommentMarkdownaddsremark-cjk-friendly/parseOnlyto its remark plugins. The editor preview and table of contents already had it.markdown-it-cjk-friendly(2.0.3, the markdown-it 14 line). It comes from the same upstream spec and author as the remark plugin. Mobile keeps markdown-it for speed on Hermes.Why
CommonMark only lets
**close when it is "right-flanking". A closing**with punctuation (。) before it and a letter (边) after it does not count, so the pair stays as text. CJK text has no spaces between sentences, so this rule misfires there. The CJK-friendly extension relaxes the check only when the character on either side is CJK. Non-CJK text keeps standard CommonMark behavior:**Note.**Nextstays literal.The editor preview already enabled this rule, but the two chat parsers did not, so the fix goes in those parsers' config. Community PR #29644 bundles a similar change with unrelated work; this PR is an independent fix for the emphasis rule only.
Linked Issue
Fixes #31368
Linear: STA-11478
Visual Proof
Real Claude reply in a hidden dev build of desktop native chat (top: the user's message, bottom: Claude's reply). Rows 3 and 4 must stay literal.
Phone, iOS simulator on Hermes, with the same text in
MobileMarkdown:Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Added tests on both surfaces for the reported case and for the non-CJK case
**Note.**Next. The CJK test fails without the fix on both surfaces.Ran all 652 CommonMark spec examples through mobile's markdown-it with and without the plugin. The output is identical for every one.
The plugin's
\p{Emoji_Presentation},\p{sc=Hangul}and\p{Zs}regexes compile underhermesc, and the iOS simulator renders the reported case bold.pnpm run build:mobile-webbuilds and verifies with the plugin bundled, within the size budget.Ran
check:code-quality:changed,check:react-doctor:changedand the mobiletsc --noEmit. All pass.Agent skill upstream boundary
Notes
markdown-it-cjk-friendly,get-east-asian-width), andpnpm install --frozen-lockfilesucceeds.marked, which has no equivalent extension, so it is left as is (it is a file editor, not chat).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)