Skip to content

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Jul 2, 2025

Fixes #18431

The ~W(…) syntax in Elixir is a sigil. It's basically another way to write strings, arrays of strings, etc… The syntax lets you use a handful of surrounding brackets like ~W(…), ~W[…], ~W{…}, ~W"…", etc… to let you write lists without necessarily having to escape characters.

In v3 our extractor was able to pick these up but in v4 Oxide does not. I've added a preprocessor for Elixir files so we can modify the code before our main extractor sees it.

Now things like this: ~W(text-white bg-gray-600) will get turned into ~W text-white bg-gray-600 which can easily be processed by our extractor.

The sigils we support are:

  • ~s / ~S (strings)
  • ~w / ~W (word lists)
  • ~c / ~C (charlists)

We're specifically detecting the use of (…), […], and {…} as using quotes already works today.

@thecrypticace thecrypticace requested a review from a team as a code owner July 2, 2025 15:32
@thecrypticace thecrypticace changed the title Detect classes inside Elixir word, string, and char list sigils Detect classes inside Elixir char list, word list, and string sigils Jul 2, 2025
@thecrypticace thecrypticace changed the title Detect classes inside Elixir char list, word list, and string sigils Detect classes inside Elixir charlist, word list, and string sigils Jul 2, 2025
@thecrypticace
Copy link
Contributor Author

@RobinMalfait if you could take a peek at this at some point. I think I did it right 😅

Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from these 2 suggestions, looks good!

The Elixir::test already makes sure that we keep the same length so that's already covered for us.

@thecrypticace thecrypticace merged commit 8c80330 into main Jul 2, 2025
7 checks passed
@thecrypticace thecrypticace deleted the feat/elixir-preprocessor branch July 2, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tailwind 4 doesn't detect classes in parenthesis
2 participants