Markdown for a custom Block
Markdown syntax for a custom Block: markdownTokenizer, parseMarkdown and renderMarkdown in the Extensions.
Without rules of its own, getMarkdown() loses no text: a Block is written as its content, an Atom
as its Atom text (renderText), a Mark as its text. But such a Block is
never recreated from Markdown. For a
Block to survive the getMarkdown() → setMarkdown() round trip, give it Markdown rules.
Try it
Press “Load Markdown” — the ::: … line becomes an acme_aside Block. “Export Markdown” writes that Block back as a
::: … line.
How it works
The rules live in the Extensions
As with any Tiptap extension, the rules live in the Extensions
(engine): markdownTokenizer finds the line, parseMarkdown builds the node, renderMarkdown
writes it back. The Tool description has no separate field for them.
The Schema still has the final say
Whatever the parser builds, only what the Schema rules allow reaches the Document.
Without rules
Without Markdown rules the kit writes the Block out as its content (as at the top of the page) and,
in development mode, prints one console.warn per Tool. Only an Atom without Atom text is lost.
Paste
Paste understands the rules too: if the text contains ordinary Markdown (a heading, list, quote,
bold, link…), it turns into Blocks, and a ::: … line in it does too; a lone ::: … line
without other Markdown stays text.