File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -169,13 +169,22 @@ export class ElementOfHtml {
169169 // Removing spaces necessary for readability of a comment
170170 commentWithText = commentWithText . slice ( 1 , - 1 )
171171
172- let textBefore = commentWithText . match ( / ^ .* (? = { { ) / s) ?. at ( 0 )
173- let text = commentWithText . match ( / (?< = { { ) .* ?(? = } } | $ ) / s) ?. at ( 0 )
174- let textAfter = commentWithText . match ( / (?< = } } ) .* $ / s) ?. at ( 0 )
172+ let text = [
173+ // Get everything up to {{
174+ commentWithText . match ( / ^ .* (? = { { ) / s) ?. at ( 0 ) ,
175+ // Get everything in {{ }}
176+ commentWithText . match ( / (?< = { { ) .* ?(? = } } | $ ) / s) ?. at ( 0 ) ,
177+ // Get everything after }}
178+ commentWithText . match ( / (?< = } } ) .* $ / s) ?. at ( 0 )
179+ ]
180+
181+ for ( let i = 0 ; i < text . length ; i ++ ) {
182+ if ( ! text [ i ] ?. trim ( ) ) {
183+ text [ i ] = ''
184+ }
185+ }
175186
176- this . textBefore = textBefore
177- this . text = text
178- this . textAfter = textAfter
187+ [ this . textBefore , this . text , this . textAfter ] = text
179188 }
180189 #setParentAndSelfSelector( fullSelector ) {
181190 let partsOfSelector = fullSelector . split ( ' ' )
Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ test('New lines are placed correctly', () => {
66 assert . equal (
77 new CssToHtml ( {
88 css : `
9- div { /* {{ text inside }} */ }
9+ div { /*
10+ {{ text inside }}
11+
12+ */ }
1013div i { /* {{ text of i }} after */ }
1114` ,
1215 } )
You can’t perform that action at this time.
0 commit comments