@@ -424,16 +424,16 @@ def extract_mixins_from_selectors(file, selectors_to_mixins)
424
424
# #scope > .mixin() -> @include scope-mixin()
425
425
# &:extend(.mixin all) -> @include mixin()
426
426
def replace_mixins ( less , mixin_names )
427
- mixin_pattern = /(\s + )(([#|\. ][\w -]+\s *>\s *)*)\. ([\w -]+\( .* \) )(?!\s \{ )/
428
-
429
- less = less . gsub ( mixin_pattern ) do |match |
430
- matches = match . scan ( mixin_pattern ) . flatten
431
- scope = matches [ 1 ] && matches [ 1 ] != '' ? matches [ 1 ] . scan ( /[\w -]+/ ) . join ( '-' ) + '-' : ''
432
- mixin_name = match . scan ( / \. ([ \w -]+) \( .* \) \s ? \{ ?/ ) . first
433
- if mixin_name && mixin_names . include? ( "#{ scope } #{ mixin_name . first } " )
434
- "#{ matches . first } @include #{ scope } #{ matches . last . gsub ( /; \s * \$ / , ', $' ) . sub ( /; \) $/ , ')' ) . sub ( / \( \) $/ , '' ) } "
427
+ mixin_pattern = /(?<=^| \s )((?: [#|\. ][\w -]+\s *>\s *)*)\. ([\w -]+) \( (.*) \ ) (?!\s \{ )/
428
+
429
+ less = less . gsub ( mixin_pattern ) do |_ |
430
+ scope , name , args = $1 , $2 , $3
431
+ scope = scope . scan ( /[\w -]+/ ) . join ( '-' ) + '-' unless scope . empty?
432
+ args = "( #{ args . tr ( ';' , ',' ) } )" unless args . empty?
433
+ if name && mixin_names . include? ( "#{ scope } #{ name } " )
434
+ "@include #{ scope } #{ name } #{ args } "
435
435
else
436
- "#{ matches . first } @extend .#{ scope } #{ matches . last . gsub ( / \( \) / , '' ) } "
436
+ "@extend .#{ scope } #{ name } "
437
437
end
438
438
end
439
439
0 commit comments