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

Tag + text wrapping option request #16

Closed f11xter closed 6 months ago

f11xter commented 6 months ago

First a thank you.

I switched to markup_fmt and dprint because I dislike the way Prettier formats void tags, and I've been really enjoying the experience, so thank you very much for making this.

Now the question.

markup_fmt wraps space-sensitive tags with long properties + short text content differently to how it wraps them with short properties + long text:

<a
  href="quite-a-long-url-that-just-keeps-going"
>short text</a>

<a href="not-a-long-url">but a long piece of
  text that wraps</a>

I find this a little confusing to read.

Would it be possible to implement an option that's closer to (what I believe is) Prettier's behaviour?

<a  href="quite-a-long-url-that-just-keeps-going"
  >short text</a
>

<a href="not-a-long-url"
  >but a long piece of text that wraps</a
>

or a compromise between the two?

<a
  href="quite-a-long-url-that-just-keeps-going"
>short text</a>

<a href="not-a-long-url"
>but a long piece of text that wraps</a>
g-plane commented 6 months ago

because I dislike the way Prettier formats void tags

Me too, so I made this.


Personally I prefer the second one, but it may conflict with the closingBracketSameLine option.

f11xter commented 6 months ago

If by the second one you mean the compromise, I agree.

It probably would conflict, so perhaps it could only be activated when closingBracketSameLine is false, since presumably users with it set to true wouldn't want the proposed changes anyway.

<!-- closingBracketSameLine false -->
<span
  class=""
  style=""
>retains the current default behaviour</span>

<span class="some long class"
>uses proposed behaviour</span>

<!-- closingBracketSameLine true -->
<span
  class=""
  style="">retains the current
  default behaviour</span>

<span class="some long class">retains
  the current default behaviour</span>
g-plane commented 6 months ago

Yes, we're on the same idea.