skip to navigation
skip to content

django-pygmentify 0.3.5

A Django template tag to highlight code with Pygments

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.

 
File Type Py Version Uploaded on Size
django-pygmentify-0.3.5.tar.gz (md5) Source 2017-07-17 3MB
django_pygmentify-0.3.5-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2017-07-17 47KB