static-renderer: renderToMarkdown puts commas between the parts of a heading with bold or italic text
Affected Packages
static-renderer
Tiptap Version
3.30.3 (main @ aef3880b4)
Browser Used
Not browser-specific
What happened?
renderToMarkdown puts commas between the parts of a heading when the heading has more than one text node, which is the case as soon as any word in it is bold, italic, a link, and so on.
import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown'
import StarterKit from '@tiptap/starter-kit'
renderToMarkdown({
extensions: [StarterKit],
content: {
type: 'doc',
content: [{
type: 'heading',
attrs: { level: 2 },
content: [
{ type: 'text', text: 'Hello ' },
{ type: 'text', text: 'bold', marks: [{ type: 'bold' }] },
{ type: 'text', text: ' and ' },
{ type: 'text', text: 'it', marks: [{ type: 'italic' }] },
],
}],
},
})
// '## Hello ,**bold**, and ,_it_\n'Cause: the heading mapping in packages/static-renderer/src/pm/markdown/markdown.ts interpolates children directly (`${'#'.repeat(level)} ${children}\n`). children is an array when the heading has several child nodes, so the template literal joins it with commas. Every other mapping in that file goes through serializeChildrenToHTMLString(children). It has been like this since the static renderer was added (#5528).
Expected Behavior
## Hello **bold** and _it_
Reproducible Example URL (Optional)
No response
Additional Context (Optional)
A one-line fix (use serializeChildrenToHTMLString(children) in the heading mapping) with a regression test and a changeset is ready: the test fails on main with '## Hello ,**bold**, and ,_it_\n' and passes with the fix, and the static-renderer suite passes (59 tests). I'd be glad to be assigned and open the PR.
This issue was found and written up by an AI agent (breken-ai); the reproduction above was run on current main.
Source: ueberdosis/tiptap