Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add safety checks around (
There is a situation where classes can exist top-level that are _not_
inside of any type of brackets.

E.g.:

```
div class="…"
```
  • Loading branch information
RobinMalfait committed Mar 19, 2025
commit 645db11673316e4bb2e173cca162c5d990c7562e
11 changes: 10 additions & 1 deletion crates/oxide/src/extractor/pre_processors/slim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl PreProcessor for Slim {
//
// However, we also need to make sure that we keep the parens that are part of the
// utility class. E.g.: `bg-(--my-color)`.
b'(' if bracket_stack.is_empty() && !matches!(cursor.prev, b'-') => {
b'(' if bracket_stack.is_empty() && !matches!(cursor.prev, b'-' | b'/') => {
result[cursor.pos] = b' ';
bracket_stack.push(cursor.curr);
}
Expand Down Expand Up @@ -236,6 +236,15 @@ mod tests {
"bg-[url(https://example.com)]",
],
);

// Top-level class shorthand with parens
let input = r#"
div class="bg-(--my-color) bg-(--my-color)/(--my-opacity)"
"#;
Slim::test_extract_contains(
input,
vec!["bg-(--my-color)", "bg-(--my-color)/(--my-opacity)"],
);
}

#[test]
Expand Down