Skip to main content

A Django app to easy integrate highlight.js syntax highlighter.

Project description

Welcome to django-highlightjs

.. image::

.. image::

.. image::
:alt: Latest Version

Use Highlight.js ( in your Django templates, the Django way.


1. Install using pip:

``pip install django-highlightjs``

Alternatively, you can install download or clone this repo and call ``pip install -e .``.

2. Add to INSTALLED_APPS in your ````:


3. In your templates, load the ``highlightjs`` library and use the ``highlightjs_*`` tags:


The django-highlightjs has some pre-configured settings.
They can be modified by adding a dict variable called ``HIGHLIGHTJS`` in your ```` and customizing the values you want.
The ``HIGHLIGHTJS`` dict variable is contains these settings and defaults:

.. code:: Python

# The URL to the jQuery JavaScript file
'jquery_url': '//',
# The highlight.js base URL
'base_url': '//',
# The complete URL to the highlight.js CSS file
'css_url': '//{0}.min.css',
# Include jQuery with highlight.js JavaScript (affects django-highlightjs template tags)
'include_jquery': False,
# The default used style.
'style': 'monokai_sublime',

Usage in your ``:
.. code:: Python

'style': 'github',

All other styles available at

Example template

.. code:: Django

{% load highlightjs %}
<link href="{% highlightjs_css_url %}" rel='stylesheet' type='text/css'>
{# Highlight Syntax using Highlightjs #}

{% highlightjs_this code_to_highlight %}
{% highlightjs_this code_to_highlight 'python' %}

{% highlightjs_javascript jquery=1 %}


- Python 2.7, 3.4, 3.5 or 3.6
- Django >= 1.8

Contributions and pull requests for other Django and Python versions are welcome.

Bugs and requests

If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.


You can use this under MIT See `LICENSE
<LICENSE>`_ file for details.


My name is Mounir Messelmeni, you can reach me at .

Project details

Download files

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

Files for django-highlightjs, version 0.2.4
Filename, size File type Python version Upload date Hashes
Filename, size django_highlightjs-0.2.4-py3-none-any.whl (8.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-highlightjs-0.2.4.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page