Convert Markdown, HTML, or LaTeX to beautifully styled PDF, DOCX, or ODT with customizable themes and modern typography.
uv sync
docgen input.md -o output.pdf
docgen input.md -o output.pdf --theme nord --mode dark
docgen input.html -o output.docx --theme gruvbox --mode light
docgen input.tex -o output.odt --theme draculaRequires Python 3.12+ and pandoc.
git clone <repo>
cd doc-generator
uv sync# Basic conversion (auto-detects formats from extensions)
docgen input.md -o output.pdf
# Specify theme and mode
docgen input.md -o output.pdf --theme nord --mode dark
# Custom theme YAML file
docgen input.md -o output.pdf --theme ./my-theme.yaml
# PDF engine selection (weasyprint or xelatex)
docgen input.md -o output.pdf --pdf-engine xelatex
# Override format detection
docgen input --to docx --from md -o output.docx
# Document title (auto-extracted from first h1 if omitted)
docgen input.md -o output.pdf --title "My Document"
# Centered title page
docgen input.md -o output.pdf --title "My Document" --title-page
# Remove the first h1 from the body (avoids duplication with header)
docgen input.md -o output.pdf --remove-title
# Custom body font
docgen input.md -o output.pdf --font-family "Noto Sans"
# Search extra directories for theme YAML files
docgen input.md -o output.pdf --extra-theme-dir ./themes
# List available themes
docgen --list-themesDirection is auto-detected per paragraph — no flag needed. Arabic, Hebrew, and other RTL scripts are detected from the content and each paragraph renders in its correct direction (dir="rtl" or dir="ltr"). Mixed Arabic/English documents work seamlessly.
Themed PDFs (via WeasyPrint) feature a modern glassy design:
- Rounded corners — code blocks, blockquotes, tables, and images
- Soft shadows — subtle depth on cards and panels
- Gradient accents — heading underlines, section dividers, title page rule
- Drop caps — decorative first letter after h1/h2 headings
- Zebra tables — alternating row backgrounds for readability
- Decorative blockquotes — large opening quote mark
- Custom list bullets — accent-colored round bullets and styled markers
- Title page — centered hero with gradient rule and soft accent glow
- Alternating page numbers — left on left pages, right on right pages
- Full-width header line — with accent tint
- Color emoji — rendered as crisp inline PNG images using the Noto Color Emoji font, precisely aligned via CSS
20 built-in themes (11 palettes × modes):
| Palette | Modes |
|---|---|
| gruvbox | dark, light |
| nord | dark, light |
| github | dark, light |
| dracula | dark |
| solarized | dark, light |
| catppuccin | mocha, latte |
| monokai | dark |
| tokyo-night | dark, light |
| ayu | dark, light |
| rose-pine | dawn, moon |
| kanagawa | wave, lotus |
Create a YAML file:
name: my-theme
mode: dark
colors:
background: "#1a1a2e"
text: "#e0e0e0"
heading: "#e94560"
link: "#0f3460"
code_bg: "#16213e"
code_text: "#a6e3a1"
blockquote_bg: "#16213e"
border: "#333"
accent: "#e94560"
table_header_bg: "#16213e"
table_border: "#333"
muted: "#888"Then use it:
docgen input.md -o output.pdf --theme ./my-theme.yamlfrom docgen import convert
# Basic usage
convert("input.md", "output.pdf")
# With theme
convert("input.md", "output.pdf", theme_name="nord", theme_mode="dark")
# Custom theme
convert("input.md", "output.pdf", theme_name="/path/to/theme.yaml")
# With title and title page
convert("input.md", "output.pdf", title="My Document", title_page=True)
# List themes
from docgen import ThemeManager
manager = ThemeManager()
themes = manager.list_themes()| Package | Purpose |
|---|---|
| pypandoc | Pandoc bridge for all conversions |
| pyyaml | Theme YAML parsing |
| jinja2 | HTML/LaTeX template rendering |
| weasyprint | Themed PDF via HTML+CSS |
| python-docx | Themed DOCX reference doc generation |
| odfpy | Themed ODT reference doc generation |
| pycairo | Emoji PNG rendering for precise alignment |
- pandoc: Install from pandoc.org or your package manager
- WeasyPrint (for themed PDF): Requires Pango, Cairo, GDK-Pixbuf libraries
Build system packages with fpm and make:
# Prerequisites: fpm (gem install fpm) and python3
make deb # → dist/docgen-0.1.0-1-x86_64.deb
make rpm # → dist/docgen-0.1.0-1-x86_64.rpm
make pacman # → dist/docgen-0.1.0-1-x86_64.pkg.tar.zst
make all # all three
make clean # remove built packagesGenerate completions for bash, fish, and zsh:
make completions # generates completions/docgen.{bash,fish} and completions/_docgenTo install system-wide:
# bash
cp completions/docgen.bash /usr/share/bash-completion/completions/docgen
# fish
cp completions/docgen.fish /usr/share/fish/vendor_completions.d/docgen.fish
# zsh
cp completions/_docgen /usr/share/zsh/site-functions/_docgenCompletions are also bundled automatically in system packages built with make deb/make rpm/make pacman.
uv sync --group dev
uv run pytest -v
0 comments
log in to comment.