Skip to main content

Frequenz Filter Lines Superfence

Build Status PyPI Package Docs

Introduction

A custom superfence for pymdown-extensions that can filters lines and plays nice with MkDocs.

This is particularly useful when you want to hide some comments or some boilerplate code from the documentation for any reason.

A typical use case is when you are testing your examples in the documentation, so you might need to add some initialization code, or importing some dependencies that are not relevant for the point you are trying to make in the documentation, but you still need the example code to work to make sure they are not inadvertedly broken.

Quick Example

When writing some documentation, and you want to show some code block, but you want to show only some lines, you can use this superfence as follows:

```text show_lines=":2,4,7,10:12,15:"
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
This is line 10
This is line 11
This is line 12
This is line 13
This is line 14
This is line 15
This is line 16
This is line 17
```

This will show the following block of code in the rendered output:

This is line 1
This is line 2
This is line 4
This is line 7
This is line 10
This is line 11
This is line 12
This is line 15
This is line 16
This is line 17

See Usage for a more detailed explanation of the available options.

Configuration

MkDocs

To use this superfence with MkDocs, you can use something like this:

markdown_extensions:
  - pymdownx.superfences:
      custom_fences:
        - name: "*"
          class: "highlight"
          format: !!python/name:pymdownx_superfence_filter_lines.do_format
          validator: !!python/name:pymdownx_superfence_filter_lines.do_validate

Standalone

To use this superfence standalone, you can use something like this:

import markdown
from pymdownx_superfence_filter_lines import do_format, do_validate

html = markdown.markdown(
    markdown_source,
    extensions=['pymdownx.superfence'],
    extension_configs={
        "pymdownx.superfences": {
            "custom_fences": [
                {
                    'name': '*',
                    'class': 'highlight',
                    'validator': do_validate,
                    'format': do_format
                }
            ]
        }
    }
)

print(html)

Usage

See Quick Example for an example.

The superfence supports the following options:

show_lines

A comma separated list of line numbers or ranges of line numbers to show.

The line numbers are 1-based. If any line number is zero or negative, a warning is logged and the line or range are ignored.

If show_lines is omitted, it defaults to showing all lines.

Ranges

Ranges are inclusive and are defined as follows:

  • The ranges are specified as start:end, where start and end are the line numbers of the first and last lines to show, respectively.

  • If start is omitted, it defaults to the first line. If end is omitted, it defaults to the last line.

  • If start is greater than end, a warning is logged and the range is ignored.

  • If start is greater than the number of lines in the code block, the range is ignored.

  • If end is greater than the number of lines in the code block, it is set to the number of lines in the code block.

Contributing

If you want to know how to build this project and contribute to it, please check out the Contributing Guide.

Metadata

Release files for pymdownx-superfence-filter-lines 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymdownx-superfence-filter-lines 1.0.0
File Size Uploaded Provenance Actions
pymdownx_superfence_filter_lines-1.0.0.tar.gz 11.7 kB With provenance Details for pymdownx_superfence_filter_lines-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymdownx-superfence-filter-lines 1.0.0
File Interpreter ABI Platform Actions
pymdownx_superfence_filter_lines-1.0.0-py3-none-any.whl Python 3 none any Details for pymdownx_superfence_filter_lines-1.0.0-py3-none-any.whl

Total release size: 19.7 kB

Release files / pymdownx_superfence_filter_lines-1.0.0.tar.gz

Download URL pymdownx_superfence_filter_lines-1.0.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c5fc6be59f404dbdb364399d266bcca01c3f86c2fb3cfedae231670788cd9bf3
BLAKE2b-256 checksum
How to use checksums
a6ea4aab989e03dbf5d65dd4038e8690c2263ae2fd6dc4733313574c15fb2d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / pymdownx_superfence_filter_lines-1.0.0-py3-none-any.whl

Download URL pymdownx_superfence_filter_lines-1.0.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94513b560619ffe0514df9c4fcc177aab2b2b6b5558173d0f08cf5bfcb67119c
BLAKE2b-256 checksum
How to use checksums
fa5cbba240ee439f7ac74ed8158aeb601a73ba29a2632801c9cb6769f8862d79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for pymdownx-superfence-filter-lines 1.0.0

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.

Select from 2 files

Attestation for pymdownx_superfence_filter_lines-1.0.0.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 Nov 13, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page