跳到正文
cccskills
免费在 GitHub 公开中文介绍

markdown-to-word-mermaid

将含 Mermaid 图表的 Markdown 转为 DOCX,嵌入 SVG 以保持放大和打印时清晰,并附带 PNG 兼容图;同时转换常见文档结构并安排较高图表的页面位置。

原文查看原文说明

Export Markdown containing Mermaid code fences to Word (.docx) with embedded SVG diagrams and PNG fallbacks. Use when diagram sharpness, Office-compatible labels, or page-aware placement matters. Not for Word-to-Markdown conversion, editable Office shapes, or general slide creation.

github/awesome-copilot星标 40,567(GitHub 40,567 + cccskills 0)
集成工具Word

实测评分 未实测

查看安装方法

适用场景

  • 将含 Mermaid 的手册转为 Word
  • 打印时保持图表清晰
  • 安排纵向长图的页面位置
  • 生成含 SVG 和 PNG 的 DOCX

中文介绍

功能

将包含 Mermaid 代码块的 Markdown 文件转换为 Word(.docx)文档。每张图都会以 SVG 形式嵌入,并保留三倍分辨率的 PNG 备用图,以兼顾放大或打印时的清晰度和不同查看环境的兼容性。标题、段落、列表、表格、引用和代码块等常见内容也会转换为 Word 文档内容。纵向较长的图会按页面布局进行放置。转换由随附脚本在本地完成。

适用场景

适用于需要将含 Mermaid 图表的设计文档、操作手册或报告交付为 Word 文档的情况。图表标签需要在打印时保持易读,或需要避免长图在分页处被拆开时,也可使用。它不会把图表转换成可单独编辑的 Word 图形或连接线。

使用示例

  • “把这份 Markdown 转成图中文字清晰的 Word 文档。”
  • “将输出保存为 report.docx,并包含 Mermaid 图表。”
  • “指定日文字体,把这份操作手册转换为 DOCX。”

注意事项

需要 Python 3.10 或更高版本、指定的软件包、Node.js、Mermaid CLI、Puppeteer 可使用的本地浏览器,以及包含文档字符的已安装字体。生成文件不需要 Word,但检查矢量图显示效果需要支持 SVG 的 Word 版本。不会覆盖已有输出文件;Mermaid 无效或渲染失败时会停止转换。字体替换情况和最终分页应在查看文档的环境中检查。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
A良好资料禁止覆盖已有文件,并要求安装依赖前取得同意、渲染前检查不可信图表。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足资料要求 Python 软件包、Node.js、Mermaid CLI、本地浏览器和合适字体。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(6)

  • SKILL.md8.1 KB
  • assets/example.md1.3 KB
  • references/publication.md2.3 KB
  • scripts/markdown_to_word.py25.9 KB
  • scripts/requirements.txt73 B
  • tests/test_markdown_to_word.py25.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Markdown to Word with Mermaid

Export technical documents without manually replacing Mermaid fences with screenshots. The bundled converter renders each diagram locally, embeds the SVG through Office OOXML relationships, and retains a 3x PNG fallback. Word is not required to generate the file; an SVG-capable Word version is needed to inspect vector rendering.

When to use

  • A design document, runbook, or report contains Mermaid code fences and must be delivered as DOCX.
  • Diagram labels must remain sharp when zoomed or printed.
  • A tall diagram needs page-aware placement rather than being split across pages.

For general Markdown-to-DOCX conversion with existing PNG images, a general converter such as md-to-docx may be simpler. This skill focuses on rendering and packaging Mermaid diagrams. SVG embedding does not create editable Word shapes, connectors, or text boxes.

Requirements and setup

  • Python 3.10+ and the packages in scripts/requirements.txt.
  • Node.js compatible with the chosen Mermaid CLI release, plus @mermaid-js/mermaid-cli.
  • A local browser usable by Puppeteer and an installed font covering the document's characters.
  • Default font: Noto Sans JP. Use --font-family to select another installed family.

