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
Don't add space adjacent to html tags in some situations, even when ingonring whitespace sensitivity #5462
Comments
How exactly this
It is not really clear why you think it is more special than the white space before I'm not sure what the use case for
Interesting. How exactly Angular Compiler decides which white spaces can be removed? |
So, Angular by default simply removes white-space-only text nodes: demo, src This behavior can be changed by setting
Now I see why Angular developers can have different expectations regarding white space formatting than the rest of those who write HTML. |
Wow, I wast totally wrong, actually. it turns out that <span foo="bar" baz="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz">
foo
</span>. also inserts a space after foo with Angular set to not preserve whitespaces. Hmm... That means I'll have to reconsider using the ignore whitespace setting, though. |
Why don't the default settings work for you? |
@thorn0 only that it ends up looking kind of ugly in some cases. I can open another issue with a concrete example of where I think it ends up looking ugly. |
Why not? Go ahead. |
Prettier 1.15.2
Playground link
# Options (if any): --html-whitespace-sensitivity ignore
Input:
Output:
Expected behavior:
This may be related to #5449 and #5439, but I think it may be distinct. The basic issue here is that even when "ignoring" whitespace, I believe prettier shouldn't be adding whitespace to the outer "edges" of elements. That means that adding whitespace on the inside "edge" of an element, say after
<span>
or before</span>
, is OK, but adding whitespace just outside of an element can be an issue. As it is now, there is now way to both ignore whitespace on the inside edge of an element, but keep it on the outside.I'd argue that adding the space before the period in this example is essentially equivalent to adding a space in the middle of a word--this is whitespace that will always be important.
This is particularly relevant for Angular users, which by default strips whitespace from code in most cases.
The text was updated successfully, but these errors were encountered: