deno icon indicating copy to clipboard operation
deno copied to clipboard

deno fmt: support html/svg/xml

Open mfulton26 opened this issue 2 years ago • 2 comments

deno fmt already formats JSX & TSX. Would it be too much extra work to also support formatting HTML, SVG, and other XML files (e.g. XML itself, XHTML, etc.)?

Today I keep reaching for Prettier on these occasions but I'd rather rely Deno for more core formatting needs. This support could likely be reused with tagged templates (https://github.com/denoland/deno/issues/19840).

mfulton26 avatar Aug 18 '23 18:08 mfulton26

I would be in favor of that, but it's a question for @dsherret if there's any appetite for supporting these natively in dprint.

bartlomieju avatar Aug 29 '23 13:08 bartlomieju

Formatting .html files is now supported. I believe support for formatting .svg files is just a matter of recognizing these files, while .xml might be harder to do.

bartlomieju avatar Oct 24 '24 22:10 bartlomieju

update: a new version of dprint isn't published yet but changes are in to format XML

https://github.com/dprint/dprint/pull/995

mfulton26 avatar Jun 23 '25 13:06 mfulton26

@dsherret am I correct in assuming that we will need to update https://github.com/denoland/deno_media_type to understand xml and svg files?

bartlomieju avatar Jun 23 '25 13:06 bartlomieju

No. We can just base it on the extension.

dsherret avatar Jun 23 '25 13:06 dsherret