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.4.tar.gz (429.8 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.4-py3-none-any.whl (285.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pimd-2.2.4.tar.gz
  • Upload date:
  • Size: 429.8 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.4.tar.gz
Algorithm Hash digest
SHA256 10dd5957bbc9f4e0c9db978db23cde29b571edaa6bfa4c1627bbea51517add4b
MD5 6f43cd63232e190e9afe8a97ced3f536
BLAKE2b-256 1b238b21b2d6eb9a278c07c2ecf1bf537251c8cc0cfa30aedb63f81fd424360e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pimd-2.2.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f39a1bc1c5d9216bfa02320b5cbacd026b421cbd815bbb4c35a34a95f95a51b
MD5 bec69ddd1b63781ede21664962f9c434
BLAKE2b-256 5b0a7ff3eeb37f67cfbf0d16b6b7c1142398f5357a0a3e1b86c99f209d831a20

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