Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minify_html = true causes Major page formatting issues to pages with numbered code blocks in Zola. #96

Closed
Jieiku opened this issue Jul 25, 2022 · 4 comments

Comments

@Jieiku
Copy link

Jieiku commented Jul 25, 2022

Bug Report

minify_html = true causes Major page formatting issues to pages with numbered code blocks.

This was first reported to the abridge theme: Jieiku/abridge#84

I then posted this to the zola issue tracker: getzola/zola#1942 (I am now posting it all here for completeness sake)

I implemented this in the after-dark theme and seen the same effect (pay particular attention to the footer at the bottom of the pages)

2022-07-25_13-26-01

with minify_html = false it looks normal:

2022-07-25_14-21-34

Environment

Zola version: 0.16.0

I also tested 0.15.3 with the same result.

Expected Behavior

The page should look the same with or without minify_html = true

Current Behavior

No Errors, just errors in page formatting when using minify_html = true

Step to reproduce

git clone https://github.com/Jieiku/zola-minify-test
cd zola-minify-test
zola serve

open this page: http://127.0.0.1:1111/overview-code-blocks/

Notice the page section headings and page footer are all broken following the numbered code blocks.

To further confirm the issue you can removed the line numbered code blocks, then minify_html = true will no longer cause an issue.

@winstonewert
Copy link
Contributor

The generate html contains several instances of:

</td></tr></span></tbody></table></code>

This attempts to close a span tag that was never opened. So html being fed into the minimizer is broken. Whatever the case for minify-html, that should be corrected.

Eliding all unneccessary details, a minimal test case looks something like this.

<pre></span></pre>

minify-html turns it into:

<pre><span><pre>

The rest of the page ends up being inside a pre tag which causes the weirdness.

@Jieiku
Copy link
Author

Jieiku commented Aug 9, 2022

So is this an issue with zola then?

@wilsonzlin
Copy link
Owner

wilsonzlin commented Aug 9, 2022

Thanks for looking into this @winstonewert. By definition, it's not possible for minify-html to understand invalid HTML (nor is it its responsibility); @Jieiku if the HTML was generated, I'd suggest raising an issue with whatever tool generated the HTML.

With regards to the <pre></span></pre> test case, the behaviour was changed in version 0.10.0 (not yet released) to simply drop the invalid closing tag instead of reinterpreting it as an opening tag, as it avoids an explosion in the tree if there are many (e.g. broken HTML generator/template). For reference, how minify-html handles invalid input is described in notes/Parsing.md as mentioned in the README.

@Jieiku
Copy link
Author

Jieiku commented Sep 21, 2022

Thanks @wilsonzlin , There is a ticket open at zola, hopefully somebody can figure out the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants