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

Issue:
HTML comment is duplicated on format
This looks to be a very similar issue to #205.

The following works as a minimum repro in Svelte for VS Code v107.10.0

```
<div>
  <!-- this is duplicated on format -->
  <style></style>
</div>
```

But both of the following work as expected

```
<div>
  <!-- this is *not* duplicated on format -->
  <p>Hi</p>
</div>
```

```
<!-- this is *not* duplicated on format -->
<style></style>
```

So it appears to be the combination of the `<style>` tag and nested structure that triggers the bug. 

Pull request description:
fix: don't duplicate comments of nested script/style tags
fixes #400

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f432b30..ef0f13d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 ## 3.2.0 (Unreleased)
 
 -   (feat) format JSON script tags
+-   (fix) don't duplicate comments of nested script/style tags
 
 ## 3.1.2
 
diff --git a/src/embed.ts b/src/embed.ts
index a647bac..e3aab56 100644
--- a/src/embed.ts
+++ b/src/embed.ts
@@ -366,7 +366,8 @@ async function embedTag(
         // the new position.
         return [...comments, result, hardline];
     } else {
-        return comments.length ? [...comments, result] : result;
+        // Only comments at the top level get the special "move comment" treatment.
+        return isTopLevel && comments.length ? [...comments, result] : result;
     }
 }
 
diff --git a/src/print/index.ts b/src/print/index.ts
index 394acc5..f525b39 100644
--- a/src/print/index.ts
+++ b/src/print/index.ts
@@ -46,7 +46,6 @@ import {
 import {
     ASTNode,
     AttributeNode,
-    CommentInfo,
     CommentNode,
     IfBlockNode,
     Node,


Test patch:
diff --git a/test/printer/samples/script-style-inside-element-comment.html b/test/printer/samples/script-style-inside-element-comment.html
new file mode 100644
index 0000000..2fd3e3c
--- /dev/null
+++ b/test/printer/samples/script-style-inside-element-comment.html
@@ -0,0 +1,10 @@
+<div>
+    <!-- hello -->
+    <style></style>
+</div>
+<svelte:head>
+    <!-- world -->
+    <script>
+        let x;
+    </script>
+</svelte:head>