PLUGIN brewdoc / Skills

md-to-pdf

sonnet user-invoked

Turns 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

FieldValue
Command/brewdoc:md-to-pdf
Arguments[prompt] <file.md> [--engine name] ["llm prompt"] | styles | test | no args = help
Modelsonnet
Output<file>.pdf in the source directory, plus a summary table

Modes

ModeExampleDoes
Convert/brewdoc:md-to-pdf README.md --engine weasyprintConverts; --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 stylesSets page size, colors, code theme, footer
Test/brewdoc:md-to-pdf testRenders a bundled file to verify the engine
Help/brewdoc:md-to-pdfPrints 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

Featurereportlabweasyprint
Installpip onlypip + brew system deps
Quality / speedGood / fastExcellent / moderate
Images, CSSBasic, no CSSFull, CSS
Code highlightingNoYes (Pygments)
Best forQuick text docsTables, 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.

ParameterOptionsDefault
Page sizeA4, Letter, LegalA4
Color schemeDefault blue (#1a3a5c), Dark (#2d3748), custom hexDefault blue
Code theme (weasyprint)github, monokai, friendly, solarized-dark, solarized-lightgithub
FooterPage {page} of {total}, {page}/{total}, disabledPage {page} of {total}

Config keys (styles saves the styles/default.json structure with the changed values):

KeyHolds
enginereportlab or weasyprint
page, colors, typography, code, footerStyle groups the converter reads (size, palette, font sizes, code font, footer enabled/format)
pygments_themeCode theme, passed to weasyprint as --pygments-theme
version, content_version, generated_by, last_updatedProvenance, 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).

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