Md To Pdf logo

Md To Pdf

Community
Mathews-Tom
md-to-pdf

Convert Markdown to styled PDFs with Mermaid diagrams, LaTeX/KaTeX math, tables, and code highlighting. Triggers on: "convert markdown to pdf", "make a pdf from this md", "export markdown as pdf", "pdf from markdown with equations".

Overview

PublisherMathews-Tom
Repositoryarmory
Skill namemd-to-pdf
Stars
318
Forks
47
Bundled files
5
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Mathews-Tom on GitHub. Read the source before you install it.

Installation

Install the Md To Pdf AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Mathews-Tom/armory.git /tmp/armory
mkdir -p .claude/skills
cp -r /tmp/armory/skills/md-to-pdf .claude/skills/md-to-pdf
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Md To Pdf in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Md To Pdf on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Md To Pdf is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Markdown to PDF Converter

Converts Markdown files to professionally styled PDFs with full rendering of Mermaid diagrams, LaTeX math (via KaTeX), tables, syntax-highlighted code blocks, and all standard Markdown features.

Architecture

text
Input .md file
     ├─ Step 1: Extract ```mermaid blocks → render to SVG via mmdc (Mermaid CLI + Puppeteer)
     │          Replace mermaid code blocks with inline <svg> in the markdown source
     ├─ Step 2: pandoc converts modified markdown → standalone HTML5
     │          (--katex flag preserves raw LaTeX in <span class="math ..."> elements)
     ├─ Step 3: Node.js KaTeX server-side rendering
     │          Replaces math spans with fully rendered KaTeX HTML (no client-side JS needed)
     ├─ Step 4: CSS injection
     │          KaTeX stylesheet (with local font paths) + professional document styles + optional custom CSS
     └─ Step 5: Playwright (headless Chromium) prints final HTML → PDF
           Output .pdf file

Supported Features

FeatureRendering EngineNotes
Mermaid diagramsmmdc (mermaid-cli) via Puppeteerflowchart, sequence, class, state, ER, gantt, pie, git, mindmap, etc.
LaTeX math (inline)KaTeX server-side$E=mc^2$ syntax
LaTeX math (display)KaTeX server-side$$\int f(x) dx$$ syntax
Tablespandoc + CSSFull GFM pipe-table support with professional styling
Code blockspandoc + CSSSyntax highlighting via pandoc, monospace styling
Imagespandoc + PlaywrightLocal file:// and remote https:// images
LinkspandocRendered as styled text
Lists / blockquotespandocOrdered, unordered, nested, blockquotes
YAML frontmatterpandoctitle used as PDF title metadata
Footnotespandoc + CSS[^1] syntax, rendered at page bottom
Definition listspandoc + CSSTerm / definition pairs
Strikethroughpandoc~~deleted~~ syntax
Horizontal rulespandoc + CSS--- rendered as styled separators

Prerequisites

Run the setup checker before first use:

bash
bash <SKILL_DIR>/scripts/setup.sh

This validates that all required tools are present and working. The standard Claude computer-use environment has everything pre-installed. For other environments, the required stack is:

DependencyPurposeInstall
pandocMarkdown → HTMLapt install pandoc
mmdc (@mermaid-js/mermaid-cli)Mermaid → SVGnpm install -g @mermaid-js/mermaid-cli
katex (npm)LaTeX → HTMLnpm install -g katex
playwright (Python)HTML → PDFpip install playwright && playwright install chromium
Chrome/ChromiumBrowser engineInstalled by Playwright or Puppeteer

Usage

Basic

bash
python3 <SKILL_DIR>/scripts/md_to_pdf.py <input.md> <output.pdf>

Full Options

bash
python3 <SKILL_DIR>/scripts/md_to_pdf.py <input.md> <output.pdf> [OPTIONS]
ParameterDefaultDescription
input(required)Path to input Markdown file
output(required)Path to output PDF file
--formatA4Page size: A4, Letter, Legal, A3
--margin0.75inMargins — single value (uniform) or top,right,bottom,left
--no-mermaidfalseSkip Mermaid rendering (keeps raw code blocks)
--no-mathfalseSkip KaTeX math rendering
--css(none)Path to additional custom CSS file to layer on top
--landscapefalseLandscape orientation
--header-footerfalseShow page numbers in footer (page / total)

Examples

bash
# Standard A4 conversion
python3 scripts/md_to_pdf.py report.md report.pdf

# US Letter, landscape, with page numbers
python3 scripts/md_to_pdf.py report.md report.pdf --format Letter --landscape --header-footer

# Custom margins and extra CSS
python3 scripts/md_to_pdf.py report.md report.pdf --margin "1in,0.75in,1in,0.75in" --css brand.css

# Plain mode (skip Mermaid + math for speed)
python3 scripts/md_to_pdf.py report.md report.pdf --no-mermaid --no-math

Workflow for Claude

When a user asks to convert Markdown to PDF:

  1. Determine the input file path (uploaded file or user-specified path)
  2. Run setup check if this is the first use in the session:
    bash
    bash <SKILL_DIR>/scripts/setup.sh
  3. Execute conversion:
    bash
    python3 <SKILL_DIR>/scripts/md_to_pdf.py /path/to/input.md /path/to/output.pdf [OPTIONS]
  4. Present the output file to the user

Handling Failures

SymptomLikely CauseFix
"mmdc FAILED" in Mermaid stepInvalid Mermaid syntaxCheck diagram syntax; mmdc stderr has the parse error
Raw LaTeX visible in PDFKaTeX couldn't parse expressionCheck LaTeX syntax; KaTeX falls back gracefully
"No Chrome binary found"Puppeteer/Playwright Chromium missingRun playwright install chromium
Blank/missing diagramsSVG too large or complexTry --no-mermaid and render diagrams separately

Customization

Custom CSS

Pass --css path/to/custom.css to inject styles after the defaults. Your rules take precedence.

Example — dark theme override:

css
body {
  background: #1a1a2e;
  color: #e0e0e0;
}
h1,
h2,
h3 {
  color: #e0e0e0;
  border-color: #444;
}
table th {
  background: #2a2a4a;
}
pre {
  background: #0d0d1a;
  border-color: #333;
}

Mermaid Theming

Set the MERMAID_CONFIG environment variable to a JSON config file:

bash
MERMAID_CONFIG=/path/to/.mermaidrc python3 scripts/md_to_pdf.py input.md output.pdf

Example .mermaidrc:

json
{
  "theme": "neutral",
  "themeVariables": {
    "primaryColor": "#e1f5fe",
    "lineColor": "#333"
  }
}

Limitations

  • Mermaid diagram rendering requires either network access for CDN-based mmdc or a local @mermaid-js/mermaid-cli install. Offline environments must use --no-mermaid and render diagrams separately.
  • Large documents (100+ pages or many high-resolution images) may hit Playwright's memory limits. Split into multiple input files and merge the resulting PDFs.
  • Custom CSS may not render identically across PDF viewers — layout is determined by Chromium at render time; Acrobat Reader, Preview, and browsers can display the same PDF differently.
  • Page breaks require explicit CSS markers (page-break-before: always or break-before: page) or manual <div style="page-break-before: always"> in the source. Pandoc does not infer page breaks from heading structure.
  • KaTeX coverage is broad but not complete — obscure LaTeX macros or packages not in KaTeX's supported set will fail to render and fall back to raw LaTeX.

File Structure

text
md-to-pdf/
├── SKILL.md                    # This file — skill documentation
├── LICENSE.txt                 # MIT license
├── README.md                   # Distribution / standalone usage docs
├── scripts/
│   ├── md_to_pdf.py            # Main conversion pipeline (Python)
│   ├── katex_render.js         # Server-side KaTeX math renderer (Node.js)
│   └── setup.sh                # Dependency checker / installer
└── tests/
    └── test_document.md        # Comprehensive test covering all features

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Md To Pdf AI skill do?

Convert Markdown to styled PDFs with Mermaid diagrams, LaTeX/KaTeX math, tables, and code highlighting. Triggers on: "convert markdown to pdf", "make a pdf from this md", "export markdown as pdf", "pdf from markdown with equations".

Why use Md To Pdf on TypingMind?

Because you install it once and use it with any model. Md To Pdf is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Md To Pdf in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Mathews-Tom/armory/tree/main/skills/md-to-pdf. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Md To Pdf?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Md To Pdf?

As many as you like. As long as a model supports skills, you can use Md To Pdf with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Md To Pdf AI skill free?

Yes. It is published on GitHub by Mathews-Tom under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