-
Notifications
You must be signed in to change notification settings - Fork 16
fix: allow parsing empty callouts like > without breaking
#1260
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: next
Are you sure you want to change the base?
fix: allow parsing empty callouts like > without breaking
#1260
Conversation
- defaults to the mdx behaviour
…to falco/cx-2520-the-symbol-in-the-description-breaks-the-rendering
…to falco/cx-2520-the-symbol-in-the-description-breaks-the-rendering
| visit(tree, 'blockquote', (node: Blockquote) => { | ||
| if (!(node.children[0].type === 'paragraph' && node.children[0].children[0].type === 'text')) return; | ||
| visit(tree, 'blockquote', (node: Blockquote, index: number | undefined, parent: Parent | undefined) => { | ||
| if (!isCalloutStructure(node)) { |
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.
Can you move this check and the code inside it to its own function, on top of this file? I think it would improve readability
|
|
||
| // For 'mdx' format (or undefined): leave empty blockquotes as-is (can be rendered as empty callout) | ||
| // For 'md' format: always replace non-callout blockquotes with stringified content | ||
| if (format !== 'md' && isEmpty) { |
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.
If it's not md but it's not empty, do we still want to stringify the content?
|
I think it would be good to add a test to render the Callout and make sure it doesn't break the UI |
🧰 Changes
Adds a format option to
calloutTransformerin bothmdxandmdxishto control empty blockquote handling:format === 'md', empty blockquotes are replaced with paragraphs containing the stringified content ('>')format === 'mdx'(or undefined) they remain as blockquotes to allow rendering as empty callouts.This fixes errors when processing standalone '>' in MD format and preserves empty callout rendering in MDX. Includes tests for both formats in the transformer, MDX serialization, and mdxish processing pipelines.
The main reason the logic is split between these formats is because the excerpt component in the page headers uses the MD format while the body uses the MDX format. This done to allow cases like this:
🧬 QA & Testing