Langsung ke konten
Skillpedia
PDF, Word & slide7.8k ยท #12907

pandoc-unicode-workaround

Fungsinya

Skill ini menjelaskan alur kerja untuk mengonversi Markdown ke PDF ketika pandoc gagal karena karakter khusus. Skill ini cocok untuk orang yang dokumennya memuat tanda centang, panah, tanda pisah, atau simbol serupa.

Kapan dipakai

  • โœ“Saat pandoc gagal membuat PDF dengan galat Unicode atau LaTeX.
  • โœ“Saat galat menyebut karakter khusus seperti tanda centang, panah, atau tanda pisah panjang.
  • โœ“Saat saya membutuhkan PDF dan bisa menerima versi teks polos dari simbol-simbol tersebut.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-workaround/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œEkspor PDF saya gagal karena tanda centang dan panah di catatan saya. Ganti dengan teks polos dan buat ulang PDF-nya.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI mencoba konversi biasa terlebih dahulu. Jika gagal, AI mengganti karakter khusus dengan padanan ASCII dari sebuah tabel, lalu mengonversi lagi.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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.pdf fails 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:

  1. Use a different PDF engine:

    pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf
    
  2. Use XeLaTeX (better Unicode support):

    pandoc input.md -o output.pdf --pdf-engine=xelatex
    
  3. Add LaTeX packages for Unicode:

    pandoc input.md -o output.pdf -H header.tex
    

    Where 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 ...
Pertanyaan umum

Apakah konversi biasa dicoba lebih dulu?

Ya, panduan ini dimulai dengan perintah pandoc biasa dan hanya membersihkan teks jika gagal.

Apa pengganti tanda centang?

Panduan ini menyarankan penanda polos seperti Y atau X dalam tanda kurung.

Apakah penggantinya tercantum?

Ya, panduan ini menyertakan tabel yang memetakan setiap simbol ke alternatif polos.

Detail

Deskripsi asli dari pembuat

Handle LaTeX Unicode errors in pandoc PDF generation by normalizing special characters to ASCII

repo: HKUDS/AgentPilot

Popularitas

Bintang GitHub
7.8k
Peringkat
#12907
Lisensi
MIT
Diperbarui
1/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa