跳到正文
Skillpedia
PDF、Word 与幻灯片7.8k · #12858

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-618c9b/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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_agent returns 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:

  1. Environment check → Verify tools are available
  2. Content creation → Use write_file to create source Markdown
  3. Auto-sanitization → Conditionally sanitize based on target format (PDF needs it, DOCX/HTML don't)
  4. Format conversion → Use appropriate tool for each format with fallback options
  5. 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能