GitHub - comarkdown/comark: 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.
Repository navigation
comarkPublic
About
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.
comark.devTopics
ai angular ansi commonmark generative-ui gfm intelligent-ui llm markdown markdown-parser markdown-renderer mdc nuxt react streaming streaming-markdown svelte vueResources
Readme MIT licenseContributing
ContributingSecurity policy
Security policy Activity Custom propertiesStars
1.1k starsWatchers
3 watchingForks
66 forks Report repositoryBranches
Tags
Go to Branches page Go to Tags page
Latest commit
History
832 Commits
View commit history for this file.
Folders and files
Repository files navigation
comark
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.
Comark parses CommonMark and GFM into a compact, serializable document at build time, at runtime, or during a stream. Render the same document across targets, or extend the syntax with components and attributes when you need custom UI.
# Regular Markdown
With a custom component:
::alert{type="warning"}
This is **Markdown** inside your own component.
::
Why Comark
- Runtime parsing :
parseMarkdown(markdown)is a pure function returning a compact, serializable Markdown document. Content from a database, CMS, or LLM is live the moment it is saved. No rebuild, no redeploy. (Comark vs MDX ) - Streaming built in : auto-close completes unterminated syntax (
**bold, open code fences, half-open components) so AI output renders correctly at every frame. - One parser, every renderer : the same source renders to HTML, ANSI, Vue, React, Svelte, and Angular. Your content outlasts your framework.
- Standard Markdown : CommonMark and GFM (with a few differences ), frontmatter, and
{.class}attributes on native elements. Components are opt-in syntax, not a new language. - Plugin ecosystem : Shiki highlighting, KaTeX math, Mermaid diagrams, TOC, alerts, footnotes, and more, plus compatibility with existing markdown-it plugins.
- Decoupled parse and render : parse once on the server, send the serializable document (
['tag', props, ...children]) to the client, and render without re-parsing. - Fast : built on markdown-exit , a TypeScript rewrite of markdown-it, with full TypeScript support.
The component and attribute syntax builds on five years of production use in MDC . Read Why Comark for the background.
Quick start
npm install comark
import { parseMarkdown } from 'comark'
const tree = await parseMarkdown('# Hello **World**')
// { nodes: [['h1', { id: 'hello' }, 'Hello ', ['strong', {}, 'World']]], frontmatter: {}, meta: {} }
Then pick a renderer:
Vue
npm install @comark/vue @comark/plugin-katex
<script setup lang="ts">
import { Markdown } from '@comark/vue'
import math from '@comark/plugin-katex'
import { Math } from '@comark/plugin-katex/vue'
import '@comark/plugin-katex/katex.css'
const chatMessage = ...
</script>
<template>
<Markdown :components="{ Math }" :plugins="[math()]">{{ chatMessage }}</Markdown>
</template>
React
npm install @comark/react @comark/plugin-katex
import { Markdown } from '@comark/react'
import math from '@comark/plugin-katex'
import { Math } from '@comark/plugin-katex/react'
import '@comark/plugin-katex/katex.css'
function App() {
const chatMessage = ...
return <Markdown components={{ Math }} plugins={[math()]}>{chatMessage}</Markdown>
}
Svelte
npm install @comark/svelte @comark/plugin-katex
<script lang="ts">
import { Markdown } from '@comark/svelte'
import math from '@comark/plugin-katex'
import { Math } from '@comark/plugin-katex/svelte'
import '@comark/plugin-katex/katex.css'
const chatMessage = ...
</script>
<Markdown value={chatMessage} components={{ math: Math }} plugins={[math()]} />
Angular
npm install @comark/angular @comark/plugin-katex
import { Component } from '@angular/core'
import { Markdown } from '@comark/angular'
import math from '@comark/plugin-katex'
import { Math } from '@comark/plugin-katex/angular'
@Component({
selector: 'app-chat',
standalone: true,
imports: [Markdown],
template: `<comark-markdown [value]="chatMessage" [components]="{ Math }" [plugins]="[math()]" />`,
})
export class ChatComponent {
chatMessage = ...
}
Add @import '@comark/plugin-katex/katex.css'; to your global styles for the KaTeX stylesheet.
HTML (no framework)
npm install @comark/html
import { renderHtml } from '@comark/html'
const chatMessage = ...
const html = await renderHtml(chatMessage)
Packages
| Package | Description |
|---|---|
comark |
Core parser, AST utilities, and plugins |
@comark/vue |
Vue 3 renderer and Nuxt module |
@comark/react |
React renderer (Next.js, Server Components) |
@comark/svelte |
Svelte 5 renderer |
@comark/angular |
Angular 21+ renderer |
@comark/html |
HTML string renderer |
@comark/ansi |
ANSI terminal renderer |
Agent skill
Coding agents can install the Comark skill from the docs site:
npx skills add https://comark.dev
See Installation on comark.dev for details.
License
Made with ❤️
Published under MIT License .
About
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.
comark.dev