Skip to main content

PiMD

PiMD

Publish documents from Markdown. Professional output. Zero config.

PyPI Python Versions Downloads Build License


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 ✅ 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 pimdpimd 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
  • 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,
)

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

# 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pimd-2.2.2.tar.gz (429.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pimd-2.2.2-py3-none-any.whl (285.7 kB view details)

Uploaded Python 3

File details

Details for the file pimd-2.2.2.tar.gz.

File metadata

  • Download URL: pimd-2.2.2.tar.gz
  • Upload date:
  • Size: 429.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pimd-2.2.2.tar.gz
Algorithm Hash digest
SHA256 994001502ce72221e340ba83c2fc74a278f3b01a273fe924aa8636d09e0bd210
MD5 7df357ce52e8de59ffd878d26e61e462
BLAKE2b-256 17721cc6d867a083958b65555f7f76be15c481d8203ef349bfab461db470fead

See more details on using hashes here.

File details

Details for the file pimd-2.2.2-py3-none-any.whl.

File metadata

  • Download URL: pimd-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 285.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pimd-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8ac4033c36ec4732dfb6bf1d26804458310ecf57b7dc6faafbfb791ab6d66859
MD5 b55cd7d779d0a724a8df12824fecb3ee
BLAKE2b-256 50d8989fc7479cc0755497aaafafe99d3fed299e4ecacd4832edff74a0372c33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page