| 1 |
:orphan: |
| 2 |
|
| 3 |
Pygments FAQ |
| 4 |
============= |
| 5 |
|
| 6 |
What is Pygments? |
| 7 |
----------------- |
| 8 |
|
| 9 |
Pygments is a syntax highlighting engine written in Python. That means, it will |
| 10 |
take source code (or other markup) in a supported language and output a |
| 11 |
processed version (in different formats) containing syntax highlighting markup. |
| 12 |
|
| 13 |
Its features include: |
| 14 |
|
| 15 |
* a wide range of common :doc:`languages and markup formats <languages>` is supported |
| 16 |
* new languages and formats are added easily |
| 17 |
* a number of output formats is available, including: |
| 18 |
|
| 19 |
- HTML |
| 20 |
- ANSI sequences (console output) |
| 21 |
- LaTeX |
| 22 |
- RTF |
| 23 |
|
| 24 |
* it is usable as a command-line tool and as a library |
| 25 |
* parsing and formatting is fast |
| 26 |
|
| 27 |
Pygments is licensed under the BSD license. |
| 28 |
|
| 29 |
Where does the name Pygments come from? |
| 30 |
--------------------------------------- |
| 31 |
|
| 32 |
*Py* of course stands for Python, while *pigments* are used for coloring paint, |
| 33 |
and in this case, source code! |
| 34 |
|
| 35 |
What are the system requirements? |
| 36 |
--------------------------------- |
| 37 |
|
| 38 |
Pygments only needs a standard Python install. No additional libraries are needed. |
| 39 |
|
| 40 |
How can I use Pygments? |
| 41 |
----------------------- |
| 42 |
|
| 43 |
Pygments is usable as a command-line tool as well as a library. |
| 44 |
|
| 45 |
From the command-line, usage looks like this (assuming the pygmentize script is |
| 46 |
properly installed):: |
| 47 |
|
| 48 |
pygmentize -f html /path/to/file.py |
| 49 |
|
| 50 |
This will print a HTML-highlighted version of /path/to/file.py to standard output. |
| 51 |
|
| 52 |
For a complete help, please run ``pygmentize -h``. |
| 53 |
|
| 54 |
Usage as a library is thoroughly demonstrated in the Documentation section. |
| 55 |
|
| 56 |
How do I make a new style? |
| 57 |
-------------------------- |
| 58 |
|
| 59 |
Please see the :doc:`documentation on styles <docs/styles>`. |
| 60 |
|
| 61 |
How can I report a bug or suggest a feature? |
| 62 |
-------------------------------------------- |
| 63 |
|
| 64 |
Please report bugs and feature wishes in the tracker at GitHub. |
| 65 |
|
| 66 |
You can also e-mail the authors, see the contact details. |
| 67 |
|
| 68 |
I want this support for this language! |
| 69 |
-------------------------------------- |
| 70 |
|
| 71 |
Instead of waiting for others to include language support, why not write it |
| 72 |
yourself? All you have to know is :doc:`outlined in the docs |
| 73 |
<docs/lexerdevelopment>`. |
| 74 |
|
| 75 |
Can I use Pygments for programming language processing? |
| 76 |
------------------------------------------------------- |
| 77 |
|
| 78 |
The Pygments lexing machinery is quite powerful can be used to build lexers for |
| 79 |
basically all languages. However, parsing them is not possible, though some |
| 80 |
lexers go some steps in this direction in order to e.g. highlight function names |
| 81 |
differently. |
| 82 |
|
| 83 |
Also, error reporting is not the scope of Pygments. It focuses on correctly |
| 84 |
highlighting syntactically valid documents, not finding and compensating errors. |
| 85 |
|
| 86 |
Who uses Pygments? |
| 87 |
------------------ |
| 88 |
|
| 89 |
This is an (incomplete) list of projects and sites known to use the Pygments highlighter. |
| 90 |
|
| 91 |
* `Wikipedia <https://en.wikipedia.org/>`_ |
| 92 |
* `BitBucket <https://bitbucket.org/>`_, a Mercurial and Git hosting site |
| 93 |
* `The Sphinx documentation builder <https://sphinx-doc.org/>`_, for embedded source examples |
| 94 |
* `rst2pdf <https://github.com/ralsina/rst2pdf>`_, a reStructuredText to PDF converter |
| 95 |
* `Codecov <https://codecov.io/>`_, a code coverage CI service |
| 96 |
* `Trac <https://trac.edgewall.org/>`_, the universal project management tool |
| 97 |
* `AsciiDoc <https://www.methods.co.nz/asciidoc/>`_, a text-based documentation generator |
| 98 |
* `ActiveState Code <https://code.activestate.com/>`_, the Python Cookbook successor |
| 99 |
* `ViewVC <http://viewvc.org/>`_, a web-based version control repository browser |
| 100 |
* `BzrFruit <https://repo.or.cz/w/bzrfruit.git>`_, a Bazaar branch viewer |
| 101 |
* `QBzr <http://bazaar-vcs.org/QBzr>`_, a cross-platform Qt-based GUI front end for Bazaar |
| 102 |
* `Review Board <https://www.reviewboard.org/>`_, a collaborative code reviewing tool |
| 103 |
* `Diamanda <https://code.google.com/archive/p/diamanda/>`_, a Django powered wiki system with support for Pygments |
| 104 |
* `Progopedia <http://progopedia.ru/>`_ (`English <http://progopedia.com/>`_), |
| 105 |
an encyclopedia of programming languages |
| 106 |
* `Bruce <https://sites.google.com/site/r1chardj0n3s/bruce>`_, a reStructuredText presentation tool |
| 107 |
* `PIDA <http://pida.co.uk/>`_, a universal IDE written in Python |
| 108 |
* `BPython <https://bpython-interpreter.org/>`_, a curses-based intelligent Python shell |
| 109 |
* `PuDB <https://pypi.org/project/pudb/>`_, a console Python debugger |
| 110 |
* `XWiki <https://www.xwiki.org/>`_, a wiki-based development framework in Java, using Jython |
| 111 |
* `roux <http://ananelson.com/software/roux/>`_, a script for running R scripts |
| 112 |
and creating beautiful output including graphs |
| 113 |
* `hurl <http://hurl.it/>`_, a web service for making HTTP requests |
| 114 |
* `wxHTMLPygmentizer <http://colinbarnette.net/projects/wxHTMLPygmentizer>`_ is |
| 115 |
a GUI utility, used to make code-colorization easier |
| 116 |
* `Postmarkup <https://code.google.com/archive/p/postmarkup/>`_, a BBCode to XHTML generator |
| 117 |
* `WpPygments <http://blog.mirotin.net/?page_id=49>`_, and `WPygments |
| 118 |
<https://github.com/capynet/WPygments>`_, highlighter plugins for WordPress |
| 119 |
* `Siafoo <http://siafoo.net>`_, a tool for sharing and storing useful code and programming experience |
| 120 |
* `D source <http://www.dsource.org/>`_, a community for the D programming language |
| 121 |
* `dpaste.com <http://dpaste.com/>`_, another Django pastebin |
| 122 |
* `Django snippets <https://djangosnippets.org/>`_, a pastebin for Django code |
| 123 |
* `Fayaa <http://www.fayaa.com/code/>`_, a Chinese pastebin |
| 124 |
* `Incollo.com <http://incollo.com>`_, a free collaborative debugging tool |
| 125 |
* `PasteBox <https://p.boxnet.eu/>`_, a pastebin focused on privacy |
| 126 |
* `hilite.me <http://www.hilite.me/>`_, a site to highlight code snippets |
| 127 |
* `patx.me <http://patx.me/paste>`_, a pastebin |
| 128 |
* `Fluidic <https://github.com/richsmith/fluidic>`_, an experiment in |
| 129 |
integrating shells with a GUI |
| 130 |
* `pygments.rb <https://github.com/pygments/pygments.rb>`_, a pygments wrapper for Ruby |
| 131 |
* `Clygments <https://github.com/bfontaine/clygments>`_, a pygments wrapper for |
| 132 |
Clojure |
| 133 |
* `PHPygments <https://github.com/capynet/PHPygments>`_, a pygments wrapper for PHP |
| 134 |
* `Spyder <https://www.spyder-ide.org/>`_, the Scientific Python Development |
| 135 |
Environment, uses pygments for the multi-language syntax highlighting in its |
| 136 |
`editor <https://docs.spyder-ide.org/editor.html>`_. |
| 137 |
* `snippet.host <https://snippet.host>`_, minimal text and code snippet hosting |
| 138 |
* `sourcehut <https://sourcehut.org>`_, the hacker's forge |
| 139 |
* `Material for MkDocs <https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown-extensions/#highlight>`_, popular static site generator |
| 140 |
|
| 141 |
If you have a project or web site using Pygments, `open an issue or PR |
| 142 |
<https://github.com/pygments/pygments>`_ and we'll add a line here. |