Fix markdown parsing for code blocks when withCodeBlocks is false#4804
Fix markdown parsing for code blocks when withCodeBlocks is false#4804SylvainChevalier wants to merge 3 commits into
Conversation
… is off
The post background-information / notebook markdown / group description
fields render MarkdownEditor without withCodeBlocks, but content authored
elsewhere may still contain ``` fences. With no codeBlockPlugin
registered, MDXEditor throws "Parsing of the following markdown structure
failed: {type: code, name: N/A}".
Always register codeBlockPlugin with the read-only Prism descriptor so
existing fences parse; withCodeBlocks now only gates the insert-code-block
toolbar affordance and the rich CodeMirror editing path.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe markdown editor now registers code-block parsing when rich code-block editing is disabled or the editor is in read mode. A write-mode test verifies fenced code blocks render without parsing errors and preserve surrounding text. ChangesFenced Code Block Parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
🚀 Preview EnvironmentYour preview environment is ready!
Details
ℹ️ Preview Environment InfoIsolation:
Limitations:
Cleanup:
|
Summary
Fixed an issue where MDXEditor would throw a parsing error when encountering code blocks (``` fences) in markdown content when the
withCodeBlocksprop is set to `false`. The code block plugin is now always registered to handle parsing of existing code blocks, while the `withCodeBlocks` flag continues to control only the UI affordances (toolbar button and rich editing experience).Key Changes
InitializedMarkdownEditorto always include thecodeBlockPlugin, regardless of thewithCodeBlockssettingwithCodeBlocksflag now only gates the insert-code-block toolbar affordance and the CodeMirror editing experience, not the parsing of existing code blockswithCodeBlocksis falseImplementation Details
!withCodeBlocks || mode === "read"instead of returning early whenwithCodeBlocksis falsehttps://claude.ai/code/session_01PZkycszwECr7vMhFzQKf56
Summary by CodeRabbit
Bug Fixes
Tests