alchaincyf avatar

Huashu Md To Pdf

Converts Markdown documents into Apple-style PDF whitepapers with auto-generated cover, table of contents, and headers.

skills.sh installs
1.1K
GitHub stars
2.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers full Markdown syntax, including code blocks, tables, blockquotes, and lists, with book-level pagination and orphan/widow control
  • Uses the scripts/convert.py script with -o for output name and --title and --author for metadata, via markdown2 and WeasyPrint
  • Requires numbered headings (## 1. Title, ### 1.1 Section) so the table of contents can be extracted and clickable
  • Designed for technical documentation, whitepapers, tutorials, and reports that need professional layout

Install

$ npx -y skills add alchaincyf/huashu-skills --skill huashu-md-to-pdf -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Markdown to PDF Skill

将 Markdown 文档转换为专业的苹果设计风格 PDF 白皮书。

核心功能

  1. 专业排版:书籍级排版质量,自动处理分页、孤行寡行
  2. 苹果设计:SF 字体系统、现代简洁风格、专业配色
  3. 完整目录:自动提取章节结构,双列布局,可点击跳转
  4. Markdown 完美支持:代码块、表格、引用、列表等全部正确渲染

使用方法

基础用法

# 转换单个文件
python scripts/convert.py input.md

# 指定输出文件名
python scripts/convert.py input.md -o "我的白皮书.pdf"

# 自定义标题和作者
python scripts/convert.py input.md --title "技术白皮书" --author "花叔"

图片路径

Markdown 里的相对路径图片,是相对 md 文件自身所在目录解析的,目录名和文件名带中文都可以:

![示意图](图片/架构图.png)     ← 和 md 文件同级的「图片」目录
![示意图](./assets/arch.png)

找不到的图片会在转换时打印警告并列出路径。以前这种情况是静默跳过的,PDF 照样生成、只是没有图。

已知未解决:某些环境下 macOS「预览」打开是乱码

有用户报告生成的 PDF 在 macOS「预览」里是乱码,浏览器打开正常。这个问题还没有解决办法,原因也还没定位——在一台用 Arial Unicode MS 渲染中文的机器上复现不出来,而报告者的字体环境和 weasyprint 版本都不清楚。

不要试图用 weasyprint 的 full_fonts=True 绕过它。 实测:macOS 上的中文字体(PingFang.ttc、Songti.ttc、Hiragino Sans GB.ttc)都是 TrueType Collection,full_fonts=True 会把整个 collection 的原始字节塞进 PDF 的 /FontFile2(magic 是 ttcf 而不是合法的 \x00\x01\x00\x00),结果是文件暴涨到几十 MB,而且照样乱码——实测一段中文从 10 KB 变成 43 MB,渲染出来是「Oě 据⊤」。它让问题更糟,不是逃生出口。

碰到乱码时可以先试:升级 weasyprint、或在 CSS 里换一个非 collection 的字体。

Markdown 文档要求

你的 Markdown 文档应该遵循以下结构:

Details

Repository
github.com/alchaincyf/huashu-skills
Categories
Office Files & Slides, Technical Documentation
First seen
May 16, 2026

More from alchaincyf/huashu-skills

All 21

Similar to Huashu Md To Pdf

More Office Files & Slides