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>
This commit is contained in:
1 parent
fe86dbbedb
commit
b01591770a
12 files changed
+86
-57
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#### Don't preserve line breaks around text-only content ([#8614](https://github.com/prettier/prettier/pull/8614) by [@fisker](https://github.com/fisker))
|
||||
|
||||
Previously, Prettier always [preserved line breaks][#5596] 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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- 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>
|
||||
```
|
||||
|
||||
[#5596]: https://prettier.io/blog/2019/01/20/1.16.0.html#respect-surrounding-linebreaks-5596-by-ikatyang
|
||||
Reference in new issue
Block a user