| 1 |
======= |
| 2 |
Plugins |
| 3 |
======= |
| 4 |
|
| 5 |
If you want to extend Pygments without hacking the sources, you can use |
| 6 |
package `entry points`_ to add new lexers, formatters, styles or filters |
| 7 |
as if they were in the Pygments core. |
| 8 |
|
| 9 |
.. _entry points: https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ |
| 10 |
|
| 11 |
The idea is to create a Python package, declare how extends Pygments, |
| 12 |
and install it. |
| 13 |
|
| 14 |
This will allow you to use your custom lexers/... with the |
| 15 |
``pygmentize`` command. They will also be found by the lookup functions |
| 16 |
(``lexers.get_lexer_by_name`` et al.), which makes them available to |
| 17 |
tools such as Sphinx, mkdocs, ... |
| 18 |
|
| 19 |
|
| 20 |
Defining plugins through entry points |
| 21 |
===================================== |
| 22 |
|
| 23 |
We have created a repository with a project template for defining your |
| 24 |
own plugins. It is available at |
| 25 |
|
| 26 |
https://github.com/pygments/pygments-plugin-scaffolding |
| 27 |
|
| 28 |
|
| 29 |
Extending The Core |
| 30 |
================== |
| 31 |
|
| 32 |
If you have written a Pygments plugin that is open source, please inform us |
| 33 |
about that. There is a high chance that we'll add it to the Pygments |
| 34 |
distribution. |