description
"django-pygments" is a Django app that provides a template tag and two filters for doing syntax highlighting with Pygments.
dependencies
installation
- Add "django_pygments" to your project directory and to INSTALLED_APPS in your "settings.py",
- If you want to see the integrated demo page, add a "urls.py" entry for "django_pygments.views.demo".
The project is also available on PyPI:
pip install django-pygments
usage
- Enclose your code snippet in a pre tag with the non-standard "lang" attribute set to a supported language like this:
<pre lang="python">....</pre>
-
See the view and demo template for examples on how to use the "pygmentify" and "pygmentify_inline" filters (the latter is rather useful for RSS feeds, because it inlines CSS styles by passing
noclasses=Truetopygments.formatters.HtmlFormatter) or the "pygment" tag. -
While using the "pygment" template tag, you can pass keyword arguments that you would pass to Pygments HtmlFormatter class constructor by passing them as with keyword arguments along with the pygment tag. Look at demo template for examples. There is one caveat with this feature still. You can only pass Python values as argument values (like strings wrapped within quotes or True or False boolean values, etc.). It doesn't support Django template/context variables as arguments yet.
E.g: to disable line numbering, use:
{% pygment linenos=False %}
<pre lang="python">...</pre>
{% endpygment %}
notes
- The custom HTML formatter class displays each line as an ordered list element, thus implementing line numbering without interfering with copy/pasting.
- To see a list of supported languages, look at the "lexer_names" variable in "utils.py".
license
3-clause BSD
credits
- main author - Ștefan Talpalaru stefantalpalaru@yahoo.com
- site - https://github.com/stefantalpalaru/django-pygments
Metadata
Release files for django-pygments 0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_pygments-0.8-py3-none-any.whl | Python 3 | none | any | Details |
| django_pygments-0.8-1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / django_pygments-0.8-py3-none-any.whl
| Download URL | django_pygments-0.8-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
636e85dbf26a1dbf82d65481a964fbefc4f2ce720786f2c8009d608e88142823
|
|
BLAKE2b-256 checksum How to use checksums |
23565c1f7b736bdc1a8dd67b9deccd3f226be656b66e51681ae59b9150f0f509
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / django_pygments-0.8-1-py3-none-any.whl
| Download URL | django_pygments-0.8-1-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19a30d24db09c5a03ffeea8a4c9401574cdd6853203312f21d52fe8da367b18f
|
|
BLAKE2b-256 checksum How to use checksums |
2d010d84893aa229e3d783964cc60280d2125b4956762ff65001fe2dc4d4d9cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for django-pygments 0.8
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.