document-gen-resilient-multiformat
它能做什么
这项技能引导 AI 把同一份文档源转换为多种格式,并先检查工具。它适合希望在多种文件类型中使用同一份文档,又不想猜测哪些工具已安装的人。
适用场景
- ✓当我需要同一份文档的 Word 文件、PDF 和网页版本的时候。
- ✓当我的电脑上可能缺少 pandoc 或 PDF 引擎的时候。
- ✓当文本包含在各种格式中表现不同的特殊字符的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-618c9b/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把这份文档制作成 Word、PDF 和 HTML 格式,如果有任何工具缺失,请告诉我。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会检查哪些工具已安装,编写源文档,为每种格式调整特殊字符,进行转换,并确认每个输出文件存在且有效。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Resilient Document Generation Workflow (Multi-Format + Unicode-Safe)
When to Use
Use this skill when generating documents in multiple formats (.docx, .pdf, .html) and you need:
- Reliable execution with pre-flight environment verification
- Automatic Unicode handling based on target format
- Fallback options when primary tools (pandoc/LaTeX) are unavailable
- Clear error isolation through discrete, observable steps
Trigger this workflow when:
shell_agentreturns unknown/unclear errors on document generation- You need multiple output formats from one source
- Documents contain special characters, symbols, or non-ASCII text
- Previous PDF generation attempts failed due to encoding or missing dependencies
Pre-Flight Environment Check
Before starting, verify your environment has the required tools:
run_shell
command: which pandoc && pandoc --version | head -1
run_shell
command: which pdflatex || which xelatex || which wkhtmltopdf || echo "No PDF engine found"
run_shell
command: python3 -c "import fpdf; print('fpdf2 available')" 2>/dev/null || echo "fpdf2 not available"
run_shell
command: python3 -c "import reportlab; print('reportlab available')" 2>/dev/null || echo "reportlab not available"
If pandoc is missing: Install via apt-get install pandoc or brew install pandoc
If no PDF engine found: Choose fallback approach:
- Install LaTeX:
apt-get install texlive-latex-recommended texlive-fonts-recommended - Or use wkhtmltopdf:
apt-get install wkhtmltopdf - Or use Python fallback (fpdf2/reportlab) - see Alternative PDF Generation section
Core Technique
Split the workflow into discrete, observable steps with automatic format detection:
- Environment check → Verify tools are available
- Content creation → Use
write_fileto create source Markdown - Auto-sanitization → Conditionally sanitize based on target format (PDF needs it, DOCX/HTML don't)
- Format conversion → Use appropriate tool for each format with fallback options
- Verification → Check output files exist and validate content
⚠️ Unicode & Format Compatibility Matrix
| Format | Unicode Support | Sanitization Needed | Recommended Engine |
|---|---|---|---|
.docx |
Excellent | No | pandoc (default) |
.html |
Excellent | No | pandoc (default) |
.pdf |
Limited (LaTeX) | Yes | xelatex > pdflatex > wkhtmltopdf > fpdf2 |
.pptx |
Good | No | pandoc (if available) or python-pptx |
Critical Unicode Characters for PDF
| Character | Issue | Safe Replacement |
|---|---|---|
— (em dash) |
May not render | -- or - |
– (en dash) |
May not render | - |
" " (curly quotes) |
Encoding errors | " " (straight quotes) |
' ' (curly apostrophe) |
Encoding errors | ' (straight apostrophe) |
… (ellipsis) |
May not render | ... |
→ ← ↑ ↓ (arrows) |
LaTeX incompatibility | -> <- ^ v |
✓ ✗ (checkmarks) |
May not render | [x] [ ] |
★ ● (symbols) |
May not render | * - |
© ® ™ |
May require packages | (c) (r) (tm) |
| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |
Step-by-Step Workflow
Step 0: Pre-Flight Check
Verify environment before proceeding:
run_shell
command: pandoc --version >/dev/null 2>&1 && echo "PANDOC_OK" || echo "PANDOC_MISSING"
If PANDOC_MISSING: Either install pandoc or use Alternative PDF Generation (Python-based)
Step 1: Create Source Content with write_file
Write your document content as Markdown to a source file:
write_file
path: /tmp/document_source.md
content: |
# Document Title
## Section 1
Content with original unicode characters...
## Section 2
More content...
Step 2: Conditional Unicode Sanitization
Only sanitize if generating PDF. Create sanitized version for PDF conversion:
write_file
path: /tmp/document_source_sanitized.md
content: |
# Document Title
## Section 1
Content with unicode replaced (em-dash -> --, curly quotes -> straight, etc.)
## Section 2
More content...
Optional: Use sanitization script (see Unicode Sanitization Script section below):
run_shell
command: ./sanitize_for_pdf.sh /tmp/document_source.md /tmp/document_source_sanitized.md
Note: Keep the original unsanitized file for DOCX/HTML conversion (these
常见问题
如果找不到 PDF 引擎怎么办?
指南提供 Python 备用方案,例如 fpdf2 或 reportlab。
它会安装缺失的工具吗?
指南提到,当缺少 pandoc 或 LaTeX 引擎时,可以用系统包管理命令进行安装。
为什么要关注特殊字符?
每种格式处理 Unicode 的方式不同,因此指南对此做了规划。
详情
作者的原始描述
Resilient multi-format document generation with environment checks, auto-sanitization, and fallback engines
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12858
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。