oga 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oga/version.rb +1 -1
- data/lib/oga/xml/lexer.rb +14 -14
- data/lib/oga/xml/sax_parser.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c097f57414df0ae5dafab755c0792c9c57c9fc8
|
4
|
+
data.tar.gz: e36bb88a9f92ccf32959f8ab31158877612af4d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3db35d326713f49c4db2142ee7c9e92ffff0c50c1053b6cca2f419261a8b4ac1342be0d0ffead460665a83260f967eba874b03dd000d88985d6e52cb7aced06
|
7
|
+
data.tar.gz: c057a3939683645551c6a51282a25345438809cf45da4c2ae5df3a936f17c538cba9d86f5588960aa63544233b414fdb355da5eb593658c0daff8e23cb282f8c
|
data/lib/oga/version.rb
CHANGED
data/lib/oga/xml/lexer.rb
CHANGED
@@ -162,6 +162,20 @@ module Oga
|
|
162
162
|
return !!html
|
163
163
|
end
|
164
164
|
|
165
|
+
##
|
166
|
+
# @return [TrueClass|FalseClass]
|
167
|
+
#
|
168
|
+
def html_script?
|
169
|
+
return html? && current_element == HTML_SCRIPT
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# @return [TrueClass|FalseClass]
|
174
|
+
#
|
175
|
+
def html_style?
|
176
|
+
return html? && current_element == HTML_STYLE
|
177
|
+
end
|
178
|
+
|
165
179
|
private
|
166
180
|
|
167
181
|
##
|
@@ -194,20 +208,6 @@ module Oga
|
|
194
208
|
return @elements.last
|
195
209
|
end
|
196
210
|
|
197
|
-
##
|
198
|
-
# @return [TrueClass|FalseClass]
|
199
|
-
#
|
200
|
-
def html_script?
|
201
|
-
return html? && current_element == HTML_SCRIPT
|
202
|
-
end
|
203
|
-
|
204
|
-
##
|
205
|
-
# @return [TrueClass|FalseClass]
|
206
|
-
#
|
207
|
-
def html_style?
|
208
|
-
return html? && current_element == HTML_STYLE
|
209
|
-
end
|
210
|
-
|
211
211
|
##
|
212
212
|
# Called when processing a single quote.
|
213
213
|
#
|
data/lib/oga/xml/sax_parser.rb
CHANGED
@@ -128,6 +128,10 @@ module Oga
|
|
128
128
|
|
129
129
|
key = ns ? "#{ns}:#{name}" : name
|
130
130
|
|
131
|
+
if value
|
132
|
+
value = EntityDecoder.try_decode(value, @lexer.html?)
|
133
|
+
end
|
134
|
+
|
131
135
|
return {key => value}
|
132
136
|
end
|
133
137
|
|
@@ -152,8 +156,30 @@ module Oga
|
|
152
156
|
return merged
|
153
157
|
end
|
154
158
|
|
159
|
+
##
|
160
|
+
# @param [String] text
|
161
|
+
#
|
162
|
+
def on_text(text)
|
163
|
+
if @handler.respond_to?(:on_text)
|
164
|
+
unless inside_literal_html?
|
165
|
+
text = EntityDecoder.try_decode(text, @lexer.html?)
|
166
|
+
end
|
167
|
+
|
168
|
+
run_callback(:on_text, text)
|
169
|
+
end
|
170
|
+
|
171
|
+
return
|
172
|
+
end
|
173
|
+
|
155
174
|
private
|
156
175
|
|
176
|
+
##
|
177
|
+
# @return [TrueClass|FalseClass]
|
178
|
+
#
|
179
|
+
def inside_literal_html?
|
180
|
+
return @lexer.html_script? || @lexer.html_style?
|
181
|
+
end
|
182
|
+
|
157
183
|
##
|
158
184
|
# @param [Symbol] method
|
159
185
|
# @param [Array] args
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|