name: md-share description: >- Produce a standalone, shareable HTML snapshot of a markdown doc using md-preview's UI (pan/zoom mermaid diagrams, TOC, fullscreen). Use when the user wants to share a markdown doc with their team while preserving the md-preview look, export md-preview to a single HTML file, send a rendered doc to Slack/email, or make a markdown doc viewable offline.
md-share
Turn a local markdown doc (rendered by md-preview) into a single self-contained HTML file that preserves the custom UI — sticky header, TOC, code copy buttons, and (most importantly) the pan/zoom/fullscreen mermaid viewports.
When to use this
The user wants to hand a teammate a rendered doc that looks like what they see in md-preview, but via email/Slack/a file drop — no running local server required.
How to run
Invoke the bundled script with the markdown file path:
~/.claude/skills/md-share/share.sh <path/to/doc.md> [output.html]
- If
output.htmlis omitted, it writes<doc>.shareable.htmlnext to the source. - Stdout prints the final output path.
- Script is idempotent — it starts its own
md-previewon a free port and tears it down on exit.
Report the final path to the user (the user wants to know where the file landed).
What the script does (and why)
md-preview renders markdown client-side by fetching /source and /meta from its server on page load, then binds pan/zoom handlers on the rendered mermaid SVGs. A naive snapshot breaks:
monolith/ plain "Save As" fails — it only inlines static resources, not runtimefetch()responses. The saved file tries to refetch from a dead server.single-filewith defaults fails — default flags strip scripts (loses pan/zoom), strip hidden elements (loses the fullscreen modal), and strip "unused" styles (loses.fullscreen-modal.open { display:flex }because nothing had.openat capture time).
So the script runs single-file with:
--block-scripts=false→ keep md-preview's client JS so PanZoom/toolbar/fullscreen classes survive.--remove-hidden-elements=false→ keep the#fullscreenmodal div (display:none at capture).--remove-unused-styles=false→ keep.fullscreen-modal.openand other conditional rules.
Then it post-processes the HTML:
- Replaces the live-reload boot (
refresh(true).then(...)) with an offline activator that callsattachCodeCopy,activateDiagrams,buildTocdirectly on the already-rendered DOM (the SVGs are baked in). - Hides
.status-rowso the "Live preview" / "Rendered at …" pills don't show on a static file.
Prerequisites
md-previewon PATH — it is themd-previewskill's Node script; that skill covers linking it into~/.local/bin.single-file-clion PATH — install once withnpm i -g single-file-cli.
If either is missing, the script exits with a clear message.
Troubleshooting
- "warn: live-reload boot not found" —
md-preview's boot code changed shape. Re-read itsrefresh(true).then(...)block and update the regex inshare.sh. - Mermaid diagrams render but don't pan/zoom — scripts were blocked; confirm
--block-scripts=false. - Fullscreen button does nothing — the
#fullscreenmodal or its.openstyle rule was stripped; confirm--remove-hidden-elements=falseand--remove-unused-styles=false. - Diagram off-center in fullscreen — the
.diagramwrapper needs height in fullscreen: grepmd-previewfor.fullscreen-modal .fullscreen-bodyand confirmdisplay:flexthere plus.diagram { flex:1; min-height:0 }.
