getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
14.11k stars 967 forks source link

lazy_async_image breaks headings #2679

Open Mobbstar opened 3 weeks ago

Mobbstar commented 3 weeks ago

Bug Report

Environment

Zola version: 0.19.2

Expected Behavior

When set to true, I expect lazy_async_image to only affect how markdown images (![alt text](path "title text")) are rendered as HTML.

Current Behavior

When setting lazy_async_image to true, markdown headers generate empty IDs.

Further issues, which are most likely consequences of the above: The page.toc still contains an entry for each header, but is missing the name and ID too. The link-checker throws an error if any links refer to the header by the expected ID.

Step to reproduce

minimal example:

content/_index.html

+++
+++
![](https://en.wikipedia.org/static/images/icons/wikipedia.png)
# Heading
[link](#heading)

templates.html (using the ToC code from the docs)

<!DOCTYPE html><html lang="en"><head></head><body>
    {%- if section.toc %}
    <ul>
    {%- for h1 in section.toc %}
        <li>
            <a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
        </li>
    {%- endfor %}
    </ul>
    {%- endif %}
    {{ section.content | safe }}
</body></html>

config.toml

base_url = "https://example.local/"
[markdown]
lazy_async_image = true

P.S.

Thanks for making Zola. It's fun and useful so far.

Keats commented 2 weeks ago

That's very odd, this attribute is only used for image related events. I don't see off hand how it would cause this issue 🤔