Skip to main content

A Django template tag to highlight code with Pygments

Project description

PyPI version Build status

https://raw.githubusercontent.com/richardcornish/django-pygmentify/master/docs/_static/img/screenshot.png

Django Pygmentify is a Django template tag application to highlight code with Pygments.

It is an alternative to Django Pygments, which hasn’t been updated in several years.

Install

$ pip install django-pygmentify

Add to settings.py.

INSTALLED_APPS = [
    # ...
    'pygmentify',
]

Usage

{% load pygmentify_tags %}

<link rel="stylesheet" href="{% pygmentify_css %}">

{% pygmentify %}
<pre class="python">
print('Hello, world!')
</pre>
{% endpygmentify %}

Result:

<link rel="stylesheet" href="/static/pygmentify/css/default.min.css">

<div class="highlight"><pre class="python"><span></span><span class="k">print</span><span class="p">(</span><span class="s2">&quot;Hello, world!&quot;</span><span class="p">)</span>
</pre></div>

Upgrading

The syntax of the template tags changed in version 0.3.0 from a template filter, {% filter pygmentify %}, to a more robust template tag, {% pygmentify %}. Consult the usage documentation for instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pygmentify-0.3.4.tar.gz (3.4 MB view details)

Uploaded Source

File details

Details for the file django-pygmentify-0.3.4.tar.gz.

File metadata

File hashes

Hashes for django-pygmentify-0.3.4.tar.gz
Algorithm Hash digest
SHA256 df29f4083a018a99ade74fbc4db4a9a07bdde03e6867de26cb11cb0da31b0dea
MD5 e53b5136835315ec468c2e6001f977f1
BLAKE2b-256 7957980d855172263ba5ca5fbdaa870ce3a706049508f4e447784906175f92cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page