From f69aeae1138871303f4997d0818d53c8f3def052 Mon Sep 17 00:00:00 2001 From: eagletrhost Date: Mon, 10 Nov 2025 14:34:19 +1100 Subject: [PATCH 1/2] fix: skip wrapping heading in callouts for non pragraph --- __tests__/migration/callouts.test.ts | 16 ++++++++++++++++ processor/transform/migrate-callouts.ts | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 __tests__/migration/callouts.test.ts diff --git a/__tests__/migration/callouts.test.ts b/__tests__/migration/callouts.test.ts new file mode 100644 index 000000000..8503cee60 --- /dev/null +++ b/__tests__/migration/callouts.test.ts @@ -0,0 +1,16 @@ +import { migrate } from '../helpers'; + +describe('migrating callouts', () => { + it('retains HTML content that starts a callout body', () => { + const md = `> ⚠️
hello
+ `; + + const mdx = migrate(md); + expect(mdx).toMatchInlineSnapshot(` + " +
hello
+
+ " + `); + }); +}); diff --git a/processor/transform/migrate-callouts.ts b/processor/transform/migrate-callouts.ts index b02920397..78ff037a5 100644 --- a/processor/transform/migrate-callouts.ts +++ b/processor/transform/migrate-callouts.ts @@ -7,6 +7,10 @@ import { wrapHeading } from './callouts'; const migrateCallouts: Plugin<[], Root> = (): Transformer => (tree: Root) => { visit(tree, 'rdme-callout', callout => { + const firstChild = callout.children?.[0]; + // This will retain the value of the node if it is not a paragraph, e.g. an HTML node + if (!firstChild || firstChild.type !== 'paragraph') return; + callout.children[0] = wrapHeading(callout); }); From 184e948096006849806b810d61dd928440715e7c Mon Sep 17 00:00:00 2001 From: eagletrhost Date: Mon, 10 Nov 2025 14:50:27 +1100 Subject: [PATCH 2/2] fix: don't early return --- processor/transform/migrate-callouts.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/processor/transform/migrate-callouts.ts b/processor/transform/migrate-callouts.ts index 78ff037a5..17bf11c52 100644 --- a/processor/transform/migrate-callouts.ts +++ b/processor/transform/migrate-callouts.ts @@ -9,9 +9,9 @@ const migrateCallouts: Plugin<[], Root> = (): Transformer => (tree: Root) visit(tree, 'rdme-callout', callout => { const firstChild = callout.children?.[0]; // This will retain the value of the node if it is not a paragraph, e.g. an HTML node - if (!firstChild || firstChild.type !== 'paragraph') return; - - callout.children[0] = wrapHeading(callout); + if (firstChild && firstChild.type === 'paragraph') { + callout.children[0] = wrapHeading(callout); + } }); return tree;