Skip to main content

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.superfences and attr_list are required dependencies and must be listed BEFORE markdown-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown_hide_code-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_hide_code-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file markdown_hide_code-0.1.0.tar.gz.

File metadata

  • Download URL: markdown_hide_code-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for markdown_hide_code-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f1bc09da9d3b1bd5d8c99d0cd6c82d15da7b2e013dbe2e920496d60e8c702e7
MD5 9bf1e0fb5e924ab6c9143942aa920097
BLAKE2b-256 a98df2e354c3f83299a23d722c23e6388aa6cce5efbc2217426590644f3d0857

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdown_hide_code-0.1.0.tar.gz:

Publisher: publish_to_pypi.yml on staadecker/markdown-hide-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file markdown_hide_code-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_hide_code-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70c7021957d1156cbe9b1c240c2f8deb585b6d7b5555dcde340cdc10ff8fb6b5
MD5 e16c89b9048390c2a0aa4b5cdf60a916
BLAKE2b-256 eb1ec781765b1a4361aa97645a6342287a6bf127439c860901928f3c344f4a5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdown_hide_code-0.1.0-py3-none-any.whl:

Publisher: publish_to_pypi.yml on staadecker/markdown-hide-code

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page