oga 0.3.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,8 @@ module CSS
15
15
  # Similar to {Oga::XPath::Parser} this parser only takes String instances as
16
16
  # input.
17
17
  #
18
+ # @api private
19
+ #
18
20
  class Parser < LL::Driver
19
21
  CONFIG = LL::DriverConfig.new
20
22
 
@@ -572,7 +574,7 @@ class Parser < LL::Driver
572
574
  # @return [TrueClass|FalseClass]
573
575
  #
574
576
  def int_node?(node)
575
- return node.type == :int
577
+ return node.type.equal?(:int)
576
578
  end
577
579
 
578
580
  ##
data/lib/oga/lru.rb CHANGED
@@ -21,6 +21,8 @@ module Oga
21
21
  #
22
22
  # cache.keys # => [:b, :c, :d]
23
23
  #
24
+ # @api private
25
+ #
24
26
  class LRU
25
27
  ##
26
28
  # @param [Fixnum] maximum
data/lib/oga/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oga
2
- VERSION = '0.3.4'
2
+ VERSION = '1.0.0'
3
3
  end # Oga
@@ -0,0 +1,20 @@
1
+ module Oga
2
+ ##
3
+ # @api private
4
+ #
5
+ class Whitelist < Blacklist
6
+ ##
7
+ # @return [TrueClass|FalseClass]
8
+ #
9
+ def allow?(name)
10
+ return names.include?(name)
11
+ end
12
+
13
+ ##
14
+ # @return [Oga::Blacklist]
15
+ #
16
+ def to_blacklist
17
+ return Blacklist.new(names)
18
+ end
19
+ end # Whitelist
20
+ end # Oga
@@ -83,7 +83,7 @@ module Oga
83
83
  # @return [TrueClass|FalseClass]
84
84
  #
85
85
  def html?
86
- return type == :html
86
+ return type.equal?(:html)
87
87
  end
88
88
 
89
89
  ##
@@ -320,21 +320,23 @@ module Oga
320
320
  #
321
321
  def available_namespaces
322
322
  # HTML(5) completely ignores namespaces
323
- if html?
324
- return @available_namespaces ||= {}
325
- elsif !@available_namespaces
326
- merged = namespaces.dup
327
- node = parent
328
-
329
- while node && node.respond_to?(:namespaces)
330
- node.namespaces.each do |prefix, ns|
331
- merged[prefix] = ns unless merged[prefix]
323
+ unless @available_namespaces
324
+ if html?
325
+ @available_namespaces = {}
326
+ else
327
+ merged = namespaces.dup
328
+ node = parent
329
+
330
+ while node && node.respond_to?(:namespaces)
331
+ node.namespaces.each do |prefix, ns|
332
+ merged[prefix] = ns unless merged[prefix]
333
+ end
334
+
335
+ node = node.parent
332
336
  end
333
337
 
334
- node = node.parent
338
+ @available_namespaces = merged
335
339
  end
336
-
337
- @available_namespaces = merged
338
340
  end
339
341
 
340
342
  return @available_namespaces
@@ -350,7 +352,7 @@ module Oga
350
352
  root = root_node
351
353
 
352
354
  if root.is_a?(Document) and root.html? \
353
- and !HTML_VOID_ELEMENTS.include?(name)
355
+ and !HTML_VOID_ELEMENTS.allow?(name)
354
356
  self_closing = false
355
357
  end
356
358
 
@@ -72,7 +72,7 @@ module Oga
72
72
 
73
73
  if input.include?(AMPERSAND)
74
74
  input = input.gsub(CODEPOINT_ENTITY) do |match|
75
- [$1 ? Integer($2, 16) : Integer($2)].pack('U')
75
+ [$1 ? Integer($2, 16) : Integer($2, 10)].pack('U*')
76
76
  end
77
77
  end
78
78
 
@@ -4,27 +4,12 @@ module Oga
4
4
  # Names of the HTML void elements that should be handled when HTML lexing
5
5
  # is enabled.
6
6
  #
7
- # @return [Set]
7
+ # @api private
8
+ # @return [Oga::Whitelist]
8
9
  #
9
- HTML_VOID_ELEMENTS = Set.new([
10
- 'area',
11
- 'base',
12
- 'br',
13
- 'col',
14
- 'command',
15
- 'embed',
16
- 'hr',
17
- 'img',
18
- 'input',
19
- 'keygen',
20
- 'link',
21
- 'meta',
22
- 'param',
23
- 'source',
24
- 'track',
25
- 'wbr'
26
- ])
27
-
28
- HTML_VOID_ELEMENTS.merge(HTML_VOID_ELEMENTS.map { |name| name.upcase })
10
+ HTML_VOID_ELEMENTS = Whitelist.new(%w{
11
+ area base br col command embed hr img input keygen link meta param source
12
+ track wbr
13
+ })
29
14
  end # XML
30
15
  end # Oga
data/lib/oga/xml/lexer.rb CHANGED
@@ -40,18 +40,53 @@ module Oga
40
40
  class Lexer
41
41
  attr_reader :html
42
42
 
43
- # @return [String]
44
- HTML_SCRIPT = 'script'
45
-
46
- # @return [String]
47
- HTML_STYLE = 'style'
43
+ # These are all constant/frozen to remove the need for String allocations
44
+ # every time they are referenced in the lexer.
45
+ HTML_SCRIPT = 'script'.freeze
46
+ HTML_STYLE = 'style'.freeze
47
+
48
+ # Elements that are allowed directly in a <table> element.
49
+ HTML_TABLE_ALLOWED = Whitelist.new(
50
+ %w{thead tbody tfoot tr caption colgroup col}
51
+ )
52
+
53
+ # Elements that should be closed automatically before a new opening tag is
54
+ # processed.
55
+ HTML_CLOSE_SELF = {
56
+ 'head' => Blacklist.new(%w{head body}),
57
+ 'body' => Blacklist.new(%w{head body}),
58
+ 'li' => Blacklist.new(%w{li}),
59
+ 'dt' => Blacklist.new(%w{dt dd}),
60
+ 'dd' => Blacklist.new(%w{dt dd}),
61
+ 'p' => Blacklist.new(%w{
62
+ address article aside blockquote div dl fieldset footer form h1 h2 h3
63
+ h4 h5 h6 header hgroup hr main nav ol p pre section table ul
64
+ }),
65
+ 'rb' => Blacklist.new(%w{rb rt rtc rp}),
66
+ 'rt' => Blacklist.new(%w{rb rt rtc rp}),
67
+ 'rtc' => Blacklist.new(%w{rb rtc}),
68
+ 'rp' => Blacklist.new(%w{rb rt rtc rp}),
69
+ 'optgroup' => Blacklist.new(%w{optgroup}),
70
+ 'option' => Blacklist.new(%w{optgroup option}),
71
+ 'colgroup' => Whitelist.new(%w{col template}),
72
+ 'caption' => HTML_TABLE_ALLOWED.to_blacklist,
73
+ 'table' => HTML_TABLE_ALLOWED,
74
+ 'thead' => Whitelist.new(%w{tr}),
75
+ 'tbody' => Whitelist.new(%w{tr}),
76
+ 'tfoot' => Whitelist.new(%w{tr}),
77
+ 'tr' => Whitelist.new(%w{td th}),
78
+ 'td' => Blacklist.new(%w{td th}) + HTML_TABLE_ALLOWED,
79
+ 'th' => Blacklist.new(%w{td th}) + HTML_TABLE_ALLOWED
80
+ }
81
+
82
+ HTML_CLOSE_SELF.keys.each do |key|
83
+ HTML_CLOSE_SELF[key.upcase] = HTML_CLOSE_SELF[key]
84
+ end
48
85
 
49
86
  ##
50
87
  # Names of HTML tags of which the content should be lexed as-is.
51
88
  #
52
- # @return [Array]
53
- #
54
- LITERAL_HTML_ELEMENTS = [HTML_SCRIPT, HTML_STYLE]
89
+ LITERAL_HTML_ELEMENTS = Whitelist.new([HTML_SCRIPT, HTML_STYLE])
55
90
 
56
91
  ##
57
92
  # @param [String|IO] data The data to lex. This can either be a String or
@@ -151,6 +186,11 @@ module Oga
151
186
  read_data do |chunk|
152
187
  advance_native(chunk)
153
188
  end
189
+
190
+ # Add any missing closing tags
191
+ unless @elements.empty?
192
+ @elements.length.times { on_element_end }
193
+ end
154
194
  ensure
155
195
  @block = nil
156
196
  end
@@ -332,13 +372,6 @@ module Oga
332
372
  add_token(:T_XML_DECL_END)
333
373
  end
334
374
 
335
- ##
336
- # Called on the start of an element.
337
- #
338
- def on_element_start
339
- add_token(:T_ELEM_START)
340
- end
341
-
342
375
  ##
343
376
  # Called on the start of a processing instruction.
344
377
  #
@@ -377,7 +410,40 @@ module Oga
377
410
  # @param [String] name The name of the element, including namespace.
378
411
  #
379
412
  def on_element_name(name)
