Markdown To PDF
Purpose
Convert any .md file to a styled .pdf using the Uvilo theme. Output PDF is placed in the same folder as the source .md file.
When to Use
- User asks to convert a markdown file to PDF
- User says “make a PDF of this .md” or “generate PDF from markdown”
- Any request to produce a PDF from a
.mdfile using the Uvilo brand style
Prerequisites
pandocinstalled (viapypandoc-binaryor system package)weasyprintinstalled (pip install weasyprint)- System libraries: pango, glib, harfbuzz (for weasyprint)
- Fontconfig configured with Uvilo fonts directory
Constants
How to Run
What the Script Does
- Validates input file, tools, CSS, and fonts directory
- Derives output path — replaces
.mdwith.pdf, same directory - Generates PDF — via
pandoc --pdf-engine weasyprint --css uvilo.css - Runs from
/tmpso pandoc can write temp files
Differences from uvilo_method_release
Simplified, general-purpose converter. Does not duplicate source, stamp versions, generate TOC, produce .docx, or create output subfolders.
Environment Setup (Cloud)
In the Railway/cloud environment, weasyprint requires system libraries not pre-installed. Setup:
Troubleshooting
Missing system libraries
- Error:
cannot load library 'libgobject-2.0-0' - Fix: Install pango/glib/harfbuzz (see Environment Setup)
Fontconfig errors
- Error:
Cannot load default config file - Fix: Set
FONTCONFIG_FILEandXDG_CACHE_HOME(see Environment Setup)
pandoc temp file permission denied
- Error:
openTempFile: permission denied - Fix: Script runs from
/tmp; ensureTMPDIR=/tmpis set
Missing fonts
- Error: Fonts render as fallback sans-serif
- Fix: Ensure
FONTS_DIRexists and fontconfig points to it