You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add markdown-to-word-mermaid, a self-contained skill for converting Markdown documents containing Mermaid code fences to DOCX. The bundled Python converter renders diagrams locally with Mermaid CLI, embeds vector SVGs using Office OOXML relationships, and retains 3x PNG fallbacks. Diagram paragraphs keep their aspect ratio, remain together, and use page-aware scaling and page breaks.
This complements the existing general md-to-docx workflow by focusing on Mermaid rendering, SVG packaging, Office-compatible labels, and tall-diagram placement. It does not create individually editable Word shapes, connectors, or diagram text.
Contents
English SKILL.md with prerequisites, safe output handling, workflow, limitations, and verification commands.
Python converter and bounded dependency requirements; no vendored libraries, browsers, fonts, or generated documents.
Synthetic English/Japanese sample with three diagrams, including a tall flowchart.
Mocked converter tests, an opt-in real-renderer integration test, and overwrite-preservation coverage.
Maintainer publication notes and the generated docs/README.skills.md entry.
Verification
npm run skill:validate: passed for all 430 skills, including this candidate.
npm run build: passed and generated the new skill listing.
Converter and overwrite regressions: passed in the submitted working tree. The optional real-renderer test was skipped in that final regression invocation.
Separate real Mermaid rendering and independent-context execution produced all three SVGs and PNG fallbacks. Image relationships, package integrity, English/Japanese labels, and source/output preservation were checked.
Word 16.0 opened the sample read-only and exported three PDF pages; all exported pages were visually inspected. The original DOCX was unchanged.
An independent context verified normal conversion, refusing an existing destination, rejecting invalid Mermaid without changing the source, and explaining the native-editable-shape boundary.
Limitations and Disclosure
SVG rendering requires an SVG-capable Word viewer and an installed font; fonts are not embedded. Ordinary Markdown image links are represented as text rather than embedded images. The title/frontmatter handling is intentionally limited, not a full YAML metadata parser. Word GUI zoom, physical printing, automatic skill selection, and non-Windows execution were not verified.
The tall sample remains on its own page, but its heading stays on the preceding page; branch labels may have connectors visible behind them. One independent execution timed out at a 170-second test cap; a sequential recheck with a 300-second cap completed in about 100 seconds. The earlier timeout cause is unverified, and no performance or skill-quality uplift is claimed.
The rights holder confirmed ownership/authority and authorized offering the skill's own code, documentation, and synthetic sample under MIT. Runtime dependencies retain their respective licenses and are not redistributed with the skill.
AI-assisted contribution. Local checks are not hosted CI results or maintainer approval.
Risk tier:merge-risk:high — Privileged execution, automation, or review-policy change Required to merge: passing submission-gate checks plus 1 approval from reviewers with write access, including a maintainer with admin or maintain permission.
Why this tier
skills/markdown-to-word-mermaid/scripts/markdown_to_word.py is a high-risk path (automation, scripts, MCP config, hooks, or review policy)
skills/markdown-to-word-mermaid/scripts/requirements.txt is a high-risk path (automation, scripts, MCP config, hooks, or review policy)
skills/markdown-to-word-mermaid/tests/test_markdown_to_word.py is a high-risk path (automation, scripts, MCP config, hooks, or review policy)
✓ [spec-compliance] All 1 skill(s) are spec-compliant.
ℹ️
✓ spec-compliance: All spec checks passed.
ℹ️
✓ [valid-refs] All file references across 1 skill(s) are valid.
ℹ️
✓ valid-refs: All file references resolve to existing files within the skill directory.
ℹ️
1 skill(s) linted, 1 passed
Full linter output
### Linting skills/markdown-to-word-mermaid
✅ markdown-to-word-mermaid (2/2 checks passed)
✓ [spec-compliance] All 1 skill(s) are spec-compliant.
✓ spec-compliance: All spec checks passed.
✓ [valid-refs] All file references across 1 skill(s) are valid.
✓ valid-refs: All file references resolve to existing files within the skill directory.
1 skill(s) linted, 1 passed
Adds a differentiated Mermaid-focused Markdown-to-DOCX skill with vector SVG packaging, PNG fallbacks, and page-aware layout. Knowledge uplift is high due to the bundled converter and OOXML handling.
Changes:
Adds the converter, dependency bounds, and usage guidance.
Adds mocked and optional real-renderer tests plus a multilingual sample.
Adds publication notes and generated skill documentation.
File
Description
skills/markdown-to-word-mermaid/SKILL.md
Defines setup, workflow, limitations, and verification.
This renderer call has no timeout, so a stuck Mermaid CLI or browser can block an agent indefinitely. The PR's own validation reports a 170-second timeout, making this a demonstrated failure mode rather than a hypothetical one. Add a documented configurable timeout and convert TimeoutExpired into a clear rendering error while ensuring spawned browser processes are terminated.
Addressed all four Copilot review findings and cleaned up the skill package in 03ab02c:
Added a per-command timeout (--timeout, default 120 seconds) to subprocess.run when invoking Mermaid CLI and converted subprocess.TimeoutExpired into a descriptive RuntimeError.
Changed convert_markdown to stage intermediate DOCX outputs inside TemporaryDirectory() and move the final file to output_path only after _inject_svg_parts succeeds, leaving the destination directory untouched on failure.
Preserved ordered list start numbers and separate ordered list boundaries instead of delegating all numbered items to Word's shared List Number sequence.
Populated diagram wp:docPrtitle and descr with contextual alt text derived from Mermaid accTitle/accDescr, the preceding heading, and the diagram type.
Replaced internal Japanese notes in references/publication.md with English scope and evaluation documentation, and consolidated the duplicate scripts/tests/test_markdown_to_word.py into tests/test_markdown_to_word.py.
Validation: 8 unit tests (including real Mermaid CLI rendering) pass, npm run skill:validate and npm run build pass with zero drift.
Addressed the 3 follow-up review comments in 28495d7:
Track list_item_open and list_item_close boundaries so continuation paragraphs within ordered and unordered list items use List Continue without emitting duplicate numbers or bullets.
Stage the temporary directory under output_path.parent so final publication stays on the destination filesystem.
Publish the completed DOCX atomically without overwriting existing files via os.link (with O_CREAT | O_EXCL fallback).
Returning immediately for quote_depth bypasses list formatting. For example, > 5. First followed by > 6. Second becomes two Quote paragraphs containing only First and Second, losing the list markers and starting number. Handle list_stack for quoted paragraphs as well, preserving list markers and continuation state while applying quote formatting.
Leading thematic break incorrectly strips non-frontmatter content
A leading thematic break is treated as frontmatter whenever another --- occurs later, without checking whether the enclosed text is metadata. A document beginning with ---, a heading and Mermaid fence, then another --- silently loses the heading and diagram here. Validate the supported metadata structure before removing this region, and preserve the original Markdown when it does not match.
Resolve Windows .cmd/.bat shims to the Mermaid JavaScript entry point and invoke it through Node with an argument list and no shell, avoiding cmd.exe metacharacter interpretation in paths such as R&D.
Keep publication atomic: use hard-link creation where available, use Windows atomic no-replace rename when hard links are unavailable, and fail clearly on other systems instead of creating a visible partial destination.
Added Windows path and publication fallback regression coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
markdown-to-word-mermaid, a self-contained skill for converting Markdown documents containing Mermaid code fences to DOCX. The bundled Python converter renders diagrams locally with Mermaid CLI, embeds vector SVGs using Office OOXML relationships, and retains 3x PNG fallbacks. Diagram paragraphs keep their aspect ratio, remain together, and use page-aware scaling and page breaks.This complements the existing general
md-to-docxworkflow by focusing on Mermaid rendering, SVG packaging, Office-compatible labels, and tall-diagram placement. It does not create individually editable Word shapes, connectors, or diagram text.Contents
SKILL.mdwith prerequisites, safe output handling, workflow, limitations, and verification commands.docs/README.skills.mdentry.Verification
npm run skill:validate: passed for all 430 skills, including this candidate.npm run build: passed and generated the new skill listing.Limitations and Disclosure
SVG rendering requires an SVG-capable Word viewer and an installed font; fonts are not embedded. Ordinary Markdown image links are represented as text rather than embedded images. The title/frontmatter handling is intentionally limited, not a full YAML metadata parser. Word GUI zoom, physical printing, automatic skill selection, and non-Windows execution were not verified.
The tall sample remains on its own page, but its heading stays on the preceding page; branch labels may have connectors visible behind them. One independent execution timed out at a 170-second test cap; a sequential recheck with a 300-second cap completed in about 100 seconds. The earlier timeout cause is unverified, and no performance or skill-quality uplift is claimed.
The rights holder confirmed ownership/authority and authorized offering the skill's own code, documentation, and synthetic sample under MIT. Runtime dependencies retain their respective licenses and are not redistributed with the skill.
AI-assisted contribution. Local checks are not hosted CI results or maintainer approval.