From f4a7eea6cc5cb9e4107d25689465515d02c50c8b Mon Sep 17 00:00:00 2001 From: Henrik Eneroth Date: Wed, 18 Jun 2025 18:38:27 +0200 Subject: [PATCH] Extract candidates with variants in Clojure/ClojureScript keywords (#18338) ## Summary Taking a shot at fixing my own complaint from #18336. Added failing test and fix for extracting classes containing a pseudo-class from Clojure keywords. Eg., `:hover:text` -> `"hover:text"`. This would previously produce `["hover", "text"]`. ## Test plan - Add a failing test. - Verify that it fails with `cargo test`. - Add fix. - Verify that `cargo test` has no further complaints. ATT: @RobinMalfait --------- Co-authored-by: Jordan Pittman --- .../src/extractor/pre_processors/clojure.rs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/oxide/src/extractor/pre_processors/clojure.rs b/crates/oxide/src/extractor/pre_processors/clojure.rs index d070c9dc0..133311734 100644 --- a/crates/oxide/src/extractor/pre_processors/clojure.rs +++ b/crates/oxide/src/extractor/pre_processors/clojure.rs @@ -42,7 +42,7 @@ impl PreProcessor for Clojure { } } - // A `.` surrounded by digits is a decimal number, so we don't want to replace it. + // A `.` surrounded by digits is a decimal number, so we don't want to replace it. // // E.g.: // ``` @@ -54,6 +54,18 @@ impl PreProcessor for Clojure { // Keep the `.` as-is } + // A `:` surrounded by letters denotes a variant. Keep as is. + // + // E.g.: + // ``` + // lg:pr-6" + // ^ + // `` + b':' if cursor.prev.is_ascii_alphanumeric() && cursor.next.is_ascii_alphanumeric() => { + + // Keep the `:` as-is + } + b':' | b'.' => { result[cursor.pos] = b' '; } @@ -178,4 +190,16 @@ mod tests { Clojure::test_extract_contains(input, vec!["flex", "gap-1.5", "p-1"]); } + + // https://github.com/tailwindlabs/tailwindcss/issues/18336 + #[test] + fn test_extraction_of_pseudoclasses_from_keywords() { + let input = r#" + ($ :div {:class [:flex :first:lg:pr-6 :first:2xl:pl-6 :group-hover/2:2xs:pt-6]} …) + + :.hover:bg-white + "#; + + Clojure::test_extract_contains(input, vec!["flex", "first:lg:pr-6", "first:2xl:pl-6", "group-hover/2:2xs:pt-6", "hover:bg-white"]); + } }