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

my code is replaced with ✂prettier:content✂ #240

Closed
Mlocik97 opened this issue Jul 31, 2021 · 16 comments
Closed

my code is replaced with ✂prettier:content✂ #240

Mlocik97 opened this issue Jul 31, 2021 · 16 comments

Comments

@Mlocik97
Copy link

I still have this problem, with for example this kind of code:

{@html `<style>
        body { background-color: ${bg_col}; }
    </style>`}

it's replaced for:

{@html `<style ✂prettier:content✂="CgkJYm9keSB7IGJhY2tncm91bmQtY29sb3I6ICR7bWYuYmFja2dyb3VuZF9jb2xvcn07IH0KCQ=="></style>`}

tried even comment above {@html ...}, but still it was transforming it to that ugly prettier:content thing.

https://www.youtube.com/watch?v=lHK66Y06OoE

@dummdidumm

Originally posted by @Mlocik97 in #59 (comment)

@Mlocik97 Mlocik97 reopened this Aug 13, 2021
@Mlocik97
Copy link
Author

so #130 didn't fix it.

@navorite
Copy link

navorite commented Aug 15, 2021

I have the same issue as well when using this code:

<iframe
    class="content"
    id="inlineviewer"
    title="Inline Viewer"
    name="Inline Viewer"
    srcdoc={`<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta charset='utf-8'/>
    <title>Inline Viewer</title>
    <style></style>
  </head>
  <body>
  </body>
</html>`}/>

It produces:

<iframe
    class="content"
    id="inlineviewer"
    title="Inline Viewer"
    name="Inline Viewer"
    srcdoc={`<!DOCTYPE html>
<html lang='en'>
  <head>
    <meta charset='utf-8'/>
    <title>Inline Viewer</title>
    <style ✂prettier:content✂=""></style>
  </head>
  <body>
  </body>
</html>`}/>

And when attempting to escape the style tag using <style><\/style> it gives me the following error on <!DOCTYPE html>: Unterminated template

@dummdidumm
Copy link
Member

Duplicate of #70

@dummdidumm dummdidumm marked this as a duplicate of #70 Aug 27, 2021
@codingwithchris
Copy link

@dummdidumm This issue still exists as of:

"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",

Example:

Input

import { getCssText } from '@tokens';
<svelte:head>
	{@html `<style>${getCssText()}</style>`}
</svelte:head>

Output

import { getCssText } from '@tokens';
<svelte:head>
    {@html `<style ✂prettier:content✂="JHtnZXRDc3NUZXh0KCl9"></style>`}
</svelte:head>

@bjornarhagen
Copy link

Using version 2.8.0 I'm getting this:

Original:

{'<script></script>'}
{`<script></script>`}

Formatted:

{'<script ✂prettier:content✂="">{}</script>'}
{`<script ✂prettier:content✂="">{}</script>`}

@justingolden21
Copy link

My code:

{@html `<script type="application/ld+json">${JSON.stringify(({
	"@context": "https://schema.org",
    "@type": "WebSite",
    "name": "Desktop Clock"
    "url": '"'+appURL+'"',
}))}

is replaced with:

{@html `<script type="application/ld+json" ✂prettier:content✂="JHtKU09OLnN0cmluZ2lmeSgoewoJIkBjb250ZXh0IjogImh0dHBzOi8vc2NoZW1hLm9yZyIsCiAgICAiQHR5cGUiOiAiV2ViU2l0ZSIsCiAgICAibmFtZSI6ICJEZXNrdG9wIENsb2NrIgogICAgInVybCI6ICciJythcHBVUkwrJyInLAp9KSl9Cgk=">{}</script>`}

@justingolden21
Copy link

Happening in July 2023...

Simple reproducible example in a svelte file conditionally rendering SVGs:

<script>
    export let name;
</script>
{#if name === 'sunlight'}
	<!-- prettier-ignore -->
	<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 423.9 590.2">
        <circle class="fill-accent-500" cx="65.8" cy="65.8" r="65.8" />
   </svg>
{:else if name === 'time'}
	<!-- prettier-ignore -->
	<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 675.67 631.95">
        <style>
            .st0{fill:#94A3B8;} /*400*/
        </style>
            <circle cx="166" cy="508.87" r="17"/>
        </svg>
{/if}

Is replaced with:

<script>
	export let name;
</script>

{#if name === 'sunlight'}
	<!-- prettier-ignore -->
	<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 423.9 590.2">
        <circle class="fill-accent-500" cx="65.8" cy="65.8" r="65.8" />
   </svg>
{:else if name === 'time'}
	<!-- prettier-ignore -->
	<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 675.67 631.95">
        <style ✂prettier:content✂="CiAgICAgICAgICAgIC5zdDB7ZmlsbDojOTRBM0I4O30gLyo0MDAqLwogICAgICAgIA=="></style>
            <circle cx="166" cy="508.87" r="17"/>
        </svg>
{/if}

@devpikachu
Copy link

Can confirm, this is still happening

@digvijayad
Copy link

For me the issue because of PhpStorms Reformat code or Optimize Imports options.

I disabled those from my git commit checks and am using either the PhpStorm Prettier plugin's Run-on-save option or Ctrl+Shift+Alt+P - Reformat with Prettier

@intzaaa
Copy link

intzaaa commented Jul 19, 2023

Can confirm, this is still happening.

@justingolden21
Copy link

Why is this issue closed? Do we need to make a new issue to reopen it?

@dummdidumm
Copy link
Member

Yes, if people still have certain code snippets that fail using the latest version of this plugin, then they should open a new issue with that code snippet.

@benediktms
Copy link

I also had this issue in webstorm, but similar to @digvijayad I got around it by disabling the build in Reformat code option and relying on prettier. I think it's probably an issue with both formatters trying to run at the same time. Running only prettier on save solved the issue for me. I think this is webstorm/jetbrains specific, at least in my case, because formatting the same file in VSCode worked fine.

@imagoiq
Copy link

imagoiq commented Jun 10, 2024

I've just got the same issue with Intellij, but in my case disabling Optimize imports for HTML seems to solve it.

@DannyFestor
Copy link

I've just get the same issue with Intellij, but in my case disabling Optimize imports for HTML seems to solve it.

Thank you, this fixed it for me in PHPstorm.

@ThibGonceDKT
Copy link

To disable Optimize imports option on code reformat in Intellij, you have to open the reformat popup with Ctrl + Alt + Shift + L (or Opt + Cmd + Shift + L on MacOS) and uncheck the Optimize imports option

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

No branches or pull requests