What is Pygments?¶
Pygments is a syntax highlighting engine written in Python. That means, it will take source code (or other markup) in a supported language and output a processed version (in different formats) containing syntax highlighting markup.
Its features include:
- a wide range of common languages and markup formats is supported
- new languages and formats are added easily
- a number of output formats is available, including:
- ANSI sequences (console output)
- it is usable as a command-line tool and as a library
- parsing and formatting is fast
Pygments is licensed under the BSD license.
Where does the name Pygments come from?¶
Py of course stands for Python, while pigments are used for coloring paint, and in this case, source code!
What are the system requirements?¶
Pygments only needs a standard Python install, version 2.6 or higher or version 3.3 or higher for Python 3. No additional libraries are needed.
How can I use Pygments?¶
Pygments is usable as a command-line tool as well as a library.
From the command-line, usage looks like this (assuming the pygmentize script is properly installed):
pygmentize -f html /path/to/file.py
This will print a HTML-highlighted version of /path/to/file.py to standard output.
For a complete help, please run pygmentize -h.
Usage as a library is thoroughly demonstrated in the Documentation section.
How can I report a bug or suggest a feature?¶
Please report bugs and feature wishes in the tracker at Bitbucket.
You can also e-mail the author or use IRC, see the contact details.
I want this support for this language!¶
Instead of waiting for others to include language support, why not write it yourself? All you have to know is outlined in the docs.
Can I use Pygments for programming language processing?¶
The Pygments lexing machinery is quite powerful can be used to build lexers for basically all languages. However, parsing them is not possible, though some lexers go some steps in this direction in order to e.g. highlight function names differently.
Also, error reporting is not the scope of Pygments. It focuses on correctly highlighting syntactically valid documents, not finding and compensating errors.
Who uses Pygments?¶
This is an (incomplete) list of projects and sites known to use the Pygments highlighter.
- Pygments API, a HTTP POST interface to Pygments
- The Sphinx documentation builder, for embedded source examples
- rst2pdf, a reStructuredText to PDF converter
- Zine, a Python blogging system
- Trac, the universal project management tool
- Bruce, a reStructuredText presentation tool
- AsciiDoc, a text-based documentation generator
- ActiveState Code, the Python Cookbook successor
- ViewVC, a web-based version control repository browser
- BzrFruit, a Bazaar branch viewer
- QBzr, a cross-platform Qt-based GUI front end for Bazaar
- BitBucket, a Mercurial and Git hosting site
- Review Board, a collaborative code reviewing tool
- skeletonz, a Python powered content management system
- Diamanda, a Django powered wiki system with support for Pygments
- Progopedia (English), an encyclopedia of programming languages
- Postmarkup, a BBCode to XHTML generator
- Language Comparison, a site that compares different programming languages
- BPython, a curses-based intelligent Python shell
- Challenge-You!, a site offering programming challenges
- PIDA, a universal IDE written in Python
- PuDB, a console Python debugger
- XWiki, a wiki-based development framework in Java, using Jython
- roux, a script for running R scripts and creating beautiful output including graphs
- hurl, a web service for making HTTP requests
- wxHTMLPygmentizer is a GUI utility, used to make code-colorization easier
- WpPygments, a highlighter plugin for WordPress
- LodgeIt, a pastebin with XMLRPC support and diffs
- SpammCan, a pastebin (demo see here)
- WowAce.com pastes, a pastebin
- Siafoo, a tool for sharing and storing useful code and programming experience
- D source, a community for the D programming language
- dumpz.org, a pastebin
- dpaste.com, another Django pastebin
- PylonsHQ Pasties, a pastebin
- Django snippets, a pastebin for Django code
- Fayaa, a Chinese pastebin
- Incollo.com, a free collaborative debugging tool
- PasteBox, a pastebin focused on privacy
- xinotes.org, a site to share notes, code snippets etc.
- hilite.me, a site to highlight code snippets
- patx.me, a pastebin
If you have a project or web site using Pygments, drop me a line, and I’ll add a link here.