Skip to content
Skillpedia
PDF, Word & slides7.8k · #12906

pandoc-unicode-sanitize

What it does

This skill prepares a Markdown file for PDF conversion by replacing symbols that LaTeX cannot handle with plain equivalents. It is for people who write documents with currency symbols, fancy quotes or arrows.

When to use it

  • ✓When my Markdown has currency symbols such as euro, pound or rupee signs and the PDF fails.
  • ✓When the document has curly quotes, arrows or bullet symbols that break PDF conversion.
  • ✓When I want a reusable cleanup step before every PDF conversion.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-sanitize/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-sanitize/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“My Markdown uses rupee and euro signs and curly quotes, and the PDF conversion fails. Please clean the symbols and make the PDF.”

5 new skills a week. 1 minute to read.

How it works

The AI runs a set of text replacements on the Markdown, turning symbols into plain text such as Rs or EUR, and then converts the cleaned file with pandoc.

Technical content (original SKILL.md)

Original text by the author, straight from 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 up
  • LaTeX Error: Unicode character ... cannot be used with pdflatex
  • Missing or garbled characters in the output PDF
FAQ

Which symbols are replaced?

The guide lists currency signs, curly quotes, arrows, bullets, copyright marks and dashes.

Does the original file change?

The guide writes the cleaned text to a new file, so the original stays as it was.

Can the cleanup be reused?

Yes, the guide suggests saving the replacements in a small shell script.

Details

Original description by the author

Pre-process Markdown to replace non-ASCII characters before pandoc PDF conversion

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#12906
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills