g-plane / markup_fmt

Configurable HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks and Vento formatter with dprint integration.
https://dprint.dev/plugins/markup_fmt/
MIT License
108 stars 10 forks source link

`Hints::indent_level` seems to always be 0 #87

Closed bartlomieju closed 21 hours ago

bartlomieju commented 2 days ago

Hints::indent_level added in https://github.com/g-plane/markup_fmt/pull/86 appears to always be 0.

I tried to use it in https://github.com/denoland/deno/pull/27164, but for following 2 files I always get value of 0:

<!-- 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>
<html>
    <body>
        <script>
            /* some multi-line comment
            with function below it */
            someFunc();
        </script>
    </body>
</html>

Also, would it be possible to use u16 as a return type, instead of usize so cast like this: typescript_config_builder.file_indent_level(hints.indent_level.try_into().unwrap_or(0)); is not necessary?

g-plane commented 2 days ago

Using u16 should be okay.