Skip to content

Fix markdown parsing for code blocks when withCodeBlocks is false#4804

Draft
SylvainChevalier wants to merge 1 commit into
mainfrom
claude/determined-carson-71BwF
Draft

Fix markdown parsing for code blocks when withCodeBlocks is false#4804
SylvainChevalier wants to merge 1 commit into
mainfrom
claude/determined-carson-71BwF

Conversation

@SylvainChevalier
Copy link
Copy Markdown
Contributor

Summary

Fixed an issue where MDXEditor would throw a parsing error when encountering code blocks (``` fences) in markdown content when the withCodeBlocks prop 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

  • Modified the plugin registration logic in InitializedMarkdownEditor to always include the codeBlockPlugin, regardless of the withCodeBlocks setting
  • The withCodeBlocks flag now only gates the insert-code-block toolbar affordance and the CodeMirror editing experience, not the parsing of existing code blocks
  • Added a test case to verify that existing code blocks render correctly in write mode when withCodeBlocks is false

Implementation Details

  • The plugin registration now uses a conditional that checks !withCodeBlocks || mode === "read" instead of returning early when withCodeBlocks is false
  • This ensures that pre-existing ``` fences in source markdown are properly parsed and don't cause MDXEditor to throw an error on unknown "code" nodes
  • The change maintains backward compatibility while fixing the parsing issue

https://claude.ai/code/session_01PZkycszwECr7vMhFzQKf56

… 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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee6351cc-62c6-4a90-b4ea-32bffc3bca9e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/determined-carson-71BwF

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4804-claude-determined-carson-71bwf-preview.mtcl.cc
📦 Docker Image ghcr.io/metaculus/metaculus:claude-determined-carson-71bwf-cea647b
🗄️ PostgreSQL NeonDB branch preview/pr-4804-claude-determined-carson-71bwf
Redis Fly Redis mtc-redis-pr-4804-claude-determined-carson-71bwf

Details

  • Commit: 8fc25426de7ba1e3564a24bcc2d0896cebeadcd7
  • Branch: claude/determined-carson-71BwF
  • Fly App: metaculus-pr-4804-claude-determined-carson-71bwf

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

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.

2 participants