A Django app to easyily integrate highlight.js syntax highlighter.
Project description
Use Highlight.js (https://highlightjs.org) in your Django templates, the Django way.
Installation
Install using pip:
pip install django-highlightjs
Alternatively, you can install download or clone this repo and call pip install -e ..
Add to INSTALLED_APPS in your settings.py:
'highlightjs',
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 is 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 available at https://github.com/isagalaev/highlight.js/tree/main/src/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.8, 3.9, 3.10 or 3.11
Django >= 3
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.
https://github.com/mounirmesselmeni/django-highlightjs/issues
License
You can use this under MIT See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_highlightjs-0.2.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08512c40bedd47d798f75b283b4bfa555d99c9b78e01a591ba0a4504495b1db7 |
|
MD5 | 53bc1313fc2007763e23bd1199940c32 |
|
BLAKE2b-256 | 36b75ffc9284d933a3b832b63556de2184c3f8b805d7e30269b0c39e55b5d315 |
Hashes for django_highlightjs-0.2.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ec6ad4d4788acee4ff65cc66f5cfdbc2eeaf0ef2ff84bc02171976e6cee737 |
|
MD5 | a5e63a5bc94febf7c05ccdf25fd3636d |
|
BLAKE2b-256 | d14b00c19a705a87174e0eeda545cd815dca0f240615ab970ed11f60df002fb5 |