namht-pdflisted
Install: claude install-skill NamHT4Devlop/nam-claude-skill
# namht-pdf — export a report/doc to PDF
Turn a Markdown or HTML report into a shareable PDF.
## Steps
0. Resolve this skill's `references/` dir first (call it `$SKILL_DIR`): `${CLAUDE_PLUGIN_ROOT}/skills/namht-pdf/references`
if `CLAUDE_PLUGIN_ROOT` is set, else the `references/` folder next to this SKILL.md, else `$HOME/.claude/skills/namht-pdf/references`.
1. **Resolve the input.** If given a `.md`, first render it to a self-contained HTML with the
bundled renderer (Mermaid drawn):
`node "$SKILL_DIR/render-html.cjs" <in.md> <tmp.html> "<title>"`
If given an `.html`, use it directly — including a hand-written or third-party one: the converter
injects the print stylesheet into a **temp copy** (the user's file is never modified), so any HTML
gets the same page-break/clipping protection. Opt out with `PDF_NO_PRINT_FIX=1`.
2. **Convert to PDF** (best-effort, no network):
`bash "$SKILL_DIR/html-to-pdf.sh" <in.html> <out.pdf>`
It prints the PDF path on success.
3. **Open it** (`open` / `xdg-open` / `start`) and give the user the path.
## Fidelity — what keeps the PDF from breaking
- **Headless Chrome is required for Mermaid.** Diagrams are drawn by JavaScript at view time, so the
script tries Chrome/Chromium/Edge/Brave FIRST. `wkhtmltopdf` (old QtWebKit, no modern JS/CSS) is a
last resort only and **warns** that diagrams will be missing — if the user's PDF has raw
```mermaid``` text instead of a picture, they converted with wkhtmltopdf or a non-JS