Plugins
Comark has two compatible extension layers. Comark plugins can transform source, tokens, the parsed document, or rendered output through typed lifecycle hooks. You can also reuse parser plugins written for markdown-it through Comark's markdown-exit foundation.
All Comark plugins are part of the core comark package, while optional rendering dependencies are installed only when you use them.
Default plugins
These plugins are enabled by default whenever you call parseMarkdown() or createMarkdownParser() (or a framework <Markdown> component). You do not need to install or register them.
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 — no 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
Optional plugins you register via plugins: [...].
Guides
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 })
]
})<script setup lang="ts">
import { Markdown } from '@comark/vue'
import emoji from '@comark/vue/plugins/emoji'
</script>
<template>
<Markdown :plugins="[emoji()]">{{ content }}</Markdown>
</template>import { Markdown } from '@comark/react'
import emoji from '@comark/react/plugins/emoji'
<Markdown plugins={[emoji()]}>{content}</Markdown><script>
import { Markdown } from '@comark/svelte'
import emoji from '@comark/svelte/plugins/emoji'
let content = '# Awesome'
</script>
<Markdown value={content} plugins={[emoji()]} />