fix: split autolinks at CJK punctuation#327
Conversation
|
@xxchan is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
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
remarkCjkAutolinkBoundaryplugin 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.
|
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 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 👍 |
|
Appreciate the PR @xxchan 🙏 |
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
Related Issues
Fixes #326
Related to #185
Changes Made
pnpm changeset)Testing
Test Coverage
pnpm --filter remend buildpnpm --filter streamdown test -- __tests__/cjk-friendly.test.tsx(runs full suite)Screenshots/Demos
N/A
Checklist
pnpm changeset)Changeset