- What is Pygments?
- Where does the name Pygments come from?
- What are the system requirements?
- Does Pygments work with Python 3.x?
- How can I use Pygments?
- How to make a new style
- How can I report a bug or suggest a feature?
- I want this support for this language!
- Does Pygments understand the source code completely?
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 (look here for a list)
- 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.
Py of course stands for Python, while pigments are used for coloring paint, and in this case, source code!
Pygments only needs a standard Python install, version 2.3 or higher (2.4 or higher from version 1.2). No additional libraries are needed.
Yes, Pygments should work on Python 3.x. You can use the same source release and run python setup.py install as usually for installation under Python 3.
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.
Please see the documentation on styles.
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.
Instead of waiting for others to include language support, why not write it yourself? All you have to know is outlined in the docs.
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.