Repository navigation
fix(editor): render CJK-adjacent emphasis in Markdown preview - #21553
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one optional scope note inline, plus a stale benchmark mirror.
Reviewed changes
- New dependency:
remark-cjk-friendly@^2.3.1added as a runtime dependency, with lockfile resolution. - Preview pipeline:
MarkdownPreviewBody.tsxnow runsremark-cjk-friendly/parseOnly, so emphasis delimiters adjacent to CJK punctuation tokenize as emphasis. - TOC pipeline: the same plugin is added to
buildMarkdownTableOfContents; theas MarkdownAstNodecast is dropped andaltwidened tostring | nullso the mdastRoottype flows through. - Tests: new
MarkdownPreviewBody.test.tsx(render + parse-equivalence cases) and a Korean-emphasis TOC case. I confirmed these fail without the fix (6 of 23), so they pin real behavior.
I verified pnpm tc:web, the focused suites, the related markdown-preview-* suites, and the changed-code quality gate — all clean.
ℹ️ GFM strikethrough stays CJK-broken
remark-cjk-friendly explicitly does not fix GFM strikethrough; the new ~~"삭제"~~문장 case is asserted as unchanged, so the preview still shows literal tildes for CJK-adjacent strikethrough. If that syntax is in scope for this stack, the companion package is missing.
Technical details
# GFM strikethrough companion
## Affected sites
- `src/renderer/src/components/editor/MarkdownPreviewBody.tsx:59` — only `remarkCjkFriendly` is added
- `src/renderer/src/components/editor/MarkdownPreviewBody.test.tsx:46` — `~~"삭제"~~문장` is in `unchangedMarkdownExamples`, locking in the still-literal rendering
## Required outcome
- Decide whether CJK-adjacent GFM strikethrough is in scope. If yes, add `remark-cjk-friendly-gfm-strikethrough` to the preview and TOC plugin lists and move the strikethrough case into the fixed-examples set.
## Suggested approach (optional)
- The dependency README (line 14) states it "does not support the strikethrough syntax (`~~`) in GFM" and recommends pairing with `remark-cjk-friendly-gfm-strikethrough`.
- This is not a regression: `remarkCjkFriendly` leaves `~~` parsing unchanged, which is exactly what the equivalence test asserts.
## Open questions for the human (optional)
- Is strikethrough handled by a later PR in the #21553 → … → #21532 stack, or intentionally out of scope?ℹ️ Nitpicks
config/scripts/markdown-toc-parse-benchmark.mjsdescribes itself as a "Mirror ofbuildMarkdownTableOfContents()'s parse + heading walk", but the mirror was not givenremarkCjkFriendly, so its per-change numbers now understate the real pipeline slightly.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| type MarkdownPluginList = NonNullable<ReactMarkdownOptions['remarkPlugins']> | ||
| const MARKDOWN_REMARK_PLUGINS: MarkdownPluginList = [ | ||
| remarkGfm, | ||
| remarkCjkFriendly, |
There was a problem hiding this comment.
Optional scope note: remark-cjk-friendly does not make GFM strikethrough (~~) CJK-friendly — its README recommends pairing it with remark-cjk-friendly-gfm-strikethrough. The new test pins ~~"삭제"~~문장 as unchanged, so preview still shows literal tildes there. Fine if strikethrough is out of scope for this stack; otherwise the companion plugin is the missing half.
Technical details
# GFM strikethrough companion
## Affected sites
- `MarkdownPreviewBody.tsx:59` — only `remarkCjkFriendly` is added
- `MarkdownPreviewBody.test.tsx:46` — `~~"삭제"~~문장` sits in `unchangedMarkdownExamples`
## Required outcome
- If in scope: add `remark-cjk-friendly-gfm-strikethrough` to both the preview and TOC plugin lists, and move the strikethrough case into the fixed set.
## Suggested approach (optional)
- Not a regression: `remarkCjkFriendly` leaves `~~` parsing byte-for-byte unchanged, which the equivalence test confirms.
ELI5
Bold and italic next to Chinese, Japanese, or Korean text render consistently in preview.
What Changed
Adds the same parser plugin to preview and table-of-contents parsing, with regression coverage. Does not change the rich-editor save path.
Why
A parser option shared by both consumers avoids separate interpretations of heading text.
Linked Issue
Related to #9858; this stack is a partial compatibility improvement and does not close the full request.
Visual Proof
Before/after from the real preview component in an isolated, hidden Electron renderer. The baseline capture disables only the new parser plugin; the after capture uses this stack. Checked Korean, Japanese, and Chinese emphasis nodes and literal inline code.
Testing
23 focused preview/TOC tests passed on this branch.
All tests and Electron validation used
ORCA_BACKGROUND_LAUNCH=1. UI screenshots were captured through CDP without revealing windows. No remote protocol, Git-provider, or mobile schema changes are included.Review
Low incremental risk: read-only parsing, with a new runtime dependency. This layer targets main.
Review order: #21553 → #21554 → #21527 → #21529 → #21530 → #21531 → #21532. Each PR targets the preceding branch; merge from left to right.
Review comments were checked against the owning layer and fixes propagated through the dependent branches. See the inline replies for the individual resolutions. Risk here describes the changed surface, not an assertion that failing cases remain.
Agent skill upstream boundary
Checklist