- Notifications
You must be signed in to change notification settings - Fork752
Pygments is a generic syntax highlighter written in Python
License
pygments/pygments
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is the source of Pygments. It is ageneric syntax highlighter writtenin Python that supports over 500 languages and text formats, for use in codehosting, forums, wikis or other applications that need to prettify source code.
... works as usual, usepip install Pygments to get published versions,orpip install -e . to install from a checkout in editable mode.
... can be found online athttps://pygments.org/ or created with Sphinx by
tox -e doc
By default, the documentation does not include the demo page, as it requireshaving Docker installed for building Pyodide. To build the documentation withthe demo page, use
tox -e web-doc
The initial build might take some time, but subsequent ones should be instantbecause of Docker caching.
To view the generated documentation, serve it using Python'shttp.servermodule (this step is required for the demo to work)
python3 -m http.server --directory doc/_build/html
... takes place onGitHub, where theGit repository, tickets and pull requests can be viewed.
Continuous testing runs on GitHub workflows:
Please read ourContributing instructions.
Pygments provides no guarantees on execution time, which needs to be takeninto consideration when using Pygments to process arbitrary user inputs. Forexample, if you have a web service which uses Pygments for highlighting, theremay be inputs which will cause the Pygments process to run "forever" and/or usesignificant amounts of memory. This can subsequently be used to perform aremote denial-of-service attack on the server if the processes are notterminated quickly.
Unfortunately, it's practically impossible to harden Pygments itself againstthose issues: Some regular expressions can result in "catastrophicbacktracking", but other bugs like incorrect matchers can alsocause similar problems, and there is no way to find them in an automated fashion(short of solving the halting problem.) Pygments has extensive unit tests,automated randomized testing, and is also tested byOSS-Fuzz,but we will never be able to eliminate all bugs in this area.
Our recommendations are:
- Ensure that the Pygments process isterminated after a reasonably shorttimeout. In general Pygments should take seconds at most for reasonably-sizedinput.
- Limit the number of concurrent Pygments processes to avoid oversubscriptionof resources.
The Pygments authors will treat any bug resulting in long processing times withhigh priority -- it's one of those things that will be fixed in a patch release.When reporting a bug where you suspect super-linear execution times, please makesure to attach an input to reproduce it.
Pygments is maintained byGeorg Brandl, e-mail addressgeorg@python.org,Matthäus Chajdas andJean Abou-Samra.
Many lexers and fixes have been contributed byArmin Ronacher, the rest ofthePocoo team andTim Hatch.
The code is distributed under the BSD 2-clause license. Contributors making pullrequests must agree that they are able and willing to put their contributionsunder that license.
About
Pygments is a generic syntax highlighter written in Python
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.