Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This is a **monorepo** containing the Comark Markdown parser, document model, pl
│ ├── comark-react/ # React renderer + plugins (@comark/react)
│ ├── comark-svelte/ # Svelte renderer + plugins (@comark/svelte)
│ ├── comark-angular/ # Angular renderer + plugins (@comark/angular)
│ └── comark-nuxt/ # Nuxt module (@comark/nuxt)
│ └── comark-nuxt/ # Deprecated @comark/nuxt: installs @comark/vue/nuxt and logs a warning
├── examples/ # Example applications
│ ├── 1.frameworks/ # Framework examples (Nuxt, Next.js, Astro, SvelteKit, VitePress)
│ ├── 2.vite/ # Vite examples (Vue, React, Svelte, Angular, HTML, ANSI)
Expand Down Expand Up @@ -235,6 +235,7 @@ packages/comark-vue/
│ ├── parse.ts # Re-exports comark/parse (@comark/vue/parse)
│ ├── render.ts # Re-exports comark/render (@comark/vue/render)
│ ├── vite.ts # Vite plugin: `<slot unwrap>` transform + prose component auto-registration (@comark/vue/vite)
│ ├── nuxt.ts # Nuxt module: auto-imports components + helpers, adds the Vite plugin (@comark/vue/nuxt)
│ ├── components/
│ │ ├── Markdown.ts # High-level markdown → render component
│ │ ├── MarkdownDocument.ts # Low-level AST → render component
Expand All @@ -258,6 +259,7 @@ packages/comark-vue/
{
".": "./dist/index.js",
"./vite": "./dist/vite.js",
"./nuxt": "./dist/nuxt.js",
"./plugins/*": "./dist/plugins/*.js",
"./utils": "./dist/utils/index.js",
"./parse": "./dist/parse.js",
Expand All @@ -274,6 +276,8 @@ import math, { Math } from '@comark/vue/plugins/math'
import mermaid, { Mermaid } from '@comark/vue/plugins/mermaid'
```

`@comark/vue/nuxt` is the Nuxt module: `modules: ['@comark/vue']` loads it because Nuxt tries the `/nuxt` subpath first. It auto-imports `Markdown`, `MarkdownDocument`, `defineMarkdownComponent` and `defineMarkdownDocumentComponent`, plus `parseMarkdown` and `createMarkdownParser` in the app and in server routes (from `@comark/vue/parse`), turns on Nuxt UI prose components, and adds the `@comark/vue/vite` plugin with `prose: false`. It does not register `~/components/prose`. `@nuxt/kit` and `@nuxt/schema` are optional peer dependencies.

## Package: @comark/react

Located at `packages/comark-react/`. React renderer with framework-specific plugin wrappers.
Expand Down Expand Up @@ -952,7 +956,7 @@ There is no ESLint or Prettier config.

The docs content is linted with [comark-linter](https://comark-ui.onmax.me/lint/) (`pnpm --filter comark-docs-site lint`):
unknown components, unclosed blocks, and broken links and anchors. `docs/comark-lint.config.ts` extends the
comark-docs layer's preset with the site's own `app/components/prose/` components and its Vue pages.
comark-docs layer's preset with the site's own `app/components/prose/` components (registered globally in `docs/nuxt.config.ts`) and its Vue pages.

Utility scripts:

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pnpm docs
- `packages/comark`: parser, document model, core plugins and Markdown string rendering.
- `packages/comark-html` and `packages/comark-ansi`: HTML and terminal renderers.
- `packages/comark-vue`, `packages/comark-react`, `packages/comark-svelte`, and `packages/comark-angular`: framework renderers.
- `packages/comark-nuxt`: Nuxt integration.
- `packages/comark-nuxt`: deprecated `@comark/nuxt`, which installs the Nuxt module from `packages/comark-vue/src/nuxt.ts`.
- `docs/content`: user-facing documentation.

Keep parser-only behavior in the core package and framework-specific behavior in its renderer. The [architecture reference](./AGENTS.md) has a more detailed package map.
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This policy applies to all packages in the Comark monorepo:
- `@comark/vue`
- `@comark/react`
- `@comark/svelte`
- `@comark/nuxt`
- `@comark/nuxt` (deprecated)

## Built-in Security

Expand Down
6 changes: 3 additions & 3 deletions docs/app/components/ComarkPlaygroundRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineMarkdownDocumentComponent } from '@comark/vue'
import { Math } from '@comark/nuxt/plugins/math'
import { Math } from '@comark/vue/plugins/math'
import 'katex/dist/katex.min.css'
import { Mermaid } from '@comark/nuxt/plugins/mermaid'
import { Binding } from '@comark/nuxt/plugins/binding'
import { Mermaid } from '@comark/vue/plugins/mermaid'
import { Binding } from '@comark/vue/plugins/binding'

export default defineMarkdownDocumentComponent({
name: 'ComarkPlaygroundRenderer',
Expand Down
42 changes: 21 additions & 21 deletions docs/app/components/Playground.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<script setup lang="ts">
import { parseMarkdown } from 'comark'
import shiki from '@comark/nuxt/plugins/shiki'
import rangi from '@comark/nuxt/plugins/rangi'
import math from '@comark/nuxt/plugins/math'
import binding from '@comark/nuxt/plugins/binding'
import emoji from '@comark/nuxt/plugins/emoji'
import mermaid from '@comark/nuxt/plugins/mermaid'
import jsonRender from '@comark/nuxt/plugins/json-render'
import footnotes from '@comark/nuxt/plugins/footnotes'
import punctuation from '@comark/nuxt/plugins/punctuation'
import breaks from '@comark/nuxt/plugins/breaks'
import titleDescription from '@comark/nuxt/plugins/title-description'
import toc from '@comark/nuxt/plugins/toc'
import summary from '@comark/nuxt/plugins/summary'
import security from '@comark/nuxt/plugins/security'
import linkify from '@comark/nuxt/plugins/linkify'
import frontmatter from '@comark/nuxt/plugins/frontmatter'
import html from '@comark/nuxt/plugins/html'
import alert from '@comark/nuxt/plugins/alert'
import taskList from '@comark/nuxt/plugins/task-list'
import components from '@comark/nuxt/plugins/components'
import attributes from '@comark/nuxt/plugins/attributes'
import shiki from '@comark/vue/plugins/shiki'
import rangi from '@comark/vue/plugins/rangi'
import math from '@comark/vue/plugins/math'
import binding from '@comark/vue/plugins/binding'
import emoji from '@comark/vue/plugins/emoji'
import mermaid from '@comark/vue/plugins/mermaid'
import jsonRender from '@comark/vue/plugins/json-render'
import footnotes from '@comark/vue/plugins/footnotes'
import punctuation from '@comark/vue/plugins/punctuation'
import breaks from '@comark/vue/plugins/breaks'
import titleDescription from '@comark/vue/plugins/title-description'
import toc from '@comark/vue/plugins/toc'
import summary from '@comark/vue/plugins/summary'
import security from '@comark/vue/plugins/security'
import linkify from '@comark/vue/plugins/linkify'
import frontmatter from '@comark/vue/plugins/frontmatter'
import html from '@comark/vue/plugins/html'
import alert from '@comark/vue/plugins/alert'
import taskList from '@comark/vue/plugins/task-list'
import components from '@comark/vue/plugins/components'
import attributes from '@comark/vue/plugins/attributes'

import { renderMarkdown } from 'comark/render'
import { Splitpanes, Pane } from 'splitpanes'
Expand Down
2 changes: 1 addition & 1 deletion docs/comark-lint.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readdirSync } from 'node:fs'
import preset from 'comark-docs/lint.mjs'

// The site's own Markdown components: @comark/nuxt registers app/components/prose/ globally.
// The site's own Markdown components: nuxt.config.ts registers app/components/prose/ globally.
const prose = readdirSync('app/components/prose').map((file) =>
file.replace(/\.vue$/, '').replace(/[A-Z]/g, (c, i) => (i ? '-' : '') + c.toLowerCase())
)
Expand Down
27 changes: 23 additions & 4 deletions docs/content/1.getting-started/1.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Choose the output you need and render your first Markdown document in minutes.
Use Comark in Vue 3 applications with full async component support and streaming.
::

::card{icon="i-logos-nuxt-icon" title="Nuxt" to="/rendering/nuxt"}
Zero-config Nuxt module with auto-imported components and Nuxt UI integration.
::card{icon="i-logos-nuxt-icon" title="Nuxt" to="/rendering/vue#nuxt"}
Add `@comark/vue` to your Nuxt modules to auto-import the components and helpers.
::

::card{icon="i-logos-react" title="React" to="/rendering/react"}
Expand Down Expand Up @@ -159,8 +159,27 @@ Use these when you need to render Markdown as an interactive document in Vue, Re
::
::
::tabs-item{label="Nuxt" icon="i-logos-nuxt-icon"}
```bash [Terminal]
npx nuxt add comark
::code-group
```bash [pnpm]
pnpm add @comark/vue
```
```bash [npm]
npm install @comark/vue
```
```bash [yarn]
yarn add @comark/vue
```
```bash [bun]
bun add @comark/vue
```
::

Then add the module to your `nuxt.config`:

```typescript [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@comark/vue']
})
```
::
::tabs-item{label="Svelte" icon="i-logos-svelte-icon"}
Expand Down
17 changes: 12 additions & 5 deletions docs/content/10.use-cases/3.vue-ai-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ links:
variant: soft
- label: Nuxt rendering
icon: i-simple-icons-nuxt
to: /rendering/nuxt
to: /rendering/vue#nuxt
color: neutral
variant: soft
---

Use the `Chat` class from `@ai-sdk/vue` to receive messages, and render each text part with Comark's `<Markdown>` component. Bind `streaming` to the part state, so Comark closes unfinished syntax until the part is complete.

This guide uses Nuxt with the `@comark/nuxt` module, which auto-imports `<Markdown>`. In a Vue app without Nuxt, import `Markdown` from `@comark/vue`. The steps follow the [AI SDK example](/examples/ai/nuxt-ai-sdk).
This guide uses Nuxt with the `@comark/vue` module, which auto-imports `<Markdown>`. In a Vue app without Nuxt, import `Markdown` from `@comark/vue`. The steps follow the [AI SDK example](/examples/ai/nuxt-ai-sdk).

## Build the chat

Expand All @@ -28,8 +28,15 @@ This guide uses Nuxt with the `@comark/nuxt` module, which auto-imports `<Markdo
### Install the packages

```bash [Terminal]
npx nuxt add comark
npm install ai @ai-sdk/vue
npm install @comark/vue ai @ai-sdk/vue
```

Then add the module to your `nuxt.config`:

```typescript [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@comark/vue']
})
```

The AI SDK reads your provider key from the environment. The example uses the Vercel AI Gateway with the `AI_GATEWAY_API_KEY` variable.
Expand Down Expand Up @@ -111,7 +118,7 @@ import { isPartStreaming } from '@nuxt/ui/utils/ai'
</template>
```

