Skip to main content

🎉 Welcome to django-highlightjs 🎉

Build Status Latest Version

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

🚀 Installation

  1. Install using pip:

    pip install django-highlightjs
    

    Alternatively, you can download or clone this repo and call:

    pip install -e .
    
  2. Add to INSTALLED_APPS in your settings.py:

    ('highlightjs',)
    
  3. In your templates, load the highlightjs library and use the highlightjs_* tags.

⚙️ Settings

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

HIGHLIGHTJS = {
    # The URL to the jQuery JavaScript file
    'jquery_url': '//code.jquery.com/jquery.min.js',
    # The highlight.js base URL
    'base_url': '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js',
    # The complete URL to the highlight.js CSS file
    'css_url': '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/{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 settings.py:

HIGHLIGHTJS = {
    'style': 'github',
}

All other styles are available at highlight.js styles.

📝 Example template

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

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

     {% highlightjs_javascript jquery=1 %}
</body>
</html>

🛠️ Requirements

  • Python 3.11, 3.12, 3.13 or 3.14
  • Django >= 5.2

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.

GitHub Issues

📜 License

You can use this under the MIT license. See the LICENSE file for details.

👤 Author

My name is Mounir Messelmeni, you can reach me at messelmeni.mounir@gmail.com.

Metadata

Release files for django-highlightjs 0.2.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-highlightjs 0.2.17
File Size Uploaded
django_highlightjs-0.2.17.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-highlightjs 0.2.17
File Interpreter ABI Platform
django_highlightjs-0.2.17-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / django_highlightjs-0.2.17.tar.gz

Download URL django_highlightjs-0.2.17.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da85b4e9bb22018c2ef5d2a95dcb7c548408184df00c6fe259c78a06985a80f9
BLAKE2b-256 checksum
How to use checksums
69f1dd6b3337866900b26f24321a427c76ca0d96981565ab6a3419dacbf88df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / django_highlightjs-0.2.17-py3-none-any.whl

Download URL django_highlightjs-0.2.17-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bd42894fe78c6cbd5d3eb5eeb4abc440f70f7c18c90733b9058b8dabadfa4cc
BLAKE2b-256 checksum
How to use checksums
00f20c1c6e7bddd12118165ee29f5afe717f34fb0d2ab6d847fd5d5c06f50209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.17 This release

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page