Skip to content

sniku/django-pygments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Complete syntax highlighting (http://pygments.org/) solution for django.

Can be used in templates as {% pygmentize 'html' %}html code here{%endpygmentize%}
or {{ var|pygmentize:"python" }} # where var is a snippet of python code
or {{ var|pygmentize_all }} # where var is a snippet of code with one or many {% pygmentize 'language' %} tags (useful for pygmentizing blog entries or user comments )
or in view:
code = "this is my code {% pygmentize 'python' %}some python code{%endpygmentize%}"
pygmentized_code = pygmentizer.pygmentize(code) # same as pygmentize_all filter but for view (useful for saving pygmentized content to db)

This app was developed mainly to enable syntax highlighting in blog posts and user comments,
but can be used to highlight any type of content. 

requires:
* pygments (easy_install pygments - if you have python setup-tools)

Installation:
* copy pygmentize folder to your project root
* add pygmentize to your INSTALLED_APPS
    INSTALLED_APPS = (
        ...
        'pygmentize',
        ...
    )

That's it.
To change your pygment theme set PYGMENT_THEME variable in settings.py it's set to 'native' by default.
PYGMENT_THEME = 'my_theme'

If you are confused:
* examples and live demo: http://suwala.eu/blog/2010/10/30/django-pygments/
* check the examples provided with the app
* mail me at pawel.suwala (a) fsfe.org 





About

pygments for django-admin, flatpages, templates and user data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages