-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix: Disable GFM auto-linking for Windows-style file paths #14000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Conversation
Added a custom plugin to disable autolinking of file paths in markdown.
WalkthroughA custom plugin is added to the Markdown parser to prevent autolinking of file paths. The plugin detects link nodes where the URL equals the text and contains backslashes, replacing them with plain text nodes. It integrates into the markdown-to-AST processing pipeline before remarkMath and remarkCallout. Changes
Sequence Diagram(s)sequenceDiagram
participant Parser as Markdown Parser
participant Plugin as File Path Plugin
participant remarkGfm as remark-gfm
participant remarkMath as remarkMath
participant AST as Output AST
Parser->>remarkGfm: Parse markdown
remarkGfm-->>Parser: Auto-linked nodes
Parser->>Plugin: Process nodes
Plugin->>Plugin: Detect file paths<br/>(URL == text, has backslashes)
Plugin->>Plugin: Replace links with<br/>plain text nodes
Plugin-->>Parser: Modified nodes
Parser->>remarkMath: Continue pipeline
remarkMath-->>Parser: Processed nodes
Parser->>AST: Final AST
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
blocksuite/affine/shared/src/adapters/markdown/markdown.ts (1)
207-241: Autolink-disabling plugin behavior looks correct; a couple of small robustness nits.The plugin correctly targets only “bare” links whose
urlequals the sole text child and contains a backslash, so it shouldn’t affect normal markdown links like[label](C:\foo\bar)or links with formatted contents. The recursive traversal also looks safe and will visit the whole tree.Two minor, optional improvements:
- To be slightly more defensive, you could guard
childrenwith an array check instead of relying on truthiness, and avoidanyfor the visitor node to keep typings tight:const visitor = (node: Root | Parent) => { if (!Array.isArray((node as any).children)) return; // ... };(or import
Parentfrommdastand use that instead ofany).
- For readability and potential reuse, consider extracting this plugin into a named helper (e.g.,
remarkDisableWindowsPathAutolinks) alongside the other remark plugins, and.use(remarkDisableWindowsPathAutolinks)here, instead of the inline closure.These are purely polish; current behavior matches the PR intent.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
blocksuite/affine/shared/src/adapters/markdown/markdown.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
blocksuite/affine/shared/src/adapters/markdown/markdown.ts (1)
blocksuite/affine/shared/src/adapters/markdown/type.ts (1)
Markdown(8-8)
| child.children.length === 1 && | ||
| child.children[0].type === 'text' && | ||
| child.url === child.children[0].value && | ||
| (child.url as string).includes('\\') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer typeof child.url === 'string'
This PR prevents
remark-gfmfrom auto-linking strings likeapi\views\project.py, which incorrectly turn into<api\views\project.py>when pasted into Affine.Key Changes
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.