md2xhs
Skill3 starsChanged 9 months agoApache-2.0View on GitHub
Convert a Markdown file into a series of 3:4 ratio PNG images, formatted for Xiaohongshu (RedNote / 小红书). Each page is automatically paginated — elements are never split across pages. Arguments: - file.md — Path to the Markdown file (required). Supports relative and absolute paths. - output-dir — Directory to save the images (optional). Defaults to the same directory as file.md. - --watermark "text" — Watermark text shown in the top-left corner of each image (optional). This skill requires the…
- Installs packages
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
If npm is not available, install Node.js first: https://nodejs.org
- Distinctive: line 54
When this skill is invoked:
- Very specific: line 62
If not found, tell the user: "File not found: <path>.
- Very specific: line 64
If output-dir was provided → use it
- Very specific: line 76
If any path is found → store it as BROWSER_PATH
- Very specific: line 77
If none found → leave BROWSER_PATH unset (Puppeteer uses its bundled Chromium)
- Very specific: line 79
If BROWSER_PATH is set, prepend PUPPETEER_EXECUTABLE_PATH="<BROWSER_PATH>" to the command
- Distinctive: line 84
If exit code is non-zero and output contains "command not found":
- Distinctive: line 86
If exit code is non-zero and output contains "Failed to launch the browser process":
- Distinctive: line 88
If exit code is non-zero for another reason, show the error output to the user
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
md2xhs — Export Markdown to Xiaohongshu (RedNote) Images
Convert a Markdown file into a series of 3:4 ratio PNG images, formatted for Xiaohongshu (RedNote / 小红书). Each page is automatically paginated — elements are never split across pages.
Usage
/md2xhs <file.md> [output-dir] [--watermark "Your Name"]Arguments:
file.md— Path to the Markdown file (required). Supports relative and absolute paths.output-dir— Directory to save the images (optional). Defaults to the same directory asfile.md.--watermark "text"— Watermark text shown in the top-left corner of each image (optional).
Examples:
/md2xhs note.md
/md2xhs note.md ./images
/md2xhs note.md ./images --watermark "LanLance"
/md2xhs ~/Documents/article.mdPrerequisites
This skill requires the md2pic CLI to be installed globally.
Install via npm:
npm install -g md2picVerify installation:
md2pic --helpIf npm is not available, install Node.js first: https://nodejs.org
What It Does
- Parses your Markdown and renders it with full support for:
- Math formulas (KaTeX:
$...$inline,$$...$$block) - Diagrams (Mermaid: flowcharts, sequence diagrams, Gantt charts)
- Data charts (ECharts: bar, line, pie, etc.)
- Callout cards (
:::card info,> [!note]Obsidian syntax) - Code blocks with syntax highlighting (Prism.js)
- Math formulas (KaTeX:
- Splits the content into 3:4 ratio pages — no element is cut in half
- Adds a watermark signature to the top-left corner of each page
- Saves each page as a numbered PNG:
md2pic-xhs-{timestamp}-1.png,-2.png, ...
Implementation
When this skill is invoked:
- Parse args — extract
<file>, optional[output-dir], and optional--watermark "text"from the user's input - Resolve path — convert the file path to absolute using the current working directory
- Check file exists:
If not found, tell the user: "File not found:test -f "<resolved-file>" && echo "exists" || echo "not found"<path>. Please check the path and try again." - Determine output directory:
- If
output-dirwas provided → use it - Otherwise → use
dirnameof the input file
- If
- Detect browser (macOS fallback):
Puppeteer's bundled Chromium may crash on newer macOS versions (25+). Before running the command, probe for a usable browser in this order:
# 1. System Google Chrome (most common on macOS) test -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" && echo "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" # 2. Chromium via Homebrew which chromium 2>/dev/null # 3. Google Chrome CLI alias which google-chrome 2>/dev/null- If any path is found → store it as
BROWSER_PATH - If none found → leave
BROWSER_PATHunset (Puppeteer uses its bundled Chromium)
- If any path is found → store it as
- Build the command:
- If
BROWSER_PATHis set, prependPUPPETEER_EXECUTABLE_PATH="<BROWSER_PATH>"to the command - Without watermark:
[PUPPETEER_EXECUTABLE_PATH="..."] md2pic "<file>" "<outDir>" --xhs - With watermark:
[PUPPETEER_EXECUTABLE_PATH="..."] md2pic "<file>" "<outDir>" --xhs --watermark "<text>"
- If
- Run the command using the Bash tool
- Handle errors:
- If exit code is non-zero and output contains "command not found":
❌
md2picis not installed. Run:npm install -g md2pic - If exit code is non-zero and output contains "Failed to launch the browser process":
❌ Puppeteer could not launch a browser. See the Troubleshooting section below.
- If exit code is non-zero for another reason, show the error output to the user
- If exit code is non-zero and output contains "command not found":
- On success — list the generated files:
ls "<outDir>"/md2pic-xhs-*.png 2>/dev/null - Report results — tell the user how many images were generated and their full paths. Example:
✅ Generated 3 images in
/Users/you/notes/:md2pic-xhs-20260331102817-1.pngmd2pic-xhs-20260331102817-2.pngmd2pic-xhs-20260331102817-3.png
Troubleshooting
| Problem | Solution |
command not found: md2pic | Run npm install -g md2pic |
npm: command not found | Install Node.js from https://nodejs.org |
| Images are blank or empty | Ensure the Markdown file has content |
| Puppeteer fails to launch Chrome (macOS) | The skill auto-detects system Chrome. If it still fails, verify Chrome is installed at /Applications/Google Chrome.app. You can also set the path manually: PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" md2pic ... |
| Puppeteer fails to launch Chrome (Linux) | Install Chrome: apt-get install -y google-chrome-stable, then the skill will auto-detect it via which google-chrome |
| Permission denied on output dir | Check write permissions or choose a different output directory |
About md2pic
md2pic is a zero-build-toolchain Markdown-to-image tool. All rendering happens in a headless browser — no server required, fully offline.
- GitHub: https://github.com/LgoLgo/md2pic
- Web UI: https://lgolgo.github.io/md2pic
- License: Apache-2.0
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

