{"record":{"id":"41373293b929abe5","repo":"zarazhangrui/frontend-slides","slug":"red-nc-413732","errorCode":null,"errorMessage":"${RED}✗${NC} $*","messagePattern":"\\$\\{RED\\}✗\\$\\{NC\\} \\$\\*","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/frontend-slides/skills/frontend-slides/scripts/export-pdf.sh","lineNumber":32,"sourceCode":"#   3. Combines all screenshots into a single PDF\n#   4. Cleans up the server and temp files\n#\n# The PDF preserves colors, fonts, and layout — but not animations.\n# Perfect for email attachments, printing, or embedding in documents.\nset -euo pipefail\n\n# ─── Colors ────────────────────────────────────────────────\nRED='\\033[0;31m'\nGREEN='\\033[0;32m'\nCYAN='\\033[0;36m'\nYELLOW='\\033[1;33m'\nBOLD='\\033[1m'\nNC='\\033[0m'\n\ninfo()  { echo -e \"${CYAN}ℹ${NC} $*\"; }\nok()    { echo -e \"${GREEN}✓${NC} $*\"; }\nwarn()  { echo -e \"${YELLOW}⚠${NC} $*\"; }\nerr()   { echo -e \"${RED}✗${NC} $*\" >&2; }\n\n# ─── Parse flags ──────────────────────────────────────────\n\n# Default resolution: 1920x1080 (full HD, ~1-2MB per slide)\n# Compact resolution: 1280x720 (HD, ~50-70% smaller files)\nVIEWPORT_W=1920\nVIEWPORT_H=1080\nCOMPACT=false\n\nPOSITIONAL=()\nfor arg in \"$@\"; do\n    case $arg in\n        --compact)\n            COMPACT=true\n            VIEWPORT_W=1280\n            VIEWPORT_H=720\n            ;;\n        *)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/zarazhangrui/frontend-slides/blob/9906a34d640d2111f724544cbc50f7f130569ae1/plugins/frontend-slides/skills/frontend-slides/scripts/export-pdf.sh#L14-L50","documentation":"This is the err() helper defined at line 32 of export-pdf.sh, a bash wrapper that exports an HTML slide deck to PDF via a generated Playwright Node script. err() prints a red ✗ and its message to stderr, then the script exits 1. It fires on usage/validation failures (missing argument, file not found), dependency failures (no Node, Playwright or Chromium install failure), or when the embedded Node export script exits non-zero ('PDF export failed.').","triggerScenarios":"Running export-pdf.sh with no arguments (usage error); passing an HTML path that does not exist (-f check at line 70); npx missing; 'npm install playwright' or 'npx playwright install chromium' failing (offline, npm registry blocked, missing system libs for Chromium); the node export-slides.mjs run failing — most commonly because the HTML contains zero '.slide' elements, or Playwright cannot launch a headless browser in the environment.","commonSituations":"First run on a machine behind a corporate proxy/firewall blocking the Chromium download; minimal Linux/CI containers missing Chromium shared-library dependencies (libnss3, libatk, etc.); pointing the script at an HTML file that doesn't use the expected <div class=\"slide\"> structure; running from a different directory with a relative path to the HTML that doesn't resolve; disk or permission issues in the mktemp temp directory.","solutions":["Re-run with correct arguments: bash scripts/export-pdf.sh ./deck/index.html [output.pdf] [--compact], verifying the HTML file exists at that path","Install Node.js (brew install node or nodejs.org) if npx is missing","If Playwright setup fails, run manually: npm install playwright && npx playwright install chromium (or npx playwright install-deps chromium on Linux for missing system libraries); check proxy/firewall if the browser download is blocked","If 'PDF export failed.' is printed, ensure the HTML uses <div class=\"slide\"> or <section class=\"slide\"> elements — the script exits with 'No .slide elements found' otherwise","Run the script from the project root or pass an absolute path to the HTML so the input-file check passes"],"exampleFix":"// before (wrong element structure → node script fails → err fires)\n<div class=\"page\">Slide 1</div>\n\n// after (matches the exporter's selector)\n<div class=\"slide\">Slide 1</div>","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Pre-flight checks before running export-pdf.sh\nset -euo pipefail\nHTML=\"$1\"\n[[ $# -ge 1 ]] || { echo \"Usage: export-pdf.sh <html> [out.pdf] [--compact]\" >&2; exit 1; }\n[[ -f \"$HTML\" ]] || { echo \"File not found: $HTML\" >&2; exit 1; }\ncommand -v npx >/dev/null || { echo \"Node.js required\" >&2; exit 1; }\ngrep -q 'class=\"slide\"\\|class=\\x27slide\\x27\\|class=\"[^\"]*\\\\bslide\\\\b' \"$HTML\" || \\\n  echo \"WARNING: no .slide elements found — export will abort\"\n# Ensure Chromium can run (CI/minimal containers)\nnpx playwright install chromium --with-deps >/dev/null 2>&1 || \\\n  { echo \"Playwright/Chromium not installed\" >&2; exit 1; }","typeGuard":"is_exportable_deck() {\n  local html=\"$1\"\n  [[ -f \"$html\" ]] && grep -Eq 'class=\"[^\"]*\\bslide\\b[^\"]*\"' \"$html\"\n}","tryCatchPattern":"# export-pdf.sh exits non-zero with err() on stderr; capture and branch\nif ! bash scripts/export-pdf.sh \"$HTML\" \"$OUT.pdf\" 2>export.err; then\n  cat export.err >&2\n  case \"$(cat export.err)\" in\n    *\"No .slide elements\"*) echo \"Deck must use <div class=\\\"slide\\\"> elements\" ;;\n    *\"Failed to install Chromium\"*) npx playwright install-deps chromium ;;\n    *\"not installed\"*) echo \"Install Node.js first\" ;;\n  esac\n  exit 1\nfi","preventionTips":["Ensure the deck's markup uses <div class=\"slide\"> or <section class=\"slide\"> — the exporter counts these to drive screenshots","Warm the Playwright cache once with 'npx playwright install chromium' before batch exports; on Linux CI use 'npx playwright install-deps chromium' for shared libraries","Verify the HTML path with 'test -f' or an absolute path before invoking; run from the repo root otherwise","On restricted networks, pre-download Chromium or configure npm/HTTPS proxy env vars so the first-run install doesn't fail","Test-render the deck in a browser first; slides that fail to display will also fail (or render blank) in the PDF export"],"tags":["bash","playwright","pdf-export","chromium","cli"],"backgroundTag":"pdf-export-failed","analyzedSha":"9906a34d640d2111f724544cbc50f7f130569ae1","analyzedAt":"2026-08-29T08:54:05.395Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}