File tree Expand file tree Collapse file tree 1 file changed +23
-21
lines changed
Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Original file line number Diff line number Diff line change @@ -153,28 +153,30 @@ export class ElementOfHtml {
153153 this . textAfter = this ?. textAfter ?. slice ( 1 , - 1 )
154154 }
155155 #setTextFromComments( entryRule ) {
156- const replaceRegexp = / { 1 , } t e x t ( | - ( b e f o r e | a f t e r ) ) : ? /
157-
158156 for ( let decl of entryRule . declarations ) {
159- let textDeclaration = decl ?. comment ?. match ( / t e x t - ( b e f o r e | a f t e r ) : | t e x t : / i) ?. at ( 0 )
160-
161- if ( ! textDeclaration ) continue
162-
163- let position = textDeclaration . toLowerCase ( ) . replace ( ':' , '' )
164- let text = decl . comment . replace ( replaceRegexp , '' )
165- // Removing one mandatory space at the end
166- . slice ( 0 , - 1 )
167-
168- switch ( position ) {
169- case 'text' :
170- this . text = text
171- break
172- case 'text-before' :
173- this . textBefore = text
174- break
175- case 'text-after' :
176- this . textAfter = text
177- break
157+ let textDeclarations = decl ?. comment ?. match ( / @ ( i n s i d e | b e f o r e | a f t e r ) / gi)
158+
159+ if ( ! textDeclarations ) continue
160+
161+ for ( let declType of textDeclarations ) {
162+ let position = declType . toLowerCase ( ) . replace ( '@' , '' )
163+ let text = decl . comment
164+ // Pulling text only for a specific position
165+ . match ( new RegExp ( `(?<=${ position } ).*? (?=@|$)` , 's' ) ) [ 0 ]
166+ // Removing mandatory spaces at the beginning and at the end
167+ . slice ( 1 , - 1 )
168+
169+ switch ( position ) {
170+ case 'inside' :
171+ this . text = text
172+ break
173+ case 'before' :
174+ this . textBefore = text
175+ break
176+ case 'after' :
177+ this . textAfter = text
178+ break
179+ }
178180 }
179181 }
180182 }
You can’t perform that action at this time.
0 commit comments