pygments

How to use Dracula theme as a style in Pygments?


I can not understand documents about Pygments Styles, which says:

To make the style usable for Pygments, you must

  1. either register it as a plugin (see the plugin docs)
  2. or ... put it into the file mondrian.py and this file into the pygments.styles subpackage directory.

Now there is already a Dracula theme for Pygments, how can I add it as a new pygments style, so that I can use the style by a simple command line (E.g. pygmentize -g xx.py).

Either by registering a plugin, or puting dracula.py in to the pygements.styles subpackage directory (where it is?). I just don't know how to do this, and there is not a single example.

PS: My OS is ubuntu-18.04 and I install pygments by sudo apt-get install python-pygments python3-pygments


Solution

  • For me (also Ubuntu 18.04), the path of the installation directory is: /usr/lib/python3/dist-packages/pygments. There you will find another directory named styles where all the existing color themes are present (e.g. autumn.py, fruity.py). You may create your own style (following: https://pygments.org/docs/styles/) and store the corresponding style file here.

    I hope this partially answers your query.