Repository: sveltejs/prettier-plugin-svelte (ts)

Issue:
Empty style and script tags are expanded into three lines
I'm using Svelte with svelte-preprocessor. The following lines:

```html
<script src="./index.ts"></script>

<style src="./index.css"></style>
```

is formatted as:

```html
<script src="./index.ts">

</script>

<style src="./index.css">

</style>
```

My expected output should be the same as first one. Is this some kind of bug?

Thanks!

Pull request description:
Make it possible to have script/style without newline
If the content of a script/style tag is completely empty (no whitespace), don't add a hardline anymore.
Fixes #87

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06c8837..45d0d2f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
 * Everything that is not explicitely a block element is now treated as an inline element, including components. This is a breaking change ([#159](https://github.com/sveltejs/prettier-plugin-svelte/issues/159))
 * Single quotes are no longer forced except inside quoted attributes/events/etc. This is a breaking change ([#94](https://github.com/sveltejs/prettier-plugin-svelte/issues/94))
 * If the content inside a mustache tag is too long, break it up if possible. Only exception are Svelte Blocks (#if/#await/etc). This is a breaking change ([#170](https://github.com/sveltejs/prettier-plugin-svelte/issues/170))
+* If the content of a script/style tag is completely empty (no whitespace), don't add a hardline anymore. ([#87](https://github.com/sveltejs/prettier-plugin-svelte/issues/87))
 
 ## 1.4.2
 
diff --git a/src/embed.ts b/src/embed.ts
index 995a534..8e71454 100644
--- a/src/embed.ts
+++ b/src/embed.ts
@@ -184,6 +184,8 @@ function embedTag(
         isNodeSupportedLanguage(node) && !isIgnoreDirective(previousComment)
             ? content.trim() !== ''
                 ? formatBodyContent(content)
+                : content === ''
+                ? ''
                 : hardline
             : preformattedBody(content);
 


Test patch:
diff --git a/test/formatting/samples/scripts-styles-empty-handling/input.html b/test/formatting/samples/scripts-styles-empty-handling/input.html
new file mode 100644
index 0000000..63f96ea
--- /dev/null
+++ b/test/formatting/samples/scripts-styles-empty-handling/input.html
@@ -0,0 +1,7 @@
+<script context="module"></script>
+
+<script> </script>
+
+<style>
+
+</style>
diff --git a/test/formatting/samples/scripts-styles-empty-handling/output.html b/test/formatting/samples/scripts-styles-empty-handling/output.html
new file mode 100644
index 0000000..278ae83
--- /dev/null
+++ b/test/formatting/samples/scripts-styles-empty-handling/output.html
@@ -0,0 +1,7 @@
+<script context="module"></script>
+
+<script>
+</script>
+
+<style>
+</style>