What Is Comark? Markdown Parser and Renderer
Comark is an open-source Markdown parser and renderer with components, attributes, and plugins. It streams AI output to React, Vue, Svelte, Angular, HTML, and the terminal. Give it CommonMark or GitHub Flavored Markdown (GFM), and render the same source to any of these targets.
Parsing and rendering are decoupled through a compact, serializable MarkdownDocument. Parse on the server, in the browser, in a worker, during a build, or as content streams in. You can then inspect, transform, cache, serialize, or render the document without tying your content to one output target.
Comark is built on markdown-exit, a TypeScript rewrite of markdown-it that preserves its plugin API. It adds streaming support, a plugin system, and optional component and attribute syntax.
Start with the renderer that matches your output:
import { renderHtml } from '@comark/html'
const content = '# Hello **World**'
const html = await renderHtml(content)import { renderAnsi } from '@comark/ansi'
const content = '# Hello **World**'
const output = await renderAnsi(content)<script setup lang="ts">
import { Markdown } from '@comark/vue'
const content = '# Hello **World**'
</script>
<template>
<Suspense>
<Markdown>{{ content }}</Markdown>
</Suspense>
</template>import { Markdown } from '@comark/react'
const content = '# Hello **World**'
export default function App() {
return <Markdown>{content}</Markdown>
}<script lang="ts">
import { Markdown } from '@comark/svelte'
const content = '# Hello **World**'
</script>
<Markdown value={content} />import { Component } from '@angular/core'
import { Markdown } from '@comark/angular'
@Component({
selector: 'app-root',
standalone: true,
imports: [Markdown],
template: `<comark-markdown [value]="content" />`,
})
export class AppComponent {
content = '# Hello **World**'
}How it works
The following diagram shows how Comark parses Markdown once and renders the resulting document to each target:
- Parse: Comark parses Markdown into a compact
MarkdownDocument. - Transform: inspect, transform, cache, or serialize the document.
- Render: convert the document to HTML, ANSI, Markdown, Vue, React, Svelte, or Angular.
Extend Markdown when needed
Plain Markdown works without any component syntax. When your content needs custom UI, Comark adds components and attributes without embedding verbose HTML or executable framework code:
# Welcome to my blog
This is regular **Markdown** with a custom component:
::alert{type="warning"}
This is an important message!
::The ::alert block supports properties, children, and named slots. The renderer only uses components you explicitly register, so the source remains portable data rather than framework-specific code. Learn more in Component syntax and Attributes.
Editor and browser extensions for Comark syntax:
- Comark for VS Code adds syntax highlighting and autocomplete for components and attributes.
- Comark for GitHub renders Comark syntax on GitHub Markdown pages.
When to use Comark
Use Comark when your project needs any of the following:
- Content platforms: parse Markdown from files, databases, APIs, or a CMS at build time or runtime.
- Multi-target publishing: render one source to web apps, static HTML, RSS, email, and terminal output.
- AI chat interfaces: stream and render incomplete Markdown responses as tokens arrive.
- Documentation and blogs: combine CommonMark and GFM with callouts, embeds, diagrams, and interactive UI.
- Content pipelines: inspect, transform, cache, or serialize a compact document before rendering.
Comparison with other tools
For detailed comparisons, see Comark vs MDX, Comark vs react-markdown, Comark vs Streamdown, and Comark vs Markdoc.
| Feature | Comark | Streamdown | MDX | Markdoc |
|---|---|---|---|---|
| Streaming support | ||||
| Component syntax | ||||
| Vue support | ||||
| React support | ||||
| Svelte support | ||||
| Angular support | ||||
| No build step | ||||
| Parse to AST | ||||
| Compact AST | ||||
| Auto-close for streams | ||||
| Decoupled parsing & rendering |
Core capabilities
FAQ
streaming prop.