@comark/svelte

中文文档
0.9.0发布于 2026/11/06MITTypeScriptES Module构建来源已验证近 30 天下载 9408

Svelte 5 renderer for Comark. Render Markdown with components at runtime, with streaming support for AI output.

原始使用文档
文档目录7 节
  1. Features
  2. Installation
  3. Usage
  4. Custom components
  5. Streaming
  6. Documentation
  7. License
Comark banner

@comark/svelte

npm version npm downloads CI Documentation license

Svelte renderer for Comark. Render markdown with custom Svelte components, streaming support, and SvelteKit SSR.

Features

  • 🧩 <Markdown> component for one-shot markdown rendering
  • 🎯 Map any Comark tag to a custom Svelte component
  • 🌊 Streaming-friendly with auto-close and caret support
  • 🖥️ SSR-safe, works in SvelteKit
  • 🔌 Plugin ecosystem (math, mermaid, highlight, binding…)
  • 🎯 Full TypeScript support

Installation

npm install @comark/svelte
# or
pnpm add @comark/svelte

Usage

<script lang="ts">
  import { Markdown } from '@comark/svelte'
  import math, { Math } from '@comark/svelte/plugins/math'

  const content = `# Hello\n\nThis is **Comark** in Svelte.`
</script>

<Markdown value={content} components={{ math: Math }} plugins={[math()]} />

Custom components

<script lang="ts">
  import { Markdown } from '@comark/svelte'
  import Alert from './Alert.svelte'
</script>

<Markdown value={content} components={{ alert: Alert }} />
::alert{type="warning"}
Heads up!
::

Streaming

Markdown and MarkdownAsync reuse completed blocks while streaming is true. Set it to false when the stream ends to run a final full parse. Changes to options, plugins, or unwrap create a new parser. Heading tails and reference definitions use a full parse to preserve heading IDs and links.

<Markdown value={content} streaming={isStreaming} caret />

Documentation

Full guide and API reference at comark.dev/rendering/svelte.

License

Made with ❤️

Published under MIT License.

版本与发布记录

@comark/svelte 共发布 16 个版本,首次发布于 2026/03/24;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.0latest2026/11/063 天前
0.8.12026/10/2119 天前
0.8.02026/10/2120 天前
0.7.02026/09/101 个月前
0.6.22026/08/073 个月前
0.6.12026/08/063 个月前

关于 @comark/svelte 的常见问题

@comark/svelte 是什么?

Svelte 5 renderer for Comark. Render Markdown with components at runtime, with streaming support for AI output.

如何安装 @comark/svelte?

在项目目录运行 npm install @comark/svelte,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:svelte(^5.57.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@comark/svelte 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@comark/svelte 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@comark/svelte 可以商用吗?

@comark/svelte 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@comark/svelte 的下载量有多少?

根据 npm 官方下载统计,@comark/svelte 在 2026/10/11 – 2026/11/09 这 30 天内被下载 9,408 次,日均约 314 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@comark/svelte 还在维护吗?

最新版本 0.9.0 发布于 2026/11/06(3 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/03/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。