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

[BUG] `*.selfClosing` doesn't work well #2

Closed iamwxq closed 10 months ago

iamwxq commented 10 months ago

The rule of *.selfClosing says when I set it to true, the tag will be formatted as <div />.

But actually it will be formatted as <div />, so that there are two space in the tag which one is redundant.

I don't know if it should be like that or it's a bug.

Case following:

input:

<div />
<div></div>

output:

<div  /> <!-- an extra space in the tag -->
<div  />

Here comes my markup config:

"markup": {
    "closingBracketSameLine": true,
    "component.selfClosing": true,

    "formatComments": true,

    "html.void.selfClosing": true,
    "html.normal.selfClosing": true,

    "mathml.selfClosing": true,
    "maxAttrsPerLine": 1,

    "printWidth": 88,

    "svg.selfClosing": true,

    "vBindStyle": "short",
    "vForDelimiterStyle": "in",
    "vOnStyle": "short",
    "vSlotStyle": "short"
}
iamwxq commented 10 months ago

Ok, now I know the reason why it works like that. Because of the maxAttrsPerLine, when it was set to a number, tag will be formatted as that, and once I set it to null, everything will be ok.

g-plane commented 10 months ago

Thanks for reporting.