theme overwrites pygments_style variable
I cannot use the flag pygments_style when using the sphinx-book-theme. Here is a minimal example
# conf.py
extensions = ['myst_parser']
html_theme='sphinx_book_theme'
pygments_style='default' # has no effect
Run
sphinx-build -M html . _sphinx
yields
(which does not look good imo) the output code highlighting should look like
which is generated with
# conf.py
extensions = ['myst_parser']
#html_theme='sphinx_book_theme'
pygments_style='default' # has no effect
I use
sphinx-build 5.0.2
sphinx-book-theme 1.0.1
Thanks for any help on how to fix this
Matthias
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Our team has run into the same issue.
After some more research, I finally stumbled across the answer to the problem:
From this page in the documentation
https://sphinx-book-theme.readthedocs.io/en/stable/reference.html
it is mentioned that pydata options are available as well. After some searching on their website one finds
https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/styling.html#configure-pygments-theme
at the end it says
The native Sphinx option pygments_style will be overwritten by this theme.
This explains why the above example does not work as expected.
The correct setting in conf.py seems to be
# conf.py
html_theme_options = {
...
"pygment_light_style": "default",
"pygment_dark_style": "monokai"
}
Considering how long it took me to find a solution to this problem I would suggest that the sphinx-book-theme documentation at least copies the danger warning about overwriting the pygments_style option and possibly explains how one is supposed to set the pygments style in the configuration.