Skip to content

Commit

Permalink
Account for Sphinx 4 changes in pygments CSS files
Browse files Browse the repository at this point in the history
Sphinx 4 changes the handling of pygments-related CSS files, including
the .css file directly in `css_files`. This breaks dark mode syntax
highlighting since pygments.css file is now included twice -- once
before the pygments_dark.css and once after.

This break the whole mechanism, since the highlighting is sentitive to
the ordering of those files being included, due to how Sphinx generates
those files.

This change works around the issue, by adding the pygments_dark.css file
after both the pygments.css files.
  • Loading branch information
pradyunsg committed Jun 18, 2021
1 parent ca9e20d commit e49e5dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/furo/theme/furo/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
{%- block theme_styles -%}
<link rel="stylesheet" href="{{ pathto(furo_assets['style'], 1) }}">
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}">
<link media="(prefers-color-scheme: dark)" rel="stylesheet" href="{{ pathto('_static/pygments_dark.css', 1) }}">
{% include "partials/_head_css_variables.html" with context %}
{%- endblock -%}

Expand All @@ -68,6 +67,7 @@
{%- endblock regular_styles -%}

{%- block extra_styles -%}
<link media="(prefers-color-scheme: dark)" rel="stylesheet" href="{{ pathto('_static/pygments_dark.css', 1) }}">
<link rel="stylesheet" href="{{ pathto(furo_assets['furo-extensions.css'], 1) }}">
{%- endblock -%}

Expand Down

0 comments on commit e49e5dd

Please sign in to comment.