deno icon indicating copy to clipboard operation
deno copied to clipboard

deno fmt panics on multiline string embedded in HTML <script>

Open mfulton26 opened this issue 1 year ago • 0 comments

Formatting works fine without the \ and newline but not with them.

<!-- demo.html -->
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Demo</title>
  </head>
  <body>
    <script type="module">
      const supportedFormats =
        await globalThis.BarcodeDetector?.getSupportedFormats() ?? [];
      if (!supportedFormats.includes("qr_code")) {
        document.body.innerHTML +=
          '<p><a \
href="https://developer.mozilla.org/en-US/docs/Web/API/BarcodeDetector">QR Code detection</a> is not natively supported by your web browser. 😔</p>';
      }
    </script>
  </body>
</html>
% RUST_BACKTRACE=1 deno fmt demo.html

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 2.0.2
Args: ["deno", "fmt", "demo.html"]

thread 'tokio-runtime-worker' panicked at cli/tools/fmt.rs:792:11:
Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file (/path/to/demo.html) differently each time. As a temporary workaround you can ignore this file.
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: tokio::runtime::task::raw::poll
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

mfulton26 avatar Oct 18 '24 23:10 mfulton26