MkDocs plugin that renders pages with Stripe's Markdoc instead of Python-Markdown
Project description
mkdocs-markdoc
An MkDocs plugin that completely replaces the default Python-Markdown renderer
with Stripe's Markdoc. Every .md page in your
docs site is parsed and rendered by Markdoc's HTML renderer — no React
required.
How it works
MkDocs ──on_page_markdown──▶ plugin.py ──stdin──▶ markdoc_runner.js
│
HTML string ◀──stdout──────────────┘
The Python plugin hooks into on_page_markdown, pipes the raw Markdown to a
bundled Node.js script via subprocess, and returns the HTML string that
MkDocs injects into the theme template.
Prerequisites
| Requirement | Minimum version |
|---|---|
| Python | 3.9 |
| MkDocs | 1.5 |
| Node.js | 18 LTS |
| npm | 8 |
Installation
1 — Install the Python package
# From the repo root (editable/development install)
pip install -e .
# Or once published to PyPI
pip install mkdocs-markdoc
2 — Install the Node.js Markdoc library
The @markdoc/markdoc npm package must be resolvable by Node.js when it runs
the bundled markdoc_runner.js script. Install it in one of these
locations (Node's module resolution will find it):
# Option A – global install (simplest for local dev / CI)
npm install -g @markdoc/markdoc
# Option B – local install in your docs project root
cd /path/to/your/docs-project
npm install @markdoc/markdoc
3 — Enable the plugin in mkdocs.yml
# mkdocs.yml
site_name: My Docs
plugins:
- markdoc # ← add this; remove or comment out the default 'search'
# plugin only if you no longer need it
Note: MkDocs' built-in
searchplugin is independent of the Markdown renderer and can be kept alongsidemarkdoc:plugins: - search - markdoc
Configuration options
All options are optional.
plugins:
- markdoc:
# Path to the Node.js executable.
# Default: "node" (resolved via $PATH)
node_path: /usr/local/bin/node
# Path to a JS or JSON file that exports a Markdoc config object.
# When omitted, Markdoc uses its built-in defaults (standard Markdown
# nodes, no custom tags or functions).
markdoc_config: docs/markdoc.config.js
# Milliseconds to wait for the Node subprocess before raising an error.
# Default: 30000 (30 seconds)
timeout: 30000
Example markdoc.config.js
// docs/markdoc.config.js
const { nodes, Tag } = require("@markdoc/markdoc");
module.exports = {
tags: {
callout: {
render: "div",
attributes: {
type: { type: String, default: "note" },
},
},
},
nodes: {
// Override the default heading to add anchor IDs
heading: {
...nodes.heading,
render: "h1",
},
},
};
Running the docs locally
mkdocs serve
Caveats & trade-offs
- Markdoc syntax differs from CommonMark. Markdoc is a superset of Markdown, but some edge-cases render differently. Review the Markdoc syntax reference when migrating an existing docs site.
- Node.js subprocess overhead. Each page spawns (and immediately exits) one Node process. For large sites with hundreds of pages the build time will increase compared to the native Python-Markdown renderer. If this becomes a bottleneck, consider batching pages in a future version.
- MkDocs extensions are bypassed. Because we skip Python-Markdown entirely,
any
markdown_extensions:listed inmkdocs.ymlwill have no effect. Equivalent behaviour must be implemented via Markdoc tags/nodes/functions.
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 mkdocs_markdoc-0.2.1.tar.gz.
File metadata
- Download URL: mkdocs_markdoc-0.2.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72e1cdeab65071adb4ea14140bbeb6c8aa560b43309172c03b51a4584c882410
|
|
| MD5 |
4d274dfde035eba34d89d5e4290eced7
|
|
| BLAKE2b-256 |
4a1db455b3e971c2084658a6dabf5ebd824a70f80ba77de6cecb39b9a11d25e1
|
Provenance
The following attestation bundles were made for mkdocs_markdoc-0.2.1.tar.gz:
Publisher:
publish.yml on jwoglom/mkdocs-markdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_markdoc-0.2.1.tar.gz -
Subject digest:
72e1cdeab65071adb4ea14140bbeb6c8aa560b43309172c03b51a4584c882410 - Sigstore transparency entry: 976918827
- Sigstore integration time:
-
Permalink:
jwoglom/mkdocs-markdoc@b8d6205c8f7aa9ae9ccf1720ab8f2299fcfa5cba -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jwoglom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8d6205c8f7aa9ae9ccf1720ab8f2299fcfa5cba -
Trigger Event:
release
-
Statement type:
File details
Details for the file mkdocs_markdoc-0.2.1-py3-none-any.whl.
File metadata
- Download URL: mkdocs_markdoc-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.9 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 |
938d6e3ea8b7b89b7f94d153a3047b243e36a06daadbfe0e5fc06ed644b82905
|
|
| MD5 |
540dbaad09af7db98bc54ce143ddb685
|
|
| BLAKE2b-256 |
e7c52d97699b373a9708c42f4f406d18f8166701714dff4a4fa296860974fcda
|
Provenance
The following attestation bundles were made for mkdocs_markdoc-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on jwoglom/mkdocs-markdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_markdoc-0.2.1-py3-none-any.whl -
Subject digest:
938d6e3ea8b7b89b7f94d153a3047b243e36a06daadbfe0e5fc06ed644b82905 - Sigstore transparency entry: 976918854
- Sigstore integration time:
-
Permalink:
jwoglom/mkdocs-markdoc@b8d6205c8f7aa9ae9ccf1720ab8f2299fcfa5cba -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jwoglom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8d6205c8f7aa9ae9ccf1720ab8f2299fcfa5cba -
Trigger Event:
release
-
Statement type: