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 mkdocx
With support for post-processing wide tables
uv tool install mkdocx[postprocess]
Installation From Source
uv tool install .
With support for post-processing wide tables
uv tool install .[postprocess]
Installation 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-docxfor post-processing wide tables (install withpip 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 frommkdocs.ymlare replaced - Relative link rewriting -
.mdlinks 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocx-0.1.3.tar.gz.
File metadata
- Download URL: mkdocx-0.1.3.tar.gz
- Upload date:
- Size: 41.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c88e9e70c724f463a99e6fbbef32e5f384a4c982548f768addb68eff2021fa26
|
|
| MD5 |
14235190199ce2b5929bc6975bef29e8
|
|
| BLAKE2b-256 |
e80287cd4a1d396e2cfe21635f43eac3850984ea9ec08b46df2b8d7b74b778d4
|
Provenance
The following attestation bundles were made for mkdocx-0.1.3.tar.gz:
Publisher:
publish.yml on Aidenwebb/mkdocx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocx-0.1.3.tar.gz -
Subject digest:
c88e9e70c724f463a99e6fbbef32e5f384a4c982548f768addb68eff2021fa26 - Sigstore transparency entry: 973655854
- Sigstore integration time:
-
Permalink:
Aidenwebb/mkdocx@bd5c5e6af1c6de2ea73d9fd713a15621b534e6c3 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Aidenwebb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd5c5e6af1c6de2ea73d9fd713a15621b534e6c3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mkdocx-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mkdocx-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68ddf4c2a0d6468b6de04d98a6fd4cf25bb23caea1b501ea08c1f1dd7f733339
|
|
| MD5 |
a8dfa04e7ecbc9aa265940892738c3d7
|
|
| BLAKE2b-256 |
5e56132670c9348ee6436ad52fce916eab56d9f32e5c407b36a0fdc4588a9283
|
Provenance
The following attestation bundles were made for mkdocx-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on Aidenwebb/mkdocx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocx-0.1.3-py3-none-any.whl -
Subject digest:
68ddf4c2a0d6468b6de04d98a6fd4cf25bb23caea1b501ea08c1f1dd7f733339 - Sigstore transparency entry: 973655916
- Sigstore integration time:
-
Permalink:
Aidenwebb/mkdocx@bd5c5e6af1c6de2ea73d9fd713a15621b534e6c3 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Aidenwebb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd5c5e6af1c6de2ea73d9fd713a15621b534e6c3 -
Trigger Event:
release
-
Statement type: