README.rst 3.6 KB

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