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

Not preserving whitespace between adjacent spans #207

Open
khemarato opened this issue Oct 27, 2024 · 1 comment
Open

Not preserving whitespace between adjacent spans #207

khemarato opened this issue Oct 27, 2024 · 1 comment

Comments

@khemarato
Copy link

khemarato commented Oct 27, 2024

If I have some HTML such as:

<body>
     <span>Hello</span>
     <span>World</span>
</body>

This is rendered as Hello World in the browser as the newline + tab between the spans is collapsed to a single space. Unfortunately, minhtml is minifying this down to:

<body><span>Hello</span><span>World</span>

Which is rendered as HelloWorld (no space between the words).

Note that this is broken with all span-like elements, such as <i> or a, etc:

<body>
     <a href="#a">Hello</a>
     <b>there</b>
     <a href="#b">World</a>
</body>

Note that "naked" text nodes are handled correctly:

<body>
  <a href="#a">Hello</a>
  there
  <a href="#b">World</a>
</body>

yields <body><a href=#a>Hello</a> there <a href=#b>World</a> with the spaces kept in correctly.

@khemarato khemarato changed the title Not preserving whitespace between spans Not preserving whitespace between adjacent spans Oct 27, 2024
@kyr0
Copy link

kyr0 commented Dec 18, 2024

This needs a space added to out

https://github.com/wilsonzlin/minify-html/blob/master/minify-html/src/minify/element.rs#L101

I'm going to fork this repo anyways.. (no active maintanance, but the code is helpful)

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

2 participants