[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XBG7WMWMYDY8G2PQT28494":3,"skill-same:01M6XBG7WMWMYDY8G2PQT28494":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":25,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":13,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":53,"install":54,"resources":67},"01M6XBG7WMWMYDY8G2PQT28494","doc-gen-unicode-diagnostic",null,"Systematic document generation with unicode sanitization, engine fallback chain, and explicit error diagnosis","UF-gzj\u002Fopenspace-claude-evolution","UF-gzj","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272393507?v=4","01M6XBCZB755P01VVYGQWPYZY3","01M6XBCZFJA5AREA17WGETA3FW",0,"MIT","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-3d3a9a\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"doc gen unicode diagnostic","doc gen","diagnostic","doc","Unicode","error","error diagnosis","sanitization","with","document generation","chain","diagnosis","systematic","generation","document","fallback","engine","2026-11-10 10:12:30",false,"---\nname: doc-gen-unicode-diagnostic\ndescription: Systematic document generation with unicode sanitization, engine fallback chain, and explicit error diagnosis\n---\n\n# Document Generation with Diagnostic Workflow (Unicode-Safe)\n\n## When to Use\n\nUse this skill when document generation tasks fail or return unclear errors, especially when:\n- Generating documents in multiple formats (`.docx`, `.pdf`, `.html`)\n- **PDF generation fails with encoding\u002FLaTeX errors**\n- `shell_agent` returns \"unknown error\" without diagnostics\n- Documents contain special characters, symbols, or non-ASCII text\n- You need systematic error diagnosis rather than blind retries\n\n## ⚠️ Critical: Why This Skill Exists\n\nRecent executions show **43% effectiveness** because agents:\n- Skip unicode sanitization before PDF conversion\n- Don't try `xelatex` engine (better Unicode support)\n- Don't capture stderr for proper diagnosis\n- Exhaust iterations on repeated failures without systematic troubleshooting\n\n**This skill fixes those gaps with mandatory steps.**\n\n## Pre-Flight Validation (NEW - Required Step 0)\n\nBefore starting document generation, verify your toolchain:\n\n```\nrun_shell\ncommand: which pandoc && pandoc --version | head -3\n```\n\n```\nrun_shell\ncommand: which pdflatex xelatex wkhtmltopdf 2>\u002Fdev\u002Fnull || echo \"Some engines missing\"\n```\n\n```\nrun_shell\ncommand: python3 -c \"import sys; print(sys.version)\"\n```\n\nIf pandoc is missing, install it:\n```\nrun_shell\ncommand: apt-get update && apt-get install -y pandoc\n```\n\nFor PDF support, install LaTeX engines:\n```\nrun_shell\ncommand: apt-get install -y texlive-latex-recommended texlive-fonts-recommended texlive-xetex\n```\n\n## Core Technique\n\n**Manually split the workflow into observable, diagnostic steps:**\n1. **Pre-flight** → Verify toolchain availability\n2. **Content creation** → Use `write_file` for markdown source (visible content)\n3. **Unicode sanitization** → **MANDATORY for PDF**: Create sanitized version\n4. **Format conversion with fallback** → Try engines in order, capture stderr\n5. **Verification** → Check outputs exist and validate content\n\n## Unicode & LaTeX Compatibility (MANDATORY for PDF)\n\n**PDF generation via LaTeX has limited Unicode support.** Before PDF conversion, you MUST sanitize:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | LaTeX incompatibility | `--` |\n| `–` (en dash) | LaTeX incompatibility | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | Require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII (é, ñ, ü) | Font-dependent | Keep for xelatex, sanitize for pdflatex |\n\n**DOCX and HTML handle Unicode natively** - use original markdown for these formats.\n\n## Step-by-Step Workflow\n\n### Step 0: Pre-Flight Validation\n\n```\nrun_shell\ncommand: which pandoc || (apt-get update && apt-get install -y pandoc)\n```\n\n```\nrun_shell\ncommand: which xelatex || echo \"xelatex not available - will use fallback\"\n```\n\n### Step 1: Create Source Content with write_file\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Your content here with full Unicode support...\n  \n  ## Section 2\n  Special chars: \"quotes\" — dashes … ellipsis ✓ checkmarks\n```\n\n### Step 2: Create Sanitized Version for PDF (**MANDATORY**)\n\n**Option A: Manual sanitization with write_file**\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Your content here...\n  \n  ## Section 2\n  Special chars: \"quotes\" -- dashes ... ellipsis [x] checkmarks\n```\n\n**Option B: Automated sanitization script**\n\nFirst create the script:\n```\nwrite_file\npath: \u002Ftmp\u002Fsanitize_for_pdf.sh\ncontent: |\n  #!\u002Fbin\u002Fbash\n  INPUT=\"$1\"\n  OUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n  sed -e 's\u002F—\u002F--\u002Fg' -e 's\u002F–\u002F-\u002Fg' \\\n      -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' -e \"s\u002F'([^']*)'\u002F\\`\\1\\`\u002Fg\" \\\n      -e 's\u002F…\u002F...\u002Fg' -e 's\u002F→\u002F->\u002Fg' -e 's\u002F←\u002F\u003C-\u002Fg' \\\n      -e 's\u002F✓\u002F[x]\u002Fg' -e 's\u002F✗\u002F[ ]\u002Fg' \\\n      -e 's\u002F©\u002F(c)\u002Fg' -e 's\u002F®\u002F(r)\u002Fg' -e 's\u002F™\u002F(tm)\u002Fg' \\\n      \"$INPUT\" > \"$OUTPUT\"\n  echo \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\n```\nrun_shell\ncommand: chmod +x \u002Ftmp\u002Fsanitize_for_pdf.sh && \u002Ftmp\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n### Step 3: Convert to DOCX (from original, supports Unicode)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx 2>&1\n```\n\n**Capture stderr** with `2>&1` to see actual errors (not \"unknown error\").\n\n### Step 4: Convert to PDF with Engine Fallback Chain (**CRITICAL**)\n\n**Try engines in order: xelatex (best Unicode) → pdflatex → wkhtmltopdf**\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=xelatex 2>&1\n```\n\nIf xelatex fails, try pdflatex:\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=pdflatex 2>&1\n```\n\nIf pdflatex fails, try wkhtmltopdf:\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=wkhtmltopdf 2>&1\n```\n\n**If ALL engines fail**, diagnose with:\n```\nrun_shell\ncommand: file \u002Ftmp\u002Fdocument_source_sanitized.md && head -20 \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n### Step 5: Convert to HTML (from original)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html 2>&1\n```\n\n### Step 6: Verify All Outputs\n\n```\nrun_shell\ncommand: ls -lh output.* && file output.*\n```\n\n```\nrun_shell\ncommand: [ -f output.pdf ] && echo \"PDF created: $(wc -c \u003C output.pdf) bytes\" || echo \"PDF MISSING\"\n```\n\n## Complete Example\n\n```markdown\n# Generate Client Report in Multiple Formats\n\n## Step 0: Pre-flight\nrun_shell\ncommand: which pandoc xelatex || echo \"Checking toolchain...\"\n\n## Step 1: Write markdown source\nwrite_file\npath: \u002Ftmp\u002Fclient_report.md\ncontent: |\n  # Client Investment Report\n  \n  ## Executive Summary\n  Portfolio performance shows strong returns — up 15% this quarter...\n  \n  ## Risk Analysis\n  Key metrics: \"Sharpe ratio\" ✓ passed … continuing analysis\n\n## Step 2: Sanitize for PDF (MANDATORY)\nwrite_file\npath: \u002Ftmp\u002Fclient_report_sanitized.md\ncontent: |\n  # Client Investment Report\n  \n  ## Executive Summary\n  Portfolio performance shows strong returns -- up 15% this quarter...\n  \n  ## Risk Analysis\n  Key metrics: \"Sharpe ratio\" [x] passed ... continuing analysis\n\n## Step 3: Convert to DOCX (original unicode OK)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report.md -o client_report.docx 2>&1\n\n## Step 4: Convert to PDF (sanitized, xelatex first)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report_sanitized.md -o client_report.pdf --pdf-engine=xelatex 2>&1\n\n## Step 5: Convert to HTML (original unicode OK)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report.md -o client_report.html 2>&1\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh client_report.* && file client_report.*\n```\n\n## Error Diagnosis Decision Tree\n\nWhen a conversion fails, **capture stderr** (`2>&1`) and diagnose:\n\n```\nIf error contains \"xelatex not found\" or \"LaTeX error\":\n  → Try next engine: --pdf-engine=pdflatex or --pdf-engine=wkhtmltopdf\n\nIf error contains \"encoding\" or \"UTF-8\":\n  → Unicode not properly sanitized; re-check Step 2\n  → Add -f markdown+utf8 to pandoc command\n\nIf error contains \"template\" or \"class\":\n  → LaTeX template issue; try --pdf-engine=wkhtmltopdf\n\nIf error is \"unknown error\" (no stderr captured):\n  → Re-run with 2>&1 to capture actual error message\n  → Check if pandoc is installed: which pandoc\n\nIf wkhtmltopdf fails:\n  → Install: apt-get install wkhtmltopdf\n  → Or use Python alternative: reportlab or fpdf2\n```\n\n## Alternative: Python PDF Generation (When pandoc Fails)\n\nIf all pandoc engines fail, use Python libraries directly:\n\n**Using fpdf2:**\n```\nrun_shell\ncommand: python3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', '', 12)\npdf.cell(0, 10, 'Document Title')\npdf.output('output.pdf')\n\"\n```\n\n**Using reportlab:**\n```\nrun_shell\ncommand: python3 -c \"\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.pdfgen import canvas\nc = canvas.Canvas('output.pdf', pagesize=letter)\nc.drawString(100, 750, 'Document Title')\nc.save()\n\"\n```\n\n## Common pandoc Commands Reference\n\n```bash\n# Markdown to Word (Unicode-safe)\npandoc input.md -o output.docx\n\n# Markdown to PDF with xelatex (BEST for Unicode)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with pdflatex (requires sanitization)\npandoc input.md -o output.pdf --pdf-engine=pdflatex\n\n# Markdown to PDF with wkhtmltopdf (HTML-based, good fallback)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n\n# Force UTF-8 encoding\npandoc -f markdown+utf8 input.md -o output.pdf\n```\n\n## Troubleshooting Quick Reference\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| \"xelatex not found\" | Missing LaTeX engine | `apt-get install texlive-xetex` or try `--pdf-engine=wkhtmltopdf` |\n| \"LaTeX error: encoding\" | Unicode in source | Use sanitized markdown for PDF |\n| \"unknown error\" (pandoc) | stderr not captured | Re-run with `2>&1` to see real error |\n| PDF missing after conversion | All engines failed | Try Python (fpdf2\u002Freportlab) as fallback |\n| DOCX has garbled text | Encoding issue | Add `-f markdown+utf8` to pandoc command |\n| HTML renders but PDF fails | LaTeX-specific issue | wkhtmltopdf engine usually works |\n\n## Verification Checklist\n\nBefore marking task complete, verify:\n\n- [ ] Pre-flight: pandoc installed and accessible\n- [ ] Source markdown created with `write_file`\n- [ ] Sanitized version created for PDF conversion\n- [ ] DOCX generated from original (unicode preserved)\n- [ ] PDF generated with xelatex (or fallback engine documented)\n- [ ] All output files exist: `ls -lh output.*`\n- [ ] File types verified: `file output.*`\n- [ ] Content validated (spot-check with `read_file` if applicable)\n\n## When to Use shell_agent Instead\n\nAfter successfully completing this manual workflow:\n- For simple DOCX-only tasks (no PDF needed)\n- When toolchain is verified working\n- For repetitive tasks with known-good content\n\n**For documents with Unicode content requiring PDF, always use this manual workflow.**\n\n## Related Skills\n\n- `spreadsheet-direct-python`: For Excel\u002FCSV generation with Python\n- `pdf-verification-cli`: For verifying PDF page count and content after creation\n","# Document Generation with Diagnostic Workflow (Unicode-Safe)\n\n## When to Use\n\nUse this skill when document generation tasks fail or return unclear errors, especially when:\n- Generating documents in multiple formats (`.docx`, `.pdf`, `.html`)\n- **PDF generation fails with encoding\u002FLaTeX errors**\n- `shell_agent` returns \"unknown error\" without diagnostics\n- Documents contain special characters, symbols, or non-ASCII text\n- You need systematic error diagnosis rather than blind retries\n\n## ⚠️ Critical: Why This Skill Exists\n\nRecent executions show **43% effectiveness** because agents:\n- Skip unicode sanitization before PDF conversion\n- Don't try `xelatex` engine (better Unicode support)\n- Don't capture stderr for proper diagnosis\n- Exhaust iterations on repeated failures without systematic troubleshooting\n\n**This skill fixes those gaps with mandatory steps.**\n\n## Pre-Flight Validation (NEW - Required Step 0)\n\nBefore starting document generation, verify your toolchain:\n\n```\nrun_shell\ncommand: which pandoc && pandoc --version | head -3\n```\n\n```\nrun_shell\ncommand: which pdflatex xelatex wkhtmltopdf 2>\u002Fdev\u002Fnull || echo \"Some engines missing\"\n```\n\n```\nrun_shell\ncommand: python3 -c \"import sys; print(sys.version)\"\n```\n\nIf pandoc is missing, install it:\n```\nrun_shell\ncommand: apt-get update && apt-get install -y pandoc\n```\n\nFor PDF support, install LaTeX engines:\n```\nrun_shell\ncommand: apt-get install -y texlive-latex-recommended texlive-fonts-recommended texlive-xetex\n```\n\n## Core Technique\n\n**Manually split the workflow into observable, diagnostic steps:**\n1. **Pre-flight** → Verify toolchain availability\n2. **Content creation** → Use `write_file` for markdown source (visible content)\n3. **Unicode sanitization** → **MANDATORY for PDF**: Create sanitized version\n4. **Format conversion with fallback** → Try engines in order, capture stderr\n5. **Verification** → Check outputs exist and validate content\n\n## Unicode & LaTeX Compatibility (MANDATORY for PDF)\n\n**PDF generation via LaTeX has limited Unicode support.** Before PDF conversion, you MUST sanitize:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | LaTeX incompatibility | `--` |\n| `–` (en dash) | LaTeX incompatibility | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | Require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII (é, ñ, ü) | Font-dependent | Keep for xelatex, sanitize for pdflatex |\n\n**DOCX and HTML handle Unicode natively** - use original markdown for these formats.\n\n## Step-by-Step Workflow\n\n### Step 0: Pre-Flight Validation\n\n```\nrun_shell\ncommand: which pandoc || (apt-get update && apt-get install -y pandoc)\n```\n\n```\nrun_shell\ncommand: which xelatex || echo \"xelatex not available - will use fallback\"\n```\n\n### Step 1: Create Source Content with write_file\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Your content here with full Unicode support...\n  \n  ## Section 2\n  Special chars: \"quotes\" — dashes … ellipsis ✓ checkmarks\n```\n\n### Step 2: Create Sanitized Version for PDF (**MANDATORY**)\n\n**Option A: Manual sanitization with write_file**\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Your content here...\n  \n  ## Section 2\n  Special chars: \"quotes\" -- dashes ... ellipsis [x] checkmarks\n```\n\n**Option B: Automated sanitization script**\n\nFirst create the script:\n```\nwrite_file\npath: \u002Ftmp\u002Fsanitize_for_pdf.sh\ncontent: |\n  #!\u002Fbin\u002Fbash\n  INPUT=\"$1\"\n  OUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n  sed -e 's\u002F—\u002F--\u002Fg' -e 's\u002F–\u002F-\u002Fg' \\\n      -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' -e \"s\u002F'([^']*)'\u002F\\`\\1\\`\u002Fg\" \\\n      -e 's\u002F…\u002F...\u002Fg' -e 's\u002F→\u002F->\u002Fg' -e 's\u002F←\u002F\u003C-\u002Fg' \\\n      -e 's\u002F✓\u002F[x]\u002Fg' -e 's\u002F✗\u002F[ ]\u002Fg' \\\n      -e 's\u002F©\u002F(c)\u002Fg' -e 's\u002F®\u002F(r)\u002Fg' -e 's\u002F™\u002F(tm)\u002Fg' \\\n      \"$INPUT\" > \"$OUTPUT\"\n  echo \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\n```\nrun_shell\ncommand: chmod +x \u002Ftmp\u002Fsanitize_for_pdf.sh && \u002Ftmp\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n### Step 3: Convert to DOCX (from original, supports Unicode)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx 2>&1\n```\n\n**Capture stderr** with `2>&1` to see actual errors (not \"unknown error\").\n\n### Step 4: Convert to PDF with Engine Fallback Chain (**CRITICAL**)\n\n**Try engines in order: xelatex (best Unicode) → pdflatex → wkhtmltopdf**\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=xelatex 2>&1\n```\n\nIf xelatex fails, try pdflatex:\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=pdflatex 2>&1\n```\n\nIf pdflatex fails, try wkhtmltopdf:\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf --pdf-engine=wkhtmltopdf 2>&1\n```\n\n**If ALL engines fail**, diagnose with:\n```\nrun_shell\ncommand: file \u002Ftmp\u002Fdocument_source_sanitized.md && head -20 \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n### Step 5: Convert to HTML (from original)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html 2>&1\n```\n\n### Step 6: Verify All Outputs\n\n```\nrun_shell\ncommand: ls -lh output.* && file output.*\n```\n\n```\nrun_shell\ncommand: [ -f output.pdf ] && echo \"PDF created: $(wc -c \u003C output.pdf) bytes\" || echo \"PDF MISSING\"\n```\n\n## Complete Example\n\n```markdown\n# Generate Client Report in Multiple Formats\n\n## Step 0: Pre-flight\nrun_shell\ncommand: which pandoc xelatex || echo \"Checking toolchain...\"\n\n## Step 1: Write markdown source\nwrite_file\npath: \u002Ftmp\u002Fclient_report.md\ncontent: |\n  # Client Investment Report\n  \n  ## Executive Summary\n  Portfolio performance shows strong returns — up 15% this quarter...\n  \n  ## Risk Analysis\n  Key metrics: \"Sharpe ratio\" ✓ passed … continuing analysis\n\n## Step 2: Sanitize for PDF (MANDATORY)\nwrite_file\npath: \u002Ftmp\u002Fclient_report_sanitized.md\ncontent: |\n  # Client Investment Report\n  \n  ## Executive Summary\n  Portfolio performance shows strong returns -- up 15% this quarter...\n  \n  ## Risk Analysis\n  Key metrics: \"Sharpe ratio\" [x] passed ... continuing analysis\n\n## Step 3: Convert to DOCX (original unicode OK)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report.md -o client_report.docx 2>&1\n\n## Step 4: Convert to PDF (sanitized, xelatex first)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report_sanitized.md -o client_report.pdf --pdf-engine=xelatex 2>&1\n\n## Step 5: Convert to HTML (original unicode OK)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fclient_report.md -o client_report.html 2>&1\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh client_report.* && file client_report.*\n```\n\n## Error Diagnosis Decision Tree\n\nWhen a conversion fails, **capture stderr** (`2>&1`) and diagnose:\n\n```\nIf error contains \"xelatex not found\" or \"LaTeX error\":\n  → Try next engine: --pdf-engine=pdflatex or --pdf-engine=wkhtmltopdf\n\nIf error contains \"encoding\" or \"UTF-8\":\n  → Unicode not properly sanitized; re-check Step 2\n  → Add -f markdown+utf8 to pandoc command\n\nIf error contains \"template\" or \"class\":\n  → LaTeX template issue; try --pdf-engine=wkhtmltopdf\n\nIf error is \"unknown error\" (no stderr captured):\n  → Re-run with 2>&1 to capture actual error message\n  → Check if pandoc is installed: which pandoc\n\nIf wkhtmltopdf fails:\n  → Install: apt-get install wkhtmltopdf\n  → Or use Python alternative: reportlab or fpdf2\n```\n\n## Alternative: Python PDF Generation (When pandoc Fails)\n\nIf all pandoc engines fail, use Python libraries directly:\n\n**Using fpdf2:**\n```\nrun_shell\ncommand: python3 -c \"\nfrom fpdf import FPDF\npdf = FPDF()\npdf.add_page()\npdf.set_font('Arial', '', 12)\npdf.cell(0, 10, 'Document Title')\npdf.output('output.pdf')\n\"\n```\n\n**Using reportlab:**\n```\nrun_shell\ncommand: python3 -c \"\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.pdfgen import canvas\nc = canvas.Canvas('output.pdf', pagesize=letter)\nc.drawString(100, 750, 'Document Title')\nc.save()\n\"\n```\n\n## Common pandoc Commands Reference\n\n```bash\n# Markdown to Word (Unicode-safe)\npandoc input.md -o output.docx\n\n# Markdown to PDF with xelatex (BEST for Unicode)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with pdflatex (requires sanitization)\npandoc input.md -o output.pdf --pdf-engine=pdflatex\n\n# Markdown to PDF with wkhtmltopdf (HTML-based, good fallback)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n\n# Force UTF-8 encoding\npandoc -f markdown+utf8 input.md -o output.pdf\n```\n\n## Troubleshooting Quick Reference\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| \"xelatex not found\" | Missing LaTeX engine | `apt-get install texlive-xetex` or try `--pdf-engine=wkhtmltopdf` |\n| \"LaTeX error: encoding\" | Unicode in source | Use sanitized markdown for PDF |\n| \"unknown error\" (pandoc) | stderr not captured | Re-run with `2>&1` to see real error |\n| PDF missing after conversion | All engines failed | Try Python (fpdf2\u002Freportlab) as fallback |\n| DOCX has garbled text | Encoding issue | Add `-f markdown+utf8` to pandoc command |\n| HTML renders but PDF fails | LaTeX-specific issue | wkhtmltopdf engine usually works |\n\n## Verification Checklist\n\nBefore marking task complete, verify:\n\n- [ ] Pre-flight: pandoc installed and accessible\n- [ ] Source markdown created with `write_file`\n- [ ] Sanitized version created for PDF conversion\n- [ ] DOCX generated from original (unicode preserved)\n- [ ] PDF generated with xelatex (or fallback engine documented)\n- [ ] All output files exist: `ls -lh output.*`\n- [ ] File types verified: `file output.*`\n- [ ] Content validated (spot-check with `read_file` if applicable)\n\n## When to Use shell_agent Instead\n\nAfter successfully completing this manual workflow:\n- For simple DOCX-only tasks (no PDF needed)\n- When toolchain is verified working\n- For repetitive tasks with known-good content\n\n**For documents with Unicode content requiring PDF, always use this manual workflow.**\n\n## Related Skills\n\n- `spreadsheet-direct-python`: For Excel\u002FCSV generation with Python\n- `pdf-verification-cli`: For verifying PDF page count and content after creation\n",{"name":5,"description":7},"main","0650921d63895de3997bc81f1ff1d0ac67032072","gdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-3d3a9a","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution","https:\u002F\u002Fgithub.com\u002FUF-gzj","2026-04-16 09:31:03",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add UF-gzj\u002Fopenspace-claude-evolution --skill doc-gen-unicode-diagnostic",{"tool":60,"command":61},"bunx","bunx skills add UF-gzj\u002Fopenspace-claude-evolution --skill doc-gen-unicode-diagnostic",{"tool":63,"command":64},"pnpm","pnpm dlx skills add UF-gzj\u002Fopenspace-claude-evolution --skill doc-gen-unicode-diagnostic","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-3d3a9a\u002FSKILL.md",true,[68],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},".skill_id","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-3d3a9a\u002F.skill_id",[75,100,116,125,155,171],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":43},"01M6XCCXD3NCM2YKR3WNGBASPC","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\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],"check","write","write special chars ts check","typescript","filters","characters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","python",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":43},"01M6XCCT7E3J922Q345PBGSHPN","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\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[107,108,83,98,109,99,110,111,112,113,114,97,115,34,87,90,92],"readback","write special chars readback","helper","post","via","scripts","cleanup","read","verification",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":43},"01M6XCCMQX1R8B6FECWB3P63T7","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\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[123,83,87,124,92,111,97,98,99,90],"write special chars heredoc","shell",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":136,"publishedAt":43},"01M6XCCG41M994JJEX6VN52PEP","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\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[131],{"categoryNo":132,"categoryName":133,"taxonomyType":134,"taxonomyTypeDesc":135},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[137,138,139,140,141,85,142,143,144,145,146,90,147,148,149,150,151,152,153,154],"reference","worldmonitor","worldmonitor reference","architecture","dashboard","css","scheduler","layer","hierarchy","source","extracting","panel","patterns","edge functions","integrations","open","api","data",{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":43},"01M6XCCCHWNKG2W4VH9E6A10HF","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[162,163,164,165,90,166,34,167,168,169,170],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":43},"01M6XCC7X8PKMR2DEW91XGHYSV","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FUF-gzj\u002Fopenspace-claude-evolution\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[178,179,180,181,182,183,98,184,185,186],"directory","verify directory structure","structure","verify","access","first","issues","diagnose","file access"]