PiMD
Publish documents from Markdown. Professional output. Zero config.
PiMD (Python Markdown Publisher) converts Markdown and HTML into professional DOCX, EPUB, PDF/A, and LaTeX documents — books, reports, technical manuals, research papers, and more. It runs entirely offline with zero cloud dependencies.
Comparison with Alternatives
PiMD fills a unique niche — it is the only Markdown-to-DOCX engine with built-in diagram rendering, equation-to-OMML conversion, and Python-native plugin system. Here's how it stacks up:
| Feature | PiMD | Pandoc | MkDocs | Sphinx | Quarto | Typst |
|---|---|---|---|---|---|---|
| DOCX output | ✅ Professional typography, TOC, cross-refs, page numbers, watermarks | ✅ Basic (pandoc-crossref for references) | ❌ | ❌ | ❌ | ⚠️ Experimental |
| DOCX templates | ✅ 10 presets + inheritance + custom + reference-docx | ✅ Custom reference-docx | ❌ | ❌ | ❌ | ❌ |
| EPUB 3.2 | ✅ Full support, TOC, MathML, SVG | ✅ EPUB 2/3 | ❌ | ❌ | ✅ | ❌ |
| PDF/A archival | ✅ Native (fpdf2) | ❌ | ❌ | ❌ | ❌ | ❌ |
| LaTeX output | ✅ Clean, compilable .tex | ✅ Native LaTeX | ❌ | ✅ Native | ✅ | ❌ |
| HTML output | ✅ Responsive, standalone or site | ✅ | ✅ Static site | ✅ Static site | ✅ Static site | ❌ |
| Diagrams (Mermaid/PlantUML/Graphviz/D2/BlockDiag/Vega) | ✅ Built-in via PiDraw | ❌ Manual pre-render | ⚠️ Plugin-only | ⚠️ Extension-only | ❌ Manual | ❌ |
| Equations (LaTeX → OMML/SVG/HTML) | ✅ Native Word OMML for DOCX, MathJax for HTML | ✅ MathML, TeX | ❌ | ✅ MathJax/Sphinx | ✅ MathJax/Katex | ✅ Native |
| Zero config | ✅ pip install pimd → pimd md file.md file.docx |
✅ pandoc file.md -o file.docx |
❌ Requires mkdocs.yml | ❌ conf.py required | ❌ _quarto.yml required | ❌ Typst file required |
| Python API | ✅ First-class importable library | ⚠️ Via subprocess/haskell-bindings | ⚠️ Via plugins | ✅ sphinx-build programmatic | ❌ CLI only | ❌ CLI only |
| Plugin system | ✅ 9 typed hook types + SDK + event bus | ⚠️ Lua filters (typed? no) | ⚠️ Theme/plugin | ✅ Extension API | ❌ | ❌ |
| WCAG validation | ✅ Built-in accessibility engine | ❌ | ❌ | ❌ | ❌ | ❌ |
| i18n / RTL | ✅ Arabic/Persian/Urdu reshaping, CJK, 15+ locales | ✅ via --pdf-engine options |
⚠️ Theme-dependent | ⚠️ Babel/Intl | ✅ locale support | ✅ Native |
| BibTeX citations | ✅ Built-in | ✅ citeproc | ❌ | ✅ built-in | ✅ | ❌ |
| Incremental build | ✅ Skip unchanged files | ❌ | ✅ | ✅ | ✅ | ❌ |
| Caching (memory/fs/Redis) | ✅ Three backends | ❌ | ❌ | ❌ | ❌ | ❌ |
| CLI watch mode | ✅ File watching | ❌ | ✅ auto-reload | ✅ auto-reload | ✅ auto-reload | ❌ |
| Batch processing | ✅ Directory batch + output mapping | ⚠️ Shell scripts | ✅ | ✅ | ✅ | ❌ |
| Safety guards | ✅ Loop detection, path traversal protection, timeout enforcement | ❌ | ❌ | ❌ | ❌ | ❌ |
| Offline | ✅ 100% offline, zero cloud | ✅ | ⚠️ Search requires online | ✅ | ⚠️ Some features online | ✅ |
| Language | Python 3.10+ | Haskell | Python | Python | Python/R | Rust |
When to use PiMD:
- You need professional DOCX with diagrams, equations, and templates from Markdown
- You want a Python API to integrate with FastAPI/Django/Flask
- You need WCAG-compliant accessible documents
- You're building scientific papers, technical manuals, or books with diagrams and equations
- You want zero-config conversion without YAML config files
When to use alternatives:
- Pandoc: If you need the broadest format support and are comfortable with Haskell filters
- MkDocs / Sphinx: If you're building documentation websites (static HTML is the primary output)
- Quarto: If you're in the R/Python statistical computing ecosystem and want HTML-first publishing
- Typst: If you want a fresh typesetting language and don't need DOCX/EPUB output
Key Features
- Publish-ready DOCX — professional typography, templates, watermarks, TOC, cross-references
- Diagrams — Mermaid, PlantUML, Graphviz, D2, BlockDiag, Vega, ASCII — powered by PiDraw
- Equations — LaTeX into native Word OMML, MathJax, or SVG
- Templates — 10 presets (academic, business, book, resume, invoice…) with inheritance, plus Pandoc-style reference DOCX support
- Multi-format — DOCX, EPUB 3.2, LaTeX, PDF/A, HTML, Markdown, TXT
- Python API — first-class library for FastAPI, Flask, Django
- Plugin system — 9 typed plugin types with SDK, hooks, and event bus
- Accessibility — built-in WCAG validation engine
- i18n — full Unicode, RTL (Arabic/Persian/Urdu), CJK, 15+ language configs
- Enterprise — incremental builds, parallel processing, caching (memory/fs/Redis), safety guards
Installation
pip install pimd # Core only
pip install "pimd[all]" # Core + all optional features
Optional extras:
| Extra | What it adds |
|---|---|
[diagrams] |
Pillow — required for diagram rendering |
[equations] |
matplotlib — renders LaTeX equations |
[export] |
PDF export (docx2pdf / weasyprint) |
[citations] |
BibTeX citation support |
[redis] |
Redis cache backend |
[pdfa] |
PDF/A archival format (fpdf2) |
[i18n] |
Arabic reshaping + bidirectional text |
[all] |
Everything above |
Quick Start
Python API
from pimd import PiMD
engine = PiMD()
# File to file
engine.md_to_docx("report.md", "report.docx")
# String to bytes (no disk writes)
docx_bytes = engine.md_text_to_docx_bytes("# Hello World")
# With options
engine.md_to_docx(
"thesis.md", "thesis.docx",
generate_toc=True,
page_numbers=True,
render_diagrams=True,
)
# With a reference DOCX for custom styles/headers/footers
engine.md_to_docx(
"report.md", "report.docx",
reference_doc="company-template.docx",
)
CLI
# Convert Markdown to DOCX
pimd md guide.md guide.docx --diagrams
# Convert to EPUB / LaTeX
pimd epub book.md book.epub
pimd latex paper.md paper.tex
# Use a template
pimd md report.md report.docx --template academic
# Use a reference DOCX for custom styles/headers/footers
pimd md report.md report.docx --reference-doc company-template.docx
# Inspect styles in a reference DOCX
pimd template inspect company-template.docx
# Batch convert a directory
pimd batch ./docs --output ./build
Common Examples
# Convert HTML to DOCX
engine.html_to_docx("page.html", "page.docx")
# EPUB generation
engine.convert("novel.md", "epub", "novel.epub")
# PDF/A for archival
engine.convert("contract.md", "pdfa", "contract.pdf")
# Watch directory for changes (CLI)
# pimd watch ./docs --output ./build
Supported Formats
| Input | Output |
|---|---|
| Markdown (.md) | DOCX (.docx) |
| HTML (.html) | EPUB 3.2 (.epub) |
| — | LaTeX (.tex) |
| — | PDF / PDF/A (.pdf) |
| — | HTML (.html) |
| — | Markdown (.md) |
| — | TXT (.txt) |
PiDraw Integration
All diagram rendering is delegated to PiDraw. PiMD auto-detects diagram type from code block language hints and renders Mermaid, PlantUML, Graphviz, D2, BlockDiag, Vega, ASCII, and more — all as high-resolution transparent PNGs embedded in DOCX or inline SVG for HTML.
# List supported diagram engines
pimd diagrams list
# Test a specific engine
pimd diagrams test mermaid
Documentation
| Guide | Location |
|---|---|
| Full CLI reference | pimd --help |
| Diagram guide | docs/diagram-guide.md |
| Equation guide | docs/equation-guide.md |
| Performance guide | docs/performance-guide.md |
| Scientific publishing | docs/scientific-publishing-guide.md |
| Plugin development | CONTRIBUTING.md |
| Migration from v1.x | docs/migration-guide.md |
| Support & FAQ | SUPPORT.md |
Contributing
We welcome contributions. See CONTRIBUTING.md for development setup, plugin SDK docs, and pull request guidelines.
git clone https://github.com/devasishpal/PiMd.git
cd PiMd
pip install -e ".[dev,all]"
License
MIT — see LICENSE for details.
Metadata
Release files for pimd 2.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pimd-2.2.5.tar.gz | 440.3 kB | Without provenance | Details for pimd-2.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pimd-2.2.5-py3-none-any.whl | Python 3 | none | any | Details for pimd-2.2.5-py3-none-any.whl |
Total release size: 735.0 kB
Release files / pimd-2.2.5.tar.gz
| Download URL | pimd-2.2.5.tar.gz |
|---|---|
| Size | 440.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b8303a81fda6fed22888063e670bc82a6293cc635c8fdbc6322fd3e05358784
|
|
BLAKE2b-256 checksum How to use checksums |
d16bf891b39fd25eaec28ccaca5099b67aac3c0d67eb8e735bcb3b87579a1618
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / pimd-2.2.5-py3-none-any.whl
| Download URL | pimd-2.2.5-py3-none-any.whl |
|---|---|
| Size | 294.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85ed7b5ecf7aaad3af3774b4828497ff1a2eff1518dd3b990edcd4ae1f15817c
|
|
BLAKE2b-256 checksum How to use checksums |
c04219280c53139e76791f2f73b16190271bd8254ddba39f438b5be8e4f06d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for pimd 2.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.