Skip to content

fix: split autolinks at CJK punctuation#327

Merged
haydenbleasel merged 2 commits into
vercel:mainfrom
xxchan:fix/cjk-autolink-boundary
Jan 5, 2026
Merged

fix: split autolinks at CJK punctuation#327
haydenbleasel merged 2 commits into
vercel:mainfrom
xxchan:fix/cjk-autolink-boundary

Conversation

@xxchan

@xxchan xxchan commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes GFM autolink literals swallowing CJK punctuation by splitting at CJK punctuation boundaries (only for literal autolinks where text equals URL).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Related Issues

Fixes #326
Related to #185

Changes Made

  • Add remark plugin to split autolink literals at CJK punctuation boundaries
  • Register plugin in default remark plugins
  • Add regression tests for with/without the plugin
  • Add changeset (generated via pnpm changeset)

Testing

  • All existing tests pass
  • Added new tests for the changes
  • Manually tested the changes

Test Coverage

  • pnpm --filter remend build
  • pnpm --filter streamdown test -- __tests__/cjk-friendly.test.tsx (runs full suite)

Screenshots/Demos

N/A

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have created a changeset (pnpm changeset)

Changeset

  • I have created a changeset for these changes

Copilot AI review requested due to automatic review settings January 4, 2026 08:20
@vercel

vercel Bot commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

@xxchan is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where GFM autolink literals incorrectly include CJK (Chinese, Japanese, Korean) fullwidth punctuation and subsequent text as part of the URL. The fix adds a new remark plugin that detects and splits autolinks at CJK punctuation boundaries for literal autolinks where the link text equals the URL.

Key Changes:

  • Added remarkCjkAutolinkBoundary plugin to split autolinks at CJK punctuation
  • Registered the plugin in the default remark plugins pipeline
  • Added regression tests to verify the fix and preserve backward compatibility when the plugin is disabled

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/streamdown/lib/remark/cjk-autolink.ts New remark plugin that splits autolink literals at CJK punctuation boundaries, converting links like https://example.com。谢谢 into separate link and text nodes
packages/streamdown/index.tsx Registers the new CJK autolink boundary plugin in the default remark plugins array
packages/streamdown/__tests__/cjk-friendly.test.tsx Adds tests verifying autolinks are split at CJK punctuation with the plugin enabled, and retain default GFM behavior when disabled
.changeset/spicy-lizards-move.md Changeset documenting this patch-level fix for autolink parsing with CJK punctuation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/streamdown/lib/remark/cjk-autolink.ts
Comment thread packages/streamdown/__tests__/cjk-friendly.test.tsx
Comment thread packages/streamdown/lib/remark/cjk-autolink.ts
Comment thread packages/streamdown/lib/remark/cjk-autolink.ts Outdated
Comment thread packages/streamdown/lib/remark/cjk-autolink.ts Outdated
@haydenbleasel

Copy link
Copy Markdown
Contributor

Nice one! @tats-u I would have expected this to be in one of your markdown-cjk-friendly packages - any chance of that?

@tats-u

tats-u commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

@haydenbleasel

Copy link
Copy Markdown
Contributor

@tats-u Ok makes sense. I'll merge this into Streamdown for now but if you decide to create a new package, let me know and I'll swap the code out with yours 👍

@haydenbleasel

Copy link
Copy Markdown
Contributor

Appreciate the PR @xxchan 🙏

@haydenbleasel haydenbleasel merged commit 48c9c51 into vercel:main Jan 5, 2026
2 of 3 checks passed
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.

Autolink literals swallow CJK punctuation and following text

4 participants