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

document-gen-dual-backend

Skill này làm gì

Skill này bảo AI dùng lệnh trực tiếp cho hầu hết tác vụ tài liệu, và giữ một agent trợ giúp cho các trường hợp phức tạp. Dành cho người cần tệp Word, PDF hoặc HTML được tạo từ Markdown.

Khi nào nên dùng

  • ✓Khi tôi cần một tài liệu đơn giản dạng Word, PDF hoặc HTML được tạo từ Markdown.
  • ✓Khi nội dung là văn bản thuần và AI đã biết lệnh chuyển đổi nào cần dùng.
  • ✓Khi tác vụ tài liệu cần tự động chuyển giữa các backend sau khi gặp lỗi.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-9f3b1f/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/document-gen-fallback-enhanced-enhanced-9f3b1f/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

“Hãy chuyển Markdown này thành tệp PDF và tệp Word. Giữ đơn giản, và chỉ dùng phương án dự phòng nếu có lỗi.”

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

Cách hoạt động

Với hầu hết tác vụ, AI viết nội dung và chạy pandoc hoặc ReportLab trực tiếp. Với trường hợp phức tạp, nó dùng hai đường PDF, một bằng pandoc và một bằng ReportLab, rồi kiểm tra từng đầu ra.

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.

Document Generation: Dual-Backend Workflow (Unicode-Safe)

When to Use

Default Approach: Lightweight Direct Execution (Recommended for 90% of tasks)

For most document generation tasks, use direct write_file + run_shell without shell_agent:

  • Generating documents in standard formats (.docx, .pdf, .html) from Markdown
  • Content is straightforward with minimal special characters
  • You already know the pandoc/ReportLab commands needed
  • Quick single-format or multi-format output is needed

Fallback Approach: shell_agent Delegation (For Complex Scenarios Only)

Use shell_agent delegation only when:

  • Automated fallback handling between backends requires complex logic
  • Dynamic content generation needs programmatic decision-making
  • You need to capture and analyze error messages for intelligent retry logic

When shell_agent May Be Useful (Optional)

Only consider shell_agent delegation for:

  • Complex error recovery requiring automated backend switching
  • Dynamic workflows with conditional branching based on generation results

Core Technique

For simple tasks (default): Use direct write_file + run_shell with pandoc or ReportLab (no shell_agent needed)

For complex tasks requiring fallback logic: Split the workflow into discrete, observable steps with two PDF generation paths:

Path A (Pandoc): Best for Markdown-to-PDF conversion with rich text formatting Path B (ReportLab): Best for programmatic PDF generation without LaTeX dependencies

Workflow steps:

  1. Content creation → Use write_file to create source document (Markdown)
  2. Choose PDF backend → Decide between pandoc (rich formatting) or ReportLab (programmatic control)
  3. Unicode handling → Apply sanitization for pandoc; ReportLab handles Unicode natively
  4. Format conversion → Use run_shell with appropriate commands for each format
  5. Verification → Check output files exist and are valid

⚠️ Backend Selection Guide

Requirement Recommended Backend Rationale
Markdown source with headers, lists, tables Pandoc Native Markdown parsing
Heavy Unicode/special characters ReportLab Native UTF-8 support, no sanitization needed
LaTeX not available ReportLab Pure Python, no external dependencies
Precise layout control (positions, graphics) ReportLab Programmatic canvas control
Quick DOCX + PDF + HTML batch Pandoc Single tool, multiple outputs
Tables with complex formatting Pandoc Better table rendering
Dynamic/charts/graphs in PDF ReportLab Drawing operations support

Unicode & LaTeX Compatibility Warning

Critical for Pandoc Path: PDF generation via pandoc typically uses LaTeX (pdflatex or xelatex), which has limited Unicode support. Common problematic characters include:

Character Issue Safe Replacement
— (em dash) May not render -- or -
– (en dash) May not render -
" " (curly quotes) Encoding errors " " (straight quotes)
' ' (curly apostrophe) Encoding errors ' (straight apostrophe)
… (ellipsis) May not render ...
→ ← ↑ ↓ (arrows) LaTeX incompatibility -> <- ^ v
✓ ✗ (checkmarks) May not render [x] [ ]
★ ● (symbols) May not render * -
© ® ™ May require packages (c) (r) (tm)
Non-ASCII letters (é, ñ, ü) Font-dependent Use xeLaTeX or replace

ReportLab Path: Handles Unicode natively. Pass content as UTF-8 strings; no character sanitization required.

Step-by-Step Workflow

Quick Start: Lightweight Direct Execution (Default for Most Tasks)

This is the recommended approach for most document generation tasks. No shell_agent delegation needed:

# Step 1: Write Markdown content
write_file
path: /tmp/doc.md
content: |
  # My Document
  
  Simple content here.

# Step 2: Convert with pandoc (direct)
run_shell
command: pandoc /tmp/doc.md -o output.docx

# Step 3: Verify
run_shell
command: ls -lh output.docx

For PDF with potential Unicode issues:

# Create sanitized version if needed
write_file
path: /tmp/doc_sanitized.md
content: |
  # My Document
  Content with safe ASCII characters only.

run_shell
command: pandoc /tmp/doc_sanitized.md -o output.pdf

For Unicode-heavy content (use ReportLab directly):

write
Câu hỏi thường gặp

Phương pháp chính là gì?

Lệnh trực tiếp là mặc định, vì chúng đáp ứng được phần lớn nhu cầu tài liệu.

Khi nào cần agent trợ giúp?

Chỉ với các trường hợp phức tạp cần xử lý lỗi tự động hoặc chuyển đổi giữa các backend.

Có kiểm tra đầu ra không?

Có. Hướng dẫn yêu cầu xác minh từng tệp được tạo ra.

Chi tiết

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

Document generation with direct pandoc/ReportLab execution (lightweight default) and optional shell_agent fallback for complex scenarios

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12860
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ự