-
Notifications
You must be signed in to change notification settings - Fork 571
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
handle whitespace within and around inline tags #519
Conversation
Did I say we have a sub-optimal case? 😏 (As it turns out, we don't need to flush |
text = prevTag || nextTag ? collapseWhitespaceSmart(text, prevTag, nextTag, options) : trimWhitespace(text); | ||
if (!text && / $/.test(currentChars) && prevTag && prevTag.charAt(0) === '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we don't want \s$
instead of $
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of collapsed whitespaces always getting turned into
- but I guess no harm making them\s
Do we know how this affects minifier performance? |
I've run In terms of minified sizes, they stayed almost the same -
|
@kangax comments addressed 😉 |
Does it mean that "eloquentjavascript" was rendering incorrectly before? With some spaces removed? |
@@ -658,7 +672,7 @@ | |||
equal(minify(input, { collapseWhitespace: true }), output); | |||
|
|||
input = '<p> foo <span> blah <i> 22</i> </span> bar <img src=""></p>'; | |||
output = '<p>foo <span>blah <i>22</i></span> bar <img src=""></p>'; | |||
output = '<p>foo <span>blah <i>22</i> </span>bar <img src=""></p>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, why is this space necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's removing the space after </span>
rather than the one before.
If there isn't any space before </span>
then this wouldn't have happened.
handle whitespace within and around inline tags
Yes - those spaces were significant, so removing them packed those links too close to normal text after them. |
@alexlamsl: are you sure this change doesn't break things? I notice differences in a project of mine, namely https://github.com/mpc-hc/mpc-hc.org (run it with |
I also notice spaces before the end closing bracket, like <a href=/acknowledgments/ > I don't remember this one happening with the old version. EDIT: happens with 1.2.0 too. |
And I don't think this PR is the one that changes this IIRC... |
But it's not XML. |
Found it: f8db419 The old behaviour is to retain the quotes as it'd cause some browsers to consume that as |
As in, I'll have a go at your project now - is there a specific link you'd want me to visit after |
It's non standard behavior if "some" browsers behave like that. And HTML is not XML so the specs are clear. Anyway, that issue is a separate one. I'm more concerned about the whitespace issue I mention #519 (comment). |
Just any page, but it's clearer in the homepage in the news post icons. Note that I have already reverted to the old version in master so in order to see what I mean you will need to set grunt-contrib-htmlmin to |
Thanks, I'll investigate now - I guess I can roll back and forth between the versions to see the difference as well... |
Feels like an idiot, but... 😓
Edit: I guess it's |
@XhmikosR I know I'm probably being annoying now, but is there a way I can test without installing ruby and jekyll and possibly more which I don't have on my PC? 😰 |
Okay, so I visit https://mpc-hc.org/ on Chrome 49:
And I compare it with another tab of the original site. The only thing I've noticed so far are the disappearing whitespace between Are there other discrepancies I should be paying attention to as well? |
It's not possible to build without Ruby, sorry. But what you see is the issue I described, yes. There might be more, but the font awesome ones were the obvious. |
The whitespace here is being removed |
inspired by the tests in PHPTAL:
should minify to:
before this PR:
note the whitespace placement before
c
.One case we cannot handle optimally is:
with this PR this turns to:
even though we should be able to remove that final whitespace safely.