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.

Cannot use self-closing <style /> or <script /> tags

See original GitHub issue

I try to run format svelte files but have an error

[error] lobby\Armory.svelte: Expected > [error] > 1 | <style type="text/scss" src="./Armory.scss"/><script ✂prettier:content✂="CgogICAgaW1wb3J0IFN0YXRCYXIgZnJvbSAnLi9TdGF0QmFyLnN2ZWx0ZSc7CiAgICBpbXBvcnQgQXJtb3J5U2xvdCBmcm9tICcuL0FybW9yeVNsb3Quc3ZlbHRlJzsKCiAgICBsZXQgc3Rhd HMgPSBbCiAgICAgICAgeyBuYW1lOidEYW1hZ2UnLCBwcm9ncmVzczo1MCwgZGlmZjo2MCB9LAogICAgICAgIHsgbmFtZTonUmFuZ2UnLCBwcm9ncmVzczozMCwgZGlmZjozNSB9LAogICAgICAgIHsgbmFtZTonUmF0ZSBvZiBmaXJlJywgcHJvZ3Jlc3M6NjAsIGRpZmY6NTAgfSwKICAgICAgICB7IG5hbWU6J 0FpbSBhY2N1cmFjeScsIHByb2dyZXNzOjIwLCBkaWZmOjQwIH0sCiAgICAgICAgeyBuYW1lOidIaXAgQWNjdXJhY3knLCBwcm9ncmVzczo3MCwgZGlmZjo3MCB9LAogICAgICAgIHsgbmFtZTonQW1tbyBjYXBhY2l0eScsIHByb2dyZXNzOjQwLCBkaWZmOjEwIH0sCiAgICBdOwoKICAgIGxldCBzbG90cyA9I FsKICAgICAgICB7IH0sCiAgICAgICAgeyBuYW1lOidBcGVydHVyZSBTaWdodCcsIGltYWdlOicvYnVpbGQvYXNzZXRzL3NpZ2h0cy9hcGVydHVyZS5wbmcnIH0sCiAgICAgICAgeyBsb2NrZWQ6dHJ1ZSB9LAogICAgICAgIHsgbG9ja2VkOnRydWUgfSwKICAgICAgICB7IGxvY2tlZDp0cnVlIH0sCiAgICBdO woK">{}</script><div class="armory">

I use “prettier”: “^2.2.1”, “prettier-plugin-svelte”: “^2.1.1”,

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
mataslibcommented, Apr 15, 2021

@dummdidumm

I have run into the same issue, however not due to self-closing tag.

// Test.svelte
<script>
    ...
    $: containerStylesHtml = `<style>${containerStyles}</style>`;
</script>

Run cmd, or “Format document” action in vscode when svelte plugin installed:

npx prettier --write --plugin-search-dir=. ./**/*.svelte

Results in:

  $: containerStylesHtml = `<style ✂prettier:content✂="JHtjb250YWluZXJTdHlsZXN9"></style>`;

Workaround escape style closing tag like so: 😕

$: containerStylesHtml = `<style>${containerStyles}<\/style>`;
1reaction
dummdidummcommented, May 10, 2021

@mataslib this issue is tracked in #219 @wiesson without a reproducible code snippet I can’t do much. Also it seems like you want to format sections of the file, not the whole file, not sure how that plays out. Either way, this seems unrelated to the original issue which is about supporting <script .. />. Please open a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why don't self-closing script elements work? - Stack Overflow
The self closing script tag won't work, because the script tag can contain inline code, and HTML is ...
Read more >
Why self-closing script tags doesn't work? - NamasteUI
Basically, the concept of self-closing tags is an XML concept. You can use them in XHTML if the document is served with an...
Read more >
HTML script tags can not be atomic/self-closing
Recently I completed a project where I converted an Actionscript form generation system I wrote for my wife's business into Javascript.
Read more >
Why self closing script tag is not working - CodeRanch
If I self closed the tag, like I shown in the code <script . ... Answer: not all browsers support the notation so...
Read more >
Why don t self-closing script elements work - Edureka
In an HTML Document - VOID ELEMENTS do not need a "closing tag" at all! In xhtml, everything is Generic, therefore they all...
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