Skip to main content

createBlockMarkdownSpec

@blockslides/core


@blockslides/core / createBlockMarkdownSpec

Function: createBlockMarkdownSpec()

createBlockMarkdownSpec(options): object

Defined in: blockslides/packages/core/src/utilities/markdown/createBlockMarkdownSpec.ts:60

Creates a complete markdown spec for block-level nodes using Pandoc syntax.

The generated spec handles:

  • Parsing blocks with :::blockName {attributes} syntax
  • Extracting and parsing attributes
  • Rendering blocks back to markdown with proper formatting
  • Nested content support

Parameters

options

BlockMarkdownSpecOptions

Configuration for the block markdown spec

Returns

object

Complete markdown specification object

parseMarkdown()

parseMarkdown: (token, h) => MarkdownParseResult

Parameters

token

MarkdownToken

h

MarkdownParseHelpers

Returns

MarkdownParseResult

markdownTokenizer

markdownTokenizer: MarkdownTokenizer

renderMarkdown()

renderMarkdown: (node, h) => string

Parameters

node

JSONContent

h

MarkdownRendererHelpers

Returns

string

Example

const calloutSpec = createBlockMarkdownSpec({
nodeName: 'callout',
defaultAttributes: { type: 'info' },
allowedAttributes: ['type', 'title'] // Only these get rendered to markdown
})

// Usage in extension:
export const Callout = Node.create({
// ... other config
markdown: calloutSpec
})