sphinx_rtd_theme icon indicating copy to clipboard operation
sphinx_rtd_theme copied to clipboard

layout: allow arbitrary CSS attributes

Open gmarull opened this issue 3 years ago • 5 comments

Allow arbitrary CSS attributes when using app.add_css_file() on Sphinx. It can be useful e.g. to insert media or any other attribute. Note that rel and type are set by default.

Fixes #1100

gmarull avatar Mar 25 '21 13:03 gmarull

Does feature for other sphinx themes? This is what the basic theme does, does this syntax work?

    {%- for css in css_files %}
      {%- if css|attr("filename") %}
    {{ css_tag(css) }}
      {%- else %}
    <link rel="stylesheet" href="{{ pathto(css, 1)|e }}" type="text/css" />
      {%- endif %}
    {%- endfor %}

Blendify avatar Mar 25 '21 19:03 Blendify

@Blendify thanks for pointing that out! I was not aware of css_tag.

gmarull avatar Mar 25 '21 20:03 gmarull

The change is good, however it requires sphinx 1.8 but currently we support versions down to 1.6 so this will need to be an if else block see https://github.com/readthedocs/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html#L59 or wait until #1075.

If you use the if else block I will add this to the upcoming 1.0 release.

Blendify avatar Mar 25 '21 21:03 Blendify

It seems to merge is blocked however, maybe because you force pushed a commit

Blendify avatar Apr 06 '21 23:04 Blendify

We still support Sphinx 1.6 in 1.1... but will be dropped in 2.0. See: https://sphinx-rtd-theme.readthedocs.io/en/stable/development.html#release-2-0-0

benjaoming avatar Aug 27 '22 19:08 benjaoming

any chance this can be merged? @Blendify

gmarull avatar May 30 '23 06:05 gmarull

Note, this was merged in #1519

agjohnson avatar Aug 29 '23 16:08 agjohnson