pandoc-unicode-workaround
它能做什么
这项技能描述了在 pandoc 因特殊字符失败时,把 Markdown 转换为 PDF 的工作流程。适合文档中有勾号、箭头、破折号等符号、且能接受普通文字替代的人。
适用场景
- ✓当 pandoc 因 Unicode 或 LaTeX 错误无法生成 PDF 时。
- ✓当错误信息指出勾号、箭头或长破折号等特殊字符时。
- ✓当我需要 PDF,并且可以接受符号的普通文字版本时。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-workaround/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我:我的笔记中有勾号和箭头,导致 PDF 导出失败。请把它们换成普通文字,然后重新生成 PDF。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 先尝试常规转换。如果失败,就根据一个对照表,把特殊字符替换为 ASCII 等价字符,然后再次转换。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Pandoc Unicode Workaround
This skill provides a workflow for generating PDFs from Markdown using pandoc when LaTeX compilation fails due to Unicode character errors.
When to Use
Use this skill when:
pandoc document.md -o document.pdffails with LaTeX/Unicode errors- Error messages mention "Unicode character", "LaTeX Error", or specific characters like ✓, →, —, etc.
- You need to produce PDF output but pandoc's default LaTeX engine cannot handle special characters
Step-by-Step Procedure
Step 1: Attempt Initial PDF Generation
pandoc input.md -o output.pdf
If this succeeds, you're done. If it fails with Unicode/LaTeX errors, proceed to Step 2.
Step 2: Normalize Unicode Characters
Replace problematic Unicode characters with ASCII equivalents. Common replacements:
| Unicode Character | ASCII Replacement | Alternative |
|---|---|---|
| ✓ (checkmark) | [Y] or [X] | OK, ✓ removed |
| ✗ or ✘ (cross) | [N] | FAIL |
| → (arrow right) | -> | => |
| ← (arrow left) | <- | |
| — (em dash) | -- or - | --- |
| – (en dash) | - | |
| • (bullet) | - | * |
| © (copyright) | (c) | Copyright |
| ® (registered) | (R) | |
| ™ (trademark) | (TM) | |
| … (ellipsis) | ... | |
| " (smart quotes) | " or ' |
Step 3: Apply Replacements
Option A - Manual edit: Open the Markdown file and manually replace the characters using find/replace.
Option B - Automated with sed (Linux/Mac):
sed -i 's/✓/[Y]/g' input.md
sed -i 's/✗/[N]/g' input.md
sed -i 's/→/->/g' input.md
sed -i 's/—/--/g' input.md
Option C - Automated with Python:
replacements = {
'✓': '[Y]',
'✗': '[N]',
'→': '->',
'—': '--',
'–': '-',
'…': '...',
'"': '"',
'"': '"',
}
with open('input.md', 'r', encoding='utf-8') as f:
content = f.read()
for orig, repl in replacements.items():
content = content.replace(orig, repl)
with open('input.md', 'w', encoding='utf-8') as f:
f.write(content)
Step 4: Regenerate PDF
pandoc input.md -o output.pdf
Step 5: Verify Output
Check that the PDF was generated successfully and review the content to ensure character replacements are acceptable for your use case.
Alternative Approaches
If Unicode normalization is not acceptable:
Use a different PDF engine:
pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdfUse XeLaTeX (better Unicode support):
pandoc input.md -o output.pdf --pdf-engine=xelatexAdd LaTeX packages for Unicode:
pandoc input.md -o output.pdf -H header.texWhere header.tex contains:
\usepackage{fontspec} \usepackage{xunicode}
Tips
- Keep the original Markdown file before normalization if you need to preserve characters
- Document which characters were replaced for future reference
- Test with a small sample first if working with large documents
- For Word documents (.docx), Unicode issues are less common; this pattern is primarily for PDF generation
Error Indicators
Common LaTeX Unicode errors to watch for:
- ! LaTeX Error: Unicode character ... not set up for use with LaTeX
- Package inputenc Error: Unicode character ... not set up
- ! Missing character: There is no ... in font ...
常见问题
会先尝试常规转换吗?
会。指南先使用普通的 pandoc 命令,只有失败时才清理文本。
勾号要替换成什么?
指南建议使用带括号的 Y 或 X 等普通标记。
替换规则有列出来吗?
有。指南包含一张对照表,把每个符号映射为普通替代写法。
详情
作者的原始描述
Handle LaTeX Unicode errors in pandoc PDF generation by normalizing special characters to ASCII
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12907
- 许可证
- 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帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。