Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot nest <style>..</style> inside script tag #219

Closed
elliott-with-the-longest-name-on-github opened this issue May 9, 2021 · 1 comment · Fixed by #220
Closed

Cannot nest <style>..</style> inside script tag #219

elliott-with-the-longest-name-on-github opened this issue May 9, 2021 · 1 comment · Fixed by #220

Comments

@elliott-with-the-longest-name-on-github

Hey all,

Here's a bizarre random behavior with an incredibly small reproduction.

When creating this file:

<script lang="ts">
  const test = '<style>.cls-1{fill:#231f20;}.cls-2{fill:#b06010;}.cls-3{fill:#578bac;}.cls-4{fill:#00446a;}.cls-5{fill:#afb1b4;}.cls-6{fill:#696a6d;}.cls-7{fill:#d7a374;}.cls-8{fill:#c1c17d;}.cls-9{fill:#8a8d09;}</style>'
</script>

If I format it:

<script lang="ts">
	const test =
		'<style ✂prettier:content✂="LmNscy0xe2ZpbGw6IzIzMWYyMDt9LmNscy0ye2ZpbGw6I2IwNjAxMDt9LmNscy0ze2ZpbGw6IzU3OGJhYzt9LmNscy00e2ZpbGw6IzAwNDQ2YTt9LmNscy01e2ZpbGw6I2FmYjFiNDt9LmNscy02e2ZpbGw6IzY5NmE2ZDt9LmNscy03e2ZpbGw6I2Q3YTM3NDt9LmNscy04e2ZpbGw6I2MxYzE3ZDt9LmNscy05e2ZpbGw6IzhhOGQwOTt9"></style>';
</script>

That's... weird.

Here's my .prettierrc:

{
	"useTabs": true,
	"singleQuote": true,
	"trailingComma": "es5",
	"printWidth": 120
}
@elliott-with-the-longest-name-on-github

For obvious reasons, I'm pretty sure the source of the issue is somewhere in the Regex in this file: https://github.com/sveltejs/prettier-plugin-svelte/blob/a4413724b2b52943c11178f826c5a3e7be29850f/src/lib/snipTagContent.ts

@dummdidumm dummdidumm changed the title My magic SVG string is destroyed by reformatting Cannot nest <style>..</style> inside script tag May 10, 2021
dummdidumm pushed a commit to dummdidumm/prettier-plugin-svelte that referenced this issue May 10, 2021
dummdidumm added a commit that referenced this issue May 10, 2021
Fixes #219
Fixes the comment case of #70
Closes #72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant