markdown-to-pdf
Converting Markdown to professional PDFs using Pandoc, WeasyPrint, ReportLab, and related tools
npx skills add cosmicstack-labs/mercury-agent-skills --skill markdown-to-pdf --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Converts Markdown documents into PDFs using multiple toolchains, including Pandoc, WeasyPrint, and ReportLab, and covers CSS print styling, template systems, and batch workflows.
How it works
- Pandoc workflows: demonstrates converting Markdown to PDF with standard and advanced options, including metadata files, specific PDF engines, templates, bibliographies, and custom LaTeX configurations.
- Pandoc filters: shows a Python-based Pandoc filter that can wrap code blocks for styling, plus a command example to run Pandoc with the filter.
- WeasyPrint: converts HTML to PDF via WeasyPrint, including examples for direct HTML input, URL-based HTML, and a full Markdown-to-HTML-to-PDF pipeline with a CSS print stylesheet. It provides a Python function markdown_to_pdf(md_path, css_path, output_path) that converts Markdown to HTML and then to PDF using a supplied CSS file.
- CSS print stylesheet: provides a detailed template for print styling, including page setup, typography, headers/footers, code blocks, tables, images, and layout rules.
- ReportLab: offers programmatic PDF generation with a basic document example, including a sample layout for a title page, table of contents, data tables, and a simple page template example. It includes Python code to create a professional PDF and to extend with custom page templates and headers/footers.
When to use it
Use when you need to produce production-quality PDFs from Markdown through varied toolchains: high-quality academic/technical documents (Pandoc with LaTeX), branded web-like PDFs (WeasyPrint), or dynamically generated PDFs from data (ReportLab).
What it can touch
- Pandoc workflows and commands as shown in code blocks.
- A Pandoc filter script (code_styler.py) and its invocation via Pandoc.
- Python environments with WeasyPrint and Markdown libraries for the HTML-to-PDF pipeline.
- A print CSS stylesheet template (print.css).
- Python code using ReportLab for programmatic PDF creation.
Caveats
- The content assumes availability of external tools: Pandoc, LaTeX engines or wkhtmltopdf, WeasyPrint, and ReportLab.
- No explicit licensing notes beyond the skill’s metadata (MIT).
# Markdown to PDF Conversion Convert Markdown documents into polished, production-ready PDFs. This skill covers the major toolchains — Pandoc, WeasyPrint, ReportLab — plus CSS print styling, template systems, and batch conversion workflows. --- ## Toolchain Overview | Tool | Approach | Best For | Output Quality | |------|----------|----------|----------------| | **Pandoc** | Markdown → PDF via LaTeX/Context/Wkhtmltopdf | Books, papers, reports | High | | **WeasyPrint** | Markdown → HTML → PDF via CSS print | Web-like documents, branded PDFs | High | | **ReportLab** | Programmatic PDF generation via Python | Dynamic, data-driven PDFs | Very High | | **md-to-pdf** | Node.js CLI for quick markdown → PDF | Simple documents, quick output | Medium | | **Puppeteer/Playwright** | Markdown → HTML → Headless browser → PDF | Pixel-perfect web-to-PDF | Very High | --- ## 1. Pandoc Workflows Pandoc is the Swiss Army knife of document conversion. It reads Markdown and outputs PDF via an intermediate engine (default: LaTeX). ### Basic Conversion ```bash # Simple markdown to PDF (uses pdflatex) pandoc input.md -o output.pdf # With metadata file pandoc input.md --metadata-file=metadata.yaml -o outp
- Toolchain Overview
- 1. Pandoc Workflows
- Basic Conversion
- Advanced Pandoc with Templates
- Metadata YAML for Pandoc
- Pandoc Filter: Custom Transformations
- 2. WeasyPrint: HTML/CSS to PDF
- Basic WeasyPrint Workflow
- Markdown → HTML → PDF Pipeline
- CSS Print Stylesheet Template
- 3. ReportLab: Programmatic PDF Generation
- Basic ReportLab Document
- ReportLab with Custom Page Templates
- 4. Syntax Highlighting in PDF
Simple markdown to PDF (uses pdflatex) pandoc input.md -o output.pdf With metadata file pandoc input.md --metadata-file=metadata.yaml -o output.pdf Specify output engine pandoc input.md --pdf-engine=xelatex -o output.pdf Using wkhtmltopdf instead of LaTeX pandoc input.md --pdf-engine=wkhtmltopdf -o output.pdf Custom LaTeX template pandoc input.md \
What does the markdown-to-pdf skill do?
Converting Markdown to professional PDFs using Pandoc, WeasyPrint, ReportLab, and related tools
How do I install it?
Run `npx skills add cosmicstack-labs/mercury-agent-skills --skill markdown-to-pdf --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From cosmicstack-labs/mercury-agent-skills, a repository with 364 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.