stop removal of spaces that causes display changes #150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I can't believe how much time I spent on this... 😄
This PR fixes some additional cases of removal of spaces that changes the display. Most of the cases are poorly formed HTML, but unfortunately we're not always in control over that. In some edge cases it's leaving a single space that doesn't affect display in the browsers I tested, but I think this keeps things simple and errs on the side of leaving a space that may affect display. I looked further into #121 and #21 and neither of them are actually bugs in the latest version.
Examples
(I'm going to exclude the
<html>
wrappers in the output for simplicity)Example 1:
Stop removal of needed space for proper display.
Un-minified:
<p> <i>first </i>second </p>
which displays as: first seconddjango-htmlmi 0.11.0:
<p><i>first</i>second</p>
which displays as: firstsecondthis PR:
<p><i>first </i>second</p>
which displays as: first secondExample 2:
Stop the removal of a space that has styling applied to it (hard to duplicate in github, but you can see the space is underlined between the words)
Un-minified:
<p><u>first </u> <s> second</s></p>
which displays as: firstseconddjango-htmlmi 0.11.0:
<p><u>first</u> <s>second</s></p>
which displays as: firstsecondthis PR:
<p><u>first </u> <s> second</s></p>
which displays as: firstsecondThis one is weird as the order dictates what styling that space in the middle receives. If you switch the order then the space in the middle gets a strike-through styling, but I have no idea if that's consistent across all browser renderers.