/django-pygments-renderer

Provides functionality for syntax highlighting using Pygments.

Primary LanguagePythonMIT LicenseMIT

django-pygments-renderer

Provides functionality for syntax highlighting using Pygments .

./example.png

Installation

django-pygments-renderer requires python 3.6 or later and Django 2.2 or later.

$ python3 -m pip install django-pygments-renderer

https://pypi.org/project/django-pygments-renderer/

Usage

INSTALLED_APPS += [
    'pygments_renderer',
]
{% load i18n %}
{% load pygmentize %}
<html>
<head>
    <title>{{ title }}</title>
    <style>{% pygments_css %}</style>  <!-- load css for pygments -->
</head>

<body>
   <div class="container">
       <div class="sourcecode">
           {{ code|pygmentize:"python3" }}  <!-- highlighting -->
       </div>
   </div>
</body>
</html>

Similar projects

Development

  • lint: tox -e flake8 or flake8
  • test: tox -e py39 or DJANGO_SETTINGS_MODULE=test_settings python -m django test

License

This software is licensed under the MIT License (See LICENSE ).