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.
```
pip install markdown-hide-code
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
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4