rexle 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rexle.rb +6 -2
- metadata +1 -1
data/lib/rexle.rb
CHANGED
@@ -211,7 +211,8 @@ class Rexle
|
|
211
211
|
if match_found then
|
212
212
|
raw_attributes, value = match_found.captures
|
213
213
|
attributes = raw_attributes.scan(/(\w+\='[^']+')|(\w+\="[^"]+")/)\
|
214
|
-
.map(&:compact).inject({}) do |r, x|
|
214
|
+
.map(&:compact).flatten.inject({}) do |r, x|
|
215
|
+
|
215
216
|
attr_name, val = x.split(/=/)
|
216
217
|
r.merge(attr_name => val[1..-2])
|
217
218
|
end
|
@@ -250,7 +251,10 @@ class Rexle
|
|
250
251
|
def scan_print(nodes)
|
251
252
|
|
252
253
|
nodes.map do |x|
|
253
|
-
|
254
|
+
a = x.attributes.to_a.map{|k,v| "%s='%s'" % [k,v]}
|
255
|
+
tag = x.name + (a.empty? ? '' : ' ' + a.join(' '))
|
256
|
+
|
257
|
+
out = ["<%s>" % tag]
|
254
258
|
out << scan_print(x.children)
|
255
259
|
out << "</%s>" % x.name
|
256
260
|
end
|