Skip to content

Provides functionality for syntax highlighting using Pygments.

License

Notifications You must be signed in to change notification settings

c-bata/django-pygments-renderer

Repository files navigation

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 ).

About

Provides functionality for syntax highlighting using Pygments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages