fix(markdown): avoid autolink angle brackets when copying plain URL l…#2661
fix(markdown): avoid autolink angle brackets when copying plain URL l…#2661Ovgodd wants to merge 2 commits intoTypeCellOS:mainfrom
Conversation
|
@Ovgodd is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the markdown exporter's remark-stringify configuration to add a custom Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~13 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/api/exporters/markdown/markdownExporter.ts`:
- Around line 39-49: The labeled-link branch in the markdown link renderer
(link: (node, _parent, state) => { ... }) interpolates node.url raw, producing
invalid Markdown for URLs with spaces or special chars; update it to use
state.safe(...) to escape the destination when constructing `[label](dest)` and
ensure you pass the position-aware info parameter into state.containerPhrasing
instead of the hardcoded now/column/offset object so the label rendering
receives correct context; specifically, call state.containerPhrasing(node, {
before: "[", after: "]", lineShift: 0, info: state.info }) (or equivalent to
supply the info) and wrap the escaped destination via state.safe(state.encode ?
state.encode(node.url) : node.url, { before: "(", after: ")" }) or the
renderer's destination-aware safe variant to produce a correctly escaped link
destination.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 90d7602b-e767-4062-938f-2fbeb967e6c0
📒 Files selected for processing (1)
packages/core/src/api/exporters/markdown/markdownExporter.ts
Port upstream #2661 to the custom HTML→markdown serializer: when an anchor's label matches its href (or is empty), output the plain URL instead of `[url](url)`, so pasting the result into another input produces a valid link. Also escape `\`, `(`, `)` in link destinations so URLs containing parens don't prematurely close the `(dest)` target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Purpose
Fix broken links when copying a URL from a BlockNote document and pasting it
into another input (link toolbar).
When copying content from the editor, BlockNote serializes links to
text/plainusing Markdown. Plain URL links (where text = URL) wereserialized as Markdown autolinks (
<https://example.com>), causing the anglebrackets to be included wherever the text was pasted, resulting in invalid
hrefs.
Proposal
linkhandler inremarkStringifyinsidecleanHTMLToMarkdownto output plain URLs instead of Markdown autolinkformat when the link text equals the URL
[label](url)is preservedSummary by CodeRabbit