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 <jordan@cryptica.me>
This commit is contained in:
parent
63b5d7bdab
commit
f4a7eea6cc
1 changed files with 25 additions and 1 deletions
|
|
@ -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"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue