Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
django-highlightjs
Readme
.. image:: https://github.com/mounirmesselmeni/django-highlightjs/actions/workflows/workflow.yml/badge.svg :target: https://github.com/mounirmesselmeni/django-highlightjs/actions?query=branch%3Amain++
.. image:: https://coveralls.io/repos/MounirMesselmeni/django-highlightjs/badge.png?branch=main :target: https://coveralls.io/r/MounirMesselmeni/django-highlightjs?branch=main
.. image:: https://img.shields.io/pypi/v/django-highlightjs.svg :target: https://pypi.python.org/pypi/django-highlightjs/ :alt: Latest Version
Use Highlight.js (https://highlightjs.org) in your Django templates, the Django way.
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:
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:
.. code:: Python
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
:
.. code:: Python
HIGHLIGHTJS = {
'style': 'github',
}
All other styles available at https://github.com/isagalaev/highlight.js/tree/main/src/styles
.. code:: Django
{% 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>
Contributions and pull requests for other Django and Python versions are welcome.
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
You can use this under MIT See LICENSE <LICENSE>
_ file for details.
My name is Mounir Messelmeni, you can reach me at messelmeni.mounir@gmail.com .
FAQs
A Django app to easyily integrate highlight.js syntax highlighter.
We found that django-highlightjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.