关于 pandoc-converter
Pandoc Converter 是一项通过 Pandoc 在常见格式间转换文档的技能,支持多种文档格式及只读表格数据输入,并可设置目录和 PDF 引擎等选项。
主要功能
- 01转换常见文档格式
- 02读取 CSV、TSV 和 XLSX 输入
- 03支持 GFM 与 CommonMark 变体
- 04指定输入和输出格式
- 05添加独立文档页眉及目录
- 06透传 Pandoc 选项
适用场景
- 01将 Markdown 转为 DOCX、PDF 或 HTML
- 02将 DOCX 文档转为 Markdown
- 03将 CSV 数据转换为 HTML 表格
- 04将 LaTeX 文档转换为 PDF
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jrajasekera/ jr-agent-skills --skill pandoc-converter安装后在 Claude Code 中输入/pandoc-converter确认已加载。
附带文件references/format-compatibility.mdscripts/convert.py
详细介绍
Pandoc 转换器
使用 Pandoc 在常见格式之间转换文档。
快速开始
# Basic conversion (format auto-detected from extensions)
python scripts/convert.py input.md output.docx
# Specify output format only
python scripts/convert.py document.md --to html
# Check if Pandoc is installed
python scripts/convert.py --check
# List supported formats
python scripts/convert.py --formats
支持的格式
文档格式(读写): markdown、html、docx、latex、epub、rtf、pptx、pdf
数据格式(只读): csv、tsv、xlsx
Markdown 变体: gfm(GitHub)、commonmark
有关兼容性的详细信息,请参阅 references/format-compatibility.md。
常见转换
| 源格式 | 目标格式 | 命令 |
|---|---|---|
| Markdown | Word | python scripts/convert.py doc.md doc.docx |
| Markdown | python scripts/convert.py doc.md doc.pdf | |
| Markdown | HTML | python scripts/convert.py doc.md doc.html |
| Word | Markdown | python scripts/convert.py doc.docx doc.md |
| CSV | HTML 表格 | python scripts/convert.py data.csv data.html |
| LaTeX | python scripts/convert.py paper.tex paper.pdf |
选项
| 选项 | 描述 |
|---|---|
--from <fmt> | 覆盖输入格式检测结果 |
--to <fmt> | 指定输出格式(未提供输出文件时) |
--standalone | 包含文档页眉和页脚 |
--toc | 添加目录 |
--pdf-engine <eng> | PDF 引擎:pdflatex、xelatex、lualatex |
其他 Pandoc 选项会直接传递。
工作流
- 检查是否已安装: 运行
python scripts/convert.py --check - 如果尚未安装: 按照提供的安装说明操作
- 转换: 使用输入和输出文件运行转换
- 提供结果: 将转换后的文件提供给用户
安装(如有需要)
脚本会提供安装指引,以下是概要:
# macOS
brew install pandoc
# Ubuntu/Debian
sudo apt-get install pandoc
# For PDF output, also install LaTeX:
# macOS: brew install --cask mactex-no-gui
# Ubuntu: sudo apt-get install texlive-xetex
限制
- CSV/TSV/XLSX: 仅支持作为输入(会转换为其他格式中的表格)
- PDF 输出: 需要安装 LaTeX
- PPTX: 可提取文本;复杂布局可能会被简化
- 复杂格式: 某些功能可能无法在不同格式之间保留
评论
支持 Markdown