380
- @elements << name if html?
413
+ before_html_element_name(name) if html?
414
+
415
+ add_element(name)
416
+ end
417
+
418
+ ##
419
+ # Handles inserting of any missing tags whenever a new HTML tag is opened.
420
+ #
421
+ # @param [String] name
422
+ #
423
+ def before_html_element_name(name)
424
+ close_current = HTML_CLOSE_SELF[current_element]
425
+
426
+ if close_current and !close_current.allow?(name)
427
+ on_element_end
428
+ end
429
+
430
+ # Close remaining parent elements. This for example ensures that a
431
+ # "<tbody>" not only closes an unclosed "<th>" but also the surrounding,
432
+ # unclosed "<tr>".
433
+ while close_current = HTML_CLOSE_SELF[current_element]
434
+ if close_current.allow?(name)
435
+ break
436
+ else
437
+ on_element_end
438
+ end
439
+ end
440
+ end
441
+
442
+ ##
443
+ # @param [String] name
444
+ #
445
+ def add_element(name)
446
+ @elements << name
381
447
 
382
448
  add_token(:T_ELEM_NAME, name)
383
449
  end
@@ -399,8 +465,8 @@ module Oga
399
465
 
400
466
  # Only downcase the name if we can't find an all lower/upper version of
401
467
  # the element name. This can save us a *lot* of String allocations.
402
- if HTML_VOID_ELEMENTS.include?(current_element) \
403
- or HTML_VOID_ELEMENTS.include?(current_element.downcase)
468
+ if HTML_VOID_ELEMENTS.allow?(current_element) \
469
+ or HTML_VOID_ELEMENTS.allow?(current_element.downcase)
404
470
  add_token(:T_ELEM_END)
405
471
  @elements.pop
406
472
  end
@@ -410,9 +476,11 @@ module Oga
410
476
  # Called on the closing tag of an element.
411
477
  #
412
478
  def on_element_end
479
+ return if @elements.empty?
480
+
413
481
  add_token(:T_ELEM_END)
414
482
 
415
- @elements.pop if html?
483
+ @elements.pop
416
484
  end
417
485
 
418
486
  ##
@@ -43,18 +43,17 @@ class Parser < LL::Driver
43
43
  :T_CDATA_START, # 13
44
44
  :T_CDATA_BODY, # 14
45
45
  :T_CDATA_END, # 15
46
- :T_ELEM_START, # 16
47
- :T_ELEM_NAME, # 17
48
- :T_ELEM_NS, # 18
49
- :T_ELEM_END, # 19
50
- :T_ATTR, # 20
51
- :T_ATTR_NS, # 21
52
- :T_XML_DECL_START, # 22
53
- :T_XML_DECL_END, # 23
54
- :T_PROC_INS_START, # 24
55
- :T_PROC_INS_NAME, # 25
56
- :T_PROC_INS_BODY, # 26
57
- :T_PROC_INS_END, # 27
46
+ :T_ELEM_NAME, # 16
47
+ :T_ELEM_NS, # 17
48
+ :T_ELEM_END, # 18
49
+ :T_ATTR, # 19
50
+ :T_ATTR_NS, # 20
51
+ :T_XML_DECL_START, # 21
52
+ :T_XML_DECL_END, # 22
53
+ :T_PROC_INS_START, # 23
54
+ :T_PROC_INS_NAME, # 24
55
+ :T_PROC_INS_BODY, # 25
56
+ :T_PROC_INS_END, # 26
58
57
  ].freeze
59
58
 
60
59
  CONFIG.rules = [
@@ -80,17 +79,17 @@ class Parser < LL::Driver
80
79
  [3, 19, 1, 12, 0, 10, 1, 10], # 19
81
80
  [3, 20, 0, 10, 1, 11], # 20
82
81
  [3, 21, 2, 0], # 21
83
- [3, 22, 1, 27, 0, 12, 1, 25, 1, 24], # 22
84
- [3, 23, 0, 12, 1, 26], # 23
82
+ [3, 22, 1, 26, 0, 12, 1, 24, 1, 23], # 22
83
+ [3, 23, 0, 12, 1, 25], # 23
85
84
  [3, 24, 2, 0], # 24
86
- [3, 25, 1, 17], # 25
87
- [3, 26, 1, 17, 1, 18], # 26
88
- [3, 27, 0, 16, 0, 13, 1, 16], # 27
89
- [3, 28, 1, 19, 0, 1, 0, 14], # 28
85
+ [3, 25, 1, 16], # 25
86
+ [3, 26, 1, 16, 1, 17], # 26
87
+ [3, 27, 0, 16, 0, 13], # 27
88
+ [3, 28, 1, 18, 0, 1, 0, 14], # 28
90
89
  [3, 29, 4, 26, 6, 0], # 29
91
- [3, 30, 8, 27, 1, 20, 1, 21], # 30
92
- [3, 31, 8, 28, 1, 20], # 31
93
- [3, 32, 1, 23, 0, 16, 1, 22], # 32
90
+ [3, 30, 8, 27, 1, 19, 1, 20], # 30
91
+ [3, 31, 8, 28, 1, 19], # 31
92
+ [3, 32, 1, 22, 0, 16, 1, 21], # 32
94
93
  [3, 33, 0, 20, 1, 1], # 33
95
94
  [3, 34, 0, 20, 1, 1], # 34
96
95
  [3, 35, 2, 0], # 35
@@ -107,35 +106,35 @@ class Parser < LL::Driver
107
106
  ].freeze
