
Huashu Md To Pdf
Turn Markdown guides, READMEs, and whitepapers into styled PDFs from the repo without leaving your agent session.
Overview
Huashu Markdown to PDF is an agent skill most often used in Build (also Validate, Launch) that converts local Markdown files to formatted PDFs via a Python script.
Install
npx skills add https://github.com/alchaincyf/huashu-skills --skill huashu-md-to-pdfWhat is this skill?
- Runs `convert.py` with metadata extraction, TOC from headings, HTML intermediate, and final PDF output
- Supports custom title, author, and `-o` output paths including non-ASCII filenames
- Batch-convert all `*.md` in a directory with a simple shell loop
- Reports file size and path after generation for quick preview (`open` on macOS)
- Documents a structured Markdown template for whitepapers and tech guides
- Extracts 5 main chapters and 12 sub-chapters in the sample TOC walkthrough
- Example output sizes cited at 0.8 MB and 1.2 MB
Adoption & trust: 757 installs on skills.sh; 939 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have polished Markdown in the repo but investors, customers, or compliance need a fixed-layout PDF without manual copy-paste.
Who is it for?
Solo builders exporting READMEs, guides, or whitepapers from git-tracked `.md` files with optional Chinese filenames and batch folder runs.
Skip if: Teams that need collaborative WYSIWYG layout, live CMS publishing, or PDF generation without shell access to run Python in the project.
When should I use this skill?
User asks to turn a `.md` file into PDF, rename the output, set title/author, or batch-convert Markdown in a directory.
What do I get? / Deliverables
You get a generated PDF (optionally renamed and titled) plus path and size confirmation so you can attach or distribute the doc immediately.
- Single or multiple `.pdf` files
- Console log with path and file size
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Technical writing and export usually happen while you are still assembling product and repo documentation in the Build phase. The skill reads `.md` sources, extracts headings for TOC, and emits PDF deliverables—classic docs pipeline work.
Where it fits
Export a landing-page spec written in Markdown into a PDF you can email before building the full site.
Convert `tech-guide.md` with extracted TOC into `tech-guide.pdf` after finishing the integration chapter.
Generate a release notes PDF from Markdown for attach-to-email ship announcements.
Produce 产品说明书.pdf from README.md for marketplace or partner onboarding packets.
How it compares
Use instead of pasting Markdown into a one-off online converter when you want repeatable, scriptable exports inside the agent workflow.
Common Questions / FAQ
Who is huashu-md-to-pdf for?
Indie developers and small teams who document in Markdown and need PDF handoffs for clients, launches, or internal review from Claude Code, Cursor, or Codex.
When should I use huashu-md-to-pdf?
During Build when finalizing docs; in Validate when turning a prototype README into a pitch PDF; at Launch when packaging a whitepaper or product manual for distribution.
Is huashu-md-to-pdf safe to install?
It runs local filesystem reads and a Python script—review the Security Audits panel on this page and inspect `convert.py` before running on sensitive repos.
SKILL.md
READMESKILL.md - Huashu Md To Pdf
# Markdown to PDF Skill 使用示例 ## 示例 1: 基础转换 **用户提问**: ``` 帮我把 tech-guide.md 转成 PDF ``` **Claude 执行**: ```bash python .claude/skills/markdown-to-pdf/scripts/convert.py tech-guide.md ``` **输出**: ``` 📖 读取文件: tech-guide.md 📑 提取元数据... 📂 提取目录结构... ✓ 找到 5 个主章节 ✓ 找到 12 个子章节 🎨 处理 Markdown 内容... 📄 生成 HTML... 📝 生成 PDF... ✅ 成功生成: tech-guide.pdf 📊 文件大小: 0.8 MB ``` --- ## 示例 2: 自定义输出 **用户提问**: ``` 把 README.md 转成 PDF,输出文件名叫"产品说明书.pdf" ``` **Claude 执行**: ```bash python .claude/skills/markdown-to-pdf/scripts/convert.py README.md -o "产品说明书.pdf" ``` --- ## 示例 3: 完整自定义 **用户提问**: ``` 转换 whitepaper.md,标题改成"技术白皮书2025",作者写"技术团队" ``` **Claude 执行**: ```bash python .claude/skills/markdown-to-pdf/scripts/convert.py whitepaper.md \ --title "技术白皮书2025" \ --author "技术团队" \ -o "技术白皮书2025.pdf" ``` --- ## 示例 4: 批量转换 **用户提问**: ``` 把当前目录下所有 .md 文件都转成 PDF ``` **Claude 执行**: ```bash for file in *.md; do python .claude/skills/markdown-to-pdf/scripts/convert.py "$file" done ``` --- ## 示例 5: 转换后预览 **用户提问**: ``` 转换 guide.md 并告诉我文件在哪 ``` **Claude 执行**: ```bash python .claude/skills/markdown-to-pdf/scripts/convert.py guide.md ``` **Claude 回复**: ``` ✅ 已成功生成 PDF: guide.pdf 📍 文件位置: /Users/xxx/Documents/guide.pdf 📊 文件大小: 1.2 MB 你可以直接打开查看,或者用以下命令预览: open guide.pdf ``` --- ## Markdown 文档模板 如果你的文档还没有结构,可以参考这个模板: ```markdown # 技术文档标题 ## 1. 简介 ### 1.1 背景 这里写背景介绍... ### 1.2 目标 这里写文档目标... ## 2. 核心概念 ### 2.1 概念A 解释概念... ### 2.2 概念B 解释概念... ## 3. 使用方法 ### 3.1 安装 安装步骤... \`\`\`bash npm install xxx \`\`\` ### 3.2 配置 配置说明... | 参数 | 说明 | 默认值 | |------|------|--------| | foo | 配置项 | true | ## 4. 最佳实践 ### 4.1 实践A 实践说明... ### 4.2 实践B 实践说明... ## 5. 常见问题 ### 5.1 问题1 解答... ### 5.2 问题2 解答... ``` --- ## 高级技巧 ### 技巧 1: 在脚本中调用 ```python from pathlib import Path import subprocess # 批量转换 md_files = Path('.').glob('*.md') for md_file in md_files: subprocess.run([ 'python', '.claude/skills/markdown-to-pdf/scripts/convert.py', str(md_file) ]) ``` ### 技巧 2: 添加到快捷命令 在 `.bash_profile` 或 `.zshrc` 中添加: ```bash alias md2pdf='python ~/.claude/skills/markdown-to-pdf/scripts/convert.py' ``` 然后就可以直接使用: ```bash md2pdf document.md md2pdf report.md -o "2025年度报告.pdf" ``` ### 技巧 3: 与 Git Hooks 结合 在 `.git/hooks/pre-commit` 中: ```bash #!/bin/bash # 自动生成 PDF 版本 if [ -f README.md ]; then python .claude/skills/markdown-to-pdf/scripts/convert.py README.md git add README.pdf fi ``` --- ## 真实使用案例 ### 案例 1: Claude Skills 白皮书 - **输入**:2万字 Markdown 文档 - **输出**:1.4 MB 专业 PDF - **特点**:10个主章节,38个子章节,双列目录 ### 案例 2: 技术文档 - **输入**:API 文档 Markdown - **输出**:带目录的技术手册 - **特点**:代码高亮、表格清晰 ### 案例 3: 产品说明书 - **输入**:产品介绍 Markdown - **输出**:专业说明书 PDF - **特点**:苹果设计风格、易读性强 # Markdown to PDF Skill 将 Markdown 文档转换为专业的苹果设计风格 PDF 白皮书。 ## 快速开始 ### 1. 安装依赖(仅首次) ```bash pip3 install markdown2 weasyprint ``` ### 2. 基础使用 ```bash # 转换 Markdown 文件 python .claude/skills/markdown-to-pdf/scripts/convert.py your-file.md # 指定输出文件名 python .claude/skills/markdown-to-pdf/scripts/convert.py your-file.md -o "我的白皮书.pdf" # 自定义标题和作者 python .claude/skills/markdown-to-pdf/scripts/convert.py your-file.md --title "技术白皮书" --author "花叔" ``` ## Markdown 格式要求 你的文档应该使用带序号的章节格式: ```markdown # 文档标题 ## 1. 第一章 ### 1.1 第一节 内容... ### 1.2 第二节 内容... ## 2. 第二章 ### 2.1 第一节 ... ``` **关键点**: - ✅ `## 1. 标题` - 正确(数字.空格标题) - ❌ `## 标题` - 错误(无序号) - ✅ `### 1.1 标题` - 正确 - ❌ `### 标题` - 错误 ## 设计特点 - 📖 **书籍级排版**:自动分页、孤行寡行控制 - 🎨 **苹果设计语言**:SF 字体、现代简洁 - 📑 **自动目录**:双列布局、可点击跳转 - 💻 **完美代码块**:语法高亮、圆角边框 - 📊 **专业表格**:清晰网格、自动表头 ## 文件结构 ``` .claude/skills/markdown-to-pdf/ ├── SKILL.md # Skill 说明文档 ├── README.md # 本文件 └── scripts/ └── convert.py # 转换脚本 ``` ## 示例 在 Claude Code 中使用: ``` 用户:帮我把这个 Markdown 文档转成 PDF Claude:好的,我使用 markdown-to-pdf skill 来转换 [执行] python .claude/skills/markdown-to-pdf/scripts/convert.py document.md ✅ 已生成 document.pdf ``` ## 常见问题 **Q: WeasyPrint 安装失败?** ```bash # macOS brew install pango pip3 in