Plugins

Extend Comark with plugins for syntax highlighting, emoji, table of contents, math, and diagrams, or reuse existing markdown-it plugins.

Comark has two compatible extension layers. Comark plugins can transform source text, tokens, the parsed document, or rendered output through typed lifecycle hooks. You can also reuse parser plugins written for markdown-it through markdown-exit, Comark's markdown-it-compatible parser.

All built-in plugins ship in the core comark package. You install optional peer dependencies only for the plugins you use.

Default plugins

These plugins are enabled by default whenever you call parseMarkdown(), createMarkdownParser(), or a framework <Markdown> component. You don't need to install or register them.

Linkify

Convert URLs and email addresses into links

Frontmatter

Parse a leading YAML frontmatter block into tree.frontmatter

HTML

Parse embedded HTML tags into Comark AST nodes

Alerts

Transform GitHub-style > [!NOTE] blockquotes

Task list

Render GitHub-style [ ] and [x] checkboxes

Components

Parse block and inline components and spans (::name, :name, [text])

Attributes

Parse inline attributes ({props} after tokens)
Default plugins run in the order shown above. Plugins you pass through plugins run afterward in the order you provide them. If an explicit plugin has the same name as a default plugin, it replaces that default and runs in its explicit position. If you provide the same explicit plugin name more than once, only the first instance runs.

Disable default plugins

Turn them all off with registerDefaultPlugins: false:

import { parseMarkdown } from 'comark'

// Plain Markdown only, with no autolinks, components, attributes, HTML, alerts, or task lists
const result = await parseMarkdown(content, {
  registerDefaultPlugins: false,
})

Opt back into specific defaults via plugins:

import { parseMarkdown } from 'comark'
import components from 'comark/plugins/components'
import attributes from 'comark/plugins/attributes'

const result = await parseMarkdown(content, {
  registerDefaultPlugins: false,
  plugins: [components(), attributes()],
})

See the registerDefaultPlugins and plugins options on the Parse API.

Plugins

Register optional plugins through the plugins option.

Binding

Interpolate frontmatter, runtime data, or parent props with {{ path || default }} and ::if

Breaks

Convert soft line breaks into <br> elements

Emoji

Convert emoji shortcodes such as :smile: into emoji characters

External links

Add rel="nofollow" and an optional target to external links

Footnotes

Add footnote references, numbered definitions, and back-links

Heading links

Link headings to themselves using their id

Title and description

Extract the page title and description from document content

JSON Render

Render JSON Render specs as UI components from json-render or yaml-render code blocks

Mathematics

Render inline and display LaTeX math formulas with KaTeX

Mermaid diagrams

Render diagrams from mermaid code blocks

Punctuation

Convert plain-text quotes, dashes, and symbols into typographic Unicode characters

Security

Sanitize Markdown by stripping dangerous HTML tags, attributes, and URLs

Summary extraction

Extract content excerpts before a <!-- more --> comment

Shiki

Highlight code blocks and inline code with Shiki themes and transformers

Rangi

Highlight code with Rangi (~13 kB with all languages, dual themes)

Pierre

Highlight code with @pierre/highlights in WebAssembly (152 languages, Shiki-compatible output)

Table of contents

Build a nested table of contents from document headings

Guides

Plugin API

Define plugins with defineComarkPlugin and pre/post lifecycle hooks

AST API

Traverse and transform MarkdownDocument nodes with visit()

Markdown-it plugins

Reuse existing markdown-it plugins or write custom parser syntax rules

Use plugins

Pass plugins to parseMarkdown() or the <Markdown> component:

import { parseMarkdown } from 'comark'
import emoji from 'comark/plugins/emoji'
import toc from 'comark/plugins/toc'

const result = await parseMarkdown(content, {
  plugins: [
    emoji(),
    toc({ depth: 3 })
  ]
})
© 2026 Vercel, Inc.