Skip to content

feat(mdxish): always compile callouts to JSX in mdxishMdastToMd#1498

Draft
eaglethrost wants to merge 1 commit into
nextfrom
dimas/rm-16782-update-callout-compiler-to-jsx
Draft

feat(mdxish): always compile callouts to JSX in mdxishMdastToMd#1498
eaglethrost wants to merge 1 commit into
nextfrom
dimas/rm-16782-update-callout-compiler-to-jsx

Conversation

@eaglethrost
Copy link
Copy Markdown
Contributor

@eaglethrost eaglethrost commented May 29, 2026

🎫 Resolve RM-16782

🎯 What does this PR do?

Updates the mdxish callout serializer (mdxishMdastToMd) to always compile callouts to <Callout> JSX syntax instead of the legacy MD blockquote format.

PR #17745 adds icon + color selection for callouts in the MdxishEditor UI, but the engine always serialized callouts to the legacy blockquote (> 📘 Hey), which dropped any custom icon/theme on round-trip. This PR persists those selections.

  • Adds processor/transform/mdxish/callout-to-jsx.ts — a transform that converts every rdme-callout mdast node into an mdxJsxFlowElement (<Callout icon=… theme=…>), reusing toAttributes and the mdxJsxStringify extension already wired into mdxishMdastToMd.
  • Registers the transform in mdxishMdastToMd (alongside mdxishTablesToJsx). The RMDX (mdx) pipeline and the shared processor/compile/callout.ts blockquote compiler are untouched, so RMDX behavior is unchanged.

🧪 QA tips

  • The transform is the exact inverse of transformCallout in mdxish-jsx-to-mdast.ts: a body-only (empty) callout drops its placeholder title paragraph so re-parsing re-derives empty from the absence of a leading heading (no fragile empty attribute needed).
  • Default-filling mirrors readme-to-mdx (icon→theme via themes, theme→icon via defaultIcons) so both attributes always persist.
  • Children are mutated in place to preserve array identity, so nested callouts in the body are still visited and converted.
  • Round-trips are stable, e.g. > 🚧 It works!<Callout icon="🚧" theme="warn">### It works!…</Callout>, body-only callouts re-derive empty: true, and authored JSX callouts round-trip unchanged in shape.

📸 Screenshot or Loom

N/A — engine-side serialization change, covered by unit tests.

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.

1 participant