Resolve paths relative to this skill's installation directory, not an assumed repository name. The examples below run from the skill directory. Use the user's selected Python environment (python, python3, or its absolute path).

Before installing dependencies, confirm the environment and obtain permission if required. Reuse an existing Mermaid CLI when available. Otherwise install it into a user-approved local tools directory, not globally:

python -m pip install -r scripts/requirements.txt
npm install --prefix ./run/mermaid-cli @mermaid-js/mermaid-cli

The local executable is ./run/mermaid-cli/node_modules/.bin/mmdc on POSIX and ./run/mermaid-cli/node_modules/.bin/mmdc.cmd on Windows. Keep installed dependencies out of the submitted skill package. Lock the selected dependency versions in the consuming project for reproducible installations.

On Windows the converter detects standard Chrome and Edge paths. For another browser location, set MERMAID_BROWSER_PATH to its absolute executable path:

$env:MERMAID_BROWSER_PATH = "C:\Program Files\Google\Chrome\Application\chrome.exe"

On POSIX, use export MERMAID_BROWSER_PATH=/absolute/path/to/browser, or use Puppeteer's installed browser. Do not disable the browser sandbox just to make a conversion pass.

Workflow

  1. Confirm the input Markdown file, output destination, and font. If no destination is provided, use the input path with a .docx extension.
  2. Check that the output does not exist. Never delete or overwrite an existing document; ask for a different destination.
  3. Run scripts/markdown_to_word.py. Preserve the user's diagram source and meaning. Do not silently repair invalid Mermaid.
  4. Check the generated package and, when Word is available, inspect the document visually. Report package checks and visual checks separately.

With mmdc on PATH:

python scripts/markdown_to_word.py input.md --output output.docx

Using a workspace-local CLI on Windows:

python scripts/markdown_to_word.py input.md --output output.docx --mermaid-cli ./run/mermaid-cli/node_modules/.bin/mmdc.cmd

Selecting an installed font:

python scripts/markdown_to_word.py input.md --output output.docx --font-family "Noto Sans JP" --timeout 120

For a reproducible example, convert assets/example.md to a new output path. It includes English and Japanese labels, multiple diagrams, and a tall diagram.

Conversion behavior

  • Headings, paragraphs, emphasis, lists (preserving ordered list start numbers and separate list boundaries), blockquotes, tables, and code blocks become Word content.
  • Each Mermaid fence renders to SVG and a 3x PNG with a per-command timeout (default: 120 seconds). Office SVG extensions reference the SVG; the normal image reference retains the PNG fallback, and drawing metadata (title and descr) includes the section heading or Mermaid accTitle/accDescr plus the diagram type.
  • Output DOCX files are staged and SVG-injected inside a temporary directory before moving to the destination path so failed runs never leave partial files behind.
  • The selected font is applied to Word paragraph styles and Mermaid's font configuration. Code runs use Consolas. Fonts are not embedded; unavailable fonts may be substituted.
  • htmlLabels: false is set globally and for flowcharts to avoid HTML foreignObject labels that Office may not display. Check actual SVG output for unsupported constructs.
  • Diagrams are centered, keep their aspect ratio, and use a non-splitting paragraph. Diagrams occupying at least 70% of the page body height start on a new page. Oversized diagrams are scaled to the page body height. Large diagrams generate a readability warning.
  • A simple single-line frontmatter title becomes the document title; other frontmatter fields are removed from the body. This is not a full YAML metadata parser.
  • Ordinary Markdown image links remain alt text and a source path or URL; they are not embedded. Raw HTML is reduced to text, not executed.

Stop conditions and limitations

  • Missing input, wrong extensions, an existing output, missing CLI, invalid Mermaid, rendering failure, or unusable SVG dimensions stop the conversion with an error.
  • The converter does not call an external rendering service or a separate AI API. Dependency installation and browser execution are not an offline sandbox. Review untrusted diagram content, including external resources, before rendering it.
  • Diagrams are not semantically editable Office objects. Word rendering, font substitution, and final pagination depend on the viewer and must be checked there.
  • A successfully created DOCX is not proof that every diagram label is readable. Split large diagrams in the source only with the user's approval.

