🎉 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.
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_highlightjs-0.2.17.tar.gz | 5.6 kB | Without provenance | Details for django_highlightjs-0.2.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_highlightjs-0.2.17-py3-none-any.whl | Python 3 | none | any | Details for django_highlightjs-0.2.17-py3-none-any.whl |
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}
|
Security for django-highlightjs 0.2.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.