-
Notifications
You must be signed in to change notification settings - Fork 16
fix(mdxish): fix rendering issues with Code magic blocks
#1259
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
fix(mdxish): fix rendering issues with Code magic blocks
#1259
Conversation
This reverts commit 80a7382.
…to falco/rm-14615-rendering-issues-with-magic-blocks
…to falco/rm-14615-rendering-issues-with-magic-blocks
…to falco/rm-14615-rendering-issues-with-magic-blocks
…to falco/rm-14615-rendering-issues-with-magic-blocks
| paragraphParent = pParent as Parent; | ||
| return false; | ||
| // If parent is a paragraph and we're inserting block nodes (which must not be in paragraphs), lift them out | ||
| if (parent.type === 'paragraph' && children.some(child => isBlockNode(child))) { |
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.
Will this not affect other magic blocks behaviour?
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.
…to falco/rm-14615-rendering-issues-with-magic-blocks
kevinports
left a 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.
I linked this branch locally and QA'd with the snippet you provided in the PR description, and I'm seeing one of the code blocks getting dropped when rendering:
Screen.Cast.2026-01-16.at.10.23.56.AM.mp4
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.
Not blocking! Just a general question about this transformer for my understanding because I wasn't really involved in the initial setup of the mdxish engine.
Why didn't we re-use the magic block parser from the legacy rdmd engine instead of writing this new transformer plus the extraction/replacement stuff?
See this code from the v6 branch: https://github.com/readmeio/markdown/blob/v6/processor/parse/magic-block-parser.js
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.
Yes actually that transformer is based off from the legacy magic block parser! It's just we had to do quite a lot of adjustments such as providing types (since the legacy was in js) and because data processing flow is a bit different from legacy
|
@kevinports ah sorry about that, turns out there was a
|
kevinports
left a 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.
Now working when I tested it. Just had a few more comments.
## Version 12.0.0 ### ⚠ BREAKING CHANGES * **mdxish:** the component tree. **3. HTML Entity Decoding** Because we introduced the double quotes, I needed to encode & decode some special characters in the attributes so it doesn't split the attributes nodes **Before** <img width="854" height="349" alt="Screenshot 2026-01-16 at 9 18 19 pm" src="https://github.com/user-attachments/assets/a948297d-6d88-410c-8c38-6324dda1d260" /> **After** https://github.com/user-attachments/assets/3973a605-eb30-4312-9029-5aa1f5aa9cb6 ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. 1. In an mdxish project, create a custom component with some props 2. In a document, use the component while passing in template literal prop. For example: ``` <MyComponent title={`Hello world`} /> ``` [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg ### 🛠 Fixes & Updates * allow parsing empty callouts like `>` without breaking ([#1260](#1260)) ([98a8c65](98a8c65)) * **mdxish:** fix rendering issues with `Code` magic blocks ([#1259](#1259)) ([ea6e7bb](ea6e7bb)) * **mdxish:** process jsx attributes on custom components ([#1298](#1298)) ([7f21a5e](7f21a5e)) * **mdxish:** remove unused whitespace nodes when rehyping components ([#1297](#1297)) ([33e868a](33e868a)) <!--SKIP CI-->
This PR was released!🚀 Changes included in v12.0.0 |



🧰 Changes
We were seeing cases where magic blocks that uses the
codecases was wrapped in paragraph nodes which caused invalid HTML and values like props not being passed down correctly which resulting in errors and causing the page to not be renderable.CodeTabswere also being split into two components like this:This PR fixes this by detecting when code-tabs nodes are inserted into paragraphs and lifting them out to the root level, preventing the paragraph wrapper and ensuring props are passed correctly.
Note
The fix only affects code tabs, so other block-level elements (like tables) are unchanged.
🧬 QA & Testing
Use the attached md file in the linear ticket. Paste it into raw mode and make sure no errors are thrown. Or use this raw md to test all magic block types in one go