I really like the formatter, was one of the best additions to the Elixir code base ever, and with the support for .heex files, it became my defacto standard formatter. My question now as I tinkered with raw HTML, is there a way to formatted raw (valid) HTML? Running mix format test.html just does nothing. I guess this happens as the formatter does not know about heex files without the proper plugin Phoenix.LiveView.HTMLFormatter, but introducing the plugin also requires me to have a mix project
I think you can write a custom formatter that mostly delegates to the Phoenix one (untested):
defmodule HTMLFormatter do
@behaviour Mix.Tasks.Format
@impl true
def features(_options) do
[sigils: [:H], extensions: [".heex", ".html"]]
end
@impl true
defdelegate format(source, options), to: Phoenix.LiveView.HTMLFormatter
end
edit: oh, if you’d rather not need to have a Mix project, then it might be pretty tricky.