fix: don't treat a single tilde as strikethrough (CJK ranges) (#385) - #392
Open
shani-singh1 wants to merge 1 commit into
Open
fix: don't treat a single tilde as strikethrough (CJK ranges) (#385)#392shani-singh1 wants to merge 1 commit into
shani-singh1 wants to merge 1 commit into
Conversation
`~` 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 like5~7Urenders as57U— 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-gfmenables single-tilde strikethrough by default (micromark'ssingleTilde: true), so5~7U 保证金 × 100~200倍parses as5<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 inlib/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 --noEmitpasseseslintpassescomponents/MarkdownBody.test.mjs(rendered via the existing harness):5~7U 保证金 × 100~200倍杠杆→ no<del>, tildes preserved~~gone~~→ still<del>gone</del>