class Sass::CSS
def fold_commas(root)
color: blue
bar, baz
foo
into
color: blue
baz
color: blue
bar
foo
Transform
def fold_commas(root) prev_rule = nil root.children.map! do |child| next child unless Tree::RuleNode === child if prev_rule && prev_rule.children == child.children prev_rule.rule << ", #{child.rule}" next nil end fold_commas(child) prev_rule = child child end root.children.compact! end