satoshiman/mdsvr/mdsvr-to-epub
- community
Checking that the SKILL.md file is still in the repository.
Convert an mdsvr documentation folder (a doc site served or exported by mdsvr) into a single valid EPUB 3 ebook. Understands mdsvr conventions — README.md directory indexes, numeric-prefix ordering, _mdsvr/settings.json metadata, mdsvr-style internal links (./page, ./dir/, no extension), .mdx files and components (Callout, Mermaid, Steps, Tabs, Card, Badge). Renders ```mermaid blocks to PNG via mermaid.ink, LaTeX math ($..$, $$..$$, ```math) to PNG via latex.codecogs.com, converts ```quiz blocks to static Q&A, and draws wide tables to PNG with Pillow.
Install
npx vskill@latest install satoshiman/mdsvr/mdsvr-to-epubSKILL.md
mdsvr to EPUB
Convert an mdsvr docs folder (e.g. docs/, default-docs/, or any doc set served by mdsvr/npx mdsvr) into one EPUB 3 ebook with cover, table of contents, and embedded images. Pure Python (stdlib + markdown + Pillow) — no pandoc / calibre / Node required.
When to use
- "convert the docs to epub", "đóng gói tài liệu mdsvr thành ebook",
"export this doc site as an ebook"
- The input is an mdsvr doc set — a directory of
.md/.mdxfiles
using README.md as directory indexes and _mdsvr/ for settings.
- For generic (non-mdsvr) markdown folders or fetched X posts, use the
docs-to-epub / x-post-to-epub skills in the vuong-knowledge repo instead.
Usage
Where <skill_dir> is the directory containing this SKILL.md (skills/mdsvr-to-epub/).
Dependencies: pip install markdown pillow if the active python3 lacks them (or reuse the vuong-knowledge venv at /Users/apple/vuong-knowledge/.venv/bin/python, which already has both).
Options:
| Argument | Description | Default | |
|---|---|---|---|
--input, -i | Docs directory and/or .md/.mdx files (required, repeatable). Directories are walked recursively in mdsvr sidebar order. | — | |
--output, -o | Output .epub path (required). | — | |
--title | Book title. | site.title from _mdsvr/settings.json, else input dir name | |
--author | Book author. | Unknown | |
--language | ISO language code (en, vi, ...). | site.language from settings.json, else en | |
--description | Book description. | site.description from settings.json | |
--cover | Cover image path. | first embedded image | |
--mermaid-aspect | Canvas aspect w:h for rendered mermaid PNGs and table images (e.g. 3:4, 16:9); none keeps natural size. | 3:4 | |
--table-image-cols | Markdown tables with more than N columns are drawn to PNG with Pillow (wide tables get clipped on e-readers); none disables. | 4 |
What it does
- Doc discovery (mdsvr sidebar order). Walks the input directory like
the auto-generated sidebar: names starting with _ or . are hidden (so _mdsvr/ is excluded), each directory's README.md/index.* is emitted first as the section intro, then files and subdirectories interleave alphabetically — 01-, 02- prefixes order the parts.
- Metadata. Reads
<input>/_mdsvr/settings.jsonforsite.title,
site.description, site.language as defaults for the EPUB metadata. Per-page YAML frontmatter title: (else the first # heading) becomes the part label in the TOC.
- MDX downgrade.
.mdxfiles (and.mdfiles containing components)
are preprocessed: import/export lines removed, <Callout type="…"> becomes a styled GitHub alert, <Mermaid> becomes a `mermaid block, <Steps>, <Tabs>/<Tab label> , <Card>, <CardGroup>, <Accordion>, <CodeGroup> are unwrapped, <Badge>x</Badge> becomes inline code. Interactive behavior is lost — content is preserved.
- Mermaid → PNG. Every
`mermaidblock renders via the
mermaid.ink API (e-reader safe — no SVG/JS), landscape diagrams rotate 90°, and results pad onto the --mermaid-aspect canvas. Renders cache under <doc-dir>/images/mermaid/ (raw renders in raw/) next to the source file so re-runs are fast — note this writes cache files inside the docs tree; delete the processed PNGs to re-apply rotation/padding.
- Math → PNG.
$...$inline math,$$...$$display math, and
`math fenced blocks render to PNG via the latex.codecogs.com API (e-readers can't run KaTeX). PNGs cache under <doc-dir>/images/math/; on render failure the LaTeX source is kept with a warning.
- Quiz → static Q&A.
`quizblocks become a numbered question
list with an answer key (True/False rendered as A/B options, self-check shows the model answer in the key). EPUB is not interactive, so grading/scoring is dropped.
- Wide tables → PNG. Tables wider than
--table-image-colscolumns
are drawn locally with Pillow into <doc-dir>/images/tables/.
- Internal links. mdsvr-style links are resolved to EPUB chapter
links: ./page, ./page.md, ./dir/ (→ dir README), ../page, /absolute/path, and #anchor fragments — including cross-chapter anchors (each ##-split chapter keeps its heading ids). Links that don't resolve to a doc in the set are left as-is.
- Alerts. GitHub
> [!NOTE|TIP|WARNING|CAUTION|IMPORTANT]alerts
become styled blockquotes (colored border + background).
- Chapters & TOC. Each doc file splits into chapters at
##
headings; the file becomes a part in the nested nav.xhtml TOC, in sidebar order.
- Images & cover. All referenced local images are embedded
(/assets/… resolves against the docs root); the first image becomes the cover unless --cover is given.
Workflow
Confirm the build plan with the user before running (same convention as x-post-to-epub):
- Point
--inputat the docs folder (e.g../docs). - Confirm title / author / language / output path — suggest defaults from
_mdsvr/settings.json and epub/<dir-name>.epub.
- Run the script, then report: output path, doc page count, chapter
count, image count, cover status. Suggest opening in Apple Books / Calibre to verify.
Notes / limitations
- Mermaid rendering needs network access to mermaid.ink; on failure the
block degrades to a plain code block with a warning.
- Math rendering needs network access to latex.codecogs.com; on failure
the LaTeX source is kept with a warning. Inline-math PNGs sit on the text baseline — alignment is approximate.
- Quiz interactivity (grading,
localStoragestats) does not transfer —
quizzes export as static Q&A with the answer key inline.
- Only locally-referenced images are embedded; remote
https://images
stay as-is (visible only on networked readers).
- MDX interactive components render as static content.
- Cache PNGs are written under
<doc-dir>/images/{mermaid,math,tables}/;
these directories contain no .md files so mdsvr ignores them, but they show up in git status if the docs tree is a repo.
Files
mdsvr_to_epub.py— main Python script (stdlib +markdown+Pillow).
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mdsvr-to-epub/SKILL.md
Popularity
- Repository stars
- 5
- Repository forks
- 1
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/satoshiman/mdsvr/mdsvr-to-epub)