Skip to content

Commit 9083bfc

Browse files
committed
Trim whitespaces around Jinja2 blocks
1 parent b8a4d88 commit 9083bfc

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

sphinx_rtd_theme/layout.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,23 @@
5454
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}{% if builder == 'dirhtml' %}/{% else %}.html{% endif %}"/>
5555
{%- endif -%}
5656

57-
{#- CANONICAL URL #}
58-
{# NB! pageurl is currently a non-documented template context variable! #}
59-
{# pageurl implementation: https://www.sphinx-doc.org/en/master/_modules/sphinx/builders/html.html #}
60-
{%- if pageurl %}
61-
{# pageurl implementation wrongly: adds .html for the dirhtml builder's pageurl #}
62-
{# Workaround for: https://github.com/sphinx-doc/sphinx/issues/9730 #}
63-
{# Once a fix is released in Sphinx, put an upper bound on the Sphinx version for the workaround #}
64-
{% if builder == 'dirhtml' and pageurl.endswith('.html') %}
65-
{# This expression trims away .html and adds a / #}
57+
{#-
58+
CANONICAL URL
59+
NB! pageurl is currently a non-documented template context variable!
60+
pageurl implementation: https://www.sphinx-doc.org/en/master/_modules/sphinx/builders/html.html
61+
-#}
62+
{%- if pageurl -%}
63+
{#-
64+
pageurl implementation wrongly: adds .html for the dirhtml builder's pageurl
65+
Workaround for: https://github.com/sphinx-doc/sphinx/issues/9730
66+
Once a fix is released in Sphinx, put an upper bound on the Sphinx version for the workaround
67+
-#}
68+
{%- if builder == 'dirhtml' and pageurl.endswith('.html') -%}
69+
{#- This expression trims away .html and adds a / -#}
6670
<link rel="canonical" href="{{ (pageurl|e)[:-5] }}/" />
67-
{% else %}
71+
{%- else -%}
6872
<link rel="canonical" href="{{ pageurl|e }}" />
69-
{% endif %}
73+
{%- endif -%}
7074
{%- endif -%}
7175

7276
{#- JAVASCRIPTS #}

0 commit comments

Comments
 (0)