pymdownx-superfence-filter-lines


Namepymdownx-superfence-filter-lines JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryA custom superfence for pymdown-extensions that can filters lines and plays nice with MkDocs
upload_time2023-12-15 12:33:14
maintainer
docs_urlNone
author
requires_python<4,>=3.11
licenseMIT
keywords frequenz python lib library pymdownx-superfence-filter-lines markdown filter mkdocs python3 mkdocs-material pymdownx pymdown-extensions superfence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Frequenz Filter Lines Superfence

[![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)
[![PyPI Package](https://img.shields.io/pypi/v/pymdownx-superfence-filter-lines)](https://pypi.org/project/pymdownx-superfence-filter-lines/)
[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/pymdownx-superfence-filter-lines-python/)

## 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:

~~~markdown
```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:

```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
```

See [Usage](#usage) for a more detailed explanation of the available options.

## Configuration

### MkDocs

To use this superfence with [MkDocs](https://www.mkdocs.org/), you can use
something like this:

```yaml
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:

```python
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](#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](CONTRIBUTING.md).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pymdownx-superfence-filter-lines",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "<4,>=3.11",
    "maintainer_email": "",
    "keywords": "frequenz,python,lib,library,pymdownx-superfence-filter-lines,markdown,filter,mkdocs,python3,mkdocs-material,pymdownx,pymdown-extensions,superfence",
    "author": "",
    "author_email": "Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>",
    "download_url": "https://files.pythonhosted.org/packages/58/b8/f070e7e35d400b24a8a7f7e9ae38cd9681d66a8ea4c7bc99a665020752ce/pymdownx-superfence-filter-lines-0.1.0.tar.gz",
    "platform": null,
    "description": "# 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 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\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",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A custom superfence for pymdown-extensions that can filters lines and plays nice with MkDocs",
    "version": "0.1.0",
    "project_urls": {
        "Changelog": "https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/releases",
        "Documentation": "https://frequenz-floss.github.io/pymdownx-superfence-filter-lines-python/",
        "Issues": "https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/issues",
        "Repository": "https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python",
        "Support": "https://github.com/frequenz-floss/pymdownx-superfence-filter-lines-python/discussions/categories/support"
    },
    "split_keywords": [
        "frequenz",
        "python",
        "lib",
        "library",
        "pymdownx-superfence-filter-lines",
        "markdown",
        "filter",
        "mkdocs",
        "python3",
        "mkdocs-material",
        "pymdownx",
        "pymdown-extensions",
        "superfence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a7fb3f4027611ae80821ad4228da00906743fc9ca97d4158aa837b1d5fca747",
                "md5": "ddc5d694c5c8d19baee7825c438476b0",
                "sha256": "53d1f6d81adbbae8db12da68efa8320f2b72a706fc52600a2c166c78ed74dc9d"
            },
            "downloads": -1,
            "filename": "pymdownx_superfence_filter_lines-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ddc5d694c5c8d19baee7825c438476b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.11",
            "size": 7931,
            "upload_time": "2023-12-15T12:33:12",
            "upload_time_iso_8601": "2023-12-15T12:33:12.711669Z",
            "url": "https://files.pythonhosted.org/packages/2a/7f/b3f4027611ae80821ad4228da00906743fc9ca97d4158aa837b1d5fca747/pymdownx_superfence_filter_lines-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "58b8f070e7e35d400b24a8a7f7e9ae38cd9681d66a8ea4c7bc99a665020752ce",
                "md5": "86bd4f4ef2ffe915f3eed36c9e8fe9e3",
                "sha256": "589e697b323a7a733cc706cc74db1f12e62706915e7438e16ef9bd5693766165"
            },
            "downloads": -1,
            "filename": "pymdownx-superfence-filter-lines-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "86bd4f4ef2ffe915f3eed36c9e8fe9e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.11",
            "size": 10100,
            "upload_time": "2023-12-15T12:33:14",
            "upload_time_iso_8601": "2023-12-15T12:33:14.601418Z",
            "url": "https://files.pythonhosted.org/packages/58/b8/f070e7e35d400b24a8a7f7e9ae38cd9681d66a8ea4c7bc99a665020752ce/pymdownx-superfence-filter-lines-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 12:33:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "frequenz-floss",
    "github_project": "pymdownx-superfence-filter-lines-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pymdownx-superfence-filter-lines"
}
        
Elapsed time: 0.17302s