mkdocs-code-validator
Checks Markdown code blocks in a MkDocs site against user-defined actions
pip install mkdocs-code-validator
Usage
Activate the plugin in mkdocs.yml. The identifiers config is mandatory. And the plugin doesn't work without pymdownx.superfences:
plugins:
- search
- code-validator:
identifiers:
bash:
validators:
- grep a
markdown_extensions:
- pymdownx.superfences
The above contrived config checks that every ```bash code block in the Markdown files of this MkDocs site must contain the letter "a", otherwise a warning will appear.
The content of each code block is piped as stdin to the command. The exit code of the command is what's checked: a non-zero code will produce a warning (which in MkDocs you can make fatal with the --strict flag). The output of the command is not used in any way, only preserved on the screen as part of a warning.
You can add any number of identifiers, and within them any number of validators commands, each of them has the ability to produce a warning.
If stdin is not usable with your command, the input can be passed as a temporary file instead -- that is done if the command contains the exact argument $< (which is then replaced with a file path). For the above example, changing the command to grep a $< would be equivalent (other than technicalities).
The commands do not allow freeform shell syntax, it's just one subprocess to call with its arguments. To explicitly opt into a shell, just run it as (e.g.) sh -c 'if grep a; then exit 1; fi'. Or, with a temporary file: sh -c 'if grep a "$1"; then exit 1; fi' $<.
The definition of what a code block is is all according to the pymdownx.superfences extension. It must be enabled; the plugin won't do anything without it.
Metadata
Release files for mkdocs-code-validator 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mkdocs_code_validator-0.2.1.tar.gz | 6.3 kB | With provenance | Details for mkdocs_code_validator-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mkdocs_code_validator-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for mkdocs_code_validator-0.2.1-py3-none-any.whl |
Total release size: 12.3 kB
Release files / mkdocs_code_validator-0.2.1.tar.gz
| Download URL | mkdocs_code_validator-0.2.1.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ecf0fdf0b27464a12008ea835cfe5af9d18dbc8743fd892c88e759550eedeb4
|
|
BLAKE2b-256 checksum How to use checksums |
1b9f170641aefa18d6bf860e14129fbb509ef4c840dab1938917f40229552987
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logRelease files / mkdocs_code_validator-0.2.1-py3-none-any.whl
| Download URL | mkdocs_code_validator-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6874be1d7f396dfaab45e487bbcbcae2be387e8845ebf0d4bbea39486d982a3
|
|
BLAKE2b-256 checksum How to use checksums |
629492bdf3dc81735020b4c114b5e57770676e365aa7ad4b929bd7acfdd3307f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logSecurity for mkdocs-code-validator 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mkdocs_code_validator-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.