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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: compressHTML whitespace #999

Open
cdtut opened this issue Apr 9, 2024 · 4 comments
Open

馃悰 BUG: compressHTML whitespace #999

cdtut opened this issue Apr 9, 2024 · 4 comments
Labels
needs triage Issue needs to be triaged

Comments

@cdtut
Copy link

cdtut commented Apr 9, 2024

What version of @astrojs/compiler are you using?

2.7.1

What package manager are you using?

pnpm

What operating system are you using?

linux

Describe the Bug

compressHTML is removing whitespace that shouldn't be #815.

There should be space between tags with significant whitespace.

<h1>
    <span>span</span>
    <span>span</span>
</h1>

That should become <h1><span>word</span> <span>word</span></h1> not <h1><span>word</span><span>word</span></h1>. Lot of examples like this.

html-minifier-terser has conservativeCollapse option that show how to do it. Or make everything like <h1> <span>word</span> <span>word</span> </h1> to be safe and solve this everywhere.

Link to Minimal Reproducible Example

https://gitlab.com/wackbyte/astro-compress-html-removes-whitespace

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 9, 2024
@cdtut
Copy link
Author

cdtut commented Apr 24, 2024

@matthewp Can it be high priority? Production build has lots of whitespace errors that can't be released.

@ematipico
Copy link
Member

@matthewp Can it be high priority? Production build has lots of whitespace errors that can't be released.

You can disable compression for the time. You have the option.

@ematipico
Copy link
Member

It's not very clear the expected result VS the current result, could you move them into a code block so it's more evident?

@cdtut
Copy link
Author

cdtut commented Apr 25, 2024

@ematipico

Original:

<h1>
    <span>span</span>
    <span>span</span>
</h1>

Expected:

Like html-minifier-terser conservativeCollapse

<h1><span>word</span> <span>word</span></h1>

Or this way simpler but file is bigger

<h1> <span>word</span> <span>word</span> </h1>

Current:

This ignores how HTML treat whitespace.

<h1><span>word</span><span>word</span></h1>

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

No branches or pull requests

2 participants