Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme overwrites pygments_style variable #762

Open
mwiesenberger opened this issue Sep 21, 2023 · 3 comments
Open

theme overwrites pygments_style variable #762

mwiesenberger opened this issue Sep 21, 2023 · 3 comments

Comments

@mwiesenberger
Copy link

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

index.md

Run

sphinx-build -M html . _sphinx

yields
is
(which does not look good imo) the output code highlighting should look like
should
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

@welcome
Copy link

welcome bot commented Sep 21, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

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! 🎉

@kennysong
Copy link

Our team has run into the same issue.

@mwiesenberger
Copy link
Author

mwiesenberger commented Jan 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants