Skip to content

fix(editor): render CJK-adjacent emphasis in Markdown preview - #21553

Merged
nwparker merged 1 commit into
mainfrom
nwparker/markdown-cjk-preview
Sep 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/markdown-cjk-preview

Conversation

@nwparker

@nwparker nwparker commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86

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.

Before After
Before After

Testing

  • Automated coverage added or updated.
  • Native Windows/Linux and live SSH UI validation performed for this revision.

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

  • Not applicable; no skill-installer source is included.

Checklist

  • User-visible behavior and implementation rationale explained.
  • Automated checks recorded with their scope.
  • Cross-platform, SSH/folder-workspace, and source-data effects considered.
  • All CI checks have finished successfully on the latest head.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one optional scope note inline, plus a stale benchmark mirror.

Reviewed changes

  • New dependency: remark-cjk-friendly@^2.3.1 added as a runtime dependency, with lockfile resolution.
  • Preview pipeline: MarkdownPreviewBody.tsx now runs remark-cjk-friendly/parseOnly, so emphasis delimiters adjacent to CJK punctuation tokenize as emphasis.
  • TOC pipeline: the same plugin is added to buildMarkdownTableOfContents; the as MarkdownAstNode cast is dropped and alt widened to string | null so the mdast Root type 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.mjs describes itself as a "Mirror of buildMarkdownTableOfContents()'s parse + heading walk", but the mirror was not given remarkCjkFriendly, so its per-change numbers now understate the real pipeline slightly.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

type MarkdownPluginList = NonNullable<ReactMarkdownOptions['remarkPlugins']>
const MARKDOWN_REMARK_PLUGINS: MarkdownPluginList = [
remarkGfm,
remarkCjkFriendly,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

1 participant