100phlecs / tailwind_formatter

Sorts tailwind classes within elixir projects
https://hexdocs.pm/tailwind_formatter
MIT License
111 stars 11 forks source link

Class strings with special characters don't get formatted #13

Closed zimt28 closed 1 year ago

zimt28 commented 1 year ago

Tailwind uses dot characters for some classes (like py-3.5), but as soon as one is added to the class string, the formatter won't sort it.

zimt28 commented 1 year ago

The formatter also stops working in other cases, like including a hash sign bg-[#333] (bg-[333] works).

100phlecs commented 1 year ago

Thanks for bringing this up!

I wasn't aware of either of these while making this. The decimal one may be an easy fix.

The issue is that # also signifies whether we're about to enter an inline elixir function/elixir code.

We may be getting to the point where Regex is too brittle. I'll see if # can also be incorporated, but I may switch to something other than Regex.

100phlecs commented 1 year ago

So I've updated the invalid_input to account for hashes as well as dots. It should not bail on sorting it anymore. Please feel free to reopen if you find it not working for a particular case. Thanks!