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 | |
|---|---|---|---|
| highlight_ranges-1.0.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| highlight_ranges-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
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
|