Pygments

Code blocks are themed using Pygments.

By default Nefertiti for Sphinx uses the emacs and monokai Pygments styles for light and dark color schemes respectively.

A Sphinx code block is written like this in reStructuredText:

.. code-block:: <language>

    the code here

Or like this in Markdown:

```<language>
the code here
```

Being <language> the name of the programming language.

The list of programming languages supported depends on the lexers provided by Pygments. Get the list using pygmentize -L lexers in the command line.

Available styles

List all available Pygments styles using the following code (extracted from here):

Note

The following code uses Pygments version 2.18.0.

import pprint
from pygments.styles import get_all_styles
styles = list(get_all_styles())
pprint.pprint(styles)
[
    'abap',
    'algol',
    'algol_nu',
    'arduino',
    'autumn',
    'bw',
    'borland',
    'coffee',
    'colorful',
    'default',
    'dracula',
    'emacs',
    'friendly_grayscale',
    'friendly',
    'fruity',
    'github-dark',
    'gruvbox-dark',
    'gruvbox-light',
    'igor',
    'inkpot',
    'lightbulb',
    'lilypond',
    'lovelace',
    'manni',
    'material',
    'monokai',
    'murphy',
    'native',
    'nord-darker',
    'nord',
    'one-dark',
    'paraiso-dark',
    'paraiso-light',
    'pastie',
    'perldoc',
    'rainbow_dash',
    'rrt',
    'sas',
    'solarized-dark',
    'solarized-light',
    'staroffice',
    'stata-dark',
    'stata-light',
    'tango',
    'trac',
    'vim',
    'vs',
    'xcode',
    'zenburn'
]

Customize Pygments

Changed in version 0.4.0.

Customize Pygments styles by modifying the pygments_light_style and pygments_dark_style settings in your conf.py module, in your html_theme_options:

html_theme_options = {
    # <other options here>
    "pygments_light_style": "pastie",
    "pygments_dark_style": "dracula",
}

These entries take precedence over the global setting pygments_style.