public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Come up with a somewhat saner model for multiline rules.
nex3 (author)
Mon Apr 28 12:13:31 -0700 2008
commit  8b2e0b5a2e1dfc2ef49d3e228f36b4dd732fccd2
tree    036fb9b54cc85e5d224fb89c6e323315cefe0e89
parent  5548ed38e99e6bd68da13071f0ef340b52f441a9
...
220
221
222
223
224
 
225
226
227
228
229
230
231
 
232
233
234
...
220
221
222
 
 
223
224
225
226
227
228
 
 
229
230
231
232
0
@@ -220,15 +220,13 @@ END
0
 
0
       # Resolve multiline rules
0
       if node.is_a?(Tree::RuleNode)
0
- continued = node.continued?
0
- while continued
0
+ if node.continued?
0
           child, index = build_tree(index) if @lines[old_index = index]
0
           if @lines[old_index].nil? || has_children?(old_index, tabs) || !child.is_a?(Tree::RuleNode)
0
             raise SyntaxError.new("Rules can't end in commas.", @line)
0
           end
0
 
0
- node.add_rule child
0
- continued = child.continued?
0
+ node.add_rules child
0
         end
0
         node.children = child.children if child
0
       end
...
13
14
15
16
 
17
18
 
19
20
21
...
33
34
35
36
 
37
38
39
...
48
49
50
51
 
52
53
54
...
13
14
15
 
16
17
 
18
19
20
21
...
33
34
35
 
36
37
38
39
...
48
49
50
 
51
52
53
54
0
@@ -13,9 +13,9 @@ module Sass::Tree
0
       Array(rule)
0
     end
0
 
0
- def add_rule(node)
0
+ def add_rules(node)
0
       self.rule = rules
0
- rules << node.rule
0
+ self.rule += node.rules
0
     end
0
 
0
     def continued?
0
@@ -33,7 +33,7 @@ module Sass::Tree
0
       total_rule = if super_rules
0
         super_rules.split(",\n").map do |super_line|
0
           super_line.strip.split(rule_split).map do |super_rule|
0
- self.rules.flatten.map do |line|
0
+ self.rules.map do |line|
0
               rule_indent + line.gsub(/,$/, '').split(rule_split).map do |rule|
0
                 if rule.include?(PARENT)
0
                   rule.gsub(PARENT, super_rule)
0
@@ -48,7 +48,7 @@ module Sass::Tree
0
         raise Sass::SyntaxError.new("Base-level rules cannot contain the parent-selector-referencing character '#{PARENT}'.", line)
0
       else
0
         per_rule_indent, total_indent = [:nested, :expanded].include?(@style) ? [rule_indent, ''] : ['', rule_indent]
0
- total_indent + self.rules.flatten.map do |r|
0
+ total_indent + self.rules.map do |r|
0
           per_rule_indent + r.gsub(/,$/, '').gsub(rule_split, rule_separator).rstrip
0
         end.join(line_separator)
0
       end

Comments

  • chriseppstein Mon Apr 28 12:32:04 -0700 2008

    Yes, that’s a much cleaner fix than mine. Thanks for turning it around so quickly!

  • nex3 Mon Apr 28 21:37:41 -0700 2008

    Your fix was great, given the crappy code I had collecting the multiline rules in the first place. I just wanted to do a more systemic solution. Thanks for your patch!