Skip to content

Commit 2f38fa5

Browse files
AprilArcusglebm
authored andcommitted
handle math.div
1 parent b34765d commit 2f38fa5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tasks/converter/less_conversion.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def convert_to_scss(file)
173173
file = replace_calculation_semantics(file)
174174
file = replace_file_imports(file)
175175
file = wrap_at_groups_with_at_root(file)
176+
file = replace_division(file)
176177
file
177178
end
178179

@@ -182,6 +183,12 @@ def wrap_at_groups_with_at_root(file)
182183
}
183184
end
184185

186+
def replace_division(less)
187+
re = /(?<!\w)\(\s*([^(]+?)\s+\/\s+([^)]+?)\s*\)/
188+
return less if less !~ re
189+
"@use \"sass:math\";\n" + less.gsub(re, 'math.div(\1, \2)')
190+
end
191+
185192
def sass_fn_exists(fn)
186193
%Q{(#{fn}("") != unquote('#{fn}("")'))}
187194
end

0 commit comments

Comments
 (0)