pandoc-unicode-sanitize
它能做什么
这项技能通过把 LaTeX 无法处理的符号替换为普通等价字符,为 PDF 转换准备 Markdown 文件。适合文档中含有货币符号、花式引号或箭头的人。
适用场景
- ✓当我的 Markdown 中含有欧元、英镑或卢比等货币符号,且 PDF 转换失败时。
- ✓当文档中有弯引号、箭头或项目符号导致 PDF 转换出错时。
- ✓当我希望每次生成 PDF 前都有一个可复用的清理步骤时。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-sanitize/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我:我的 Markdown 中有卢比和欧元符号以及弯引号,PDF 转换失败了。请清理这些符号并生成 PDF。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 对 Markdown 运行一组文本替换,把符号转换为普通文字,例如 Rs 或 EUR,然后用 pandoc 转换清理后的文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Pandoc Unicode Sanitization for PDF Conversion
Problem
LaTeX (used by pandoc for PDF output) may fail or produce errors when encountering non-ASCII Unicode characters like currency symbols (₹, €, £), special quotes, or other Unicode characters not supported by the default LaTeX engine.
Solution
Pre-process Markdown files to replace problematic Unicode characters with ASCII equivalents before running pandoc PDF conversion.
Steps
1. Identify Problematic Characters
Common problematic characters include:
- Currency symbols: ₹, €, £, ¥
- Special quotes: " " ' '
- Arrows: →, ←, ↑, ↓
- Bullets: •, ◦
- Other symbols: ©, ®, ™, ±, ×, ÷, —, –
2. Create a Sed Substitution Script
Create a shell script for reusable sanitization:
#!/bin/bash
# sanitize-for-pdf.sh
sed -e 's/₹/Rs/g' \
-e 's/€/EUR/g' \
-e 's/£/GBP/g' \
-e 's/¥/JPY/g' \
-e 's/"/"/g' \
-e 's/"/"/g' \
-e "s/'/'/g" \
-e "s/'/'/g" \
-e 's/→/->/g' \
-e 's/←/<-/g' \
-e 's/•/-/g' \
-e 's/©/(c)/g' \
-e 's/®/(R)/g' \
-e 's/™/(TM)/g' \
-e 's/±/+/ -/g' \
-e 's/×/x/g' \
-e 's/÷/\//g' \
-e 's/—/--/g' \
-e 's/–/-/g' \
"$1"
3. Run Sanitization Before Pandoc
# Using the script
./sanitize-for-pdf.sh input.md > sanitized.md
pandoc sanitized.md -o output.pdf
# Or inline
cat input.md | sed 's/₹/Rs/g; s/€/EUR/g; s/£/GBP/g' | pandoc -o output.pdf
4. Alternative: Use iconv for Automatic Transliteration
For broader Unicode coverage:
iconv -f UTF-8 -t ASCII//TRANSLIT < input.md > sanitized.md
pandoc sanitized.md -o output.pdf
5. Alternative: Use XeLaTeX or LuaLaTeX Engine
If you want to preserve Unicode characters, use a Unicode-capable engine:
pandoc input.md -o output.pdf --pdf-engine=xelatex
# or
pandoc input.md -o output.pdf --pdf-engine=lualatex
Best Practices
- Sanitize files before conversion rather than debugging LaTeX errors after
- Keep a mapping of your organization's common symbols and preferred replacements
- Test with a small sample before processing large documents
- Consider using XeLaTeX/LuaLaTeX if Unicode preservation is required
- Document which characters cause issues in your specific environment
Common Error Signs
Look for these LaTeX errors that indicate Unicode issues:
Package inputenc Error: Unicode character ... not set upLaTeX Error: Unicode character ... cannot be used with pdflatex- Missing or garbled characters in the output PDF
常见问题
哪些符号会被替换?
指南列出了货币符号、弯引号、箭头、项目符号、版权符号和各种破折号。
原始文件会被修改吗?
不会。指南把清理后的文本写入新文件,原始文件保持不变。
这个清理步骤可以重复使用吗?
可以。指南建议把这些替换规则保存在一个小型 shell 脚本中。
详情
作者的原始描述
Pre-process Markdown to replace non-ASCII characters before pandoc PDF conversion
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12906
- 许可证
- 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帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。