lib/csl/parser.rb in csl-1.0.0.pre1 vs lib/csl/parser.rb in csl-1.0.0.pre2
- old
+ new
@@ -63,11 +63,12 @@
def parse_tree(node, scope = Node)
return nil if node.nil?
root = parse_node node, scope
-
+ scope = specialize_scope(root, scope)
+
node.children.each do |child|
root << parse_tree(child, scope) unless comment?(child)
end unless root.textnode?
root
@@ -84,9 +85,21 @@
def comment?(node)
node.respond_to?(:comment?) && node.comment? ||
node.respond_to?(:node_type) && [:comment, :xmldecl].include?(node.node_type)
end
-
+
+ def specialize_scope(root, scope = Node)
+ case root
+ when Style
+ Style
+ when Locale
+ Locale
+ when Info
+ Info
+ else
+ scope
+ end
+ end
end
end
\ No newline at end of file