markdown-hide-code
An small extension for Python's Markdown library that
hides code blocks marked with hide from the markdown output. This is useful
when developers want to include unit tests in their markdown documentation (e.g., using pytest-markdown-docs) but don't want those tests to be visible to documentation readers. I created this extension while developing Pyoframe.
```python {hide}
# This code block will be hidden in the rendered markdown.
```
Install
pip install markdown-hide-code
Usage with mkdocs
Add the extension to your mkdocs.yml configuration:
markdown_extensions:
...
- pymdownx.superfences
- attr_list
- markdown_hide_code # must appear after superfences and attr_list
...
Then, to hide a code block simply add {hide}:
```python {hide}
# This code block will be hidden in the output
```
Usage directly with the Markdown library
Just add the extension to the list. Order matters (see above warning).
from markdown import Markdown
md = Markdown(extensions=["pymdownx.superfences", "attr_list", "markdown_hide_code"])
...
Notes for contributors (and myself)
Clone the repo and run uv sync and pre-commit install to get setup. The core code is all found in src/markdown_hide_code/main.py.
Metadata
Release files for markdown-hide-code 0.1.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 | |
|---|---|---|---|
| markdown_hide_code-0.1.1.tar.gz | 20.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| markdown_hide_code-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.5 kB
Release files / markdown_hide_code-0.1.1.tar.gz
| Download URL | markdown_hide_code-0.1.1.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cc359cd44fc93cbc4903d0a39189697d8e17f8fcb636234b7e7fd6ed559eb1e
|
|
BLAKE2b-256 checksum How to use checksums |
21dc026c7f49c225f1c9addd41dac63b1e3a86146642f8ddec3a3824b891732d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jun 1, 2025.
Transparency logRelease files / markdown_hide_code-0.1.1-py3-none-any.whl
| Download URL | markdown_hide_code-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ed3bb577c77e9fc0d9ba4fed39144b85593bf2dbf2e2eef74cbb582c6397cb3
|
|
BLAKE2b-256 checksum How to use checksums |
8dc24e6c76cfded3e231bfe19ec1948bcf8cbf3c8e8f86fedcad1664a3fdee31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jun 1, 2025.
Transparency log