Skip to content

Media query dependent pygments style #7101

Closed
@septatrix

Description

@septatrix

Is your feature request related to a problem? Please describe.
Currently it is not easily possible to add an alternative pygments style based on a media query. This prevents simple implementations of a dark themes based on the prefers-color-scheme media query. The only way to do this currently is to hard code another css file with fitting overwrites which in not very user friendly and annoying if you want to change it.

Describe the solution you'd like
I would like an option inside the html section of the theme.conf file similar to the html_css_files. This option would then create additional pygments stylesheets, add them to the static files with a fitting postfix and link them as an html <link> element with a media attribute.

Describe alternatives you've considered
Manually linking the pygments stylesheets would require one to manually generate them which would not be fitting for a theme as it does not happen automatically in the build process.

Additional context
This would most likely require only small changes to create_pygments_style_file and init_highlighter

We stumbled upon this problem whilst implement a dark theme here python/python-docs-theme#44

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions