[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KHZ64CP0GNY16WW11G6TWM":3,"skill-same:01M6KHZ64CP0GNY16WW11G6TWM":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":13,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":6,"ownerDescription":38,"updatedAt":39,"install":40,"resources":53},"01M6KHZ64CP0GNY16WW11G6TWM","document-gen-resilient",null,"Multi-path document generation with tool checks, Unicode handling, and Python fallbacks","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-96865f\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27],"document","document gen resilient","python","tool","generation","multi","Unicode","document generation","with","path","2026-11-10 10:12:30",false,"---\nname: document-gen-resilient\ndescription: Multi-path document generation with tool checks, Unicode handling, and Python fallbacks\n---\n\n# Resilient Document Generation Workflow\n\n## When to Use\n\nUse this skill when document generation tasks encounter errors or when you need reliable multi-format output:\n- `shell_agent` returns unknown or unclear errors on document generation\n- Generating documents in multiple formats (e.g., `.docx`, `.pdf`, `.html`)\n- **PDF generation fails due to LaTeX encoding or missing dependencies**\n- **You need to handle special characters, symbols, or non-ASCII text safely**\n- Previous document generation attempts have failed\n\n## Core Technique\n\nInstead of delegating the entire document generation to `shell_agent`, manually split the workflow into discrete, observable steps with built-in fallbacks:\n1. **Tool availability check** → Verify pandoc and PDF engines are available\n2. **Content creation** → Use `write_file` to create source document (Markdown)\n3. **Unicode assessment** → Determine if sanitization is needed based on target format\n4. **Format conversion** → Try primary method, fall back to alternatives on failure\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Format-Specific Unicode Guidance\n\n**Critical**: Different formats handle Unicode differently. Plan accordingly:\n\n| Format | Unicode Support | Sanitization Needed? | Recommended Engine |\n|--------|-----------------|---------------------|-------------------|\n| `.docx` | Excellent | No | pandoc (default) |\n| `.html` | Excellent | No | pandoc (default) |\n| `.pdf` (pdflatex) | Limited | **Yes** | pandoc + sanitization |\n| `.pdf` (xelatex) | Good | Rarely | pandoc --pdf-engine=xelatex |\n| `.pdf` (wkhtmltopdf) | Good | Rarely | pandoc --pdf-engine=wkhtmltopdf |\n| `.pdf` (Python) | Excellent | No | fpdf2 or reportlab |\n\n## Step-by-Step Workflow\n\n### Step 0: Check Tool Availability\n\nBefore starting, verify which tools are available:\n\n```\nrun_shell\ncommand: which pandoc && echo \"PANDOC: OK\" || echo \"PANDOC: MISSING\"\n```\n\n```\nrun_shell\ncommand: which pdflatex && echo \"PDFLATEX: OK\" || echo \"PDFLATEX: MISSING\"\n```\n\n```\nrun_shell\ncommand: which xelatex && echo \"XELATEX: OK\" || echo \"XELATEX: MISSING\"\n```\n\n```\nrun_shell\ncommand: python3 -c \"import fpdf; print('FPDF2: OK')\" 2>\u002Fdev\u002Fnull || echo \"FPDF2: MISSING\"\n```\n\n**Decision Tree Based on Availability:**\n- **pandoc + xelatex available** → Use pandoc with xelatex engine (best Unicode support)\n- **pandoc + pdflatex only** → Use pandoc with sanitization (Step 2)\n- **pandoc missing, Python available** → Use Python libraries (Step 3 Alternative)\n- **All missing** → Install dependencies or use shell_agent with explicit instructions\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2: Assess and Handle Unicode (Conditional)\n\n**Before PDF conversion**, check if your content contains problematic characters:\n\n```\nrun_shell\ncommand: grep -P '[\\x{2014}\\x{2013}\\x{201C}\\x{201D}\\x{2026}]' \u002Ftmp\u002Fdocument_source.md && echo \"UNICODE_DETECTED\" || echo \"UNICODE_CLEAN\"\n```\n\n**If Unicode detected AND using pdflatex**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table below)\n```\n\n**Common Problematic Characters:**\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n\n**Note**: Keep the original unsanitized file for DOCX\u002FHTML conversion (these formats handle Unicode better).\n\n### Step 3: Convert to Target Formats with run_shell\n\nUse `run_shell` with explicit commands for each format. Try primary method first, fall back on failure.\n\n#### For DOCX (from original, no sanitization needed):\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n#### For PDF (try in order):\n\n**Option A: xelatex (best Unicode support)**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.pdf --pdf-engine=xelatex\n```\n\n**Option B: wkhtmltopdf (good alternative)**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.pdf --pdf-engine=wkhtmltopdf\n```\n\n**Option C: pdflatex with sanitization**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n**Option D: Python fpdf2 fallback**\n```\nrun_shell\ncommand: python3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', size=12)\nwith open('\u002Ftmp\u002Fdocument_source.md', 'r', encoding='utf-8') as f:\n    content = f.read()\npdf.multi_cell(0, 10, content)\npdf.output('output.pdf')\n\"\n```\n\n#### For HTML (from original, no sanitization needed):\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\nCheck that files were created successfully:\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html 2>\u002Fdev\u002Fnull\n```\n\n```\nrun_shell\ncommand: file output.pdf 2>\u002Fdev\u002Fnull\n```\n\n## Complete Example\n\n```markdown\n# Generate Negotiation Strategy Document\n\n## Step 0: Check tools\nrun_shell\ncommand: which pandoc && which xelatex && echo \"TOOLS_OK\" || echo \"TOOLS_MISSING\"\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with original unicode...]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 2: Check for Unicode (if PDF needed)\nrun_shell\ncommand: grep -P '[\\x{2014}\\x{2013}\\x{201C}\\x{201D}]' \u002Ftmp\u002Fnegotiation_strategy.md && echo \"UNICODE_DETECTED\" || echo \"UNICODE_CLEAN\"\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.docx\n\n## Step 4: Convert to PDF (try xelatex first)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=xelatex\n\n## Step 5: If Step 4 failed, try wkhtmltopdf\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=wkhtmltopdf\n\n## Step 6: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.html\n\n## Step 7: Verify\nrun_shell\ncommand: ls -lh negotiation_strategy.*\n```\n\n## Advantages Over shell_agent\n\n| Aspect | shell_agent | Manual Workflow |\n|--------|-------------|-----------------|\n| Error visibility | Opaque, may retry silently | Each step shows explicit output |\n| Recovery | Automatic but may loop | Manual intervention at specific step |\n| Debugging | Hard to isolate failure point | Clear which step failed |\n| Unicode control | Agent may not handle encoding | You control character sanitization |\n| Tool fallback | Single approach | Multiple fallback options |\n| Control | Agent decides approach | You control each conversion |\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX or wkhtmltopdf)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (good alternative)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Troubleshooting\n\n### PDF Generation Failures\n\n- **PDF generation fails with encoding error**: \n  - Use `--pdf-engine=xelatex` for better Unicode support\n  - Or use `--pdf-engine=wkhtmltopdf` as alternative\n  - Or create sanitized markdown file and use pdflatex\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - Or use `--pdf-engine=wkhtmltopdf` instead\n  - Or fall back to Python fpdf2 (Step 3 Option D)\n\n- **PDF generation fails: wkhtmltopdf not found**: \n  - Install: `apt-get install wkhtmltopdf`\n  - Or use xelatex or pdflatex with sanitization\n  - Or fall back to Python fpdf2\n\n### DOCX Formatting Issues\n\n- Add `--reference-doc=template.docx` for custom styles\n- Ensure pandoc version is 2.0+ for best DOCX support\n\n### Unicode\u002FEncoding Errors in Any Format\n\n- Add `-f markdown+utf8` to pandoc command\n- Ensure source file is UTF-8 encoded: `file -i source.md`\n- For PDF: prefer xelatex engine over pdflatex\n\n### Special Characters Not Rendering in PDF\n\n- Use xelatex engine: `--pdf-engine=xelatex`\n- Or use the character replacement table above\n- Or create sanitized version before PDF conversion\n\n### Missing pandoc\n\n- Install via `apt-get install pandoc` or `brew install pandoc`\n- Or use Python libraries directly (fpdf2, reportlab)\n\n### Python PDF Library Fallback\n\nIf pandoc is unavailable or consistently failing:\n\n```bash\n# Using fpdf2\npython3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', size=12)\npdf.multi_cell(0, 10, open('input.md').read())\npdf.output('output.pdf')\n\"\n\n# Using reportlab (more control)\npython3 -c \"\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph\nfrom reportlab.lib.styles import getSampleStyleSheet\ndoc = SimpleDocTemplate('output.pdf', pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = [Paragraph(open('input.md').read(), styles['Normal'])]\ndoc.build(story)\n\"\n```\n\n## Unicode Sanitization Script (Optional)\n\nFor repeated use, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)\u002F'\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Matrix: Which Approach to Use\n\n| Scenario | Recommended Approach |\n|----------|---------------------|\n| DOCX only, any content | pandoc (no sanitization needed) |\n| HTML only, any content | pandoc (no sanitization needed) |\n| PDF, simple ASCII content | pandoc + pdflatex |\n| PDF, Unicode content | pandoc + xelatex (preferred) |\n| PDF, Unicode, xelatex unavailable | pandoc + sanitization + pdflatex |\n| PDF, pandoc unavailable | Python fpdf2 or reportlab |\n| Multiple formats needed | pandoc for all, sanitization for PDF only |\n| shell_agent failing repeatedly | Use this manual workflow |\n\n## When to Return to shell_agent\n\nAfter successfully completing the manual workflow once, you can attempt `shell_agent` again for similar tasks, now with a known-working fallback if errors recur. For documents with heavy Unicode content requiring PDF output, consider always using the manual workflow with xelatex or sanitization.\n\n## Related Skills\n\n- `write-file-fallback-report`: Use when web sourcing fails, create from embedded knowledge\n- `spreadsheet-direct-python`: Use Python libraries directly for spreadsheet operations\n- Use this skill when your documents contain special characters, symbols, or non-ASCII text that may cause LaTeX\u002FPDF conversion issues\n","# Resilient Document Generation Workflow\n\n## When to Use\n\nUse this skill when document generation tasks encounter errors or when you need reliable multi-format output:\n- `shell_agent` returns unknown or unclear errors on document generation\n- Generating documents in multiple formats (e.g., `.docx`, `.pdf`, `.html`)\n- **PDF generation fails due to LaTeX encoding or missing dependencies**\n- **You need to handle special characters, symbols, or non-ASCII text safely**\n- Previous document generation attempts have failed\n\n## Core Technique\n\nInstead of delegating the entire document generation to `shell_agent`, manually split the workflow into discrete, observable steps with built-in fallbacks:\n1. **Tool availability check** → Verify pandoc and PDF engines are available\n2. **Content creation** → Use `write_file` to create source document (Markdown)\n3. **Unicode assessment** → Determine if sanitization is needed based on target format\n4. **Format conversion** → Try primary method, fall back to alternatives on failure\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Format-Specific Unicode Guidance\n\n**Critical**: Different formats handle Unicode differently. Plan accordingly:\n\n| Format | Unicode Support | Sanitization Needed? | Recommended Engine |\n|--------|-----------------|---------------------|-------------------|\n| `.docx` | Excellent | No | pandoc (default) |\n| `.html` | Excellent | No | pandoc (default) |\n| `.pdf` (pdflatex) | Limited | **Yes** | pandoc + sanitization |\n| `.pdf` (xelatex) | Good | Rarely | pandoc --pdf-engine=xelatex |\n| `.pdf` (wkhtmltopdf) | Good | Rarely | pandoc --pdf-engine=wkhtmltopdf |\n| `.pdf` (Python) | Excellent | No | fpdf2 or reportlab |\n\n## Step-by-Step Workflow\n\n### Step 0: Check Tool Availability\n\nBefore starting, verify which tools are available:\n\n```\nrun_shell\ncommand: which pandoc && echo \"PANDOC: OK\" || echo \"PANDOC: MISSING\"\n```\n\n```\nrun_shell\ncommand: which pdflatex && echo \"PDFLATEX: OK\" || echo \"PDFLATEX: MISSING\"\n```\n\n```\nrun_shell\ncommand: which xelatex && echo \"XELATEX: OK\" || echo \"XELATEX: MISSING\"\n```\n\n```\nrun_shell\ncommand: python3 -c \"import fpdf; print('FPDF2: OK')\" 2>\u002Fdev\u002Fnull || echo \"FPDF2: MISSING\"\n```\n\n**Decision Tree Based on Availability:**\n- **pandoc + xelatex available** → Use pandoc with xelatex engine (best Unicode support)\n- **pandoc + pdflatex only** → Use pandoc with sanitization (Step 2)\n- **pandoc missing, Python available** → Use Python libraries (Step 3 Alternative)\n- **All missing** → Install dependencies or use shell_agent with explicit instructions\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2: Assess and Handle Unicode (Conditional)\n\n**Before PDF conversion**, check if your content contains problematic characters:\n\n```\nrun_shell\ncommand: grep -P '[\\x{2014}\\x{2013}\\x{201C}\\x{201D}\\x{2026}]' \u002Ftmp\u002Fdocument_source.md && echo \"UNICODE_DETECTED\" || echo \"UNICODE_CLEAN\"\n```\n\n**If Unicode detected AND using pdflatex**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table below)\n```\n\n**Common Problematic Characters:**\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n\n**Note**: Keep the original unsanitized file for DOCX\u002FHTML conversion (these formats handle Unicode better).\n\n### Step 3: Convert to Target Formats with run_shell\n\nUse `run_shell` with explicit commands for each format. Try primary method first, fall back on failure.\n\n#### For DOCX (from original, no sanitization needed):\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n#### For PDF (try in order):\n\n**Option A: xelatex (best Unicode support)**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.pdf --pdf-engine=xelatex\n```\n\n**Option B: wkhtmltopdf (good alternative)**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.pdf --pdf-engine=wkhtmltopdf\n```\n\n**Option C: pdflatex with sanitization**\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n**Option D: Python fpdf2 fallback**\n```\nrun_shell\ncommand: python3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', size=12)\nwith open('\u002Ftmp\u002Fdocument_source.md', 'r', encoding='utf-8') as f:\n    content = f.read()\npdf.multi_cell(0, 10, content)\npdf.output('output.pdf')\n\"\n```\n\n#### For HTML (from original, no sanitization needed):\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\nCheck that files were created successfully:\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html 2>\u002Fdev\u002Fnull\n```\n\n```\nrun_shell\ncommand: file output.pdf 2>\u002Fdev\u002Fnull\n```\n\n## Complete Example\n\n```markdown\n# Generate Negotiation Strategy Document\n\n## Step 0: Check tools\nrun_shell\ncommand: which pandoc && which xelatex && echo \"TOOLS_OK\" || echo \"TOOLS_MISSING\"\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Fnegotiation_strategy.md\ncontent: |\n  # Negotiation Strategy\n  \n  ## Executive Summary\n  [Content with original unicode...]\n  \n  ## Resolution Path\n  [Content...]\n  \n  ## BATNA Analysis\n  [Content...]\n\n## Step 2: Check for Unicode (if PDF needed)\nrun_shell\ncommand: grep -P '[\\x{2014}\\x{2013}\\x{201C}\\x{201D}]' \u002Ftmp\u002Fnegotiation_strategy.md && echo \"UNICODE_DETECTED\" || echo \"UNICODE_CLEAN\"\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.docx\n\n## Step 4: Convert to PDF (try xelatex first)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=xelatex\n\n## Step 5: If Step 4 failed, try wkhtmltopdf\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=wkhtmltopdf\n\n## Step 6: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fnegotiation_strategy.md -o negotiation_strategy.html\n\n## Step 7: Verify\nrun_shell\ncommand: ls -lh negotiation_strategy.*\n```\n\n## Advantages Over shell_agent\n\n| Aspect | shell_agent | Manual Workflow |\n|--------|-------------|-----------------|\n| Error visibility | Opaque, may retry silently | Each step shows explicit output |\n| Recovery | Automatic but may loop | Manual intervention at specific step |\n| Debugging | Hard to isolate failure point | Clear which step failed |\n| Unicode control | Agent may not handle encoding | You control character sanitization |\n| Tool fallback | Single approach | Multiple fallback options |\n| Control | Agent decides approach | You control each conversion |\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX or wkhtmltopdf)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (good alternative)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Troubleshooting\n\n### PDF Generation Failures\n\n- **PDF generation fails with encoding error**: \n  - Use `--pdf-engine=xelatex` for better Unicode support\n  - Or use `--pdf-engine=wkhtmltopdf` as alternative\n  - Or create sanitized markdown file and use pdflatex\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - Or use `--pdf-engine=wkhtmltopdf` instead\n  - Or fall back to Python fpdf2 (Step 3 Option D)\n\n- **PDF generation fails: wkhtmltopdf not found**: \n  - Install: `apt-get install wkhtmltopdf`\n  - Or use xelatex or pdflatex with sanitization\n  - Or fall back to Python fpdf2\n\n### DOCX Formatting Issues\n\n- Add `--reference-doc=template.docx` for custom styles\n- Ensure pandoc version is 2.0+ for best DOCX support\n\n### Unicode\u002FEncoding Errors in Any Format\n\n- Add `-f markdown+utf8` to pandoc command\n- Ensure source file is UTF-8 encoded: `file -i source.md`\n- For PDF: prefer xelatex engine over pdflatex\n\n### Special Characters Not Rendering in PDF\n\n- Use xelatex engine: `--pdf-engine=xelatex`\n- Or use the character replacement table above\n- Or create sanitized version before PDF conversion\n\n### Missing pandoc\n\n- Install via `apt-get install pandoc` or `brew install pandoc`\n- Or use Python libraries directly (fpdf2, reportlab)\n\n### Python PDF Library Fallback\n\nIf pandoc is unavailable or consistently failing:\n\n```bash\n# Using fpdf2\npython3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', size=12)\npdf.multi_cell(0, 10, open('input.md').read())\npdf.output('output.pdf')\n\"\n\n# Using reportlab (more control)\npython3 -c \"\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph\nfrom reportlab.lib.styles import getSampleStyleSheet\ndoc = SimpleDocTemplate('output.pdf', pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = [Paragraph(open('input.md').read(), styles['Normal'])]\ndoc.build(story)\n\"\n```\n\n## Unicode Sanitization Script (Optional)\n\nFor repeated use, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)\u002F'\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Matrix: Which Approach to Use\n\n| Scenario | Recommended Approach |\n|----------|---------------------|\n| DOCX only, any content | pandoc (no sanitization needed) |\n| HTML only, any content | pandoc (no sanitization needed) |\n| PDF, simple ASCII content | pandoc + pdflatex |\n| PDF, Unicode content | pandoc + xelatex (preferred) |\n| PDF, Unicode, xelatex unavailable | pandoc + sanitization + pdflatex |\n| PDF, pandoc unavailable | Python fpdf2 or reportlab |\n| Multiple formats needed | pandoc for all, sanitization for PDF only |\n| shell_agent failing repeatedly | Use this manual workflow |\n\n## When to Return to shell_agent\n\nAfter successfully completing the manual workflow once, you can attempt `shell_agent` again for similar tasks, now with a known-working fallback if errors recur. For documents with heavy Unicode content requiring PDF output, consider always using the manual workflow with xelatex or sanitization.\n\n## Related Skills\n\n- `write-file-fallback-report`: Use when web sourcing fails, create from embedded knowledge\n- `spreadsheet-direct-python`: Use Python libraries directly for spreadsheet operations\n- Use this skill when your documents contain special characters, symbols, or non-ASCII text that may cause LaTeX\u002FPDF conversion issues\n",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-96865f","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think about is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add AG064\u002FOpenSpace --skill document-gen-resilient",{"tool":46,"command":47},"bunx","bunx skills add AG064\u002FOpenSpace --skill document-gen-resilient",{"tool":49,"command":50},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill document-gen-resilient","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-96865f\u002FSKILL.md",true,[54],{"path":55,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":59},".skill_id","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-96865f\u002F.skill_id",[61,84,100,109,134,150],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":28},"01M6KKMPWA0B5SCCH766F8M5EA","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,20,83],"write special chars ts check","check","write","filters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","typescript",{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":28},"01M6KKMJXVBNVEY3TRK055F4A7","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[91,92,70,81,93,94,82,20,95,96,97,98,99,74,76,26],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":28},"01M6KKMEGX9M9NC105J0W3Q5B9","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[70,107,20,74,97,81,108,82,76],"write special chars heredoc","shell",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":28},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[],[116,117,118,119,83,120,121,122,123,124,74,125,126,127,128,129,130,131,132,133],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":28},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[141,142,143,144,74,145,26,146,147,148,149],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":28},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[157,158,159,160,161,162,82,163,164,165],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]