Will there ever be a formatter API?

I love the Elixir formatter. In fact, I’ve started using it for ordinary HTML files as well: GitHub - ream88/formatter: Format any HTML with mix format

However, this approach feels hacky and could break at any moment. My question is: Are there plans to extract the Elixir formatter into its own Hex package with a proper public API?

I don’t think the formatter will ever become an external package, because that would mean elixir itself can no longer use it. Elixir using it was one of the primary reasons for its creation though.

Can you elaborate on what exactly you mean by “this approach”?

Sure. I basically have the project linked above checked out on my computer. I then symlink all my HTML files to the lib folder and then run mix format on them. Please don’t judge me :sweat_smile:

Have you tried using Code.format_string!/2

You could write

“mix format path/to/file”

Unfortunately this does not work, especially as my project is not a mix app. :wink:

Tbh I’m not sure how this could “break at any moment”. You’re using the formatter like it’s intended. The only specialty is the usage of symlinks, which is a really common way to handle files. I also wouldn’t expect that part to cause any breakage.

I was concerned about the symlinking part, but if you say it’s fine, it should be fine. Thank you. :blush: