File contents Markdown to XHS Images
Convert a Markdown article into fixed-size Xiaohongshu (小红书) long-form images.
Usage
/xhs-md2img posts/turing-story/source.md
Script Directory
Important : All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions :
Determine this SKILL.md file's directory path as SKILL_DIR
Script path = ${SKILL_DIR}/scripts/<script-name>.ts
Replace all ${SKILL_DIR} in this document with the actual path
Script Reference :
Script
Purpose
scripts/md2image.ts
Main script to convert Markdown to images
File Structure
Output directory: xhs-img/{topic-slug}/
Slug: 2-4 words kebab-case from topic (e.g., alan-turing-bio)
Conflict: append timestamp (e.g., turing-story-20260118-143052)
Contents :
File
Description
source.{ext}
Source files
pages/temp.html
Temporary HTML file for rendering
NN-page.png
Generated images
Workflow
Progress Checklist
Comic Progress:
- [ ] Step 1: Check existing
- [ ] Step 2: Generate images
- [ ] Step 3: Completion report
Step Summary
Step
Action
Key Output
1
Check existing directory
Handle conflicts
2
Generate images
NN-page.png
3
Completion report
Summary
Step 2: Image Generation ⚠️ CRITICAL
# Basic (render directly from the original Markdown)
npx -y bun ${SKILL_DIR}/scripts/md2image.ts article.md \
--out xhs-img/${TOPIC_SLUG} \
--width 1440 --height 1920 \
--device-scale 2 \
--body-font-px 50 \
--font sans \
Options
Option
Description
<markdown-file>
Input Markdown file path (required)
--out <dir>
Output directory (default: xhs-img). Supports nested paths like xhs-img/<topic-slug>
--width <px>
Single-page width (default: 1440)
--height <px>
Single-page height (default: 1920, 3:4)
--device-scale <n>
Device scale factor / DPR (default: 2)
--body-font-px <px>
Body font size in px (default: 50)
--font <sans|serif>
Body font family style (default: sans)
Environment Variables
Variable
Description
(none)
No environment variables are required by this skill
Load Priority : CLI args > defaults
Browser Selection
If a system browser is found (Chrome/Edge/Chromium by OS-specific known paths) → launch it via Playwright executablePath
Otherwise → use Playwright bundled Chromium
Pagination & Output
Auto pagination: content flows into CSS columns (column-width = page width, column-gap = 0)
Page count: computed from rendered content’s maximum right edge
Screenshot: one image per page via clip: { x: pageIndex * width, y: 0, width, height }
Rendering Notes
Relative images in Markdown are rewritten to absolute file://... URLs
Horizontal rules (---) are not rendered (treated as semantic separators but visually noisy)
Error Handling
Missing Markdown file → exit with error
Browser not found → fallback to Playwright Chromium
1 --- 2 name: xhs-md2img 3 description: Xhs Md2img 4 --- 5 6 # Markdown to XHS Images 7 8 Convert a Markdown article into fixed-size Xiaohongshu (小红书) long-form images. 9 10 ## Usage 11 12 ```bash 13 /xhs-md2img posts/turing-story/source.md 14 ``` 15 16 ## Script Directory 17 18 **Important**: All scripts are located in the `scripts/` subdirectory of this skill. 19 20 **Agent Execution Instructions**: 21 1. Determine this SKILL.md file's directory path as `SKILL_DIR` 22 2. Script path = `${SKILL_DIR}/scripts/<script-name>.ts` 23 3. Replace all `${SKILL_DIR}` in this document with the actual path 24 25 **Script Reference**: 26 | Script | Purpose | 27 |--------|---------| 28 | `scripts/md2image.ts` | Main script to convert Markdown to images | 29 30 ## File Structure 31 32 Output directory: `xhs-img/{topic-slug}/` 33 - Slug: 2-4 words kebab-case from topic (e.g., `alan-turing-bio`) 34 - Conflict: append timestamp (e.g., `turing-story-20260118-143052`) 35 36 **Contents**: 37 | File | Description | 38 |------|-------------| 39 | `source.{ext}` | Source files | 40 | `pages/temp.html` | Temporary HTML file for rendering | 41 | `NN-page.png` | Generated images | 42 43 44 ## Workflow 45 46 ### Progress Checklist 47 48 ``` 49 Comic Progress: 50 - [ ] Step 1: Check existing 51 - [ ] Step 2: Generate images 52 - [ ] Step 3: Completion report 53 ``` 54 ### Step Summary 55 56 | Step | Action | Key Output | 57 |------|--------|------------| 58 | 1 | Check existing directory | Handle conflicts | 59 | **2** | Generate images | `NN-page.png` | 60 | 3 | Completion report | Summary | 61 62 ### Step 2: Image Generation ⚠️ CRITICAL 63 64 ```bash 65 # Basic (render directly from the original Markdown) 66 npx -y bun ${SKILL_DIR}/scripts/md2image.ts article.md \ 67 --out xhs-img/${TOPIC_SLUG} \ 68 --width 1440 --height 1920 \ 69 --device-scale 2 \ 70 --body-font-px 50 \ 71 --font sans \ 72 ``` 73 74 ## Options 75 76 | Option | Description | 77 |--------|-------------| 78 | `<markdown-file>` | Input Markdown file path (required) | 79 | `--out <dir>` | Output directory (default: `xhs-img`). Supports nested paths like `xhs-img/<topic-slug>` | 80 | `--width <px>` | Single-page width (default: `1440`) | 81 | `--height <px>` | Single-page height (default: `1920`, 3:4) | 82 | `--device-scale <n>` | Device scale factor / DPR (default: `2`) | 83 | `--body-font-px <px>` | Body font size in px (default: `50`) | 84 | `--font <sans\|serif>` | Body font family style (default: `sans`) | 85 86 ## Environment Variables 87 88 | Variable | Description | 89 |----------|-------------| 90 | (none) | No environment variables are required by this skill | 91 92 **Load Priority**: CLI args > defaults 93 94 ## Browser Selection 95 96 1. If a system browser is found (Chrome/Edge/Chromium by OS-specific known paths) → launch it via Playwright `executablePath` 97 2. Otherwise → use Playwright bundled Chromium 98 99 ## Pagination & Output 100 101 - Auto pagination: content flows into CSS columns (`column-width = page width`, `column-gap = 0`) 102 - Page count: computed from rendered content’s maximum right edge 103 - Screenshot: one image per page via `clip: { x: pageIndex * width, y: 0, width, height }` 104 105 ## Rendering Notes 106 107 - Relative images in Markdown are rewritten to absolute `file://...` URLs 108 - Horizontal rules (`---`) are not rendered (treated as semantic separators but visually noisy) 109 110 111 ## Error Handling 112 113 - Missing Markdown file → exit with error 114 - Browser not found → fallback to Playwright Chromium
daqi/daqi-skills/tree/main/skills/xhs-md2img commit f0e3c21667
Frequently asked questions How do I install the Xhs Md2img skill? Run npx skillmds@latest add daqi/xhs-md2img in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Xhs Md2img skill do? Xhs Md2img It is listed under Coding & Dev Tools on SkillMD.
Is Xhs Md2img safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Xhs Md2img? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Xhs Md2img free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Xhs Md2img? daqi (@daqi) published this skill. Their other Agent Skills are listed on their SkillMD profile.