-
Notifications
You must be signed in to change notification settings - Fork 649
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
Line numbers are misaligned on several Sphinx themes #1579
Comments
I'm not sure I see the bug. I've been changing it here: b6fb70f, to the output you see there, and I'd like to understand how that output is causing issues? Is Pygments on its own inconsistent with spacing, or is it just in conjunction with Sphinx and Sphinx expecting a particular class/tag? (Note that Sphinx can always just override some CSS if that's causing trouble.) |
But you see the misalignment? You might not consider the colors a bug, but the misalignment definitely is, isn't it? I'm not saying that it's necessarily a bug in Pygments, but it is a bug somewhere!
Does sphinx-doc/sphinx#8254 (comment) explain the issues sufficiently?
I don't know, I've only ever used Pygments in conjunction with Sphinx. How would I test Pygments on its own?
I don't think so. At least not in a general way that un-breaks all affected themes. Sphinx (in its Only each individual theme knows its correct vertical padding, therefore the problem can only be fixed by the theme, and not by Sphinx. I'm willing to fix my own theme (mgeier/insipid-sphinx-theme#21), but I think it would be better to simply not break all those themes in the first place. Again, I'm not saying the bug is necessarily in Pygments. If you know a way to fix this in Sphinx in a generic way, please let me know! |
I agree it looks broken, I'm just saying I'm not sure if this qualifies as a bug if 2.6/2.7 kind of works with Sphinx 3.0 (as in, the output is not mismatched). It looks like there were (implicit) assumptions on both sides about how things are supposed to work, and something is broken now :) Let me try raw Pygments output first. I'm fairly certain that did look correct. If it does indeed look correct, the next step will be to figure out how it violates Sphinx' assumptions. To test Pygments on your own, you can simply run |
This removes the top/bottom padding changes, and only keeps left/right padding, in the hope that this does not break all Sphinx themes.
It looks fine with Pygments "standalone". The colors for the |
Thanks @Anteru, this indeed fixes the alignment problem! As you mentioned, this changes the colors though, which I think most theme authors would consider a bug.
What was hardcoded?
OK, I don't really have an opinion on this. Sphinx currently has additional padding on the parent element: I'm not sure whether that's too much if Pygments also adds padding.
That's great! |
Could you please provide an example |
The line number colors were hardcoded previously and didn't match the theme. The original CSS for them was For |
OK, thanks, that explains a lot! I was wondering why this suddenly appeared out of the blue ... Thanks for the It looks like the "solarized" style ( pygments/pygments/styles/solarized.py Lines 121 to 122 in 3e1b79c
pygments/pygments/styles/solarized.py Lines 133 to 134 in 3e1b79c
All other styles seem to just take the default: Lines 179 to 183 in 3e1b79c
Are there any plans to choose proper colors for the other styles? I think the line number colors should definitely be overridden by Sphinx when using the |
Yes, but there's history again here. All styles used to use the same colors, and it was plain broken for solarized. A PR was made to implement a way to fix it, and for solarized, it was fixed properly, but the other styles continue to use the default (which seems ok as nobody was complaining about styles other than solarized being broken -- it seems likely nobody was using line numbers with a dark style.) I'm happy to accept a PR to fix all other styles, but it doesn't seem high priority. Sphinx is of course free to override things, and frankly that's what I'd expect from a downstream user of Pygments. On the Pygments side, we have to be "self consistent", i.e. Pygments output needs to work, and if someone else is applying styling on top, they need to be able to override anything Pygments is doing as otherwise we'll be constrained by all downstream users -- which we may not even know. My plan for this weekend is to release 2.7.2 with the padding fix (as I mentioned, fixing the padding to 0 was not intentional), but when it comes to colors you need to find a solution in Sphinx. My suggestion would be to use |
I've just suggested exactly that in sphinx-doc/sphinx#8333. However, this affects only the As mentioned above, the Pygments colors would probably make sense in the If somebody else wants to update the colors, please go ahead!
Well there is already a But I think it is a very good feature of Sphinx to not be limited to a single style and to allow arbitrary Pygments styles.
The long-term plan for Sphinx is to drop But for a bright future with the |
Sure, but that's further out. You may want to file an issue for themes where the default colors just don't work at all, maybe someone picks it up in the meantime. I'm closing this bug as resolved, 2.7.2 will remove the vertical padding rule, so please update Sphinx to use <2.7 || >= 2.7.2. |
A change in Sphinx (sphinx-doc/sphinx#7482) combined with a change in Pygments (#1477) has led to a wrong alignment of line numbers.
This happens with Pygments 2.7+ and Sphinx 3.1+.
See sphinx-doc/sphinx#8254 for details including screenshots.
So far, I've found these Sphinx themes to be affected:
I'm not sure whether this should be fixed in Sphinx or in Pygments (or both?), but I found out that disabling this chunk of CSS (which comes from Pygments) seems to fix the problem for most themes (I didn't try all, though):
The text was updated successfully, but these errors were encountered: