🎉 Welcome to django-highlightjs 🎉
Use Highlight.js in your Django templates, the Django way.
🚀 Installation
-
Install using pip:
pip install django-highlightjs
Alternatively, you can download or clone this repo and call:
pip install -e .
-
Add to
INSTALLED_APPSin yoursettings.py:'highlightjs',
-
In your templates, load the
highlightjslibrary and use thehighlightjs_*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.
📜 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.
Release files for django-highlightjs 0.2.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_highlightjs-0.2.16.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_highlightjs-0.2.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / django_highlightjs-0.2.16.tar.gz
| Download URL | django_highlightjs-0.2.16.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07e53d9138a0dce4985be97e5993402531dcbd00107b0811ffe81101db53e1ca
|
|
BLAKE2b-256 checksum How to use checksums |
d638346b79641d3973efd9c4a25e79fed3df1b94fa1ce83e9f393a2375c6b1b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.16-py3-none-any.whl
| Download URL | django_highlightjs-0.2.16-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
807fe7a1b4baf1d1fb5cda904cbc72eb7ead7ea7bd7debab557b382f1460aef5
|
|
BLAKE2b-256 checksum How to use checksums |
3485c87f7cad905f1327d18b964c54fae38e32b3dba31036a18a0b8cbe0b5b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|