From d0d30239852ab16378d57cc270ba4aaee0f48944 Mon Sep 17 00:00:00 2001 From: object-Object Date: Wed, 19 Jul 2023 21:51:43 -0400 Subject: [PATCH] Remove scuffed whitespace stripping --- doc/src/common/jinja_extensions.py | 15 +-------------- doc/templates/pages/LinkPage.html.jinja | 2 +- doc/templates/pages/Page.html.jinja | 15 ++++++--------- doc/templates/pages/PageWithText.html.jinja | 4 ++-- doc/templates/pages/PageWithTitle.html.jinja | 11 +++++------ doc/templates/pages/SpotlightPage.html.jinja | 2 +- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/doc/src/common/jinja_extensions.py b/doc/src/common/jinja_extensions.py index 136cf1f2..3082dcd0 100644 --- a/doc/src/common/jinja_extensions.py +++ b/doc/src/common/jinja_extensions.py @@ -28,21 +28,8 @@ class IncludeRawExtension(Extension): return Markup(source[0]) -_BETWEEN_TAGS_RE = re.compile(r"
\s+<") - - def hexdoc_minify(value: str) -> str: - merged_lines = "".join(line.strip() for line in value.splitlines()) - # FIXME: hack - return _BETWEEN_TAGS_RE.sub("
<", merged_lines) - - # return minify_html.minify( - # code=value, - # keep_closing_tags=True, - # keep_html_and_head_opening_tags=True, - # keep_spaces_between_attributes=True, - # ensure_spec_compliant_unquoted_attribute_values=True, - # ) + return "".join(line.strip() for line in value.splitlines()) def hexdoc_block(value: Any, allow_none: bool = False) -> str: diff --git a/doc/templates/pages/LinkPage.html.jinja b/doc/templates/pages/LinkPage.html.jinja index b0223aa0..59506108 100644 --- a/doc/templates/pages/LinkPage.html.jinja +++ b/doc/templates/pages/LinkPage.html.jinja @@ -1,7 +1,7 @@ {% extends "pages/PageWithTitle.html.jinja" %} {% block inner_body %} - {{ super() }} + {{- super() }}

{{ page.link_text }}

diff --git a/doc/templates/pages/Page.html.jinja b/doc/templates/pages/Page.html.jinja index dcd33418..55591610 100644 --- a/doc/templates/pages/Page.html.jinja +++ b/doc/templates/pages/Page.html.jinja @@ -1,12 +1,9 @@ -{% if page.anchor %} - {# set a variable so children can use this value #} - {% set page_anchor_id = entry.id.path ~ "@" ~ page.anchor %} +{%- if page.anchor -%} + {%- set page_anchor_id = entry.id.path ~ "@" ~ page.anchor -%}{# set a variable so children can use this value -#}
- {# body isn' required because EmptyPage uses this template directly #} - {% block body scoped %}{% endblock %} + {% block body scoped %}{% endblock %}{# not required because EmptyPage uses this template directly -#}
-{% else %} - {# can't define a block twice in the same template, so just reference it with self #} - {{ self.body() }} -{% endif %} +{%- else -%} + {{ self.body() }}{# can't define a block twice in the same template, so just reference it #} +{%- endif -%}
diff --git a/doc/templates/pages/PageWithText.html.jinja b/doc/templates/pages/PageWithText.html.jinja index be05a4ae..db7dba7b 100644 --- a/doc/templates/pages/PageWithText.html.jinja +++ b/doc/templates/pages/PageWithText.html.jinja @@ -1,5 +1,5 @@ {% extends "pages/Page.html.jinja" %} {% block body %} - {{ page.text|hexdoc_block(true) }} -{% endblock body %} + {{- page.text|hexdoc_block(true) -}} +{% endblock %} diff --git a/doc/templates/pages/PageWithTitle.html.jinja b/doc/templates/pages/PageWithTitle.html.jinja index c5ae628a..979c2307 100644 --- a/doc/templates/pages/PageWithTitle.html.jinja +++ b/doc/templates/pages/PageWithTitle.html.jinja @@ -2,9 +2,8 @@ {% import "macros.html.jinja" as macros %} {% block body %} - {% if page.title is not none %} - {# we need title_attrs for PageWithPattern #} - + {%- if page.title is not none -%} + {# we need title_attrs for PageWithPattern -#} {{ page.title|hexdoc_block }} {% if page_anchor_id is defined %} {# note: page_anchor_id is conditionally defined in Page #} {{ macros.permalink(page_anchor_id) }} @@ -12,7 +11,7 @@ {% endif %} {# pretty sure this is the only good way to do this #} - {# and yes, winfy - this probably would have worked just fine in python too #} - {% set outer_body = super() %} - {% block inner_body scoped %}{{ outer_body }}{% endblock %} + {# and yes, this probably would have worked just fine in python too #} + {% set super_body = super() %} + {% block inner_body scoped %}{{ super_body }}{% endblock %} {% endblock body %} diff --git a/doc/templates/pages/SpotlightPage.html.jinja b/doc/templates/pages/SpotlightPage.html.jinja index 1877868b..39e0366f 100644 --- a/doc/templates/pages/SpotlightPage.html.jinja +++ b/doc/templates/pages/SpotlightPage.html.jinja @@ -1,6 +1,6 @@ {% extends "pages/PageWithTitle.html.jinja" %} -{% block inner_body %} +{% block inner_body -%}