Plugins

Extend Comark with powerful plugins for syntax highlighting, emojis, table of contents, math equations, diagrams, and more.

Comark's plugin system extends markdown functionality with specialized features. All plugins are part of the core comark package.

Plugins

Security

Sanitize markdown by removing dangerous HTML elements and attributes

Emoji

Convert emoji shortcodes like :smile: into emoji characters

Syntax Highlighting

Beautiful code syntax highlighting using Shiki with multi-theme support

Summary

Extract content summaries using <!-- more --> delimiter

Table of Contents

Generate hierarchical TOC from headings automatically

Alerts

Render GitHub-style alert blockquotes with icons and colors

Task List

Render interactive checkboxes from [ ] and [x] list syntax

Mermaid

Create diagrams and visualizations using Mermaid syntax in code blocks

Math

Render LaTeX math formulas using KaTeX with inline and display equations

JSON Render

Transform JSON Render specs into UI components using json-render or yaml-render code blocks

Punctuation

Convert plain-text punctuation into typographically correct Unicode characters

Breaks

Convert soft line breaks directly into :br components

Binding

Interpolate frontmatter, runtime data, or parent props with {{ path || default }} shorthand

Guides

Plugin API

Define plugins with the ComarkPlugin interface and lifecycle hooks

Markdown-it Plugins

Use existing markdown-it plugins or create new parser syntax rules

AST API

Traverse and transform the ComarkTree AST using the visit() utility

Use Plugins

Pass plugins to parse() or the <Comark> component:

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

const result = await parse(content, {
  plugins: [
    emoji(),
    toc({ depth: 3 })
  ]
})