mermaidjs-v11
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMermaid.js v11
Mermaid.js v11
Overview
概述
Create text-based diagrams using Mermaid.js v11 declarative syntax. Convert code to SVG/PNG/PDF via CLI or render in browsers/markdown files.
使用Mermaid.js v11的声明式语法创建基于文本的图表。可通过CLI将代码转换为SVG/PNG/PDF格式,或在浏览器/Markdown文件中渲染。
Quick Start
快速入门
Basic Diagram Structure:
{diagram-type}
{diagram-content}Common Diagram Types:
- - Process flows, decision trees
flowchart - - Actor interactions, API flows
sequenceDiagram - - OOP structures, data models
classDiagram - - State machines, workflows
stateDiagram - - Database relationships
erDiagram - - Project timelines
gantt - - User experience flows
journey
See for all 24+ types with syntax.
references/diagram-types.md基本图表结构:
{diagram-type}
{diagram-content}常见图表类型:
- - 流程图、决策树
flowchart - - 参与者交互、API流程
sequenceDiagram - - 面向对象结构、数据模型
classDiagram - - 状态机、工作流
stateDiagram - - 数据库关系
erDiagram - - 项目时间线
gantt - - 用户体验流程
journey
查看获取所有24余种图表类型的语法说明。
references/diagram-types.mdCreating Diagrams
创建图表
Inline Markdown Code Blocks:
markdown
```mermaid
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action]
B -->|No| D[End]
```Configuration via Frontmatter:
markdown
```mermaid
---
theme: dark
---
flowchart LR
A --> B
```Comments: Use prefix for single-line comments.
%% Markdown内联代码块:
markdown
```mermaid
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action]
B -->|No| D[End]
```通过Frontmatter配置:
markdown
```mermaid
---
theme: dark
---
flowchart LR
A --> B
```注释: 使用前缀添加单行注释。
%% CLI Usage
CLI使用方法
Convert files to images:
.mmdbash
undefined将文件转换为图片:
.mmdbash
undefinedInstallation
Installation
npm install -g @mermaid-js/mermaid-cli
npm install -g @mermaid-js/mermaid-cli
Basic conversion
Basic conversion
mmdc -i diagram.mmd -o diagram.svg
mmdc -i diagram.mmd -o diagram.svg
With theme and background
With theme and background
mmdc -i input.mmd -o output.png -t dark -b transparent
mmdc -i input.mmd -o output.png -t dark -b transparent
Custom styling
Custom styling
mmdc -i diagram.mmd --cssFile style.css -o output.svg
See `references/cli-usage.md` for Docker, batch processing, and advanced workflows.mmdc -i diagram.mmd --cssFile style.css -o output.svg
查看`references/cli-usage.md`获取Docker、批量处理及高级工作流相关内容。JavaScript Integration
JavaScript集成
HTML Embedding:
html
<pre class="mermaid">
flowchart TD
A[Client] --> B[Server]
</pre>
<script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
<script>mermaid.initialize({ startOnLoad: true });</script>See for Node.js API and advanced integration patterns.
references/integration.mdHTML嵌入:
html
<pre class="mermaid">
flowchart TD
A[Client] --> B[Server]
</pre>
<script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
<script>mermaid.initialize({ startOnLoad: true });</script>查看获取Node.js API及高级集成模式相关内容。
references/integration.mdConfiguration & Theming
配置与主题设置
Common Options:
- : "default", "dark", "forest", "neutral", "base"
theme - : "classic", "handDrawn"
look - : Custom font specification
fontFamily - : "strict", "loose", "antiscript"
securityLevel
See for complete config options, theming, and customization.
references/configuration.md常用选项:
- : "default", "dark", "forest", "neutral", "base"
theme - : "classic", "handDrawn"
look - : 自定义字体设置
fontFamily - : "strict", "loose", "antiscript"
securityLevel
查看获取完整的配置选项、主题设置及自定义内容。
references/configuration.mdPractical Patterns
实用模式
Load for:
references/examples.md- Architecture diagrams
- API documentation flows
- Database schemas
- Project timelines
- State machines
- User journey maps
查看获取以下内容:
references/examples.md- 架构图
- API文档流程
- 数据库架构
- 项目时间线
- 状态机
- 用户旅程图
Resources
资源
- - Syntax for all 24+ diagram types
references/diagram-types.md - - Config, theming, accessibility
references/configuration.md - - CLI commands and workflows
references/cli-usage.md - - JavaScript API and embedding
references/integration.md - - Practical patterns and use cases
references/examples.md
- - 24余种图表类型的语法说明
references/diagram-types.md - - 配置、主题设置、无障碍功能
references/configuration.md - - CLI命令与工作流
references/cli-usage.md - - JavaScript API与嵌入方式
references/integration.md - - 实用模式与使用场景
references/examples.md