createInlineMarkdownSpec
@blockslides/core / createInlineMarkdownSpec
Function: createInlineMarkdownSpec()
createInlineMarkdownSpec(
options):object
Defined in: blockslides/packages/core/src/utilities/markdown/createInlineMarkdownSpec.ts:107
Creates a complete markdown spec for inline nodes using attribute syntax.
The generated spec handles:
- Parsing shortcode syntax with
[nodeName attributes]content[/nodeName]format - Self-closing shortcodes like
[emoji name=party_popper] - Extracting and parsing attributes from the opening tag
- Rendering inline elements back to shortcode markdown
- Supporting both content-based and self-closing inline elements
Parameters
options
Configuration for the inline markdown spec
Returns
object
Complete markdown specification object
parseMarkdown()
parseMarkdown: (
token,h) =>MarkdownParseResult
Parameters
token
h
Returns
markdownTokenizer
markdownTokenizer:
MarkdownTokenizer
renderMarkdown()
renderMarkdown: (
node) =>string
Parameters
node
Returns
string
Example
// Self-closing mention: [mention id="madonna" label="Madonna"]
const mentionSpec = createInlineMarkdownSpec({
nodeName: 'mention',
selfClosing: true,
defaultAttributes: { type: 'user' },
allowedAttributes: ['id', 'label'] // Only these get rendered to markdown
})
// Self-closing emoji: [emoji name="party_popper"]
const emojiSpec = createInlineMarkdownSpec({
nodeName: 'emoji',
selfClosing: true,
allowedAttributes: ['name']
})
// With content: [highlight color="yellow"]text[/highlight]
const highlightSpec = createInlineMarkdownSpec({
nodeName: 'highlight',
selfClosing: false,
allowedAttributes: ['color', 'style']
})
// Usage in extension:
export const Mention = Node.create({
name: 'mention', // Must match nodeName
// ... other config
markdown: mentionSpec
})