Skip to content

fix: don't treat a single tilde as strikethrough (CJK ranges) (#385) - #392

Open
shani-singh1 wants to merge 1 commit into
agegr:mainfrom
shani-singh1:fix/385-cjk-single-tilde-strikethrough
Open

fix: don't treat a single tilde as strikethrough (CJK ranges) (#385)#392
shani-singh1 wants to merge 1 commit into
agegr:mainfrom
shani-singh1:fix/385-cjk-single-tilde-strikethrough

Conversation

@shani-singh1

Copy link
Copy Markdown
Contributor

Summary

Fixes #385.

~ is the standard CJK notation for numeric ranges — 5~7U, 100~200倍, 8~9点. GFM strikethrough accepts a single tilde as a delimiter, so any assistant message containing two ~ in one paragraph had both tildes dropped and an arbitrary span struck through. A range like 5~7U renders as 57U — the content is silently altered, which is especially misleading in data-heavy answers. This is very common in LLM output for CJK users.

Root cause

remark-gfm enables single-tilde strikethrough by default (micromark's singleTilde: true), so 5~7U 保证金 × 100~200倍 parses as 5<del>7U 保证金 × 100</del>200倍.

Fix

Pass singleTilde: false (remark-gfm's supported option) so strikethrough requires ~~double~~ tildes and single-tilde ranges stay literal. Set once in the shared plugin config in lib/markdown.ts, so all three renderers inherit it — chat (markdownRemarkPlugins), file preview (markdownPreviewRemarkPlugins), and the minimap (which spreads the preview plugins).

~~double-tilde~~ strikethrough still works.

Testing

  • tsc --noEmit passes
  • eslint passes
  • Added regression tests in components/MarkdownBody.test.mjs (rendered via the existing harness):
    • 5~7U 保证金 × 100~200倍杠杆 → no <del>, tildes preserved
    • ~~gone~~ → still <del>gone</del>
    • full suite: 10/10 pass

`~` is the standard CJK notation for numeric ranges (e.g. "5~7U",
"100~200倍"). GFM strikethrough accepts a single tilde as a delimiter, so
any assistant message with two `~` in one paragraph had the tildes
dropped and an arbitrary span struck through - silently corrupting the
content (a "5~7U" range renders as "57U"). This is common in LLM output
for CJK users.

Pass singleTilde:false to remark-gfm (its supported option) so
strikethrough requires ~~double~~ tildes, leaving single-tilde ranges
literal. Applied via the shared markdown plugin config, so chat, file
preview, and the minimap all honor it.

Fixes agegr#385
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.

Bug: '~' used as a range separator in CJK text is parsed as strikethrough and silently dropped

1 participant