-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
37 lines (26 loc) · 1.33 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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