diff --git a/.changeset/sharp-lobsters-turn.md b/.changeset/sharp-lobsters-turn.md
new file mode 100644
index 00000000..f6c1afaf
--- /dev/null
+++ b/.changeset/sharp-lobsters-turn.md
@@ -0,0 +1,5 @@
+---
+"markdown-to-jsx": patch
+---
+
+fix: handle empty HTML tags more consistently #597
diff --git a/index.compiler.spec.tsx b/index.compiler.spec.tsx
index 26388e6a..b30376ac 100644
--- a/index.compiler.spec.tsx
+++ b/index.compiler.spec.tsx
@@ -4711,3 +4711,12 @@ it('handles naked brackets in link text', () => {
`)
})
+
+it('#597 handles script tag with empty content', () => {
+ render(compiler(''))
+
+ expect(root.innerHTML).toMatchInlineSnapshot(`
+
+ `)
+})
diff --git a/index.tsx b/index.tsx
index e94e8762..e6a563a3 100644
--- a/index.tsx
+++ b/index.tsx
@@ -1546,7 +1546,7 @@ export function compiler(
render(node, output, state) {
return (
- {node.text || output(node.children, state)}
+ {node.text || (node.children ? output(node.children, state) : '')}
)
},