Skip to main content

Provides functionality for syntax highlighting using Pygments.

Project description

Provides functionality for syntax highlighting using Pygments .

./example.png

Installation

django-pygments-renderer requires python 3.6 or later and Django 2.0 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>{{ snippet.title}} - djangosnippets</title>
    <style>{% pygments_css %}</style>
    <!-- other header tags -->
</head>

<body>
   <div class="container">
       <h2 class="title">{{ snippet.title }} by {{ snippet.created_by.username }}</h2>

       <div class="sourcecode">
           {{ snippet.code|pygmentize:"python3" }}
       </div>

       <div>
           {{ snippet.description }}
       </div>
   </div>
</body>
</html>

Similar projects

Development

  • lint: tox -e flake8 or flake8

  • test: tox -e py37 or DJANGO_SETTINGS_MODULE=test_settings python -m django test

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pygments-renderer-0.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

django_pygments_renderer-0.0.1-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page