Skip to main content

Export MkDocs Material markdown files to clean DOCX documents using pandoc

Project description

mkdocx

Export MkDocs Material markdown files to clean DOCX documents using pandoc.

Converts MkDocs markdown files into standard DOCX documents ready to be pasted into a branded template. Heading levels are shifted down by one (Markdown H2 becomes Word Heading 1, etc.) since H1 is the page title handled by MkDocs.

Installation

uv tool install .

With support for post-processing wide tables

uv tool install .[postprocess]

Or for development:

uv pip install -e ".[dev]"

Requirements

  • Python 3.10+
  • pandoc must be installed and available on PATH (or specify with --pandoc)
  • Optional: python-docx for post-processing wide tables (install with pip install mkdocx[postprocess])

Usage

# Single file (output defaults to docx-exports/<filename>.docx)
mkdocx docs/guides/getting-started.md

# Single file with explicit output path
mkdocx docs/guides/getting-started.md -o getting-started.docx

# Single file into a specific output folder
mkdocx docs/guides/getting-started.md -of docx-exports/custom

# Export an entire directory (mirrors structure relative to docs/)
mkdocx docs/guides/

# Export a directory, filtering by frontmatter tag
mkdocx docs/ --tag report

# Export with tag into a custom output folder
mkdocx docs/ -t report -of docx-exports/custom

CLI reference

mkdocx <input> [-o OUTPUT | -of [OUTPUT_FOLDER]] [-t TAG] [--pandoc PATH] [--preserve-heading-numbers]
Flag Description
input Path to a markdown file or directory
-o, --output Explicit DOCX output path (single file only, mutually exclusive with -of)
-of, --output-folder Output folder (default: docx-exports/)
-t, --tag Filter by frontmatter tag (directory mode only)
--pandoc Path to pandoc binary (auto-detected if omitted)
--preserve-heading-numbers Keep leading numbers like "1. Introduction" in headings

Output behaviour

Input Flags Output path
File (none) docx-exports/<stem>.docx
File -o path.docx path.docx
File -of folder folder/<stem>.docx
Directory (none) docx-exports/ mirroring structure relative to docs/
Directory -of folder folder/ mirroring structure relative to docs/
Directory -t policy docx-exports/tag/policy/<stem>.docx (flat)
Directory -t policy -of dir dir/tag/policy/<stem>.docx (flat)

Features

  • Macro resolution - {{ extra_var }} placeholders from mkdocs.yml are replaced
  • Relative link rewriting - .md links become full site URLs
  • Admonition conversion - !!! / ??? blocks become styled fenced divs
  • Heading shift - H2 becomes H1, H3 becomes H2, etc.
  • Empty header table fix - promotes first data row when header is blank
  • Abbreviation stripping - removes *[ABBR]: ... definition lines
  • Content-aware table widths - Lua filter balances column proportions
  • Wide table font shrinking - tables with 4+ columns get a smaller font size

Development

# Install dev dependencies
uv pip install -e ".[dev]"

# Run tests
pytest

Project details


Download files

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

Source Distribution

mkdocx-0.1.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

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

mkdocx-0.1.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file mkdocx-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocx-0.1.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mkdocx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e6f401fff0317790f96a359c12e4170b81f183b3e7027efd1990363c2928ca0
MD5 81f335b5e24a6d9f969c2f031457e8a0
BLAKE2b-256 98eb88c57c5d6d04bdfed3878e19da6bfc372271e4c8dc7f1e25b8f96aa8eeba

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocx-0.1.0.tar.gz:

Publisher: publish.yml on Aidenwebb/mkdocx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkdocx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mkdocx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mkdocx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0905413149b2138b2dbca13115c888d81f6c3e9e094fd3a7487e10c884ef4043
MD5 c09cc16294a2b0348dff6ecb4d098812
BLAKE2b-256 50395ce5c192631c5542394ce3bac6f9eb449ebad5a2a102b774a6fdf554c9de

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocx-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Aidenwebb/mkdocx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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