Skip to content

Commit f4a7eea

Browse files
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 <[email protected]>
1 parent 63b5d7b commit f4a7eea

File tree

1 file changed

+25
-1
lines changed
  • crates/oxide/src/extractor/pre_processors

1 file changed

+25
-1
lines changed

crates/oxide/src/extractor/pre_processors/clojure.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl PreProcessor for Clojure {
4242
}
4343
}
4444

45-
// A `.` surrounded by digits is a decimal number, so we don't want to replace it.
45+
// A `.` surrounded by digits is a decimal number, so we don't want to replace it.
4646
//
4747
// E.g.:
4848
// ```
@@ -54,6 +54,18 @@ impl PreProcessor for Clojure {
5454
// Keep the `.` as-is
5555
}
5656

57+
// A `:` surrounded by letters denotes a variant. Keep as is.
58+
//
59+
// E.g.:
60+
// ```
61+
// lg:pr-6"
62+
// ^
63+
// ``
64+
b':' if cursor.prev.is_ascii_alphanumeric() && cursor.next.is_ascii_alphanumeric() => {
65+
66+
// Keep the `:` as-is
67+
}
68+
5769
b':' | b'.' => {
5870
result[cursor.pos] = b' ';
5971
}
@@ -178,4 +190,16 @@ mod tests {
178190

179191
Clojure::test_extract_contains(input, vec!["flex", "gap-1.5", "p-1"]);
180192
}
193+
194+
// https://github.com/tailwindlabs/tailwindcss/issues/18336
195+
#[test]
196+
fn test_extraction_of_pseudoclasses_from_keywords() {
197+
let input = r#"
198+
($ :div {:class [:flex :first:lg:pr-6 :first:2xl:pl-6 :group-hover/2:2xs:pt-6]} …)
199+
200+
:.hover:bg-white
201+
"#;
202+
203+
Clojure::test_extract_contains(input, vec!["flex", "first:lg:pr-6", "first:2xl:pl-6", "group-hover/2:2xs:pt-6", "hover:bg-white"]);
204+
}
181205
}

0 commit comments

Comments
 (0)