### Installation Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Instructions for installing the tiptap-markdown extension for Tiptap v3 and v2. ```APIDOC ## Installation Install the package for Tiptap v3 using npm. ```bash npm install tiptap-markdown@latest ``` For Tiptap v2 compatibility: ```bash npm install tiptap-markdown@^0.8 ``` ``` -------------------------------- ### Basic Editor Setup Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Initialize a Tiptap editor with markdown support using the Markdown extension alongside StarterKit. ```APIDOC ## Basic Editor Setup Initialize a Tiptap editor with markdown support using the Markdown extension alongside StarterKit. ```javascript import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Markdown } from 'tiptap-markdown'; // Create editor with markdown content const editor = new Editor({ content: `# Hello World This is a **bold** statement and this is *italic*. - List item 1 - List item 2 \`\`\`javascript console.log('Hello'); \`\`\` `, // Note: Backticks escaped for JSON string extensions: [ StarterKit, Markdown, ], }); // The markdown content is automatically parsed into rich HTML console.log(editor.getHTML()); // Output:

Hello World

This is a bold statement...

``` ``` -------------------------------- ### Install Tiptap Markdown Extension Source: https://github.com/aguingand/tiptap-markdown/blob/main/README.md Installation commands for different versions of the Tiptap editor using npm. ```bash npm install tiptap-markdown@^0.8 ``` ```bash npm install tiptap-markdown@latest ``` -------------------------------- ### Install tiptap-markdown Extension Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Instructions for installing the tiptap-markdown package using npm for Tiptap v3 and v2 compatibility. ```bash npm install tiptap-markdown@latest For Tiptap v2 compatibility: npm install tiptap-markdown@^0.8 ``` -------------------------------- ### Basic Tiptap Editor Setup with Markdown Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Initializes a Tiptap editor with the Markdown extension and StarterKit, demonstrating how markdown content is automatically parsed into HTML. ```javascript import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Markdown } from 'tiptap-markdown'; // Create editor with markdown content const editor = new Editor({ content: `# Hello World This is a **bold** statement and this is *italic*. - List item 1 - List item 2 \ \ javascript console.log('Hello'); \ \ `, extensions: [ StarterKit, Markdown, ], }); // The markdown content is automatically parsed into rich HTML console.log(editor.getHTML()); // Output:

Hello World

This is a bold statement...

``` -------------------------------- ### Initialize Tiptap Editor with Markdown Source: https://github.com/aguingand/tiptap-markdown/blob/main/README.md Basic setup of a Tiptap editor instance configured with the Markdown extension to handle markdown content. ```javascript import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Markdown } from 'tiptap-markdown'; const editor = new Editor({ content: "# Title", extensions: [ StarterKit, Markdown, ], }); const markdownOutput = editor.storage.markdown.getMarkdown(); ``` -------------------------------- ### Create Custom Node Extension with Markdown Support Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Shows how to define a custom block node that supports Markdown serialization and parsing using addStorage. This example implements a container node that maps to Markdown ':::' syntax. ```javascript import { Node } from '@tiptap/core'; import markdownitContainer from 'markdown-it-container'; const ContainerNode = Node.create({ name: 'container', group: 'block', content: 'block+', defining: true, addOptions() { return { classes: ['info', 'warning', 'danger'], }; }, addStorage() { return { markdown: { serialize(state, node) { state.write('::: ' + (node.attrs.containerClass || '') + '\n'); state.renderContent(node); state.flushClose(1); state.write(':::'); state.closeBlock(node); }, parse: { setup(markdownit) { this.options.classes.forEach(className => { markdownit.use(markdownitContainer, className); }); }, }, }, }; }, addAttributes() { return { containerClass: { default: null, parseHTML: element => [...element.classList].find(cn => this.options.classes.includes(cn)), renderHTML: attributes => ({ class: attributes.containerClass, }), }, }; }, parseHTML() { return [{ tag: 'div', getAttrs: element => [...element.classList].find(cn => this.options.classes.includes(cn)) ? null : false, }]; }, renderHTML({ HTMLAttributes }) { return ['div', HTMLAttributes, 0]; }, }); ``` -------------------------------- ### Extend Marks with Markdown Serialization Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Explains how to extend existing Tiptap marks to include custom Markdown syntax. This example adds support for '==' syntax for highlighted text. ```javascript import { Highlight } from '@tiptap/extension-highlight'; import markdownitMark from 'markdown-it-mark'; const MarkdownHighlight = Highlight.extend({ addStorage() { return { markdown: { serialize: { open: '==', close: '==', }, parse: { setup(markdownit) { markdownit.use(markdownitMark); }, }, }, }; }, }); ``` -------------------------------- ### editor.commands.setContent() - Set Markdown Content Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Replace the entire editor content with new markdown text that gets automatically parsed. ```APIDOC ## editor.commands.setContent() - Set Markdown Content Replace the entire editor content with new markdown text that gets automatically parsed. ```javascript import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Markdown } from 'tiptap-markdown'; const editor = new Editor({ content: '', extensions: [StarterKit, Markdown], }); // Set content using markdown syntax editor.commands.setContent(` # New Document This is **bold** and this is *italic*. ## Code Example \`\`\`python def hello(): print("Hello, World!") \`\`\` | Column 1 | Column 2 | |----------|----------| | Cell 1 | Cell 2 | `); // The markdown is parsed and rendered as rich HTML in the editor ``` ``` -------------------------------- ### Indented Code Block Example Source: https://github.com/aguingand/tiptap-markdown/blob/main/example/src/data/content.md Shows the usage of indented code blocks in Markdown. Indented blocks are treated as preformatted text and are useful for displaying code snippets without explicit language fences. ```text // Some comments line 1 of code line 2 of code line 3 of code ``` -------------------------------- ### Migrate Basic Editor Initialization Source: https://github.com/aguingand/tiptap-markdown/blob/main/docs/migration.md Demonstrates the transition from the deprecated createMarkdownEditor wrapper to the standard Tiptap Editor instance using the Markdown extension. It also updates the method for retrieving markdown output from the editor instance. ```javascript import { Editor } from '@tiptap/core'; import { Markdown } from 'tiptap-markdown'; const editor = new Editor({ extensions: [ Markdown, ], }); const markdownOutput = editor.storage.markdown.getMarkdown(); ``` -------------------------------- ### Configure Markdown Extension Options Source: https://github.com/aguingand/tiptap-markdown/blob/main/docs/migration.md Shows how to move markdown configuration options from the top-level editor object into the Markdown extension's configure method. ```javascript const editor = new Editor({ extensions: [ Markdown.configure({ breaks: true, }) ], }); ``` -------------------------------- ### Define JavaScript Function with Syntax Highlighting Source: https://github.com/aguingand/tiptap-markdown/blob/main/example/src/data/content.md Demonstrates how to define a JavaScript function and log the output. This snippet uses standard Markdown code fences with language specification for syntax highlighting. ```javascript var foo = function (bar) { return bar++; }; console.log(foo(5)); ``` -------------------------------- ### Markdown.configure() - Configuration Options Source: https://context7.com/aguingand/tiptap-markdown/llms.txt Configure the Markdown extension with various options to control parsing and serialization behavior. ```APIDOC ## Markdown.configure() - Configuration Options Configure the Markdown extension with various options to control parsing and serialization behavior. ```javascript import { Editor } from '@tiptap/core'; import StarterKit from '@tiptap/starter-kit'; import { Markdown } from 'tiptap-markdown'; const editor = new Editor({ content: '# Document', extensions: [ StarterKit, Markdown.configure({ html: true, // Allow HTML input/output tightLists: true, // No

inside

  • in markdown output tightListClass: 'tight', // Add class to