comark-icon

中文文档
0.9.0发布于 2026/11/03MITTypeScriptES Module构建来源已验证

Iconify icons in Markdown, as :icon{name="lucide:apple"}, drawn as CSS in every renderer with no script. A shared resolver for other plugins' icons. A Comark plugin.

原始使用文档

comark-icon

npm version npm downloads license docs

Iconify icons in Markdown, written as :icon{name="lucide:apple"}. Icons are resolved while parsing and drawn as CSS images, so the page asks no server for them and they show without a script. An icon in one color takes the color of the text around it; a logo keeps its own. A Comark plugin for HTML, Vue, React, and Svelte.

pnpm add comark comark-icon
import { createHtmlRenderer } from "@comark/html";
import icon, { components } from "comark-icon/html";

const render = createHtmlRenderer({ plugins: [icon()], components });
Press :icon{name="lucide:command"} K to search.

Built with :icon{name="logos:vue" label="Vue"}.

name is set:name, from any set on icones.js.org, or an image URL. Nuxt UI's i-lucide-apple works too. Without a label the icon is decoration and screen readers skip it.

With no options, icons come from the Iconify API. To build offline, install the sets you use and pass them: icon({ collections: { lucide }, fetch: false }), with import { icons as lucide } from "@iconify-json/lucide". A set can also be SVG markup by name, for icons of your own. fetch takes the URL of an Iconify API of your own, too.

The plugin adds every problem to meta.issues and leaves the icon out.

Renderers

RendererImport
@comark/htmlcomark-icon/html: the styles are inlined
@comark/vuecomark-icon/vue
@comark/reactcomark-icon/react
@comark/sveltecomark-icon/svelte

Each entry exports the parse plugin as default and the renderer's components. Import comark-icon/style.css with your styles when you render on a server.

An icon is a .ci, 1em tall; set --comark-icon-size to change it. The rules sit in a comark CSS layer, so any plain rule of your own wins; see the icon's Theming page.

For other plugins

createIcons(options) returns a resolver with resolve(names), which never throws and maps each name to its icon or its problem; describeIconProblem() words a problem the way this plugin does. Pass one resolver to every plugin that draws icons, so a page sets its options once, and draw with iconHtml() and iconStyles(state) from comark-icon/html or the Icon component. See Guides.

版本与发布记录

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

版本发布日期距今
0.9.0latest2026/11/03今天
0.8.22026/11/021 天前
0.8.12026/11/011 天前
0.8.02026/10/312 天前
0.7.62026/10/313 天前
0.7.52026/10/303 天前

关于 comark-icon 的常见问题

comark-icon 是什么?

在Markdown中将图标图标化,如:icon{name="lucide:apple"},在每个渲染器中绘制为CSS,无需脚本。其他插件图标的共享解析器。一个Comark插件。

如何安装 comark-icon?

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

comark-icon 支持 TypeScript 吗?

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

comark-icon 支持 ESM 还是 CommonJS?

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

comark-icon 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

comark-icon 可以商用吗?

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

comark-icon 还在维护吗?

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