2016-10-07 22:45:59 +02:00
|
|
|
<figure class="{{ include.class }}">
|
2020-03-06 21:37:07 +01:00
|
|
|
<img src="{{ include.image_path | relative_url }}"
|
|
|
|
alt="{% if include.alt %}{{ include.alt }}{% endif %}">
|
Fix closing tag of figures without captions in lists (#2697)
When the figure helper is used in a list, which can be either ordered or
unordered, and no caption is specified, a line with text "</figure>"
will be shown below the figure on the rendered page.
This is because, if the '{% if include.caption %}' evaluates to false,
the lines between that 'if' statement and '{% endif %}' will be emptied,
not removed, so the block will be filled by empty lines.
HTML ignores redundant empty lines, but Markdown takes them seriously.
In addition, Markdown expects proper indentation of lines inside lists,
and the closing '</figure>' tag is not indented. When combined, the
empty space and absence of indentation cause Markdown to process the
'</figure>' tag as a separate paragraph instead of an HTML tag, thus the
text for the tag is directly rendered on the page.
The fix for this issue is very simple: remove the empty space when
'include.caption' is false. As described in
<https://shopify.github.io/liquid/basics/whitespace/>, this can be done
by adding hyphens to the 'if' and 'endif' tags.
2020-10-28 19:43:09 +01:00
|
|
|
{%- if include.caption -%}
|
2019-03-22 21:05:48 +01:00
|
|
|
<figcaption>
|
|
|
|
{{ include.caption | markdownify | remove: "<p>" | remove: "</p>" }}
|
2020-03-06 21:37:07 +01:00
|
|
|
</figcaption>
|
Fix closing tag of figures without captions in lists (#2697)
When the figure helper is used in a list, which can be either ordered or
unordered, and no caption is specified, a line with text "</figure>"
will be shown below the figure on the rendered page.
This is because, if the '{% if include.caption %}' evaluates to false,
the lines between that 'if' statement and '{% endif %}' will be emptied,
not removed, so the block will be filled by empty lines.
HTML ignores redundant empty lines, but Markdown takes them seriously.
In addition, Markdown expects proper indentation of lines inside lists,
and the closing '</figure>' tag is not indented. When combined, the
empty space and absence of indentation cause Markdown to process the
'</figure>' tag as a separate paragraph instead of an HTML tag, thus the
text for the tag is directly rendered on the page.
The fix for this issue is very simple: remove the empty space when
'include.caption' is false. As described in
<https://shopify.github.io/liquid/basics/whitespace/>, this can be done
by adding hyphens to the 'if' and 'endif' tags.
2020-10-28 19:43:09 +01:00
|
|
|
{%- endif -%}
|
2020-03-06 21:37:07 +01:00
|
|
|
</figure>
|