Skip to content

Conversation

@maximilianfalco
Copy link
Contributor

PR App Fix RM-14652

🧰 Changes

Fixes an issue where callout magic blocks ([block:callout]...[/block]) were not rendering correctly in the mdxish pipeline. The placeholder tokens (__MAGIC_BLOCK_0__) are parsed as inlineCode nodes, which can end up inside paragraphs. When magic blocks create flow elements (like mdxJsxFlowElement), they need to be unwrapped from the paragraph to maintain valid AST structure.

Changes

  • Magic block parser: Callout magic blocks now create mdxJsxFlowElement nodes directly with name 'Callout' instead of intermediate rdme-callout nodes
  • Title conversion: Callout titles are converted to h3 headings to match calloutTransformer behavior
  • Unwrapping logic: Added logic to unwrap mdxJsxFlowElement nodes from paragraphs in magicBlockRestorer, since flow elements cannot be children of paragraphs in MDAST

Before

Screen.Recording.2025-12-17.at.22.12.27.mov

After

Screen.Recording.2025-12-17.at.23.32.40.mov

🧬 QA & Testing

Copy link
Contributor

@kevinports kevinports left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Noticed a few small things to be addressed but giving approval so this isn't blocked.

const md = '[block:callout]{"type":"info","title":"Note","body":"This is important"}[/block]';

const ast = mdxish(md);
console.log(JSON.stringify(ast, null, 2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(JSON.stringify(ast, null, 2));

Comment on lines +421 to +424
// Check if first child is a flow element that needs unwrapping (mdxJsxFlowElement, etc.)
const needsUnwrapping = (child: RootContent): boolean => {
return child.type === 'mdxJsxFlowElement';
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could move out of the top visitor function so it is only created once.

}
}
} else {
parent.children.splice(index, 1, ...children);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are mutating parent.children do we need to return an index of the next node to visit here?

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