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

Comments in Svelte SFC <script> tags still breaking #628

Closed
alexanderniebuhr opened this issue Jul 17, 2021 · 3 comments
Closed

Comments in Svelte SFC <script> tags still breaking #628

alexanderniebuhr opened this issue Jul 17, 2021 · 3 comments
Assignees
Labels
bug:upstream bug Something isn't working sp:13

Comments

@alexanderniebuhr
Copy link
Contributor

Still having issues with comments and Svelte SFC Files.
following is breaking hard-code string extraction caused by // <. If you remove that line it does work.

So, it seems that it does have issue with comments including html tags. That said, it does not have any issue with normal comments, like // text

<script>
  // <s
  
  import { onMount } from "svelte";
  import { link, useRouter, useGuard, exists } from "@svelteuse/router";
  import { msalInstance } from "../logic/auth.js";
  import { t } from "svelte-i18n";

  // "google",
  // "google-cn",
  // "deepl",
  // "libretranslate"
</script>

<div class="min-h-100vh flex flex-col">
  <header class="flex flex-row place-content-center p-4">
    <div class="flex flex-row gap-2">
      <a href="/farmer1" use:link><f-button>FENDT FARMER 1</f-button></a>
      <a href="/news" use:link>
        <f-button>
          {$t("layout.default.news")}
        </f-button>
      </a>
      <f-button on:click={(e) => handle365Logout(e)}>
        {$t("layout.default.logout")}
      </f-button>
    </div>
  </header>

  <main class="flex-grow grid place-content-center">
    <slot />
  </main>

  <footer class="flex flex-row place-content-center p-6">
    <div class="flex flex-col items-center gap-2">
      <span> REPGUIDE © 2021 </span>
      <div class="flex flex-row gap-2">
        <a href="/">Impressum</a><a href="/">DATENSCHUTZ</a><a href="/">AGB</a>
      </div>
    </div>
  </footer>
</div>
@alexanderniebuhr alexanderniebuhr added the bug Something isn't working label Jul 17, 2021
@antfu
Copy link
Contributor

antfu commented Jul 17, 2021

Seems like a bug of htmlparser2

https://astexplorer.net/#/gist/eb06e19ab7d3333547177f6d43a581e4/51f3b82b0735fbe925dbe72960017249ab00cdd3

(the startIndex and endIndex are incorrect for script text)

@alexanderniebuhr
Copy link
Contributor Author

@antfu could you wrap the parser & hard-code extraction step in a try / catch and send full error messages into output channel, or anywhere else? Then it would be easier to check why it fails?

@antfu
Copy link
Contributor

antfu commented Jul 17, 2021

I think we already did. The problem it that this is not an error but an unexpected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:upstream bug Something isn't working sp:13
Development

No branches or pull requests

4 participants