Chuyển đến nội dung
Skillpedia
PDF, Word và slide7.8k · #12907

pandoc-unicode-workaround

Skill này làm gì

Skill này mô tả quy trình chuyển Markdown sang PDF khi pandoc thất bại với ký tự đặc biệt. Dành cho người có tài liệu chứa dấu tích, mũi tên, dấu gạch hoặc ký hiệu tương tự.

Khi nào nên dùng

  • ✓Khi pandoc không tạo được PDF với lỗi Unicode hoặc LaTeX.
  • ✓Khi lỗi nêu tên một ký tự đặc biệt như dấu tích, mũi tên hoặc dấu gạch dài.
  • ✓Khi tôi cần một PDF và chấp nhận được phiên bản văn bản thuần của các ký hiệu.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-workaround/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Xuất PDF của tôi thất bại vì các dấu tích và mũi tên trong ghi chú. Hãy thay chúng bằng văn bản thuần và tạo lại PDF.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI thử chuyển đổi thông thường trước. Nếu thất bại, nó thay các ký tự đặc biệt bằng tương đương ASCII lấy từ một bảng, rồi chuyển đổi lại.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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 ...
Câu hỏi thường gặp

Nó có thử chuyển đổi thông thường trước không?

Có. Hướng dẫn bắt đầu bằng lệnh pandoc thông thường và chỉ làm sạch văn bản nếu nó thất bại.

Dấu tích được thay bằng gì?

Hướng dẫn gợi ý một ký hiệu đánh dấu đơn giản như Y hoặc X trong ngoặc vuông.

Các thay thế có được liệt kê không?

Có. Hướng dẫn có một bảng ánh xạ từng ký hiệu sang dạng thay thế đơn giản.

Chi tiết

Mô tả gốc của tác giả

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

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12907
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự