---
title: "Why Comark? One Markdown Pipeline for Every Renderer"
description: "Comark gives JavaScript applications one Markdown pipeline for standards-based parsing, serializable documents, multiple renderers, plugins, and streaming."
canonical_url: "https://comark.dev/kb/why-comark"
---
# Why Comark? One Markdown Pipeline for Every Renderer

> Comark gives JavaScript applications one Markdown pipeline for standards-based parsing, serializable documents, multiple renderers, plugins, and streaming.

Writing Markdown is the solved part. The work starts after: parsing it into structured data, rendering custom UI components, targeting more than one output format, and updating the screen while an AI response streams.

Comark is an open-source Markdown parser and renderer with components, attributes, and plugins. It parses Markdown into a serializable document and renders it to Vue, React, Svelte, Angular, HTML, and ANSI terminal output.

## Why Markdown?

Web content often has two readers: people who write and scan prose, and programs or language models that consume structure.

HTML is verbose, and extra markup costs tokens whenever a model reads or writes a page. JSON is structured, but nobody wants to write documentation or articles in JSON.

Markdown sits between the two. [John Gruber designed it in 2004](https://daringfireball.net/projects/markdown/) as plain text that is easy to read and converts to HTML. Those same properties make it practical for language models and developer tools.

### Token cost and structure

Serving the same page as Markdown instead of HTML can use roughly 80% fewer tokens. Fewer tokens mean lower API cost, faster responses, and more room in the context window.

Markdown also marks structure with minimal noise. A `##` prefix marks a section heading directly, whereas HTML wraps the same text in tags and class attributes such as `<h2 class="...">`.

### Streaming and agent tooling

Language models output Markdown by default and stream it token by token. Renderers such as `react-markdown` expect a complete document, so unclosed fences and emphasis markers break formatting mid-stream. Vercel built [Streamdown](https://github.com/vercel/streamdown) to handle streamed Markdown in React with `useChat` from `@ai-sdk/react` ([Comark vs Streamdown](https://comark.dev/compare/comark-vs-streamdown)).

Developer tools also use Markdown for configuration. Files such as `AGENTS.md`, `CLAUDE.md`, and `.cursorrules` configure GitHub Copilot, Claude Code, and Cursor. Developers edit them as normal docs, and tools pass them straight into prompts.

## Why Comark?

Most JavaScript Markdown libraries handle one part of the pipeline. A renderer may target a single UI framework. A build-time compiler may only read local files instead of database rows or API responses. A standard parser assumes the input is complete, which breaks formatting during a stream.

Comark separates parsing from rendering. It parses Markdown into a shared document model, lets you inspect or store that document as JSON, and renders it through the package for your target. The same API runs at build time or runtime, on the server or in the browser, on complete text or a live stream.

### Built on markdown-it

Comark supports CommonMark and GitHub Flavored Markdown (GFM) through [markdown-exit](https://github.com/serkodev/markdown-exit), a TypeScript rewrite of markdown-it that keeps its plugin API. Standard Markdown works as expected, and markdown-it parsing plugins work alongside [Comark plugins](https://comark.dev/plugins).

### Markdown as data, not code

`parseMarkdown(markdown)` returns a compact, serializable [`MarkdownDocument`](https://comark.dev/getting-started/document-model). Text stays as strings, elements use tuples such as `['tag', props, ...children]`, and plugins attach metadata to `meta`.

That document boundary supports a four-step pipeline:

1. Read raw Markdown from a file, database, CMS, or API.
2. Parse it with `parseMarkdown(markdown)` to get a [`MarkdownDocument`](https://comark.dev/getting-started/document-model).
3. Inspect, transform, cache, or send the document as JSON.
4. Render the final output with the HTML, ANSI, Vue, React, Svelte, or Angular renderer.

You parse once and render anywhere without tying stored content to a framework or bundler.

::tip
Store the `MarkdownDocument` directly in your database or cache to skip parsing on every request.
::

### One source, every renderer

Because parsing is separate from rendering, one Markdown source can target:

- [`renderHtml()` in @comark/html](https://comark.dev/rendering/html): server-side HTML strings, RSS feeds, emails, and static builds
- [`renderAnsi()` in @comark/ansi](https://comark.dev/rendering/ansi): styled terminal output for CLIs and coding agents
- [`<Markdown>` in Vue](https://comark.dev/rendering/vue): async components, streaming, and Vue slots
- [`<Markdown>` in React](https://comark.dev/rendering/react): Server Components and client rendering
- [`<Markdown>` in Svelte](https://comark.dev/rendering/svelte): Svelte 5 snippets and streaming
- [`<Markdown>` in Angular](https://comark.dev/rendering/angular): standalone components with signals and streaming

Adding a terminal view, an HTML email, or another web framework doesn't require rewriting your Markdown files.

### Streaming in the parser

Comark's [auto-close](https://comark.dev/reference/auto-close) step closes unfinished emphasis, links, code fences, tables, and component blocks before each parse, so intermediate frames render without raw syntax markers.

Framework renderers expose a `streaming` prop that reuses completed blocks across updates. Any custom integration can use the same behavior through `parseMarkdown()` or `autoCloseMarkdown()`.

### Components without embedded code

Standard Markdown has no syntax for callouts, tabbed code groups, video embeds, or pricing cards. Raw HTML is verbose and mixes markup into prose. MDX embeds JSX and JavaScript, which ties content to a bundler ([Comark vs MDX](https://comark.dev/compare/comark-vs-mdx)).

Comark keeps custom blocks in plain text. Its component syntax follows the [CommonMark directives proposal](https://talk.commonmark.org/t/generic-directives-plugins-syntax/444) and builds on five years of production use in [MDC](https://github.com/nuxt-content/mdc):

```mdc
::alert{type="warning"}
This action cannot be undone.
::
```

The source stays readable in a text editor. The parser produces an `alert` node with `{ type: 'warning' }` and its children. The renderer mounts only components you register in your app, so content stays data and never executes code.

Inline attributes (`{.lead #intro}`) add classes, IDs, and metadata to standard Markdown elements the same way. Plain CommonMark and GFM continue to work unchanged.

### Named slots

Components can accept Markdown in named regions using `#slot` markers, with no HTML wrappers or template imports:

```mdc
::hero
#title
Build UIs from **Markdown**

#description
Comark parses component syntax at runtime with no build step.
Renders to HTML, ANSI, Vue, React, Svelte, and Angular.

#cta
[Get started](/getting-started/installation)
::
```

Each slot accepts full Markdown, including formatting, links, code blocks, and nested components, and maps to native slots, props, or snippets in your renderer.

---

- [Component syntax](https://comark.dev/syntax/components)
- [Installation](https://comark.dev/getting-started/installation)


## Sitemap

See the full [sitemap](https://comark.dev/sitemap.md) for all pages.
