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

Normalize `accept` HTML attribute value as a comma separated string #40

Open UnknownPlatypus opened 1 month ago

UnknownPlatypus commented 1 month ago

The html accept attribute expect a comma separated list of string. This is easy to normalize the same way we normalize class as a space-separated list of string so I went for it.

This could possibly be expanded to other attribute with defined semantics (See https://github.com/g-plane/markup_fmt/pull/40#issuecomment-2273030728).

-<input type="file" accept=" image/gif
-                               , image/jpeg ">
+<input type="file" accept="image/gif, image/jpeg">
g-plane commented 1 month ago

I'm neutral on this, so I'm going to leave it open for discussions.

UnknownPlatypus commented 1 month ago

For context this is tracked more generally in prettier too Format values of attributes with defined semantics and led to the formatting of class and style attributes.

I've also done some research for other good candidates from the HTML attribute list (cross referencing the HTML spec) and found the followings that could be formatted space-separated like class:

Quick searches using https://sourcegraph.com/search found matches with weird spaces for all of them so I suppose it could benefit some people.