108
107
 
109
108
  CONFIG.table = [
110
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 0
111
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # 1
112
- [-1, 6, -1, -1, -1, 2, -1, -1, -1, -1, 4, -1, -1, 3, -1, -1, 7, -1, -1, -1, -1, -1, 8, -1, 5, -1, -1, -1], # 2
113
- [-1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 3
114
- [12, 12, 12, 12, 12, 12, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], # 4
115
- [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13], # 5
116
- [-1, -1, 14, 14, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 6
117
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 7
118
- [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18], # 8
119
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 9
120
- [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21], # 10
121
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1], # 11
122
- [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 24], # 12
123
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 13
124
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 14
125
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 15
126
- [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29], # 16
127
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 30, -1, -1, -1, -1, -1, -1], # 17
128
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, -1, -1, -1], # 18
129
- [-1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 19
130
- [35, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35], # 20
131
- [-1, -1, 37, 36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 21
132
- [39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39], # 22
133
- [-1, 40, -1, -1, -1, 40, -1, -1, -1, -1, 40, -1, -1, 40, -1, -1, 40, -1, -1, -1, -1, -1, 40, -1, 40, -1, -1, -1], # 23
134
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 24
135
- [-1, -1, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 25
136
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1, -1], # 26
137
- [-1, -1, 44, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 27
138
- [-1, -1, 45, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 28
109
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 0
110
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # 1
111
+ [-1, 6, -1, -1, -1, 2, -1, -1, -1, -1, 4, -1, -1, 3, -1, -1, 7, 7, -1, -1, -1, 8, -1, 5, -1, -1, -1], # 2
112
+ [-1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 3
113
+ [12, 12, 12, 12, 12, 12, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], # 4
114
+ [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13], # 5
115
+ [-1, -1, 14, 14, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 6
116
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 7
117
+ [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18], # 8
118
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 9
119
+ [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21], # 10
120
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1], # 11
121
+ [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 24], # 12
122
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 13
123
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 14
124
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 15
125
+ [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29], # 16
126
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 30, -1, -1, -1, -1, -1, -1], # 17
127
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, -1, -1, -1], # 18
128
+ [-1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 19
129
+ [35, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35], # 20
130
+ [-1, -1, 37, 36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 21
131
+ [39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39], # 22
132
+ [-1, 40, -1, -1, -1, 40, -1, -1, -1, -1, 40, -1, -1, 40, -1, -1, 40, 40, -1, -1, -1, 40, -1, 40, -1, -1, -1], # 23
133
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 24
134
+ [-1, -1, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 25
135
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1, -1], # 26
136
+ [-1, -1, 44, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 27
137
+ [-1, -1, 45, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 28
139
138
  ].freeze
140
139
 
141
140
  CONFIG.actions = [
@@ -166,7 +165,7 @@ class Parser < LL::Driver
166
165
  [:_rule_24, 0], # 24
167
166
  [:_rule_25, 1], # 25
168
167
  [:_rule_26, 2], # 26
169
- [:_rule_27, 3], # 27
168
+ [:_rule_27, 2], # 27
170
169
  [:_rule_28, 3], # 28
171
170
  [:_rule_29, 1], # 29
172
171
  [:_rule_30, 3], # 30
@@ -542,7 +541,7 @@ class Parser < LL::Driver
542
541
 
543
542
  def _rule_27(val)
544
543
 
545
- on_element(val[1][0], val[1][1], val[2])
544
+ on_element(val[0][0], val[0][1], val[1])
546
545
 
547
546
  end
548
547
 
data/lib/oga/xml/text.rb CHANGED
@@ -59,7 +59,7 @@ module Oga
59
59
  node = parent
60
60
 
61
61
  return node.is_a?(Element) && html? &&
62
- Lexer::LITERAL_HTML_ELEMENTS.include?(node.name)
62
+ Lexer::LITERAL_HTML_ELEMENTS.allow?(node.name)
63
63
  end
64
64
  end # Text
65
65
  end # XML