getzola/zola

Multi-line shortcodes end lists too early

Open

#2,618 opened on Aug 19, 2024

View on GitHub
 (11 comments) (0 reactions) (1 assignee)Rust (1,046 forks)batch import
buggood first issuehelp wanted

Repository metrics

Stars
 (15,349 stars)
PR merge metrics
 (Avg merge 48d 17h) (4 merged PRs in 30d)

Description

Bug Report

I think this is identical to #1355, but given that issue is 3 years old, I am reopening an issue at @Keats 's request.

In summary, shortcodes that span multiple lines will result in lists closing too early and generating invalid HTML.

Environment

Zola version: 0.19.2 (1aa21e0d95a2a7a2ed98bdc9d06f96db82ac66b2)

Step to reproduce

content/_index.md

+++
template = "index.html"
+++

Test

- A
  {{image()}}
- B
- C

template/index.html

{{ section.content | safe }}

template/shortcodes/image.md

<div>
</div>

Expected Behavior

If the shortcode is put on a single line, then the generated code is correct:

<p>Test</p>
<ul>
<li>
<p>A</p>
<div> </div>
</li>
<li>
<p>B</p>
</li>
<li>
<p>C</p>
</li>
</ul>

Current Behavior

The generated code is:

<p>Test</p>
<ul>
<li>A<div>
</li>
</ul>
</div>
<ul>
<li>B</li>
<li>C</li>
</ul>

Note the </ul> closing too early.

Contributor guide