FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use consistent line-height for light & dark theme by tomasr8 · Pull Request #227 · python/python-docs-theme · GitHub

Repository navigation

Use consistent line-height for light & dark theme - #227

Merged
AA-Turner merged 2 commits into
python:mainfrom
tomasr8:line-height
Apr 10, 2025
Merged

AA-Turner merged 2 commits into
python:mainfrom
tomasr8:line-height

Conversation

tomasr8 commented Apr 8, 2025 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

While working on the copy button, I noticed the line height of the pre element differs for the light and dark theme. It is set to 120% for the light theme 125% 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.css takes precedence:

Whereas for the dark theme, it is pygments_dark.css which 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/

Comment thread python_docs_theme/static/pydoctheme.css Outdated
}

pre {
line-height: 125%;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To keep the initial value for the theme, rather than the overridden one:

Suggested change
line-height: 125%;
line-height: 120%;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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%

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It was indeed the case. I went for div.body pre to increase the specificity and override pygments_dark.css

AA-Turner merged commit 06987c2 into python:main Apr 10, 2025
tomasr8 deleted the line-height branch April 10, 2025 19:22
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL