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
91 stars 4 forks source link

Unstable formatting of jinja interpolation in div tag #26

Closed UnknownPlatypus closed 3 months ago

UnknownPlatypus commented 3 months ago

Hello !

I'm experiencing an unstable formatting with this snippet. It is making cargo insta fail when added to fmt/jinja/interpolation/fixture.jinja:

<div>{{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}</div>

Running markup fmt on it first does this:

-<div>{{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}</div>
+<div>
+{{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}
+</div>

Running it a second time does this:

<div>
-{{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}
+    {{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}
</div>

Note that adding a space between the div tag and the jinja interpolation make the formatting stable:

-<div> {{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}</div>
+<div>
+    {{ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }}
+</div>

Would it be possible to format this snippet in one pass ? Thanks again for this tool, i'm really enjoying playing around with it

UnknownPlatypus commented 3 months ago

Awesome thanks!