-
Notifications
You must be signed in to change notification settings - Fork 97
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
Sort out whitespace between text and HTML nodes #120
Sort out whitespace between text and HTML nodes #120
Conversation
…mma in "<b>Milk</b>, <b>Bread</b>")
…ce inside inline elements
…nto preserve-inline-element-whitespace
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.
This is really fantastic work! I have some small code-style change requests, but that's all 👍
@dummdidumm Thanks for the review! I've applied the changes you suggested and also reformatted |
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.
🎉
This solves the issue of whitespace either being wrongly added or removed inside inline tags or between text and tags.
See the description for #116 on which it builds. In addition to the examples mentioned there, it fixes more cases involving extraneous or removed whitespace. See examples below. It is, however, a much bigger rewrite than #116, so I suspect this PR might get turned down on the basis of being too radical a change. I'm therefore opening this as a separate PR so that merging just #116 is still an option.
Apart from fixing more issues, I also find the code in this PR cleaner.
In addition to the fixes mentioned in #116 it fixes #58 fully.
It also handles for example:
where it used to add a whitespace inside the
<a>...</a>
tag to makeYou might not want whitespace before or after
{#if}
blocks, such as with this (somewhat contrived) code that printsitem*
for new items anditem!
for updated ones:which used to be formatted as
thereby printing
item *
anditem !
. (Add a space or newline before each{#if}
and they will still be placed on separated lines)It used to turn
into
(thereby adding whitespace around the comma). with this PR the result is
It used to remove manually added empty lines between text and tags, so e.g.
would become
but is now
(note that the empty lines right inside the
<div>...</div>
are also removed)