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

pygments_style background ignored #2081

Closed
rtimms opened this issue Nov 25, 2024 · 6 comments · Fixed by #2082
Closed

pygments_style background ignored #2081

rtimms opened this issue Nov 25, 2024 · 6 comments · Fixed by #2082
Assignees
Labels
bug Something isn't working

Comments

@rtimms
Copy link

rtimms commented Nov 25, 2024

I may be doing something wrong, but simply setting

pygments_style = "xcode"
pygments_style_dark = "github-dark"

in conf.py results in notebook cells displaying with the wrong background color in dark mode. Are there other settings I should be editing too?

Light mode looks as expected:
Screenshot 2024-11-25 at 13 09 25

Dark mode has a light background instead of dark:
Screenshot 2024-11-25 at 13 09 18

Thanks!

@kai687
Copy link
Owner

kai687 commented Nov 26, 2024

Hi @rtimms, what extensions are you using? This theme might not play well with notebooks and such. It works for 'plain' code blocks, but I never tested/developed it for notebooks.

My guess is that whatever extension renders these notebook cells (if that's what they are) as code blocks overrides the background color of the .highlight class.

@rtimms
Copy link
Author

rtimms commented Nov 26, 2024

I'm using the following extensions:

extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.intersphinx",
    "sphinx.ext.mathjax",
    "extend_parent",
    "sphinx_design",
    "myst_nb",
]

Yeah, I think that is what is happening. It looks like other themes do some custom stuff to overwrite pygments CSS files, e.g. see what pydata does.

@kai687
Copy link
Owner

kai687 commented Nov 26, 2024

Ok, I'm going to check myst_nb and my theme. No guarantees though.

@rtimms
Copy link
Author

rtimms commented Nov 26, 2024

Great, thanks! I tried just adding a custom pygments.css but that also failed. I'm not totally sure of the order in which things happen and what takes precedence.

@kai687 kai687 self-assigned this Nov 26, 2024
@kai687 kai687 added the bug Something isn't working label Nov 26, 2024
@kai687 kai687 linked a pull request Nov 26, 2024 that will close this issue
@kai687
Copy link
Owner

kai687 commented Nov 26, 2024

@rtimms does this look ok to you? I made a PR with some (hopefully) improvements.

@rtimms
Copy link
Author

rtimms commented Nov 26, 2024

Looks good! Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants