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
100 stars 9 forks source link

Fix panic for empty line in script tag containing only a tab (or few spaces) #33

Closed UnknownPlatypus closed 3 months ago

UnknownPlatypus commented 4 months ago

This fixes an error I discovered by formatting this snippet containing a mix of 2 and 4 spaces indents with markup_fmt.

<head>
    <style>
      .foo .icon {
        height: 32px;
        width: 32px;
      }

      .foo {
        margin: 0;
      }
    </style>
</head>

The first pass lead to this:

<head>
    <style>
    .foo .icon {
      height: 32px;
      width: 32px;
    }
-    
+  
    .foo {
      margin: 0;
    }
    </style>
</head>

And the second one panicked because of the 2-space indent between the css classes

g-plane commented 3 months ago

There's a single space in the <style> tag of the tests. Is this expected?

UnknownPlatypus commented 3 months ago

Wasn't expected (tho the error exists for any number of space smaller than the indent width). Got probably scammed because I opened the file in intellij after editing in nano. This should be fixed now!