Verification

Run the test suite from the skill directory:

python -m unittest discover -s tests -v

The ordinary suite mocks Mermaid rendering. To run the real-renderer test as well, set MERMAID_CLI to the CLI executable's absolute path, then run the command again. On Windows PowerShell:

$env:MERMAID_CLI = (Join-Path $env:APPDATA "npm\mmdc.cmd")
python -m unittest discover -s tests -v

That test renders the bundled sample and checks the resulting DOCX's SVG references, PNG fallbacks, labels, and drawing dimensions. It does not automate Word visual inspection.

Before reporting completion:

  • Count Mermaid fences and verify the same number of SVG parts and SVG image references in the DOCX.
  • Confirm PNG fallback references exist and no label foreignObject remains in the sample's SVGs.
  • In Word, inspect node names, branch labels, font, diagram placement, and page boundaries; check zoomed or printed output when sharpness matters.
  • If Word or the actual renderer was unavailable, state which checks were not performed.

For contribution scope, evaluation cases, and a draft submission description, see references/publication.md. That file is maintainer guidance, not permission to publish.

Gotchas

  • mmdc.cmd needs Windows command handling; pass its path with --mermaid-cli rather than rewriting the script.
  • A missing font can affect both PNG rendering and SVG display. Use a family installed on the rendering and viewing machines.
  • Keep the SVG and PNG paired. Replacing SVG with a screenshot defeats the vector-preserving workflow.
  • Package validation, renderer tests, agent-selection evaluation, and human visual acceptance are different checks.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

扫描现有项目的代码与配置,生成涵盖技术栈、结构、架构、规范、集成、测试和风险的七份文档。为结论标注文件依据和未知项,并指出计划描述与实际实现的差异。

  • 了解陌生代码库
  • 准备项目交接文档
  • 对照设计资料与实际实现
github/awesome-copilot4.1万2026年10月29日 更新

acreadiness-assess

免费有简介

使用AgentRC评估代码仓库对AI智能体的准备情况,并生成可独立打开的HTML报告。查看九个方面的评分和优先改进建议,也可按组织自定评分政策。

  • 引入AI智能体前检查准备情况
  • 根据评估结果安排改进优先级
  • 按组织自定政策评分
github/awesome-copilot4.1万2026年10月29日 更新

使用AgentRC分析项目代码中的语言、框架和开发惯例,生成或更新AI编程代理的指令文件。可集中写入一个文件,也可按主题和项目区域拆分,并在写入前预览改动。

  • 创建VS Code Copilot指令
  • 将开发规则变更写入指令
  • 按单体仓库区域整理规则
github/awesome-copilot4.1万2026年10月29日 更新

acreadiness-policy

免费有简介

按团队或组织标准调整AgentRC准备度评估。可选择或创建JSON策略,调整检查权重、停用无关检查、设置通过率,并在CI流程中设定自动检查门槛。

  • 制定组织共用的评估标准
  • 只评估AI相关的准备情况
  • 调整特定检查项的权重
github/awesome-copilot4.1万2026年10月29日 更新

ad-campaign-analyzer

免费有简介

分析你提供的广告成效数据,找出浪费支出和表现较好的广告,并整理暂停、加预算或继续测试的候选项。还可比较不同平台、评估A/B测试差异,并提出预算调整建议。

  • 找出应暂停的广告或关键词
  • 发现适合增加预算的广告系列
  • 判断A/B测试的数据是否足够
github/awesome-copilot4.1万2026年10月29日 更新

为指定代码文件添加学习注释,解释语法、编程概念和设计选择;可按读者水平调整讲解深度和重复频率,并保持文件结构、编码与语法。

  • 为现有代码添加初学者说明
  • 解释语法或设计选择的原因
  • 按读者经验调整注释内容
github/awesome-copilot4.1万2026年10月29日 更新

查看 github 的全部技能

报告此技能的问题