feat: add mermaid-md skill for rendering mermaid blocks in Markdown - #2728
Open
TheNha wants to merge 1 commit into
Open
feat: add mermaid-md skill for rendering mermaid blocks in Markdown#2728TheNha wants to merge 1 commit into
TheNha wants to merge 1 commit into
Conversation
Co-Authored-By: Nguyen The Nha @nha.nt
Contributor
🔒 PR Risk Scan ResultsScanned 2 changed file(s).
|
Contributor
🔍 Vally Lint Results✅ All checks passed
Summary
Full linter output |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.mainbranch for this pull request.Description
Adds the
mermaid-mdskill: it takes a Markdown file that already contains```mermaidblocks and renders each block to a PNG/SVG/PDF, optionally inserting the image under its block.This is the opposite direction from authoring a diagram — nothing here writes
.mmdfiles. The Markdown stays the single source of truth, and failures are reported against the block's line range in the.md(docs/design.md:633-654) so the diagram gets fixed where it lives.Why it's useful: GitHub, GitLab and Obsidian render mermaid natively, but Word, PDF, Confluence, SharePoint and slide decks do not. Today that means hand-exporting each diagram through mermaid.live. The skill turns a 20-diagram RFC into 20 named PNGs in one command, and pairs directly with the existing
md-to-docxskill, which embeds PNGs referenced from the Markdown:What the bundled script does beyond a
mmdcone-liner:--listinventories the blocks (index, line range, diagram type, title) before rendering anything--checkvalidates every block into a temp dir and exits non-zero — CI-ready--only 2,5-7re-renders just the blocks that changed```and~~~fences, blocks indented inside list items, while skipping mermaid examples nested in a longer outer fence, other languages, and YAML front matterdesign-03-auth-flow.png) from a%% title:comment, front-mattertitle:, or the nearest heading; accents folded to ASCII so non-English headings stay readable--in-placekeeps the mermaid block and puts the image underneath, and is idempotent — re-running refreshes that image line instead of stacking duplicates, so it fits a pre-commit hookSyntaxError: Unexpected token importfrommmdc), finds Chrome in Puppeteer's cache or on the system, and retries with--no-sandboxin containersEverything renders locally through
mermaid-cli— no diagram content is sent to any service.Type of Contribution
Additional Notes
On the unchecked box: the script itself is tested end-to-end —
--list,--check, PNG/SVG/PDF output,--only, both rewrite modes, idempotent--in-place, and the toolchain-recovery paths (old Node onPATH, missing Chrome, bad--chrome) — on Linux with mermaid-cli 11.16, Node 20 and system Chrome, including a 7-diagram Vietnamese design doc. It has been driven by an agent through itsSKILL.md, but not specifically through GitHub Copilot, so I have left that box unchecked rather than tick something I did not verify.npm run skill:validatereportsmermaid-md is valid(411 skills pass), andnpm run buildadds exactly one row todocs/README.skills.md.Requires
python3(standard library only), Node >= 18,@mermaid-js/mermaid-cli, and a Chrome/Chromium — the same browser dependency mermaid-cli already has.