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

Issue:
`<style></style>` in comment results incorrect output
source:

```svelte
<!-- <style>
.foo {
  background-image: url("x");
}
</style> -->

<style lang="scss">
.foo {
  background-image: url("x");
}

$map: (
  'alpha': 10,
  'beta': 20,
  'gamma': 30
);
</style>

<span>Hi</span>
```

result:

```svelte
<span>Hi</span>

<!-- <style ✂prettier:content✂="Ci5mb28gewogIGJhY2tncm91bmQtaW1hZ2U6IHVybCgieCIpOwp9Cg=="></style> -->
<style lang="scss">
  .foo {
    background-image: url('x');
  }

  $map: (
    'alpha': 10,
    'beta': 20,
    'gamma': 30
  );
</style>
```

Pull request description:
(fix) adjust snip regex
Account for the script/style being inside a comment
Fixes #212

Patch:
diff --git a/src/lib/snipTagContent.ts b/src/lib/snipTagContent.ts
index 0f8d119..b61757a 100644
--- a/src/lib/snipTagContent.ts
+++ b/src/lib/snipTagContent.ts
@@ -1,8 +1,11 @@
 export const snippedTagContentAttribute = '✂prettier:content✂';
 
 export function snipTagContent(tagName: string, source: string, placeholder = ''): string {
-    const regex = new RegExp(`<${tagName}([^]*?)>([^]*?)<\/${tagName}>`, 'g');
-    return source.replace(regex, (_, attributes, content) => {
+    const regex = new RegExp(`<!--[^]*?-->|<${tagName}([^]*?)>([^]*?)<\/${tagName}>`, 'g');
+    return source.replace(regex, (match, attributes, content) => {
+        if (match.startsWith('<!--')) {
+            return match;
+        }
         const encodedContent = Buffer.from(content).toString('base64');
         return `<${tagName}${attributes} ${snippedTagContentAttribute}="${encodedContent}">${placeholder}</${tagName}>`;
     });


Test patch:
diff --git a/test/printer/samples/style-script-commented-out.html b/test/printer/samples/style-script-commented-out.html
new file mode 100644
index 0000000..c5648ac
--- /dev/null
+++ b/test/printer/samples/style-script-commented-out.html
@@ -0,0 +1,15 @@
+<!-- <script>
+    const a = true;
+</script> -->
+<script>
+    const a = true;
+</script>
+
+<!-- <style>
+    a { color: true }
+</style> -->
+<style>
+    a {
+        color: true;
+    }
+</style>