Parse and render Markdown anywhere.
# Hello World
A JavaScript library to **parse and render Markdown** anywhere.
```ts
import { parseMarkdown } from 'comark'
const doc = await parseMarkdown('# Hello **World**')
```
## Features
- CommonMark and GFM support
- HTML, ANSI, and framework renderers
- Streaming, components, and plugins
::callout{icon="i-lucide-info"}
Built on markdown-exit, a TypeScript rewrite of markdown-it.
::// Renderers //
Parse once, render anywhere
Comark parses Markdown into a compact MarkdownDocument. Parse on the server, during a build, or as content streams in, then render it natively in your framework. Your content outlasts your stack.
// Streaming //
Built for AI output
A model streams Markdown a few characters at a time. Render it as it lands and your users watch raw asterisks appear, code fences hang open, and the layout jump on every token. Comark closes what is still open, so every frame renders as finished markup.
// Plugins //
Use official plugins, or write your own
Official plugins add syntax highlighting, math, diagrams, table of contents, and more. Write your own against the plugin API or browse all plugins.
import { parseMarkdown } from 'comark'
import shiki from 'comark/plugins/shiki'
import githubDark from '@shikijs/themes/github-dark'
import githubLight from '@shikijs/themes/github-light'
const document = await parseMarkdown(content, {
plugins: [
shiki({
themes: { light: githubLight, dark: githubDark }
})
]
})// Syntax //
Components in Markdown
Discover our opt-in syntax for components, attributes, and frontmatter, handled by default plugins you can turn off. CommonMark and GFM are supported by default, so every Markdown file you already have keeps working.
::alert{type="info"}
This is an **important** message.
::
::card{title="My Card"}
Card content with full **markdown** support.
::
Click the :button[Submit]{type="primary"} to continue.// FAQ //