{"id":15169466,"url":"https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python","last_synced_at":"2025-10-13T07:36:33.557Z","repository":{"id":209661618,"uuid":"724193224","full_name":"frequenz-floss/pymdownx-superfence-filter-lines-python","owner":"frequenz-floss","description":"A custom superfence for pymdown-extensions that can filters lines and plays nice with MkDocs","archived":false,"fork":false,"pushed_at":"2025-01-02T14:00:28.000Z","size":2100,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"v0.x.x","last_synced_at":"2025-01-16T09:41:41.762Z","etag":null,"topics":["filter","frequenz","markdown","mkdocs","mkdocs-material","pymdown","pymdown-extensions","python","python3","superfence"],"latest_commit_sha":null,"homepage":"https://frequenz-floss.github.io/pymdownx-superfence-filter-lines-python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frequenz-floss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-27T15:28:00.000Z","updated_at":"2025-01-02T13:48:07.000Z","dependencies_parsed_at":"2023-11-28T15:29:03.163Z","dependency_job_id":"6866a06d-d2d7-48b3-aa86-edd1623c5f82","html_url":"https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python","commit_stats":{"total_commits":47,"total_committers":3,"mean_commits":"15.666666666666666","dds":0.4893617021276596,"last_synced_commit":"bd2355bace25dbfb6b6ad87f68cf3d2ba6d39644"},"previous_names":["frequenz-floss/frequenz-pymdown-superfence-filter-lines-python","frequenz-floss/frequenz-pymdownx-superfences-filter-lines-python"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frequenz-floss%2Fpymdownx-superfence-filter-lines-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frequenz-floss%2Fpymdownx-superfence-filter-lines-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frequenz-floss%2Fpymdownx-superfence-filter-lines-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frequenz-floss%2Fpymdownx-superfence-filter-lines-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frequenz-floss","download_url":"https://codeload.github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/tar.gz/refs/heads/v0.x.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515428,"owners_count":19002481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","frequenz","markdown","mkdocs","mkdocs-material","pymdown","pymdown-extensions","python","python3","superfence"],"created_at":"2024-09-27T07:01:44.696Z","updated_at":"2025-10-06T09:30:27.445Z","avatar_url":"https://github.com/frequenz-floss.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frequenz Filter Lines Superfence\n\n[![Build Status](https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/actions/workflows/ci.yaml)\n[![PyPI Package](https://img.shields.io/pypi/v/pymdownx-superfence-filter-lines)](https://pypi.org/project/pymdownx-superfence-filter-lines/)\n[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/pymdownx-superfence-filter-lines-python/)\n\n## Introduction\n\nA custom superfence for pymdown-extensions that can filters lines and plays\nnice with MkDocs.\n\nThis is particularly useful when you want to hide some comments or some\nboilerplate code from the documentation for any reason.\n\nA typical use case is when you are testing your examples in the documentation,\nso you might need to add some initialization code, or importing some dependencies\nthat are not relevant for the point you are trying to make in the\ndocumentation, but you still need the example code to work to make sure they are\nnot inadvertedly broken.\n\n## Quick Example\n\nWhen writing some documentation, and you want to show some code block, but\nyou want to show only some lines, you can use this superfence as follows:\n\n~~~markdown\n```text show_lines=\":2,4,7,10:12,15:\"\nThis is line 1\nThis is line 2\nThis is line 3\nThis is line 4\nThis is line 5\nThis is line 6\nThis is line 7\nThis is line 8\nThis is line 9\nThis is line 10\nThis is line 11\nThis is line 12\nThis is line 13\nThis is line 14\nThis is line 15\nThis is line 16\nThis is line 17\n```\n~~~\n\nThis will show the following block of code in the rendered output:\n\n```text\nThis is line 1\nThis is line 2\nThis is line 4\nThis is line 7\nThis is line 10\nThis is line 11\nThis is line 12\nThis is line 15\nThis is line 16\nThis is line 17\n```\n\nSee [Usage](#usage) for a more detailed explanation of the available options.\n\n## Configuration\n\n### MkDocs\n\nTo use this superfence with [MkDocs](https://www.mkdocs.org/), you can use\nsomething like this:\n\n```yaml\nmarkdown_extensions:\n  - pymdownx.superfences:\n      custom_fences:\n        - name: \"*\"\n          class: \"highlight\"\n          format: !!python/name:pymdownx_superfence_filter_lines.do_format\n          validator: !!python/name:pymdownx_superfence_filter_lines.do_validate\n```\n\n### Standalone\n\nTo use this superfence standalone, you can use something like this:\n\n```python\nimport markdown\nfrom pymdownx_superfence_filter_lines import do_format, do_validate\n\nhtml = markdown.markdown(\n    markdown_source,\n    extensions=['pymdownx.superfence'],\n    extension_configs={\n        \"pymdownx.superfences\": {\n            \"custom_fences\": [\n                {\n                    'name': '*',\n                    'class': 'highlight',\n                    'validator': do_validate,\n                    'format': do_format\n                }\n            ]\n        }\n    }\n)\n\nprint(html)\n```\n\n## Usage\n\nSee [Quick Example](#quick-example) for an example.\n\nThe superfence supports the following options:\n\n### `show_lines`\n\nA comma separated list of line numbers or ranges of line numbers to show.\n\nThe line numbers are 1-based. If any line number is zero or negative, a warning\nis logged and the line or range are ignored.\n\nIf `show_lines` is omitted, it defaults to showing all lines.\n\n#### Ranges\n\nRanges are inclusive and are defined as follows:\n\n* The ranges are specified as `start:end`, where `start` and `end` are the line\n  numbers of the first and last lines to show, respectively.\n\n* If `start` is omitted, it defaults to the first line. If `end` is omitted, it\n  defaults to the last line.\n\n* If `start` is greater than `end`, a warning is logged and the range is\n  ignored.\n\n* If `start` is greater than the number of lines in the code block, the range\n  is ignored.\n\n* If `end` is greater than the number of lines in the code block, it is set to\n  the number of lines in the code block.\n\n## Contributing\n\nIf you want to know how to build this project and contribute to it, please\ncheck out the [Contributing Guide](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrequenz-floss%2Fpymdownx-superfence-filter-lines-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrequenz-floss%2Fpymdownx-superfence-filter-lines-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrequenz-floss%2Fpymdownx-superfence-filter-lines-python/lists"}