PLUGIN brewdoc / Skills
On this page
md-to-pdf
sonnet user-invokedTurns a Markdown file into a PDF next to the source. reportlab needs no system dependencies; weasyprint adds full CSS, syntax highlighting and accurate tables. An optional quoted instruction rewrites a temporary copy first, so the original is never touched.
Quick reference
| Field | Value |
|---|---|
| Command | /brewdoc:md-to-pdf |
| Arguments | [prompt] <file.md> [--engine name] ["llm prompt"] | styles | test | no args = help |
| Model | sonnet |
| Output | <file>.pdf in the source directory, plus a summary table |
Modes
| Mode | Example | Does |
|---|---|---|
| Convert | /brewdoc:md-to-pdf README.md --engine weasyprint | Converts; --engine overrides the saved engine |
| Convert+Prompt | /brewdoc:md-to-pdf spec.md "remove the Internal Notes section" | Edits a temp copy, then converts |
| Styles | /brewdoc:md-to-pdf styles | Sets page size, colors, code theme, footer |
| Test | /brewdoc:md-to-pdf test | Renders a bundled file to verify the engine |
| Help | /brewdoc:md-to-pdf | Prints usage |
Flow: parse the mode and strip --engine; pick the engine (flag, project config, global config, reportlab; asks once if none saved); check dependencies; preprocess a temp copy when a prompt is quoted; convert, retry once after an auto-fix, print the summary.
Engines
| Feature | reportlab | weasyprint |
|---|---|---|
| Install | pip only | pip + brew system deps |
| Quality / speed | Good / fast | Excellent / moderate |
| Images, CSS | Basic, no CSS | Full, CSS |
| Code highlighting | No | Yes (Pygments) |
| Best for | Quick text docs | Tables, code, complex layout |
The default is reportlab. The first conversion asks for an engine and saves it to .claude/md-to-pdf.config.json; --engine overrides any run.
Example
/brewdoc:md-to-pdf docs/report.md --engine weasyprint
The skill writes docs/report.pdf and prints source, output, page count, size, engine and preprocessing summary (none without a prompt).
Styles and config
styles asks four questions and merges the answers into .claude/md-to-pdf.config.json, so a saved engine survives.
| Parameter | Options | Default |
|---|---|---|
| Page size | A4, Letter, Legal | A4 |
| Color scheme | Default blue (#1a3a5c), Dark (#2d3748), custom hex | Default blue |
| Code theme (weasyprint) | github, monokai, friendly, solarized-dark, solarized-light | github |
| Footer | Page {page} of {total}, {page}/{total}, disabled | Page {page} of {total} |
Config keys (styles saves the styles/default.json structure with the changed values):
| Key | Holds |
|---|---|
engine | reportlab or weasyprint |
page, colors, typography, code, footer | Style groups the converter reads (size, palette, font sizes, code font, footer enabled/format) |
pygments_theme | Code theme, passed to weasyprint as --pygments-theme |
version, content_version, generated_by, last_updated | Provenance, resolved from the plugin on every write |
{
"engine": "weasyprint",
"page": { "size": "Letter" },
"colors": { "primary": "#2d3748" },
"footer": { "enabled": true, "format": "{page}/{total}" },
"pygments_theme": "monokai"
}Lookup order: --engine, project .claude/md-to-pdf.config.json, global ~/.claude/md-to-pdf.config.json, default reportlab.
Dependency pins. check_deps.sh installs exact versions only: reportlab 5.0.1 (reportlab); weasyprint 70.0, markdown 3.11, pygments 2.21.0 (weasyprint).
Test mode, temp files and images
test converts the bundled test-all-elements.md (headings, tables, code, images, lists) into a private mktemp -d directory (mode 0700) removed on exit; with no saved engine it uses reportlab and writes no config.
Convert+Prompt creates {original_dir}/.tmp_XXXXXX with a random suffix, so concurrent runs never collide; a trap removes it on exit. A remote, missing or unreadable image logs a warning with the path and alt text, and conversion continues.
Tests: bash brewdoc/skills/md-to-pdf/tests/run.sh (3 suites, 21 checks).
Related
Publish
Share the generated PDF as a link.
Brewdoc overview
All brewdoc skills.
GitHub source
Scripts, styles and the bundled test file.
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