highlight-ranges
Highlight ranges of code in pygments output.
This provides a filter that uses spor anchors to determine which ranges of code to highlight in the pygmentized output. You specify the ranges by creating anchors with metadata where the key “highlight” is true, e.g.:
{"highlight": true}
Quick start
First, install highlight-ranges. See the “Installation” section for details.
Create a directory somewhere and create a file named example.py with the following contents:
def func(x):
y = x * 4
return y
Now initialize a spor repository and add an anchor that will highlight the second line in the file:
spor init spor add example.py 17 9 5
Finally, use the highlight-ranges filter to generate the pygmentized HTML of the code:
pygmentize -l python3 -f html -O full -F highlight-ranges:file=example.py example.py > example.html
If you open example.html in a browser, you should see the second line in the code emphasized.
Installation
You can install from PyPI with pip::
pip install highlight-ranges
Or you can install from source:
pip install .
Styling
The filter marks highlighted ranges of code with the Generic.Emph type. From a CSS point of view, this means you can style the highlights via the ge class.
Filter options
- file
The file being pygmentized.
Metadata
Release files for highlight-ranges 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| highlight_ranges-1.0.0.tar.gz | 3.5 kB | Without provenance | Details for highlight_ranges-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| highlight_ranges-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for highlight_ranges-1.0.0-py3-none-any.whl |
Total release size: 9.1 kB
Release files / highlight_ranges-1.0.0.tar.gz
| Download URL | highlight_ranges-1.0.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e677fd1d50fba186dee4391b3dd5de5f2c59a49469773d8fcf6cf28cfd44b21
|
|
BLAKE2b-256 checksum How to use checksums |
34ee1882b1a027b559cb05b1f3b84499a6c3b24329c4ce3ecf466cfcdb66f1f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6
|
Release files / highlight_ranges-1.0.0-py3-none-any.whl
| Download URL | highlight_ranges-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ac2a28ab9c3f001a218332bd75f77657138730b73e112794eec5c4366d224de
|
|
BLAKE2b-256 checksum How to use checksums |
8d096facec819590e50823b7d43549c3451d7ac3620a127a308b85a652f00963
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6
|
Security for highlight-ranges 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.