Coder Social home page Coder Social logo

django-highlightjs's Introduction

Welcome to django-highlightjs

https://travis-ci.org/MounirMesselmeni/django-highlightjs.png?branch=master https://coveralls.io/repos/MounirMesselmeni/django-highlightjs/badge.png?branch=master Latest Version

Use Highlight.js (https://highlightjs.org) in your Django templates, the Django way.

Installation

  1. Install using pip:

    pip install django-highlightjs

    Alternatively, you can install 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 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/8.3/highlight.min.js',
  # The complete URL to the highlight.js CSS file
  'css_url': '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/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/master/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 2.7, 3.4, 3.5 or 3.6
  • Django >= 1.8

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.

Author

My name is Mounir Messelmeni, you can reach me at [email protected] .

django-highlightjs's People

Contributors

bumfo avatar mounirmesselmeni avatar movermeyer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.