Use consistent line-height for light & dark theme#227
Merged
AA-Turner merged 2 commits intopython:mainfrom Apr 10, 2025
Merged
Conversation
AA-Turner
reviewed
Apr 9, 2025
| } | ||
|
|
||
| pre { | ||
| line-height: 125%; |
Member
There was a problem hiding this comment.
To keep the initial value for the theme, rather than the overridden one:
Suggested change
| line-height: 125%; | |
| line-height: 120%; |
Member
Author
There was a problem hiding this comment.
I have to check later if this will work or if we need a more specific selector since pygments_dark.css is included last and sets 125%
Member
Author
There was a problem hiding this comment.
It was indeed the case. I went for div.body pre to increase the specificity and override pygments_dark.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on the copy button, I noticed the line height of the
preelement differs for the light and dark theme. It is set to120%for the light theme125%for the dark theme, which is not a huge difference but it's better to be consistent.The reason for the discrepancy is the order in which the css is included in the

<head>. For the light theme,classic.csstakes precedence:Whereas for the dark theme, it is

pygments_dark.csswhich is the last stylesheet in the<head>:This seems to be related to how sphinx inserts the css for pygments:
https://github.com/sphinx-doc/sphinx/blob/a6d7ae16739bf92a032a7c4df0297db7cf120ec9/sphinx/builders/html/__init__.py#L258-L262
In any case, we can fix this by simply setting the line height in
pydoctheme.css.📚 Documentation preview 📚: https://python-docs-theme-previews--227.org.readthedocs.build/