What I do
- •Scan a specified directory for Markdown (
.md) files - •Convert each file to HTML using the Python
markdownlibrary - •Render diagrams from code blocks (Mermaid, PlantUML, GraphViz, etc.) using Kroki.io
- •Apply CSS styling for better readability (GitHub-like style)
- •Generate a PDF for each Markdown file using
weasyprint - •Preserve code blocks with syntax highlighting
- •Support tables, images, and standard Markdown syntax
When to use me
Use this skill when you need to:
- •Batch convert documentation from Markdown to PDF
- •Create printable reports from Markdown notes
- •Render technical diagrams directly within your PDF documentation
- •Share documentation with non-technical users
- •Archive project documentation in a portable format
How to use me
Ask me to convert Markdown files in a folder:
code
Use the md-to-pdf skill to convert files in /path/to/docs
Or convert the current directory:
code
Use the md-to-pdf skill to convert files in the current directory
Supported Diagrams
I can automatically render diagrams defined in code blocks with the following languages:
- •
mermaid - •
plantuml - •
graphviz/dot - •
ditaa - •
blockdiag,actdiag,nwdiag,packetdiag,rackdiag - •
c4plantuml - •
erd - •
nomnoml
Just use a fenced code block with the appropriate language identifier:
mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
What I need
- •Target Directory (optional) - The folder containing
.mdfiles- •Defaults to current directory if not specified
- •Must be a valid directory path
- •Internet Connection - Required to fetch rendered diagrams from Kroki.io
What I provide
- •
Dependency setup - Automatically installs required packages:
- •
markdown- Markdown to HTML conversion - •
weasyprint- HTML to PDF conversion - •
pygments- Syntax highlighting for code blocks
- •
- •
Conversion process:
- •Reads each
.mdfile - •Converts Markdown to HTML with extensions (tables, fenced code blocks)
- •Detects and renders diagram code blocks
- •Applies a clean, readable CSS stylesheet
- •Generates a
.pdffile with the same name in the same directory
- •Reads each
- •
Output:
- •PDF files created alongside source Markdown files
- •Summary of converted files
Implementation approach
python
1. Validate input directory
2. Install/verify required dependencies (markdown, weasyprint, pygments)
3. Find all .md files in the directory
4. For each file:
- Read Markdown content
- Pre-process diagram blocks:
- Detect diagram language (mermaid, plantuml, etc.)
- Compress diagram source
- Generate Kroki.io URL
- Replace block with image tag
- Convert to HTML using `markdown` lib with extensions
- Add CSS for styling and syntax highlighting
- Generate PDF using `weasyprint`
5. Report success/failure for each file