[FIX] Detect dark mode in a wider range of sphinx themes #201
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.
The CSS file currently uses
body[data-theme="dark"]
to detect whether the theme is using dark mode. But different Sphinx themes use different mechanisms for marking this.Here is a summary of the mechanisms used by all the themes in https://sphinx-themes.org/ which are currently building and which support dark mode.
body[data-theme="dark"]
andbody[data-theme="auto"]
html[data-mode="dark"]
andhtml[data-mode="auto"]
html[data-mode="dark"]
andhtml[data-mode="auto"]
body.theme-dark
. The auto mode either sets this orbody.theme-light
html[data-mode="dark"]
andhtml[data-mode="auto"]
html.dark
. The auto mode either sets this class or removes ithtml.dark
. The auto mode either sets this class or removes itmedia
attribute of stylesheetlink
elements to toggle these stylesheets on and off. Supporting this would require some JavaScript hacking.media
attribute of stylesheetlink
elements to toggle these stylesheets on and off. Supporting this would require some JavaScript hacking.body.theme-dark
. There's no auto modeOverall there are five different mechanisms. This PR enables detecting dark mode in the four cases where this can be done using pure CSS.
Fixes #193
Fixes #194
Fixes #195