Debian Codegraph @

README.rst

raw
1 Welcome to Pygments
2 ===================
3
4 This is the source of Pygments. It is a **generic syntax highlighter** written
5 in Python that supports over 500 languages and text formats, for use in code
6 hosting, forums, wikis or other applications that need to prettify source code.
7
8 Installing
9 ----------
10
11 ... works as usual, use ``pip install Pygments`` to get published versions,
12 or ``pip install -e .`` to install from a checkout in editable mode.
13
14 Documentation
15 -------------
16
17 ... can be found online at https://pygments.org/ or created with Sphinx by ::
18
19 tox -e doc
20
21 By default, the documentation does not include the demo page, as it requires
22 having Docker installed for building Pyodide. To build the documentation with
23 the demo page, use ::
24
25 tox -e web-doc
26
27 The initial build might take some time, but subsequent ones should be instant
28 because of Docker caching.
29
30 To view the generated documentation, serve it using Python's ``http.server``
31 module (this step is required for the demo to work) ::
32
33 python3 -m http.server --directory doc/_build/html
34
35
36 Development
37 -----------
38
39 ... takes place on `GitHub <https://github.com/pygments/pygments>`_, where the
40 Git repository, tickets and pull requests can be viewed.
41
42 Continuous testing runs on GitHub workflows:
43
44 .. image:: https://github.com/pygments/pygments/workflows/Pygments/badge.svg
45 :target: https://github.com/pygments/pygments/actions?query=workflow%3APygments
46
47 Please read our `Contributing instructions <https://pygments.org/docs/contributing>`_.
48
49 Security considerations
50 -----------------------
51
52 Pygments provides no guarantees on execution time, which needs to be taken
53 into consideration when using Pygments to process arbitrary user inputs. For
54 example, if you have a web service which uses Pygments for highlighting, there
55 may be inputs which will cause the Pygments process to run "forever" and/or use
56 significant amounts of memory. This can subsequently be used to perform a
57 remote denial-of-service attack on the server if the processes are not
58 terminated quickly.
59
60 Unfortunately, it's practically impossible to harden Pygments itself against
61 those issues: Some regular expressions can result in "catastrophic
62 backtracking", but other bugs like incorrect matchers can also
63 cause similar problems, and there is no way to find them in an automated fashion
64 (short of solving the halting problem.) Pygments has extensive unit tests,
65 automated randomized testing, and is also tested by `OSS-Fuzz <https://github.com/google/oss-fuzz/tree/master/projects/pygments>`_,
66 but we will never be able to eliminate all bugs in this area.
67
68 Our recommendations are:
69
70 * Ensure that the Pygments process is *terminated* after a reasonably short
71 timeout. In general Pygments should take seconds at most for reasonably-sized
72 input.
73 * *Limit* the number of concurrent Pygments processes to avoid oversubscription
74 of resources.
75
76 The Pygments authors will treat any bug resulting in long processing times with
77 high priority -- it's one of those things that will be fixed in a patch release.
78 When reporting a bug where you suspect super-linear execution times, please make
79 sure to attach an input to reproduce it.
80
81 The authors
82 -----------
83
84 Pygments is maintained by **Georg Brandl**, e-mail address *georg*\ *@*\ *python.org*, **Matthäus Chajdas** and **Jean Abou-Samra**.
85
86 Many lexers and fixes have been contributed by **Armin Ronacher**, the rest of
87 the `Pocoo <https://www.pocoo.org/>`_ team and **Tim Hatch**.
88
89 The code is distributed under the BSD 2-clause license. Contributors making pull
90 requests must agree that they are able and willing to put their contributions
91 under that license.