Hide code blocks from the rendered markdown output, useful for running tests on your documentation.
Project description
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
...
[!WARNING]
pymdownx.superfencesandattr_listare required dependencies and must be listed BEFOREmarkdown-hide-code.
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.
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 markdown_hide_code-0.1.1.tar.gz.
File metadata
- Download URL: markdown_hide_code-0.1.1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc359cd44fc93cbc4903d0a39189697d8e17f8fcb636234b7e7fd6ed559eb1e
|
|
| MD5 |
dea496a626dbf3c99287dfeb4708613c
|
|
| BLAKE2b-256 |
21dc026c7f49c225f1c9addd41dac63b1e3a86146642f8ddec3a3824b891732d
|
Provenance
The following attestation bundles were made for markdown_hide_code-0.1.1.tar.gz:
Publisher:
publish_to_pypi.yml on staadecker/markdown-hide-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_hide_code-0.1.1.tar.gz -
Subject digest:
5cc359cd44fc93cbc4903d0a39189697d8e17f8fcb636234b7e7fd6ed559eb1e - Sigstore transparency entry: 226834358
- Sigstore integration time:
-
Permalink:
staadecker/markdown-hide-code@bd24c1ca01944996e537647810193efba5709ed7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/staadecker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@bd24c1ca01944996e537647810193efba5709ed7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file markdown_hide_code-0.1.1-py3-none-any.whl.
File metadata
- Download URL: markdown_hide_code-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed3bb577c77e9fc0d9ba4fed39144b85593bf2dbf2e2eef74cbb582c6397cb3
|
|
| MD5 |
3a58db4c1392cfb8357422c4177e4d48
|
|
| BLAKE2b-256 |
8dc24e6c76cfded3e231bfe19ec1948bcf8cbf3c8e8f86fedcad1664a3fdee31
|
Provenance
The following attestation bundles were made for markdown_hide_code-0.1.1-py3-none-any.whl:
Publisher:
publish_to_pypi.yml on staadecker/markdown-hide-code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_hide_code-0.1.1-py3-none-any.whl -
Subject digest:
7ed3bb577c77e9fc0d9ba4fed39144b85593bf2dbf2e2eef74cbb582c6397cb3 - Sigstore transparency entry: 226834359
- Sigstore integration time:
-
Permalink:
staadecker/markdown-hide-code@bd24c1ca01944996e537647810193efba5709ed7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/staadecker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@bd24c1ca01944996e537647810193efba5709ed7 -
Trigger Event:
release
-
Statement type: