mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use add_css_file instead of template modification
This commit is contained in:
parent
d269483a6f
commit
25f90ed3ee
@ -505,7 +505,6 @@ class StandaloneHTMLBuilder(Builder):
|
||||
'logo': logo,
|
||||
'favicon': favicon,
|
||||
'html5_doctype': html5_ready and not self.config.html4_writer,
|
||||
'pygments_dark_style': self.dark_highlighter is not None,
|
||||
}
|
||||
if self.theme:
|
||||
self.globalcontext.update(
|
||||
@ -743,6 +742,9 @@ class StandaloneHTMLBuilder(Builder):
|
||||
if self.dark_highlighter:
|
||||
with open(path.join(self.outdir, '_static', 'pygments_dark.css'), 'w') as f:
|
||||
f.write(self.dark_highlighter.get_stylesheet())
|
||||
self.add_css_file('pygments_dark.css',
|
||||
media='(prefers-color-scheme: dark)',
|
||||
id='pygments_dark_css')
|
||||
|
||||
def create_pygments_aux_style_files(self) -> None:
|
||||
"""create a style file for pygments."""
|
||||
|
@ -96,9 +96,6 @@
|
||||
{%- macro css() %}
|
||||
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
||||
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
|
||||
{%- if pygments_dark_style %}
|
||||
<link rel="stylesheet" href="{{ pathto('_static/pygments_dark.css', 1) }}" type="text/css" media="(prefers-color-scheme: dark)" id="pygments_dark_css" />
|
||||
{%- endif %}
|
||||
{%- for css in css_files %}
|
||||
{%- if css|attr("filename") %}
|
||||
{{ css_tag(css) }}
|
||||
|
Loading…
Reference in New Issue
Block a user