markdown-to-pdf
/markdown-to-pdf
Zamienia plik Markdown w PDF do druku lub udostępnienia, z diagramami Mermaid, szerokimi tabelami, numerami stron i nagłówkiem.
- Autor
- darblinko ↗
- Repozytorium
- claude-skills ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 30.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 13
- Skrypty
- 2
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 30.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
- 2 skrypty w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: md2pdf.js, test/smoke.test.js
Co robi i kiedy
Zamienia plik Markdown w PDF do druku lub udostępnienia, z diagramami Mermaid, szerokimi tabelami, numerami stron i nagłówkiem.
Oryginalny opis (EN)
Use when asked to turn a Markdown file into a PDF, export a .md report for printing or sharing, or produce a printable deliverable from Markdown, especially documents containing mermaid diagrams, wide tables, or that need page numbers and a running header.
Jak działa
- Overview
- Usage
- After rendering, always verify
- Design notes (why it is built this way)
- Common problems
- Styling
Podgląd SKILL.md
---
name: markdown-to-pdf
description: Use when asked to turn a Markdown file into a PDF, export a .md report for printing or sharing, or produce a printable deliverable from Markdown, especially documents containing mermaid diagrams, wide tables, or that need page numbers and a running header.
---
# Markdown to PDF
## Overview
Renders a Markdown file to a print-quality PDF via headless Chromium. Mermaid
diagrams come out as **vector SVG**, tables repeat their header row across page
breaks, and every page gets a running header and `Page N of M` footer.
Oversized diagrams are the hard part, and the script handles them: a diagram
taller than the page is sliced across consecutive pages, and one far wider than
the page is wrapped into stacked left-to-right bands. Both keep labels readable
instead of shrinking the figure into an unreadable sliver.
Rendering is local. The page runs under a Content Security Policy that lets
only the renderer's own scripts run and blocks every external fetch, and the
browser aborts any request that gets past it. Scripts, event handlers and
remote resources in raw HTML are blocked and listed on stderr.
## Usage
```bash
node ~/.claude/skills/markdown-to-pdf/md2pdf.js <input.md> [output.pdf] [options]
```
Use the path where the skill is installed if it is not under `~/.claude/skills`.
Output defaults to the input path with `.pdf` substituted. Options:
| Option | Effect |
|---|---|
| `--note "TEXT"` | Right-hand running-header text (e.g. a status or confidentiality caveat) |
| `--format Letter\|A4` | Paper size (default `Letter`) |
| `--landscape` | Landscape orientation |
The document title (browser tab, PDF metadata, left-hand running header) comes
from the first `#` heading, falling back to the filename.
Mermaid diagrams are fenced code blocks with the info string `mermaid`, with
backticks or tildes. Markdown images with a local path are read relative to the
Markdown file and embedded. A missing local image, or an image with an `http`
or `https` URL, stops the render with an error: download remote images first.
The script prints a line per oversized diagram saying how it was handled, and a
`blocked` line per script or resource the page was not allowed to run or load.
Relay anything still flagged as too small, and any blocked line, to the user.
First run installs `markdown-it`, `mermaid`, and `playwright-core` into the skill
directory automatically. Chromium is found in this order: `CHROME_PATH`, the
build pinned by `playwright-core` at Playwright's install path, the newest build
in the Playwright cache, then system Chrome/Chromium.
## After rendering, always verify
The command exits non-zero if a diagram fails, but it cannot see layout problems.
Render pages to images and look at them:
```bash
pdftoppm -png -r 75 out.pdf /tmp/preview/p # then Read the PNGs
```
Check: no diagram clipped at a page edge, no table or code block running off the
right margin, no page of pure whitespace (a blank page means content was clipped,
not merely pushed). Report the page count to the user.
## Design notes (why it is built this way)
Each of these fixes a bug that is invisible until you look at rendered pages:
- **Chrome clips; it does not slice or scroll.** Anything overflowing the print
margin box is silently cut: an SVG taller than the page loses its lower half,
a long code line loses its right end. Hence `white-space: pre-wrap` on `pre`,
and the diagram slicing/banding rather than plain scaling.
- **Page margins are 6 mm; `<main>` is padded 10 mm.** Body text keeps a readable
measure while `.mermaid-slot` uses negative margins to reach nearly the full
sheet. A diagram cannot be given more room by breaking out *past* the margins,
because that region is clipped, so the margins themselves have to be narrow.
- **Mermaid's inline `width`/`max-width` are stripped after render.** Mermaid
writes them on the `<svg>`, where they outrank the stylesheet and let wide
flowcharts run off the page. The script removes them and scales via the viewBox.
- **The viewport is set to the printed diagram width** so mermaid measures label
wrapping at the width the diagram will occupy in print.
- **Slices and bands overlap** (36 px / 110 px) so a node cut by a seam reappears
whole on the adjacent slice.
- **`thead { display: table-header-group }`** repeats table headers on
continuation pages; `tr { break-inside: avoid }` stops rows splitting mid-cell.
## Common problems
| Symptom | Cause / fix |
|---|---|
| Diagram cut off at a page edge | Inline SVG sizing survived, or margins were widened. See design notes. |
| Blank page containing only a faint box | A diagram overflowed and was clipped; the slicing threshold did not trigger. |
| Diagram still flagged too small | Dense and neither tall nor wide enough to band. It is vector, so it zooms; for print, try `--landscape` or ask whether the diagram can be split at the source. |
| Large blank gap before a diagram | A diagram that will not fit is pushed whole to the next page. Expected. |
| Source file changed mid-build | `stat` the `.md` against the `.pdf` afterwards; rerun if it moved. |
## Styling
`report.css` holds the print stylesheet: serif body, sans headings and tables,
navy accent, banded rows, callout styling for blockquotes. Edit it to restyle;
it applies to every document rendered by this skill.
Pliki w paczce (13)
- .gitignore 1 KB
- README.md 4 KB
- SKILL.md 5 KB
- md2pdf.js 17 KB
- package-lock.json 46 KB
- package.json 1 KB
- report.css 4 KB
- test/smoke.test.js 8 KB
- test/fixtures/inject.md 1 KB
- test/fixtures/long-table.md 3 KB
- test/fixtures/sample.md 1 KB
- test/fixtures/tall.md 1 KB
- test/fixtures/wide.md 1 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · darblinko/claude-skills | 100 | Apache-2.0 |
| OutlineDriven/outline-driven-development | 100 | Apache-2.0 |
| staskh/trading_skills | 100 | MIT |
| kennethkhoocy/legal-scholarship-skills | 100 | MIT |
| uhstray-io/huhhb | 100 | MIT |
| z-soulx/ai-toolkit | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 0c964e2ae38a (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100md-to-pdf
Konwertuje Markdown na stylowane pliki PDF z diagramami Mermaid, wzorami LaTeX i KaTeX, tabelami i podświetlaniem składni kodu. - 95do.pdf-to-markdown
Zamienia PDF na wierny Markdown z kontrolą pokrycia stron i sekcji, zwłaszcza w artykułach z wzorami, tabelami i kolumnami. - 100md-to-pdf
Konwertuje dowolny plik markdown na czysty plik PDF, na przykład przy eksporcie dokumentu z pliku .md. - 90markdown-mermaid-writing
Tworzy lub recenzuje dokumenty w Markdown z diagramami Mermaid, dbając o format, dostępność, wydajność i wizualną weryfikację wyniku. - 100make-pdf
Zamienia plik markdown w PDF o jakości publikacyjnej: strona tytułowa, klikalny spis treści z numerami stron, nagłówki i numeracja, drukarskie cudzysłowy, kolorowanie składni kodu i opcjonalny znak wodny DRAFT. - 96markdown-pdf-pipeline
Renderuje poradnik lub raport z Markdown do PDF, dbając o układ i spis treści.