document-gen-unicode-safe
它能做什么
这项技能在文本包含特殊字符,或常用工具失败时,引导 AI 制作多种格式的文档。它适合导出时因符号或重音字符而出错的人。
适用场景
- ✓当我的文档中有破折号、弯引号、箭头或重音字母,导致 PDF 出错的时候。
- ✓当常用的文档工具返回含糊不清的错误的时候。
- ✓当我需要同时得到同一份 Word、PDF 和 HTML 文档的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-c5d426/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的文档中有弯引号和重音字母,PDF 导出一直失败。你能制作能正常使用的 Word、PDF 和 HTML 版本吗?”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会判断适合简单路线还是谨慎的手动路线,替换 PDF 工具无法显示的字符,转换每种格式,并检查文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Document Generation Fallback Workflow (Unicode-Safe)
When to Use
First, assess whether to delegate to shell_agent or use manual workflow:
✅ Use shell_agent Directly When:
- Document is straightforward (no special Unicode characters, symbols, or non-ASCII text)
- Single format output needed (e.g., just
.docx) - Content is primarily ASCII text with standard punctuation
- No complex formatting requirements (tables, equations, custom templates)
- You want quick iteration and
shell_agenthas succeeded on similar tasks before
⚠️ Use Manual Workflow When:
shell_agentreturns unknown or unclear errors- Document contains special characters, symbols, or non-ASCII text (see Unicode table below)
- Generating multiple formats simultaneously (e.g.,
.docx,.pdf,.html) - PDF generation fails due to LaTeX encoding issues
- You need fine-grained control over each conversion step
- Previous
shell_agentattempts failed on similar content
📋 Decision Checklist
1. Does the document contain: em-dashes (—), curly quotes (" "), arrows (→),
checkmarks (✓), or other special symbols? → Use Manual Workflow
2. Is non-ASCII text present (é, ñ, ü, 中文,العربية)? → Use Manual Workflow with sanitization
3. Did shell_agent already fail on this or similar content? → Use Manual Workflow
4. Need multiple output formats with guaranteed success? → Use Manual Workflow
5. Simple ASCII document, single format, first attempt? → Try shell_agent First
Core Technique
Quick Path (for straightforward documents): Delegate directly to shell_agent with clear instructions:
shell_agent
task: Create a Word document from markdown content. Write the markdown to
/tmp/document.md, then convert to .docx using pandoc, and verify the output exists.
Manual Path (for complex/Unicode-heavy documents): Split the workflow into discrete, observable steps:
- Content creation → Use
write_fileto create source document (Markdown) - Unicode sanitization → Preprocess markdown to replace problematic characters before PDF conversion
- Format conversion → Use
run_shellwithpandocfor each target format - Verification → Check output files exist and are valid
Why This Adaptive Approach?
| Scenario | Recommended Approach | Rationale |
|---|---|---|
| Simple ASCII doc, single format | shell_agent | Faster, less manual overhead |
| Unicode symbols present | Manual workflow | Prevents LaTeX encoding failures |
| Previous shell_agent failure | Manual workflow | Avoids repeat failures |
| Multiple formats needed | Manual workflow | Granular control per format |
| Time-sensitive, low-risk | shell_agent first | Try fast path, fallback if needed |
- Content creation → Use
write_fileto create source document (Markdown) - Unicode sanitization → Preprocess markdown to replace problematic characters before PDF conversion
- Format conversion → Use
run_shellwithpandocfor each target format - Verification → Check output files exist and are valid
⚠️ Unicode & LaTeX Compatibility Warning
Critical: PDF generation via pandoc typically uses LaTeX (pdflatex or xelatex), which has limited Unicode support. Common problematic characters include:
| 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 1: Create Source Content with write_file
Write your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.
write_file
path: /tmp/document_source.md
content: |
# Document Title
## Section 1
Content here...
## Section 2
More content...
Step 2: Sanitize Unicode Characters (Pre-PDF Conversion)
Before PDF conversion, create a sanitized version of your markdown with LaTeX-safe
常见问题
什么时候应该使用手动路线?
指南说,当文本含有特殊字符、常用工具失败,或需要多种格式时,就应使用手动路线。
哪些字符会被替换?
指南列出了破折号、短破折号和弯引号等,它们会被替换为更简单的字符。
这需要特殊工具吗?
它使用 pandoc 进行转换,因此电脑上必须有 pandoc。
详情
作者的原始描述
Unicode-safe fallback workflow for multi-format document generation with character sanitization
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12861
- 许可证
- 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帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。