diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bde2966b4c0..dd549036ed0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/crates/oxide/src/extractor/pre_processors/markdown.rs b/crates/oxide/src/extractor/pre_processors/markdown.rs index d2acc6a58738..488614ee57bd 100644 --- a/crates/oxide/src/extractor/pre_processors/markdown.rs +++ b/crates/oxide/src/extractor/pre_processors/markdown.rs @@ -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#"{
}"#, + r#" "#, + ), + (r#"{content-['example.js']}"#, r#" content-['example.js'] "#), + ] { + Markdown::test(input, expected); + } + } }