Fix missing extracted classes in mdx files (#19711)
This commit is contained in:
parent
1a973557ed
commit
58d1fe3948
2 changed files with 22 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Allow trailing dash in functional utility names for backwards compatibility ([#19696](https://github.com/tailwindlabs/tailwindcss/pull/19696))
|
||||
- Fix missing extracted classes in mdx files containing `.` ([#19711](https://github.com/tailwindlabs/tailwindcss/pull/19711))
|
||||
|
||||
## [4.2.0] - 2026-02-18
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ impl PreProcessor for Markdown {
|
|||
let len = content.len();
|
||||
let mut result = content.to_vec();
|
||||
let mut cursor = cursor::Cursor::new(content);
|
||||
let mut bracket_stack = vec![];
|
||||
|
||||
let mut in_directive = false;
|
||||
|
||||
|
|
@ -18,11 +19,17 @@ impl PreProcessor for Markdown {
|
|||
result[cursor.pos] = b' ';
|
||||
in_directive = true;
|
||||
}
|
||||
(true, b'(' | b'[' | b'{' | b'<') => {
|
||||
bracket_stack.push(cursor.curr());
|
||||
}
|
||||
(true, b')' | b']' | b'}' | b'>') if !bracket_stack.is_empty() => {
|
||||
bracket_stack.pop();
|
||||
}
|
||||
(true, b'}') => {
|
||||
result[cursor.pos] = b' ';
|
||||
in_directive = false;
|
||||
}
|
||||
(true, b'.') => {
|
||||
(true, b'.') if bracket_stack.is_empty() => {
|
||||
result[cursor.pos] = b' ';
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -60,4 +67,17 @@ mod tests {
|
|||
Markdown::test(input, expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_classes_keep_the_dots() {
|
||||
for (input, expected) in [
|
||||
(
|
||||
r#"{<div class="px-2.5"></div>}"#,
|
||||
r#" <div class="px-2.5"></div> "#,
|
||||
),
|
||||
(r#"{content-['example.js']}"#, r#" content-['example.js'] "#),
|
||||
] {
|
||||
Markdown::test(input, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue