@diagrammo/dgmo

中文文档
0.98.0发布于 2026/11/09MITTypeScriptES Module构建来源已验证近 30 天下载 2515

DGMO diagram markup language — parser, renderer, and color system

原始使用文档
文档目录12 节
  1. Simple text in. Brilliant diagrams out.
  2. Author it visually
  3. Install
  4. CLI
  5. Library
  6. Drop into any web page
  7. Use it from your AI tool
  8. Chart types
  9. Palettes & themes
  10. Editor support
  11. Develop
  12. License

@diagrammo/dgmo

Simple text in. Brilliant diagrams out.

Write plain-text .dgmo files, get clean, themeable diagrams and charts. One markup language, 50+ chart types — flowcharts, sequence diagrams, ER, org charts, C4, gantt, maps, bar/line/pie, and a lot more.

npm npm downloads license

📖 Docs · 🧩 Language Reference · 🖥️ Desktop App · 🪄 Live Editor

Typing a DGMO sequence diagram and watching it render live


sequence Boarding the Marauder

Quartermaster -Hoist the colors-> Crew
Crew -Aye, captain-> Bosun
Bosun -Heading 270-> Helm
Helm -On course-> Quartermaster

That's a complete diagram. No coordinates, no XML, no drag-and-drop — just text you can diff, review, and version like any other source file.

Author it visually

Want a richer editing experience than a text file? The Diagrammo desktop app (native macOS, offline, auto-updating) and the online editor (any browser, nothing to install) turn DGMO into a full authoring environment:

  • Live preview — the diagram redraws as you type
  • Smart editing — syntax highlighting, autocomplete, and optional vim keybindings
  • 7 themeable palettes, each with light / dark / transparent variants
  • One-click export to PNG or SVG, plus instant shareable links
  • Local-first — your .dgmo files are plain text on disk, work fully offline, and never go stale the way an exported image does

Because every diagram is just text, it lives in git, diffs cleanly in PRs, and drops straight into your docs, your AI tools, or any web page.

→ Start at diagrammo.app

Install

# Library
npm install @diagrammo/dgmo

# CLI (macOS and Linux)
npm install -g @diagrammo/dgmo-cli

# CLI (no install)
npx @diagrammo/dgmo-cli diagram.dgmo

Homebrew and Arch/Omarchy (pacman) installs of the CLI are listed at diagrammo.app/dev.

CLI

dgmo                                   # creates a sample.dgmo to get you started
dgmo diagram.dgmo                      # → diagram.png
dgmo diagram.dgmo -o out.svg           # → SVG (format from extension)
cat diagram.dgmo | dgmo > out.png      # pipe in, PNG to stdout
dgmo diagram.dgmo --theme dark --palette catppuccin
FlagValuesDefault
--themelight, dark, transparentlight
--paletteone of 7 palettes (see below)slate
-ooutput path (.svg → SVG, else PNG)<input>.png

Library

Render any diagram to an SVG string — no browser, no visible DOM:

import { render } from '@diagrammo/dgmo';

const { svg } = await render(
  `
bar Revenue by Quarter
Q1 12
Q2 19
Q3 15
Q4 22
`,
  { theme: 'light', palette: 'slate' }
);

render() auto-detects the chart type and dispatches to the right engine. Need the lower-level parsers, config builders, and per-type renderers? They live under the @diagrammo/dgmo/advanced subpath — see the docs for the full surface and stability contract.

Drop into any web page

Add one <script> tag and every <pre class="dgmo"> block renders on load:

<script src="https://cdn.jsdelivr.net/npm/@diagrammo/dgmo-standalone/dist/auto.js"></script>

<pre class="dgmo">
pie Crew Rations
Grog: 58
Hardtack: 21
Limes: 21</pre
>

Prefer an explicit element? Use <dgmo-diagram> from the same package:

<script src="https://cdn.jsdelivr.net/npm/@diagrammo/dgmo-standalone/dist/element.js"></script>

<dgmo-diagram palette="slate"
  >pie Crew Rations Grog: 58 Hardtack: 21 Limes: 21</dgmo-diagram
>

Theme detection, copy button, and "open in editor" come for free. Full config, framework recipes (Astro, Docusaurus, Hugo, MkDocs), self-hosting, and CSP guidance: diagrammo.app/embed.

Using a docs framework? First-class plugins wrap all of this: remark-dgmo · astro-dgmo · docusaurus-plugin-dgmo · fumadocs-dgmo · nextra-dgmo · vitepress-dgmo

Use it from your AI tool

Claude, Cursor, Codex, and other agents can author and render DGMO directly. One command sets up every assistant you have — no second package, no prompts:

dgmo install

It auto-detects Claude Code, Codex, Claude Desktop, Cursor, Windsurf, and Copilot and wires each one to the bundled MCP server. More: diagrammo.app/ai.

Chart types

Data charts — bar · line · area · pie · doughnut · radar · polar-area · bar-stacked · multi-line · scatter · heatmap · funnel · sankey · chord

Visualizations — slope · wordcloud · arc · timeline · venn · quadrant · tech-radar · cycle · pyramid · ring · function · map

Diagrams — sequence · flowchart · class · er · org · c4 · state · infra · kanban · sitemap · mindmap · gantt · pert · journey-map · boxes-and-lines · wireframe · raci · rasci · daci

Beta — expect rough edges and syntax changes: c4, venn, whiteboard. dgmo types marks them too.

Every chart type is categorized with live examples at diagrammo.app/reference.

Each type's full syntax, directives, and options live in the Language Reference — the authoritative spec.

Palettes & themes

Built-in palettes, each with light, dark, and transparent variants:

slate (default) · atlas · blueprint · tidewater · nord · catppuccin · tokyo-night

Register your own with registerPalette(). Color helpers (getPalette, tint, mute, contrastText, …) and Mermaid theme-variable generation ship from the package too — see the docs.

Editor support

Syntax highlighting and autocomplete for .dgmo files ship as ready-to-use exports:

  • @diagrammo/dgmo/highlight — standalone highlighter
  • @diagrammo/dgmo/editor — CodeMirror 6 language support

Both back the desktop app and the live editor.

Develop

pnpm install
pnpm build        # tsup → dist/ (ESM + CJS + CLI)
pnpm test         # vitest
pnpm typecheck

License

MIT © Demian Neidetcher

版本与发布记录

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

版本发布日期距今
0.98.0latest2026/11/093 天前
0.97.02026/11/083 天前
0.96.02026/11/0210 天前
0.95.02026/10/2913 天前
0.94.02026/10/2815 天前
0.93.02026/10/2616 天前

关于 @diagrammo/dgmo 的常见问题

@diagrammo/dgmo 是什么?

DGMO diagram markup language — parser, renderer, and color system

如何安装 @diagrammo/dgmo?

在项目目录运行 npm install @diagrammo/dgmo,或使用 pnpm add / yarn add / bun add。

@diagrammo/dgmo 支持 TypeScript 吗?

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

@diagrammo/dgmo 支持 ESM 还是 CommonJS?

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

@diagrammo/dgmo 需要什么版本的 Node.js?

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

@diagrammo/dgmo 可以商用吗?

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

@diagrammo/dgmo 的下载量有多少?

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

@diagrammo/dgmo 还在维护吗?

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