rexleparser 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rexleparser.rb +21 -9
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 184b302c376712daab6a0df650cfe03ac5a40c4d
|
4
|
+
data.tar.gz: 691646e7927e878c6341febc8c18406093654fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811abaa767db4514dc6ba1da8a5dd4420d1fbbef17ee2bfa6c0842c2152a13f9a7fa090d8189403a32585923ae800bad6d43985df1c6a55e1d7d120abcb9df6e
|
7
|
+
data.tar.gz: caa1b074ec6de75c8ad087808c830889e149a4e543398a2cedcf9d0c2f4d92d276291d86b503b774550db65f53335f43bdec1263298e49aaec724af54e74c3e6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rexleparser.rb
CHANGED
@@ -14,8 +14,8 @@ class RexleParser
|
|
14
14
|
@instructions = s.scan(/<\?([\w-]+) ([^>]+)\?>/)
|
15
15
|
@doctype = s.slice!(/<!DOCTYPE html>\n?/)
|
16
16
|
|
17
|
-
s2 = s.gsub('<![CDATA[','
|
18
|
-
@to_a = reverse(
|
17
|
+
s2 = s.gsub('<![CDATA[','<!--').gsub(']]>','-->')
|
18
|
+
@to_a = reverse(parse_node(s2.strip.gsub(/<\?[^>]+>/,'').reverse))
|
19
19
|
|
20
20
|
end
|
21
21
|
|
@@ -24,7 +24,7 @@ class RexleParser
|
|
24
24
|
|
25
25
|
|
26
26
|
def scan_next(r, tagname)
|
27
|
-
|
27
|
+
|
28
28
|
j = tagname
|
29
29
|
|
30
30
|
if (r =~ /^>/) == 0 then
|
@@ -48,6 +48,11 @@ class RexleParser
|
|
48
48
|
# broken tag found
|
49
49
|
broken_tag = tag
|
50
50
|
return [:child, [nil, [], broken_tag]] if broken_tag
|
51
|
+
|
52
|
+
elsif tag[/^>--(.*)--!</] then
|
53
|
+
|
54
|
+
# it's a comment tag
|
55
|
+
return [:child, $1]
|
51
56
|
else
|
52
57
|
|
53
58
|
text, tag = tag.sub('>',';tg&').split(/>/,2)
|
@@ -70,14 +75,17 @@ class RexleParser
|
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
73
|
-
def
|
78
|
+
def parse_node(r, j=nil)
|
79
|
+
|
80
|
+
return unless r.length > 0
|
74
81
|
|
75
82
|
tag = r.slice!(/^>[^<]+</) if (r =~ /^>[^<]+</) == 0
|
76
|
-
|
77
|
-
if tag[0,3] == '>--' then
|
83
|
+
|
84
|
+
if tag and tag[0,3] == '>--' then
|
78
85
|
|
79
86
|
i = r =~ /<--/
|
80
87
|
tag += r.slice!(0,i+5)
|
88
|
+
|
81
89
|
# it's a comment tag
|
82
90
|
tagname = '-!'
|
83
91
|
return [">#{tagname}<", [tag[/>--(.*)--!</,1]], ">#{tagname}/<"]
|
@@ -95,15 +103,18 @@ class RexleParser
|
|
95
103
|
until end_tag do
|
96
104
|
|
97
105
|
key, res = scan_next r, tagname
|
98
|
-
|
106
|
+
|
99
107
|
case key
|
100
108
|
when :end_tag
|
101
109
|
end_tag = res
|
102
|
-
|
110
|
+
r2 = [start_tag, children, end_tag]
|
111
|
+
end_tag = nil
|
112
|
+
|
113
|
+
return r2
|
103
114
|
when :child
|
104
115
|
children << res
|
105
116
|
when :newnode
|
106
|
-
children <<
|
117
|
+
children << parse_node(r, tagname)
|
107
118
|
end
|
108
119
|
end
|
109
120
|
|
@@ -127,6 +138,7 @@ class RexleParser
|
|
127
138
|
|
128
139
|
def reverse(raw_obj)
|
129
140
|
|
141
|
+
return unless raw_obj
|
130
142
|
obj = raw_obj.clone
|
131
143
|
return obj.reverse! if obj.is_a? String
|
132
144
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|