Saltar al contenido
Skillpedia
PDF, Word y diapositivas7,8 mil · #12856

document-gen-resilient-workflow

Qué hace

Esta skill guía a la IA para producir documentos como archivos Word, PDF o HTML, con alternativas cuando una herramienta falla. Está pensada para quienes necesitan un documento fiable, sobre todo si contiene caracteres especiales.

Cuándo usarla

  • ✓Cuando la creación de PDF falla por falta de LaTeX o por errores de codificación.
  • ✓Cuando un documento debe salir en varios formatos a partir de una misma fuente.
  • ✓Cuando el texto contiene símbolos o caracteres no ingleses que rompen la conversión.

Link de la skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-2794b4/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-2794b4/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Necesito que mis notas se conviertan en un archivo Word y en un PDF, y que los caracteres con tilde se vean bien.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La IA escribe el contenido en Markdown, limpia los caracteres especiales cuando hace falta, prueba los motores PDF uno tras otro hasta que uno funcione y comprueba que el archivo de salida es válido.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Resilient Document Generation Workflow (Multi-Engine Fallback)

When to Use

Use this skill when document generation tasks fail or when shell_agent returns unknown errors, especially for:

  • Generating documents in multiple formats (.docx, .pdf, .html)
  • PDF generation fails due to missing LaTeX, encoding issues, or tool errors
  • Documents contain special characters, symbols, or non-ASCII text
  • You need maximum reliability with automatic fallback options

Core Technique

Split document generation into discrete, observable steps with cascading fallbacks for PDF generation:

  1. Content creation → Use write_file to create source Markdown
  2. Unicode sanitization → Use Python script for reliable character replacement
  3. Format conversion → Try multiple PDF engines in sequence until one succeeds
  4. Verification → Check file exists, has non-zero size, and is valid

⚠️ Unicode & PDF Engine Guide

Different PDF engines have different Unicode support:

Engine Unicode Support Best For Fallback Position
pdflatex Limited (ASCII-focused) Simple documents 1st (fastest)
xelatex Full Unicode Documents with non-ASCII 2nd
wkhtmltopdf Good Unicode Web-style documents 3rd
reportlab (Python) Full control Programmatic PDFs 4th
fpdf2 (Python) Full control Simple text PDFs 5th (last resort)

Character Replacement Table

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

Step-by-Step Workflow

Step 1: Create Source Content with write_file

Write your document content as Markdown to a source file:

write_file
path: /tmp/document_source.md
content: |
  # Document Title
  
  ## Section 1
  Content here...
  
  ## Section 2
  More content...

Step 2: Sanitize Unicode with Python Script

Create a reusable Python sanitizer for reliable character replacement:

write_file
path: /tmp/sanitize_unicode.py
content: |
  #!/usr/bin/env python3
  import sys
  import re
  
  if len(sys.argv) < 2:
      print("Usage: sanitize_unicode.py <input.md> [output.md]")
      sys.exit(1)
  
  input_file = sys.argv[1]
  output_file = sys.argv[2] if len(sys.argv) > 2 else input_file.replace('.md', '_sanitized.md')
  
  replacements = {
      '—': '--',    # em dash
      '–': '-',     # en dash
      '"': '"',     # left curly quote
      '"': '"',     # right curly quote
      "'": "'",     # left curly apostrophe
      "'": "'",     # right curly apostrophe
      '…': '...',   # ellipsis
      '→': '->',    # right arrow
      '←': '<-',    # left arrow
      '↑': '^',     # up arrow
      '↓': 'v',     # down arrow
      '✓': '[x]',   # checkmark
      '✗': '[ ]',   # cross
      '★': '*',     # star
      '●': '-',     # bullet
      '©': '(c)',   # copyright
      '®': '(r)',   # registered
      '™': '(tm)',  # trademark
  }
  
  with open(input_file, 'r', encoding='utf-8') as f:
      content = f.read()
  
  for old, new in replacements.items():
      content = content.replace(old, new)
  
  with open(output_file, 'w', encoding='utf-8') as f:
      f.write(content)
  
  print(f"Sanitized: {input_file} -> {output_file}")

Apply sanitization for PDF:

run_shell
command: python3 /tmp/sanitize_unicode.py /tmp/document_source.md /tmp/document_source_sanitized.md

Note: Keep original for DOCX/HTML (these formats handle Unicode well).

Step 3: Convert to Target Formats with Cascading Fallbacks

For DOCX (from original, no sanitization needed):

run_shell
command: pandoc /tmp/document_source.md -o output.docx

For PDF (try multiple engines in sequence):

Attempt 1: pdflatex (fastest, limited Unicode)

run_shell
command: pandoc /tmp/document_source_sanitized.md -o output.pdf --pdf-engine=pdflatex

*If pdflatex fails, Attempt 2: xelatex (full Unicode)

Preguntas frecuentes

¿Qué motores PDF prueba?

La guía enumera pdflatex, xelatex, wkhtmltopdf, reportlab y fpdf2 como opciones, en un orden establecido.

¿Por qué importa el soporte Unicode?

Algunos motores PDF manejan mal los caracteres que no son ASCII, así que la guía explica qué motor usar.

¿Revisa el resultado?

Sí. La guía indica que se confirme que el archivo existe, tiene contenido y es válido.

Detalles

Descripción original del autor

Multi-engine document generation with cascading PDF fallbacks and robust Unicode handling

repo: HKUDS/AgentPilot

Popularidad

Estrellas en GitHub
7,8 mil
Posición en el ranking
#12856
Licencia
MIT
Actualizada
1/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas