Skip to content
cccskills
FreePublished on GitHubEnglish overview

markdown-to-word-mermaid

Convert Markdown documents containing Mermaid diagrams into DOCX files with embedded SVG for sharp vector rendering and PNG fallbacks for compatibility. The converter preserves common document structure and positions tall diagrams with page layout in mind; it does not create editable Word shapes.

OriginalShow the original description

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-copilot40,567 stars(GitHub 40,567 + cccskills 0)
Works withWord

Run score Not tested

See how to install

Good for

  • Delivering a Mermaid runbook as a Word document
  • Keeping diagram labels sharp when printed
  • Placing tall diagrams across Word pages
  • Creating a DOCX with SVG and PNG diagram assets

Overview

What it does

Convert Markdown files containing Mermaid code fences into Word (.docx) documents. Each diagram is embedded as SVG and also kept as a three-times-resolution PNG fallback, supporting sharp output when zoomed or printed and compatibility with viewing environments. Headings, paragraphs, lists, tables, quotations, and code blocks are also converted into Word content. Tall diagrams are positioned to fit the page. The bundled script performs the conversion locally.

When it helps

Use it when a design document, runbook, or report with Mermaid diagrams must be delivered in Word. It can help keep diagram labels readable in print and avoid splitting long diagrams across pages. It does not turn diagrams into individually editable Word shapes or connectors.

Example requests

  • “Convert this Markdown file into a Word document with sharp diagram text.”
  • “Save the DOCX as report.docx and include the Mermaid diagrams.”
  • “Use a Japanese font and convert this runbook to DOCX.”

Notes

Requirements include Python 3.10 or newer, the specified packages, Node.js, Mermaid CLI, a local browser usable by Puppeteer, and installed fonts covering the document's characters. Word is not needed to generate the file, but an SVG-capable version is needed to check vector rendering. Existing output files are not overwritten, and invalid Mermaid or rendering failures stop conversion. Check font substitution and final pagination in the viewing environment.

This overview was written by AI (OpenAI Codex) from the public SKILL.md. Check the original below for the exact behavior.

Document check

AI checked the SKILL.md for operations that need care and for setup requirements. The score comes only from actually running the skill (hands-on test).

SafetyAre sending data, deleting files, and running commands disclosed?
AGoodIt prevents overwrites and calls for approval before dependency installation and review of untrusted diagrams.
Easy setupDoes it need few tools or API keys, and are they documented?
BPartly lackingIt requires Python packages, Node.js, Mermaid CLI, a local browser, and suitable fonts.

Not counted in the score. Rated by AI (OpenAI Codex) as of Oct 26, 2026. Treat it as a guide and read the original before installing.

Disagree? Request a re-evaluation

Tell us which point is wrong and why. No login needed. We will check it against the SKILL.md, redo the evaluation, and show the result here.

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

Files included (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 (original)

Review the instructions the agent will receive before you install.

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.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Map an existing codebase into seven documents covering its technology, structure, architecture, conventions, integrations, tests, and concerns. Link findings to file evidence, mark unknowns, and highlight differences between stated plans and the actual implementation.

  • Get oriented in an unfamiliar codebase
  • Prepare documentation for a project handover
  • Compare documented architecture with implementation
github/awesome-copilot40.6KUpdated Oct 29, 2026

Assess a repository’s readiness for AI agents with AgentRC and generate a standalone HTML dashboard. Review scores across nine areas, see prioritized improvements, and optionally apply scoring policies tailored to an organization.

  • Assessing a repository’s readiness for AI agents
  • Prioritizing improvements from assessment results
  • Reviewing scores under an organization’s own policy
github/awesome-copilot40.6KUpdated Oct 29, 2026

Generate coding agent instruction files from a project's actual code using AgentRC. Capture detected languages, frameworks, and conventions in one shared file or split rules by topic and project area, with a preview before writing.

  • Create project instructions for VS Code Copilot
  • Refresh agent rules after project changes
  • Split monorepo instructions by project area
github/awesome-copilot40.6KUpdated Oct 29, 2026

Customize AgentRC readiness assessments to match team or organization standards. Choose or create policies that adjust check importance, disable irrelevant checks, set pass thresholds, and define requirements for automated checks in CI workflows.

  • Set shared readiness standards across an organization
  • Focus assessments on AI tooling
  • Adjust the importance of individual checks
github/awesome-copilot40.6KUpdated Oct 29, 2026

Analyze supplied ad performance data to identify wasted spend, strong campaigns, and next tests. Compare channels, assess whether test differences are meaningful, and produce budget reallocation recommendations with a prioritized action plan.

  • Identify ads and keywords to pause
  • Find campaigns and audiences worth scaling
  • Assess whether A/B test results are meaningful
github/awesome-copilot40.6KUpdated Oct 29, 2026

Turn code files into learning resources by adding comments that explain syntax, programming concepts, and design choices. Adjust explanation depth and repetition to the reader’s knowledge while preserving file structure, encoding, and syntax.

  • Add beginner-friendly explanations to existing code
  • Document the reasoning behind syntax and design choices
  • Adjust comment depth for readers with different experience
github/awesome-copilot40.6KUpdated Oct 29, 2026

See all skills by github

Report a problem with this skill