-
Notifications
You must be signed in to change notification settings - Fork 321
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
inline code doesn't respect dark theme #890
Comments
Hmm - I suspect that this may be because our inline code selector uses the Sphinx inline structure instead of the docutils structure. Can you share an HTML website with the built docs not working? |
I think there are 2 pygments.css used (https://sphinxcontrib-inlinesyntaxhighlight.readthedocs.io/en/latest/) so we would need to duplicate the dark one as well. How do you build your documentation? |
I use the doxygen + sphinx + breathe workflow, but doxygen + breathe aren't relevant/affecting the issue here. This is my conf.py (with doxygen and breathe related things commented out)
I build using |
Can you share an HTML snippet of the paragraph with the inline code that is not working? This is what we would need to check against our CSS |
Here's the generated html I think the relevant bit is:
|
also double check that you are running the latest release candidate, not the latest stable release. |
@braxtons12 your "pygment_light_style": "manni",
"pygment_dark_style": "manni", Wouldn't you expect the highlighting to be the same in that case? |
I guess that depends on what you mean by "the same". I would expect that "the same" here means stylistically equivalent, so for dark mode you get a dark equivalent (or in light mode you get a light equivalent if the chosen theme was "dark"). I.E. I would expect that for light mode w/ a "light" theme, it looks exactly like in the This allows using the same colorset for both light + dark so you don't end up with two totally stylistically different themes for each mode. That's the current visual behavior for code blocks (the current behavior might actually invert the value on all colors in dark mode, but I can't tell visually), so I'd expect inline code to follow the same behavior. |
to perform the highlight coloring of the code blocks (and inline code) we are relying on Pygments (https://pygments.org) which is already providing a solid number of coloring schemes. The only thing we enforce is the background to make sure its the same as the background color of the selected theme (specifically the dark one which is not exactly black). In short if you want to have 2 highlighting colors you'll need to select a "dark" and a "light" scheme (or rely on ours). |
That's a reasonable expectation, but is in fact not how Pygments works. As for why it doesn't work that way: IMO it's not easy to come up with enough colors that are distinct from one another, and sufficiently high-contrast against both dark and light background colors, to make one theme work well in the way you suggest. Even if you allow for "reversing" grayscale colors, where do you draw the line between what counts as "grayscale" and not? Do only "pure" grays get reversed, or also slightly-reddish-grays? It's not obvious to me that there's one correct answer there. Pygments could try to be clever, but I'd bet that it's pretty hard to make an automated "convert light theme to dark theme" algorithm that would end up with results that look as good as what a human would do.
That's why there are pairs like "solarized-light" and "solarized-dark" or "gruvbox-light" and "gruvbox-dark" here. |
Right now for code blocks, using the same theme for light + dark mode, more is being changed than just the background color: Both of those screenshots are using:
All I'm asking for is that inline code follows the same behavior as code blocks instead of this:
if the pydata theme supports all pygments styles, then the docs need updated, as the link on this page points |
welcom in the fantastic world of color illusion. the colors are exactly the same but as the background changes your eyes feel them differently.
I want to investigate why the background is not changing, that is a bug. The color on the other hand is a feature (again we are and we will continue to rely on the fine tailored Pygments styles)
That's an open-source repository, if you think we should change the link, I'm happy to review a PR (there's an "edit this page" on every documentation section) |
I understand that, when I said "more is being changed than just the background color", I'm specifically talking about the grayscale text, IE how
Done |
Accidentally stumbled on this, but it turns out that this behavior isn't dark mode specific. Both images are generated using
|
I cannot reproduce this. I just hard-coded our theme to use pydata-sphinx-theme/src/pydata_sphinx_theme/__init__.py Lines 784 to 785 in 5d35205
and what I see when I build the docs locally is this: EDIT: note that in these screenshots the foreground color of the inline code does change subtly between light and dark modes (from ...which indeed looks like a bug; we should (as you say) be altering the background color on the inline lexed code the same way we do for code blocks. |
minimal example: It's not really relevant though. IMO that's preferred. The point of this whole issue/thread is the background differences. |
right, agreed. see my edited post just above yours. |
Ah yeah, I see that now |
I tested on the latest version of the theme with the following .rst: hyperion-utils
**************
.. role:: python(code)
:language: python
:python:`import sphinx`
.. code-block:: python
import sphinx the colored output looks just fine to me: maybe the works from #838 has changed the behavior. Can someone test it again to let me know if it still need to be worked on? |
@12rambau maybe it's enough to add an example of it to our docs? I'm not sure the best place; maybe a new section on this page: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/light-dark.html that just says "here are examples of preformatted text (sphinx colors it) inline lexed code (pygments colors it) and code blocks (also pygments)? edit: yes probably was #838 that fixed it |
Using inline code, eg via:
in docutils.conf:
and in an rst file:
Results in the code using a light theme, even when the dark theme is active.
This should be changed to be dynamic like code blocks
The text was updated successfully, but these errors were encountered: