tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Classes are not detected in Ruby `%w` literals using angle brackets `<>` or custom delimiters

Open yhatt opened this issue 3 months ago • 4 comments

What version of Tailwind CSS are you using?

v4.3.3

What build tool (or framework if it abstracts the build tool) are you using?

@tailwindcss/cli 4.3.3, tailwindcss 4.3.3

What version of Node.js are you using?

v26.6.0

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL

https://github.com/yhatt/tailwind-ruby-percent-literal-bug

Describe your issue

Tailwind CSS 4.3.3 parses Ruby files and extracts class names from the string defined by percent literals %w(bg-red-400).

However, it fails to parse percent literals that contain angle brackets (%w<bg-red-400>) or a custom non-paired delimiter (%w|bg-red-400|).

https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#percent-literals

PERCENT_LITERAL_WITH_BRACKETS       = %w[bg-red-400]
PERCENT_LITERAL_WITH_PARENTHESIS    = %w(bg-orange-400)
PERCENT_LITERAL_WITH_BRACES         = %w{bg-yellow-400}
PERCENT_LITERAL_WITH_ANGLE_BRACKETS = %w<bg-green-400>
PERCENT_LITERAL_WITH_PIPE           = %w|bg-blue-400|
PERCENT_LITERAL_WITH_COLON          = %w:bg-indigo-400:
Expected Actual
Expected Actual

yhatt avatar Aug 05 '26 12:08 yhatt

Hey! Thanks for reporting this.

The issue describes a failure to parse Ruby percent literals with angle brackets and custom delimiters in Tailwind CSS. The expected behavior is that all valid percent literals should be parsed correctly, while the observed behavior shows that only standard delimiters are recognized.

The most likely root cause is the current parsing logic in the ruby.rs file, which does not account for angle brackets and custom delimiters.

If no one is currently working on this, I'd be happy to take a look and put together a fix.

Mahnoor-Zaffar avatar Aug 05 '26 13:08 Mahnoor-Zaffar

Hey! This should be fixed by #20387, and will be available in the next release.

You can already try it by using the insiders build: CLI:

npm install tailwindcss@insiders @tailwindcss/cli@insiders

PostCSS:

npm install tailwindcss@insiders @tailwindcss/postcss@insiders

Vite:

npm install tailwindcss@insiders @tailwindcss/vite@insiders

webpack:

npm install tailwindcss@insiders @tailwindcss/webpack@insiders

RobinMalfait avatar Aug 06 '26 12:08 RobinMalfait

Nice! Thank you for the quick work! 😄

yhatt avatar Aug 06 '26 13:08 yhatt

You have to thank @lazerg for that :smile:

RobinMalfait avatar Aug 06 '26 13:08 RobinMalfait