diff --git a/changelog_unreleased/html/pr-8614.md b/changelog_unreleased/html/pr-8614.md new file mode 100644 index 000000000..19d77a66a --- /dev/null +++ b/changelog_unreleased/html/pr-8614.md @@ -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. + + +```html + +
- 123 -
- - 123 - +123
+ 123
Foo Bar
@@ -2812,9 +2810,7 @@ printWidth: Infinity
tag name in other namespace should also lower cased
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, "seddoeiusmod".
-
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, "seddoeiusmod".
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
seddoeiusmod.
diff --git a/tests/html/whitespace/__snapshots__/jsfmt.spec.js.snap b/tests/html/whitespace/__snapshots__/jsfmt.spec.js.snap
index 7176eac75..9441233f7 100644
--- a/tests/html/whitespace/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/html/whitespace/__snapshots__/jsfmt.spec.js.snap
@@ -517,18 +517,12 @@ printWidth: 80
123
123
123
-
- 123
-
+ 123
123
-
- 123
-
123
-
- 123
-
+123
+123
================================================================================
`;
diff --git a/tests/mjml/mjml/__snapshots__/jsfmt.spec.js.snap b/tests/mjml/mjml/__snapshots__/jsfmt.spec.js.snap
index aabb76351..297ff67b0 100644
--- a/tests/mjml/mjml/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/mjml/mjml/__snapshots__/jsfmt.spec.js.snap
@@ -48,9 +48,7 @@ printWidth: 80
=====================================output=====================================
-
- The green fix eats mango.
-
+ The green fix eats mango.
Do you like cheese? We do!
diff --git a/tests/vue/interpolation/__snapshots__/jsfmt.spec.js.snap b/tests/vue/interpolation/__snapshots__/jsfmt.spec.js.snap
new file mode 100644
index 000000000..3b930d98f
--- /dev/null
+++ b/tests/vue/interpolation/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,29 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`template.vue format 1`] = `
+====================================options=====================================
+parsers: ["vue"]
+printWidth: 80
+ | printWidth
+=====================================input======================================
+
+
+
+ We are going to add this simple card here
+
+
+ What is going on {{ prop1 }} and {{ prop2 }}
+
+
+
+
+=====================================output=====================================
+
+
+ We are going to add this simple card here
+ What is going on {{ prop1 }} and {{ prop2 }}
+
+
+
+================================================================================
+`;
diff --git a/tests/vue/interpolation/jsfmt.spec.js b/tests/vue/interpolation/jsfmt.spec.js
new file mode 100644
index 000000000..2fd7eede9
--- /dev/null
+++ b/tests/vue/interpolation/jsfmt.spec.js
@@ -0,0 +1 @@
+run_spec(__dirname, ["vue"]);
diff --git a/tests/vue/interpolation/template.vue b/tests/vue/interpolation/template.vue
new file mode 100644
index 000000000..26f7b0381
--- /dev/null
+++ b/tests/vue/interpolation/template.vue
@@ -0,0 +1,10 @@
+
+
+
+ We are going to add this simple card here
+
+
+ What is going on {{ prop1 }} and {{ prop2 }}
+
+
+
diff --git a/tests/vue/vue/__snapshots__/jsfmt.spec.js.snap b/tests/vue/vue/__snapshots__/jsfmt.spec.js.snap
index 5c3ca3a34..06754d65f 100644
--- a/tests/vue/vue/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/vue/vue/__snapshots__/jsfmt.spec.js.snap
@@ -1914,9 +1914,7 @@ semi: false
-
- Do not go out, you'll got yourself cloned by bad bad people.
-
+ Do not go out, you'll got yourself cloned by bad bad people.
@@ -1947,9 +1945,7 @@ trailingComma: "none"
-
- Do not go out, you'll got yourself cloned by bad bad people.
-
+ Do not go out, you'll got yourself cloned by bad bad people.
@@ -1979,9 +1975,7 @@ printWidth: 80
-
- Do not go out, you'll got yourself cloned by bad bad people.
-
+ Do not go out, you'll got yourself cloned by bad bad people.
@@ -3127,9 +3121,7 @@ semi: false
{{ fileSizeReadable }}
-
- |
-
+ |
W: {{ width }} | H: {{ height }}
@@ -3193,9 +3185,7 @@ trailingComma: "none"
{{ fileSizeReadable }}
-
- |
-
+ |
W: {{ width }} | H: {{ height }}
@@ -3258,9 +3248,7 @@ printWidth: 80
{{ fileSizeReadable }}
-
- |
-
+ |
W: {{ width }} | H: {{ height }}