When `@nuxt/ui` is installed, Comark also renders Markdown elements with the Nuxt UI prose components. See [Nuxt UI integration](/rendering/nuxt#nuxt-ui-integration).
When `@nuxt/ui` is installed, Comark also renders Markdown elements with the Nuxt UI prose components. See [Nuxt UI integration](/rendering/vue#nuxt-ui-integration).

## Add components and plugins

Expand Down
4 changes: 2 additions & 2 deletions docs/content/10.use-cases/7.docs-and-blogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Each framework calls `getPost()` from the previous section on the server. It the

### Nuxt

Move `getPost()` to `server/utils/posts.ts`, so server routes can use it. With the `@comark/nuxt` module, `<MarkdownDocument>` is auto-imported:
Move `getPost()` to `server/utils/posts.ts`, so server routes can use it. With the [`@comark/vue` module](/rendering/vue#nuxt), `<MarkdownDocument>` is auto-imported:

```typescript [server/api/posts/[slug].get.ts]
export default defineEventHandler(event => getPost(getRouterParam(event, 'slug')!))
Expand Down Expand Up @@ -130,7 +130,7 @@ Each framework has a complete example: [Nuxt](/examples/frameworks/nuxt), [Next.

## Override Markdown elements

Map a native tag in `components` to change how it renders, for example `pre` for code blocks with a copy button. In Nuxt, place components such as `ProseH2.vue` in `~/components/prose`. See [overriding HTML elements](/rendering/nuxt#overriding-html-elements) and [custom code blocks](/kb/custom-code-block).
Map a native tag in `components` to change how it renders, for example `pre` for code blocks with a copy button. See [overriding HTML elements](/rendering/vue#overriding-html-elements) and [custom code blocks](/kb/custom-code-block).

## FAQ

Expand Down
6 changes: 3 additions & 3 deletions docs/content/11.compare/11.comark-vs-vue-markdown-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ links:
variant: soft
- label: Render in Nuxt
icon: i-simple-icons-nuxtdotjs
to: /rendering/nuxt
to: /rendering/vue#nuxt
color: neutral
variant: soft
---
Expand Down Expand Up @@ -82,7 +82,7 @@ import Heading from './components/Heading.vue'
</template>
```

Comark looks up `ProseH2`, then `H2`, then `h2`, then globally registered components. In Nuxt, the `@comark/nuxt` module registers the components in `~/components/prose` for you.
Comark looks up `ProseH2`, then `H2`, then `h2`, then globally registered components.

## Components in the content

Expand Down Expand Up @@ -147,7 +147,7 @@ If you render trusted, static Markdown and don't need components, vue-markdown-r
:::

:::accordion-item{label="Does Comark work with Nuxt and Nuxt UI?"}
Yes. The `@comark/nuxt` module auto-imports the components and registers prose overrides. It uses Nuxt UI prose components when `@nuxt/ui` is installed. See [Nuxt](/rendering/nuxt).
Yes. Add `@comark/vue` to your Nuxt modules to auto-import the components. It uses Nuxt UI prose components when `@nuxt/ui` is installed. See [Nuxt](/rendering/vue#nuxt).
:::

:::accordion-item{label="Is raw HTML in model output safe with Comark?"}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/11.compare/3.comark-vs-streamdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Because `::flight-card` is text, not JSX, the component syntax runs no code. A t

## Beyond React

Streamdown is React-only by design. Comark ships the same streaming behavior for [Vue](/rendering/vue), [React](/rendering/react), [Svelte](/rendering/svelte), [Angular](/rendering/angular), and [Nuxt](/rendering/nuxt), plus string renderers for [HTML](/rendering/html) and [ANSI](/rendering/ansi). One content pipeline, whatever your stack looks like today or in three years.
Streamdown is React-only by design. Comark ships the same streaming behavior for [Vue](/rendering/vue), [React](/rendering/react), [Svelte](/rendering/svelte), [Angular](/rendering/angular), and [Nuxt](/rendering/vue#nuxt), plus string renderers for [HTML](/rendering/html) and [ANSI](/rendering/ansi). One content pipeline, whatever your stack looks like today or in three years.

## What Streamdown does well

Expand Down
2 changes: 1 addition & 1 deletion docs/content/11.compare/4.comark-vs-markdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Markdoc nodes are objects carrying `type`, `tag`, `attributes`, `children`, and

## Framework coverage

Markdoc officially renders to React and HTML. Comark ships official renderers for [Vue](/rendering/vue), [React](/rendering/react), [Svelte](/rendering/svelte), [Angular](/rendering/angular), and [Nuxt](/rendering/nuxt), plus [HTML](/rendering/html) and [ANSI](/rendering/ansi) string output, all consuming the same AST.
Markdoc officially renders to React and HTML. Comark ships official renderers for [Vue](/rendering/vue), [React](/rendering/react), [Svelte](/rendering/svelte), [Angular](/rendering/angular), and [Nuxt](/rendering/vue#nuxt), plus [HTML](/rendering/html) and [ANSI](/rendering/ansi) string output, all consuming the same AST.

## What Markdoc does well

Expand Down
16 changes: 14 additions & 2 deletions docs/content/3.rendering/3.vue.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Vue Markdown Component with Streaming and Custom Components'
description: 'Render Markdown in Vue 3 with the Markdown component: map elements to your own components, add plugins, and stream AI output as it arrives.'
description: 'Render Markdown in Vue 3 and Nuxt with the Markdown component: map elements to your own components, add plugins, and stream AI output as it arrives.'
navigation:
title: Vue
icon: i-simple-icons-vuedotjs
Expand Down Expand Up @@ -41,6 +41,18 @@ bun add @comark/vue

::

### Nuxt

Add `@comark/vue` to the `modules` in your `nuxt.config`:

```typescript [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@comark/vue']
})
```

Nuxt auto-imports the `<Markdown>` and `<MarkdownDocument>` components and the `defineMarkdownComponent()` and `defineMarkdownDocumentComponent()` helpers, so you can skip their imports in the examples below. `parseMarkdown()` and `createMarkdownParser()` are auto-imported too, in your app and in server routes.

## `<Markdown>`

The `<Markdown>` component is the quickest way to render markdown in Vue. It handles parsing and rendering automatically.
Expand Down Expand Up @@ -702,7 +714,7 @@ If none match, the tag renders as a native HTML element.

## Nuxt UI integration

When [`@nuxt/ui`](https://ui.nuxt.com) is installed, Comark automatically uses Nuxt UI's prose components for enhanced styling.
When [`@nuxt/ui`](https://ui.nuxt.com) is installed, Comark automatically uses Nuxt UI's prose components for enhanced styling. In [Nuxt](#nuxt), the module turns them on for you.

### Vite setup

Expand Down
Loading
Loading