Files
test-repo/changelog_unreleased/html/pr-8614.md
T
fisker CheungandGeorgii Dolzhykov b01591770a HTML: Don't preserve line breaks around text-only content (#8614)
* Fix inconsistent formatting on Vue interpolation

* Fix text

* Update changelog

* Fix snapshot

* Add an explanation to the changelog

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-07-06 09:18:22 +03:00

1.1 KiB

Don't preserve line breaks around text-only content (#8614 by @fisker)

Previously, Prettier always preserved line breaks around inline nodes (i.e. inline elements, text, interpolations). In general, Prettier, as much as possible, tries to avoid relying on original formatting, but there are at least two cases when collapsing inline nodes into a single line is undesirable, namely list-like content and conditional constructions (e.g. v-if/v-else in Vue). A good way to detect those cases couldn't be found, so such a trade-off was made. It turned out, however, for text-only content, this relaxation of rules was unnecessary and only led to confusingly inconsistent formatting.

<!-- Input -->
<div>
  Hello, world!
</div>
<div>
  Hello, {{ username }}!
</div>

<!-- Prettier stable -->
<div>
  Hello, world!
</div>
<div>Hello, {{ username }}!</div>

<!-- Prettier master -->
<div>Hello, world!</div>
<div>Hello, {{ username }}!</div>