Skip to content

Commit 737994b

Browse files
authored
Allow _ before numbers during candidate extraction (#17961)
This PR fixes a bug where a class like `header_1` wasn't properly extracted because we didn't allow an `_` before a number. This PR fixes that by allowing an `_` before a number. Fixes: #17960 ## Test plan 1. Added a test to verify this works 2. Existing tests work Used the visualizer tool for this to verify that the `header_1` class is being extracted: <img width="1816" alt="image" src="https://github.com/user-attachments/assets/fdc21602-0e2b-4e4e-92a1-19c4f4f5393f" />
1 parent 2d13998 commit 737994b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Allow `_` before numbers during candidate extraction ([#17961](https://github.com/tailwindlabs/tailwindcss/pull/17961))
1113

1214
## [4.1.6] - 2025-05-09
1315

crates/oxide/src/extractor/named_utility_machine.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,11 @@ impl Machine for NamedUtilityMachine<ParsingState> {
279279
Class::Number => {
280280
if !matches!(
281281
cursor.prev.into(),
282-
Class::Dash | Class::Dot | Class::Number | Class::AlphaLower
282+
Class::Dash
283+
| Class::Underscore
284+
| Class::Dot
285+
| Class::Number
286+
| Class::AlphaLower
283287
) {
284288
return self.restart();
285289
}
@@ -415,6 +419,9 @@ mod tests {
415419
// With numbers
416420
("px-5", vec!["px-5"]),
417421
("px-2.5", vec!["px-2.5"]),
422+
// Underscores followed by numbers
423+
("header_1", vec!["header_1"]),
424+
("header_1_2", vec!["header_1_2"]),
418425
// With number followed by dash or underscore
419426
("text-title1-strong", vec!["text-title1-strong"]),
420427
("text-title1_strong", vec!["text-title1_strong"]),

0 commit comments

Comments
 (0)