question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTML comments inside svelte markup cause a distortion of the tag <script>

See original GitHub issue

If you add any html comment (for example: <!--SomeComment-->) before the closing </ul> tag in src/routes/blog/index.svelte in this project, the script tag will be distorted. Here is an example:

<svelte:head>
  <title>Blog</title>
</svelte:head>

<h1>Recent posts</h1>

<ul>
  {#each posts as post}
    <!-- we're using the non-standard `rel=prefetch` attribute to
				tell Sapper to load the data for the page as soon as
				the user hovers over the link or taps it, instead of
				waiting for the 'click' event -->
    <li><a rel="prefetch" href="blog/{post.slug}">{post.title}</a></li>
  {/each}
  <!--Comment-->
</ul>

<script<svelte:head>
  >
  export function preload() {
    return this.fetch(`blog.json`)
      .then((r) => r.json())
      .then((posts) => {
        return { posts };
      });
  }
</script>

VSCode 1.50.0 Svelte for VS Code: v102.1.1 Prettier - Code formatter: v5.7.1

my settings.json:

{
  "workbench.iconTheme": "material-icon-theme",
  "editor.tabSize": 2,
  "editor.fontFamily": "' JetBrains Mono','Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
  "editor.fontSize": 14.5,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  },
  "[svelte]": {
    "editor.defaultFormatter": "svelte.svelte-vscode"
  },
  "files.watcherExclude": {
    "**/build/**": true,
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true
  },
  "files.autoSave": "onFocusChange",
  "html.format.indentInnerHtml": true,
  "svelte.plugin.css.enable": false,
  "svelte.plugin.css.diagnostics.enable": false,
  "svelte.plugin.svelte.diagnostics.enable": false
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ljonyacommented, Oct 17, 2020

@dummdidumm Sorry, I forgot to update the plugin. Everything works great. Thank you!

1reaction
dummdidummcommented, Oct 17, 2020

Is prettier-plugin-svelte part of your node_modules? If so, that needs to be bumped to the latest version, too. If the plugin is present in the node_modules that one is used instead of the one bundled with VS Code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML comments inside svelte markup cause formatting to fail
Describe the bug HTML comments inside svelte markup prevents remaining ... of the Sapper template project, the tag <script context="module"> is distorted:
Read more >
Are HTML comments inside script tags a best practice? [closed]
Using HTML Comments In Script Is Bad // DON'T do this! Code is just representative on how things were done <script language="javascript"> <!...
Read more >
Introduction / HTML tags • Svelte Tutorial
Ordinarily, strings are inserted as plain text, meaning that characters like < and > have no special meaning. But sometimes you need to...
Read more >
Untitled
All in it justin bieber piano, Actiiv fitband nz, Four seasons garden center rochford, Borang kenaikan pangkat dg32 ke dg34, Monitoramento online gratis, ......
Read more >
KoA - River Thames Conditions - Environment Agency - GOV.UK
#miele Golf ulzama hotel, Kranenburgweg 142 den haag, Verliefdheid weghalen, Amor platonico lyrics in english, Compendio farmacologia katzung pdf, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found