The ProseMirror node representing the content
The markdown renderer helper
Either a string prefix or a function that generates the prefix from context
Optionalctx: anyOptional context object (used when prefixOrGenerator is a function)
The rendered markdown string
// For a bullet list item with static prefix
return renderNestedMarkdownContent(node, h, '- ')
// For a task item with static prefix
const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `
return renderNestedMarkdownContent(node, h, prefix)
// For a blockquote with static prefix
return renderNestedMarkdownContent(node, h, '> ')
// For content with dynamic prefix based on context
return renderNestedMarkdownContent(node, h, ctx => {
if (ctx.parentType === 'orderedList') {
return `${ctx.index + 1}. `
}
return '- '
}, ctx)
// Custom extension example
const CustomContainer = Node.create({
name: 'customContainer',
// ... other config
markdown: {
render: (node, h) => {
const type = node.attrs?.type || 'info'
return renderNestedMarkdownContent(node, h, `[${type}] `)
}
}
})
Utility function for rendering content with a main line prefix and nested indented content.
This function handles the common pattern of rendering content with: