Documentation
Using Pygments in various scenarios
back to documentation indexTable of contents
PyGtk
Armin has written a piece of sample code that shows how to create a Gtk TextBuffer object containing Pygments-highlighted text.
See the article here: http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-gtk-rendering/
Wordpress
He also has a snippet that shows how to use Pygments in WordPress:
http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-in-wordpress/
Markdown
Since Pygments 0.9, the distribution ships Markdown preprocessor sample code that uses Pygments to render source code in external/markdown-processor.py. You can copy and adapt it to your liking.
TextMate
Antonio Cangiano has created a Pygments bundle for TextMate that allows to colorize code via a simple menu option. It can be found here.
Bash completion
The source distribution contains a file external/pygments.bashcomp that sets up completion for the pygmentize command in bash.
Java
See the Java quickstart document.
Did you like the documentation? Do you have suggestions? Leave your comment here!
Fernando wrote on July 7, 2012:
PyGtk link is also broken, athough its code seems to be accessible here: http://snipplr.com/view/40019/pygments-in-pygtk/
Darren Slatten wrote on May 22, 2012:
WordPress link is broken.
Eugene Mirotin (emirotin@gmail.com) wrote on May 30, 2011:
I've created a WP plugin operating through the shared web-service: http://blog.mirotin.net/?page_id=49
waylan@gmail.com wrote on Nov. 1, 2007:
The Markdown extension looks a little old. The API has improved [1] making is easier to add extensions to the Markdown class instance (since markdown v0.6). There is also an extension [2] available that does *not* add in a new syntax for defining codeblocks (simple indented blocks work fine).
[1]: http://www.freewisdom.org/projects/python-markdown/Writing_Extensions
[2]: http://achinghead.com/markdown/codehilite/
Disclaimer: I developed and maintain that extension and was recently added as a core developer to Python-Markdown.