@@ -9,6 +9,7 @@ impl PreProcessor for Markdown {
99 let len = content. len ( ) ;
1010 let mut result = content. to_vec ( ) ;
1111 let mut cursor = cursor:: Cursor :: new ( content) ;
12+ let mut bracket_stack = vec ! [ ] ;
1213
1314 let mut in_directive = false ;
1415
@@ -18,11 +19,17 @@ impl PreProcessor for Markdown {
1819 result[ cursor. pos ] = b' ' ;
1920 in_directive = true ;
2021 }
22+ ( true , b'(' | b'[' | b'{' | b'<' ) => {
23+ bracket_stack. push ( cursor. curr ( ) ) ;
24+ }
25+ ( true , b')' | b']' | b'}' | b'>' ) if !bracket_stack. is_empty ( ) => {
26+ bracket_stack. pop ( ) ;
27+ }
2128 ( true , b'}' ) => {
2229 result[ cursor. pos ] = b' ' ;
2330 in_directive = false ;
2431 }
25- ( true , b'.' ) => {
32+ ( true , b'.' ) if bracket_stack . is_empty ( ) => {
2633 result[ cursor. pos ] = b' ' ;
2734 }
2835 _ => { }
@@ -60,4 +67,17 @@ mod tests {
6067 Markdown :: test ( input, expected) ;
6168 }
6269 }
70+
71+ #[ test]
72+ fn test_nested_classes_keep_the_dots ( ) {
73+ for ( input, expected) in [
74+ (
75+ r#"{<div class="px-2.5"></div>}"# ,
76+ r#" <div class="px-2.5"></div> "# ,
77+ ) ,
78+ ( r#"{content-['example.js']}"# , r#" content-['example.js'] "# ) ,
79+ ] {
80+ Markdown :: test ( input, expected) ;
81+ }
82+ }
6383}
0 commit comments