wentorai/research-claw/md2pdf-export
Claude Code and agent skill by wentorai/research-claw
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Convert Markdown files to PDF, PNG, or JPEG using headless Chrome (Puppeteer), following the same methodology as VS Code's Markdown Preview Enhanced extension. Use this skill whenever the user asks to: export/convert/render markdown to PDF or image, generate a printable document from .md files, create publication-ready PDFs from markdown, set up a markdown-to-PDF pipeline, or install/configure the Node.js + Puppeteer + Chrome environment needed for headless rendering. Also trigger when the user mentions "md2pdf", "markdown export", "puppeteer PDF", "headless chrome PDF", "crossnote", "mume", or wants WYSIWYG-quality PDF output from markdown source files. This skill covers both environment setup AND the actual conversion process.
Install
npx vskill@latest install wentorai/research-claw/md2pdf-exportSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as wentorai/research-claw/md2pdf-export.
Markdown → PDF/PNG/JPEG Export (Puppeteer Method)
Architecture Overview
The conversion pipeline mirrors Markdown Preview Enhanced's chromeExport():
The key insight: Chrome IS the rendering engine. What Chrome renders is what you get — true WYSIWYG.
Step 0: Environment Check & Setup
Before any conversion, verify the environment is ready. Run the setup script:
This script is idempotent — safe to run multiple times. It handles:
- Detecting OS (macOS / Ubuntu / Debian / Alpine / CentOS)
- Installing Node.js (via nvm, prefers LTS)
- Installing npm packages globally:
puppeteer(which bundles Chromium) - Verifying Chrome/Chromium is launchable in headless mode
- Printing a diagnostic summary
If the user's system already has Node.js ≥ 18 and puppeteer installed, the script skips those steps.
Manual Setup (if the script fails)
For environments where the automated script doesn't work (e.g. restricted Docker containers):
Using an Existing Chrome Installation
If the system already has Chrome/Chromium installed, set the environment variable to skip Chromium download:
Step 1: Convert Markdown to HTML
Use markdown-it with plugins for a feature-rich render. The conversion script at skills/md2pdf-export/scripts/md2pdf.js handles this internally, but the logic is:
- Read the
.mdfile - Parse YAML front-matter (for puppeteer config overrides)
- Render Markdown → HTML via
markdown-itwith these plugins:
markdown-it-texmath+ KaTeX for math ($...$, $$...$$)markdown-it-highlightjsfor syntax highlightingmarkdown-it-anchor+markdown-it-toc-done-rightfor TOCmarkdown-it-footnotefor footnotes
- Wrap in a full HTML document with:
- A CSS theme (GitHub-light by default, configurable)
- Embedded styles for print (
@media printrules) - All resources inlined (no external dependencies)
Step 2: Launch Headless Chrome & Export
The script then:
- Launches Puppeteer with
headless: 'new'(new headless mode) - Creates a new page, sets viewport (for PNG/JPEG) or paper size (for PDF)
- Loads the HTML via
page.setContent()orpage.goto('file://...') - Waits for rendering to complete (
waitUntil: 'networkidle0') - Calls the appropriate Puppeteer API:
- PDF:
page.pdf({ path, format, printBackground, margin, ... }) - PNG:
page.screenshot({ path, fullPage: true, type: 'png' }) - JPEG:
page.screenshot({ path, fullPage: true, type: 'jpeg', quality })
- Closes the browser
Running the Conversion
Basic Usage
Front-Matter Configuration
Users can embed Puppeteer config directly in the Markdown file's YAML front-matter:
CLI Options Reference
| Option | Default | Description | |
|---|---|---|---|
--type | pdf | Output type: pdf, png, jpeg | |
-o, --output | <input>.pdf | Output file path | |
--format | A4 | Paper format (A3, A4, A5, Letter, Legal, Tabloid) | |
--landscape | false | Landscape orientation | |
--no-background | Disable printing background graphics | ||
--margin | 10mm | Uniform margin (or use --margin-top etc.) | |
--quality | 80 | JPEG quality (1-100) | |
--scale | 1 | Device scale factor for screenshots | |
--width | 1200 | Viewport width for screenshots | |
--theme | github | CSS theme: github, github-dark, minimal | |
--chrome-path | auto | Path to Chrome/Chromium executable | |
--wait | 0 | Extra wait time in ms after page load | |
--toc | false | Generate table of contents |
Programmatic Usage (Node.js)
For integration into agent pipelines:
Troubleshooting
| Symptom | Cause | Fix | |
|---|---|---|---|
| "Chromium revision is not downloaded" | Puppeteer can't find Chrome | Run npx puppeteer browsers install chrome or set PUPPETEER_EXECUTABLE_PATH | |
| Blank PDF | Page not fully rendered before export | Increase --wait timeout, or check for async content | |
| Missing fonts (CJK, etc.) | System fonts not installed | Install fonts-noto-cjk (Ubuntu) or noto-fonts-cjk (Arch) | |
| "No usable sandbox" on Linux | Chrome sandboxing in Docker | Add --no-sandbox arg (already handled by the script in Docker detection) | |
| Math not rendering | KaTeX CSS not loaded | Ensure markdown-it-texmath + KaTeX are in dependencies | |
| Mermaid diagrams missing | Client-side JS not executed | Use --wait 2000 to give Mermaid time to render |
Advanced: Batch Conversion
For converting an entire directory of Markdown files:
Reference Files
references/puppeteer-config.md— Full Puppeteerpage.pdf()andpage.screenshot()API optionsreferences/themes.md— Available CSS themes and how to create custom ones
Security
- Security scanPassed, 93 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/md2pdf-export/SKILL.md
Popularity
- Repository stars
- 846
- Repository forks
- 114
- 7-day trend score
- 34
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
configConfiguration overrides
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/wentorai/research-claw/md2pdf-export)