public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Try to be better about preserving commas in css2sass.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@702 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sun Dec 16 14:50:59 -0800 2007
commit  acda22070f1022eb3c3ab41dd5f37349715a6776
tree    6ca633fddc782675e60ca80362b5b81551457c0a
parent  c882b2d33275b574615fded8516f9d02da34d710
...
121
122
123
 
124
125
126
...
284
285
286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
288
...
121
122
123
124
125
126
127
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
0
@@ -121,6 +121,7 @@ module Sass
0
       expand_commas root
0
       nest_rules root
0
       flatten_rules root
0
+ fold_commas root
0
       root
0
     end
0
 
0
@@ -284,5 +285,36 @@ module Sass
0
 
0
       flatten_rules(rule)
0
     end
0
+
0
+ # Transform
0
+ #
0
+ # foo
0
+ # bar
0
+ # color: blue
0
+ # baz
0
+ # color: blue
0
+ #
0
+ # into
0
+ #
0
+ # foo
0
+ # bar, baz
0
+ # color: blue
0
+ #
0
+ def fold_commas(root)
0
+ prev_rule = nil
0
+ root.children.map! do |child|
0
+ next child unless Tree::RuleNode === child
0
+
0
+ if prev_rule && prev_rule.children == child.children
0
+ prev_rule.rule << ", #{child.rule}"
0
+ next nil
0
+ end
0
+
0
+ fold_commas(child)
0
+ prev_rule = child
0
+ child
0
+ end
0
+ root.children.compact!
0
+ end
0
   end
0
 end

Comments

    No one has commented yet.