Markdown to PDF
Convert markdown documents to professional, clean PDFs with proper formatting.
Usage
CODEBLOCK0
Features
- - Headers: H1-H6 with hierarchical styling
- Text formatting: Bold, italic, inline code
- Lists: Bullet lists, numbered lists, task lists
- Code blocks: Syntax highlighting with background
- Tables: Full table support with headers
- Links: Clickable hyperlinks
- Horizontal rules: Visual section dividers
- YAML frontmatter: Automatically skipped
- Special characters: Emojis, Unicode symbols
- Page numbers: Automatic footer with page numbers
- Professional styling: Clean, readable output
Options
- -
-o, --output: Output PDF file path (default: input_filename.pdf) - INLINECODE1 : Print detailed processing information
Supported Markdown Elements
| Element | Syntax | Status |
|---|
| Headers | INLINECODE2 to INLINECODE3 | ✅ |
| Bold |
**text** or
__text__ | ✅ |
| Italic |
*text* or
_text_ | ✅ |
| Inline code | `
code
| ✅ |
| Code blocks | `
| ✅ |
| Bullet lists | - item
or item | ✅ |
| Numbered lists | 1. item | ✅ |
| Task lists | - [x] done | ✅ |
| Tables | | col | col | | ✅ |
| Links | text | ✅ |
| Horizontal rules | --- or | ✅ |
| Blockquotes | > quote` | ✅ |
Markdown 转 PDF
将 Markdown 文档转换为格式规范、清晰专业的 PDF 文件。
使用方法
bash
基本用法
uv run scripts/md-to-pdf.py input.md
指定输出文件
uv run scripts/md-to-pdf.py input.md -o output.pdf
uv run scripts/md-to-pdf.py input.md --output my-report.pdf
详细模式
uv run scripts/md-to-pdf.py input.md -v
功能特性
- - 标题:支持 H1-H6 层级样式
- 文本格式:粗体、斜体、行内代码
- 列表:无序列表、有序列表、任务列表
- 代码块:语法高亮并带背景色
- 表格:完整表格支持,含表头
- 链接:可点击的超链接
- 水平分割线:可视化段落分隔符
- YAML 前置元数据:自动跳过
- 特殊字符:表情符号、Unicode 符号
- 页码:自动添加页脚页码
- 专业样式:清晰、可读性强的输出效果
选项参数
- - -o, --output:输出 PDF 文件路径(默认:输入文件名.pdf)
- -v, --verbose:打印详细处理信息
支持的 Markdown 元素
| 元素 | 语法 | 状态 |
|---|
| 标题 | # H1 至 ###### H6 | ✅ |
| 粗体 |
文本 或
文本 | ✅ |
| 斜体 |
文本 或
文本 | ✅ |
| 行内代码 | 代码 | ✅ |
| 代码块 | | ✅ |
| 无序列表 | - 项目 或 * 项目 | ✅ |
| 有序列表 | 1. 项目 | ✅ |
| 任务列表 | - [x] 已完成 | ✅ |
| 表格 | | 列 | 列 | | ✅ |
| 链接 |
文本 | ✅ |
| 水平分割线 | --- 或
* | ✅ |
| 引用块 | > 引用内容 | ✅ |