renderNestedMarkdownContent
@blockslides/core / renderNestedMarkdownContent
Function: renderNestedMarkdownContent()
renderNestedMarkdownContent(
node,h,prefixOrGenerator,ctx?):string
Defined in: blockslides/packages/core/src/utilities/markdown/renderNestedMarkdownContent.ts:56
Utility function for rendering content with a main line prefix and nested indented content.
This function handles the common pattern of rendering content with:
- A main line with a prefix (like "- " for lists, "> " for blockquotes, etc.)
- Nested content that gets indented properly
Parameters
node
The ProseMirror node representing the content
h
The markdown renderer helper
renderChildren
(nodes) => string
indent
(text) => string
prefixOrGenerator
Either a string prefix or a function that generates the prefix from context
string | (ctx) => string
ctx?
any
Optional context object (used when prefixOrGenerator is a function)
Returns
string
The rendered markdown string
Example
// 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}] `)
}
}
})