nokogiri 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/CHANGELOG.ja.rdoc +28 -8
- data/CHANGELOG.rdoc +24 -1
- data/Manifest.txt +2 -1
- data/README.ja.rdoc +1 -1
- data/README.rdoc +22 -4
- data/Rakefile +6 -2
- data/ext/nokogiri/extconf.rb +55 -32
- data/ext/nokogiri/nokogiri.h +2 -0
- data/ext/nokogiri/xml_document.c +5 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_node.c +58 -12
- data/ext/nokogiri/xml_node_set.c +7 -7
- data/ext/nokogiri/xml_reader.c +20 -1
- data/ext/nokogiri/xml_xpath_context.c +2 -0
- data/lib/nokogiri/css/generated_parser.rb +155 -148
- data/lib/nokogiri/css/generated_tokenizer.rb +2 -1
- data/lib/nokogiri/css/parser.y +3 -0
- data/lib/nokogiri/css/xpath_visitor.rb +1 -7
- data/lib/nokogiri/ffi/libxml.rb +29 -4
- data/lib/nokogiri/ffi/xml/document.rb +4 -0
- data/lib/nokogiri/ffi/xml/node.rb +27 -19
- data/lib/nokogiri/ffi/xml/node_set.rb +3 -3
- data/lib/nokogiri/ffi/xml/reader.rb +4 -0
- data/lib/nokogiri/html.rb +2 -2
- data/lib/nokogiri/html/document_fragment.rb +7 -4
- data/lib/nokogiri/version.rb +2 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +1 -2
- data/lib/nokogiri/xml/document_fragment.rb +7 -0
- data/lib/nokogiri/xml/node.rb +4 -2
- data/lib/nokogiri/xml/node_set.rb +25 -0
- data/lib/nokogiri/xml/reader.rb +2 -0
- data/lib/nokogiri/xml/sax/document.rb +3 -1
- data/test/css/test_parser.rb +11 -1
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +2 -2
- data/test/html/test_document_fragment.rb +34 -6
- data/test/test_memory_leak.rb +2 -2
- data/test/test_reader.rb +28 -6
- data/test/test_xslt_transforms.rb +29 -28
- data/test/xml/test_attr.rb +31 -4
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +8 -8
- data/test/xml/test_document_fragment.rb +2 -2
- data/test/xml/test_node.rb +1 -1
- data/test/xml/test_node_reparenting.rb +26 -11
- data/test/xml/test_node_set.rb +38 -2
- data/test/xml/test_text.rb +11 -2
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +78 -11
- metadata +24 -5
- data/lib/nokogiri/version_warning.rb +0 -14
data/ext/nokogiri/xml_node_set.c
CHANGED
@@ -49,8 +49,8 @@ static VALUE push(VALUE self, VALUE rb_node)
|
|
49
49
|
xmlNodeSetPtr node_set;
|
50
50
|
xmlNodePtr node;
|
51
51
|
|
52
|
-
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
53
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
52
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
53
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
54
54
|
|
55
55
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
56
56
|
Data_Get_Struct(rb_node, xmlNode, node);
|
@@ -70,9 +70,9 @@ static VALUE delete(VALUE self, VALUE rb_node)
|
|
70
70
|
xmlNodeSetPtr node_set ;
|
71
71
|
xmlNodePtr node ;
|
72
72
|
|
73
|
-
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
74
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
75
|
-
|
73
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
74
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
75
|
+
|
76
76
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
77
77
|
Data_Get_Struct(rb_node, xmlNode, node);
|
78
78
|
|
@@ -117,8 +117,8 @@ static VALUE include_eh(VALUE self, VALUE rb_node)
|
|
117
117
|
xmlNodeSetPtr node_set;
|
118
118
|
xmlNodePtr node;
|
119
119
|
|
120
|
-
if(!rb_obj_is_kind_of(rb_node, cNokogiriXmlNode))
|
121
|
-
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
|
120
|
+
if(!(rb_obj_is_kind_of(rb_node, cNokogiriXmlNode) || rb_obj_is_kind_of(rb_node, cNokogiriXmlNamespace)))
|
121
|
+
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node or Nokogiri::XML::Namespace");
|
122
122
|
|
123
123
|
Data_Get_Struct(self, xmlNodeSet, node_set);
|
124
124
|
Data_Get_Struct(rb_node, xmlNode, node);
|
data/ext/nokogiri/xml_reader.c
CHANGED
@@ -523,7 +523,7 @@ static VALUE outer_xml(VALUE self)
|
|
523
523
|
Data_Get_Struct(self, xmlTextReader, reader);
|
524
524
|
|
525
525
|
value = xmlTextReaderReadOuterXml(reader);
|
526
|
-
|
526
|
+
|
527
527
|
if(value) {
|
528
528
|
str = NOKOGIRI_STR_NEW2((char*)value);
|
529
529
|
xmlFree(value);
|
@@ -620,6 +620,24 @@ static VALUE from_io(int argc, VALUE *argv, VALUE klass)
|
|
620
620
|
return rb_reader;
|
621
621
|
}
|
622
622
|
|
623
|
+
/*
|
624
|
+
* call-seq:
|
625
|
+
* reader.empty_element? # => true or false
|
626
|
+
*
|
627
|
+
* Returns true if the current node is empty, otherwise false.
|
628
|
+
*/
|
629
|
+
static VALUE empty_element_p(VALUE self)
|
630
|
+
{
|
631
|
+
xmlTextReaderPtr reader;
|
632
|
+
|
633
|
+
Data_Get_Struct(self, xmlTextReader, reader);
|
634
|
+
|
635
|
+
if(xmlTextReaderIsEmptyElement(reader))
|
636
|
+
return Qtrue;
|
637
|
+
|
638
|
+
return Qfalse;
|
639
|
+
}
|
640
|
+
|
623
641
|
VALUE cNokogiriXmlReader;
|
624
642
|
|
625
643
|
void init_xml_reader()
|
@@ -656,6 +674,7 @@ void init_xml_reader()
|
|
656
674
|
rb_define_method(klass, "attribute", reader_attribute, 1);
|
657
675
|
rb_define_method(klass, "namespaces", namespaces, 0);
|
658
676
|
rb_define_method(klass, "attribute_at", attribute_at, 1);
|
677
|
+
rb_define_method(klass, "empty_element?", empty_element_p, 0);
|
659
678
|
rb_define_method(klass, "attributes?", attributes_eh, 0);
|
660
679
|
rb_define_method(klass, "value?", value_eh, 0);
|
661
680
|
rb_define_method(klass, "default?", default_eh, 0);
|
@@ -13,90 +13,90 @@ module Nokogiri
|
|
13
13
|
##### State transition tables begin ###
|
14
14
|
|
15
15
|
racc_action_table = [
|
16
|
-
|
17
|
-
41, 12,
|
18
|
-
|
19
|
-
12, 9, 10,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
4, 56, 27, 22, 12, 24, 57, 4, 65, 1,
|
17
|
+
41, 12, 75, 57, 4, 23, 1, 82, 12, 19,
|
18
|
+
93, 92, 5, 1, 9, 10, 19, 13, 16, 5,
|
19
|
+
12, 9, 10, 19, 13, 16, 5, 5, 9, 10,
|
20
|
+
4, 13, 16, 16, 12, 41, 64, 4, 5, 1,
|
21
|
+
60, 10, 12, 59, 16, 59, 28, 1, 29, 19,
|
22
|
+
12, 12, 5, 62, 9, 10, 19, 13, 16, 12,
|
23
|
+
5, 9, 83, 10, 12, 13, 16, 84, 5, 5,
|
24
|
+
63, 10, 10, 12, 16, 16, 58, 5, 61, 62,
|
25
|
+
10, 4, 5, 16, 87, 10, 27, 53, 16, 54,
|
26
|
+
49, 5, 88, 41, 10, 68, 70, 16, 27, 53,
|
27
|
+
19, 54, 44, 91, 21, 9, 69, 71, 72, 94,
|
28
|
+
74, 68, 70, -23, 66, 33, 35, 37, 27, 53,
|
29
|
+
96, 54, 69, 71, 72, 32, 74, 34, 36, 97,
|
30
|
+
66, 27, 53, nil, 54 ]
|
31
31
|
|
32
32
|
racc_action_check = [
|
33
|
-
0, 20,
|
34
|
-
39,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
41,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
0, 20, 4, 4, 0, 4, 43, 9, 27, 0,
|
34
|
+
39, 9, 29, 20, 31, 4, 9, 43, 31, 0,
|
35
|
+
73, 73, 0, 31, 0, 0, 9, 0, 0, 9,
|
36
|
+
7, 9, 9, 31, 9, 9, 31, 14, 31, 31,
|
37
|
+
57, 31, 31, 14, 57, 7, 26, 5, 7, 57,
|
38
|
+
22, 7, 41, 53, 7, 22, 5, 41, 5, 57,
|
39
|
+
8, 79, 57, 54, 57, 57, 5, 57, 57, 18,
|
40
|
+
41, 5, 55, 41, 17, 41, 41, 56, 8, 79,
|
41
|
+
25, 8, 79, 15, 8, 79, 21, 18, 24, 24,
|
42
|
+
18, 16, 17, 18, 60, 17, 59, 59, 17, 59,
|
43
|
+
16, 15, 61, 11, 15, 30, 30, 15, 19, 19,
|
44
|
+
16, 19, 10, 67, 2, 16, 30, 30, 30, 76,
|
45
|
+
30, 28, 28, 1, 30, 6, 6, 6, 62, 62,
|
46
|
+
81, 62, 28, 28, 28, 6, 28, 6, 6, 88,
|
47
|
+
28, 65, 65, nil, 65 ]
|
48
48
|
|
49
49
|
racc_action_pointer = [
|
50
|
-
-2,
|
51
|
-
|
52
|
-
1,
|
53
|
-
|
50
|
+
-2, 95, 86, nil, -8, 45, 118, 24, 54, 5,
|
51
|
+
101, 82, nil, nil, 13, 77, 89, 68, 63, 98,
|
52
|
+
1, 75, 43, nil, 77, 57, 23, -4, 118, -13,
|
53
|
+
102, 12, nil, nil, nil, nil, nil, nil, nil, -11,
|
54
54
|
nil, 46, nil, -6, nil, nil, nil, nil, nil, nil,
|
55
|
-
nil,
|
56
|
-
|
57
|
-
nil,
|
58
|
-
nil, nil, nil, nil, nil, nil, nil, 126, nil,
|
59
|
-
nil, nil, nil, nil, nil, nil, nil ]
|
55
|
+
nil, nil, nil, 41, 51, 49, 77, 38, nil, 86,
|
56
|
+
81, 95, 118, nil, nil, 131, nil, 88, nil, nil,
|
57
|
+
nil, nil, nil, 10, nil, nil, 94, nil, nil, 55,
|
58
|
+
nil, 107, nil, nil, nil, nil, nil, nil, 126, nil,
|
59
|
+
nil, nil, nil, nil, nil, nil, nil, nil ]
|
60
60
|
|
61
61
|
racc_action_default = [
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-11, -
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
62
|
+
-24, -21, -69, -2, -69, -69, -18, -45, -50, -24,
|
63
|
+
-69, -16, -54, -22, -12, -53, -69, -52, -51, -69,
|
64
|
+
-69, -69, -38, -28, -36, -69, -69, -37, -57, -69,
|
65
|
+
-57, -24, -5, -3, -8, -4, -7, -6, -9, -44,
|
66
|
+
-11, -24, -46, -69, -19, -15, -13, -14, -49, -43,
|
67
|
+
-42, -48, -47, -38, -36, -69, -69, -24, -20, -69,
|
68
|
+
-69, -41, -69, -29, -30, -69, -58, -69, -63, -59,
|
69
|
+
-64, -60, -61, -69, -62, -27, -69, -17, -10, -66,
|
70
|
+
-68, -69, -32, -31, 98, -1, -35, -40, -69, -33,
|
71
|
+
-34, -25, -55, -56, -26, -67, -65, -39 ]
|
72
72
|
|
73
73
|
racc_goto_table = [
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
39, 42, 25, 40, 77, 30, 20, 45, 48, 79,
|
75
|
+
51, 52, 67, 46, 76, 43, 50, 55, 47, 38,
|
76
|
+
31, 26, 81, nil, nil, nil, nil, nil, nil, nil,
|
77
|
+
85, nil, nil, nil, 80, 78, nil, nil, nil, nil,
|
78
78
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
79
|
-
nil, nil, nil, nil, nil, nil, nil,
|
80
|
-
nil,
|
81
|
-
nil,
|
79
|
+
nil, nil, nil, nil, nil, nil, nil, 86, nil, nil,
|
80
|
+
89, nil, nil, 90, nil, nil, nil, nil, nil, nil,
|
81
|
+
nil, nil, 95 ]
|
82
82
|
|
83
83
|
racc_goto_check = [
|
84
|
-
7, 7,
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
7, 7, 15, 8, 2, 9, 1, 8, 7, 5,
|
85
|
+
7, 7, 14, 10, 14, 1, 9, 15, 11, 6,
|
86
|
+
3, 16, 19, nil, nil, nil, nil, nil, nil, nil,
|
87
|
+
2, nil, nil, nil, 7, 8, nil, nil, nil, nil,
|
88
88
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
89
|
-
nil, nil, nil, nil, nil, nil, nil,
|
90
|
-
nil,
|
91
|
-
nil, 7 ]
|
89
|
+
nil, nil, nil, nil, nil, nil, nil, 15, nil, nil,
|
90
|
+
15, nil, nil, 15, nil, nil, nil, nil, nil, nil,
|
91
|
+
nil, nil, 7 ]
|
92
92
|
|
93
93
|
racc_goto_pointer = [
|
94
|
-
nil, 6, -
|
95
|
-
|
94
|
+
nil, 6, -27, 14, nil, -32, 12, -7, -4, 0,
|
95
|
+
-1, 4, nil, nil, -16, -2, 17, nil, nil, -19 ]
|
96
96
|
|
97
97
|
racc_goto_default = [
|
98
|
-
nil, nil,
|
99
|
-
15, 17,
|
98
|
+
nil, nil, 3, nil, 6, 7, nil, 11, nil, 14,
|
99
|
+
15, 17, 18, 2, nil, nil, nil, 8, 73, nil ]
|
100
100
|
|
101
101
|
racc_reduce_table = [
|
102
102
|
0, 0, :racc_error,
|
@@ -114,63 +114,64 @@ racc_reduce_table = [
|
|
114
114
|
1, 35, :_reduce_none,
|
115
115
|
2, 35, :_reduce_13,
|
116
116
|
2, 35, :_reduce_14,
|
117
|
-
|
118
|
-
|
117
|
+
2, 35, :_reduce_15,
|
118
|
+
1, 35, :_reduce_16,
|
119
|
+
3, 33, :_reduce_17,
|
119
120
|
1, 33, :_reduce_none,
|
120
|
-
2,
|
121
|
-
3, 36, :
|
122
|
-
1, 36, :_reduce_20,
|
121
|
+
2, 43, :_reduce_19,
|
122
|
+
3, 36, :_reduce_20,
|
123
123
|
1, 36, :_reduce_21,
|
124
|
-
1,
|
125
|
-
|
126
|
-
|
127
|
-
4,
|
128
|
-
|
129
|
-
|
130
|
-
|
124
|
+
1, 36, :_reduce_22,
|
125
|
+
1, 44, :_reduce_23,
|
126
|
+
0, 44, :_reduce_none,
|
127
|
+
4, 42, :_reduce_25,
|
128
|
+
4, 42, :_reduce_26,
|
129
|
+
3, 42, :_reduce_27,
|
130
|
+
2, 40, :_reduce_28,
|
131
131
|
3, 40, :_reduce_29,
|
132
132
|
3, 40, :_reduce_30,
|
133
133
|
3, 40, :_reduce_31,
|
134
|
-
3,
|
135
|
-
3,
|
136
|
-
3,
|
137
|
-
|
138
|
-
1,
|
139
|
-
1,
|
140
|
-
|
141
|
-
|
142
|
-
|
134
|
+
3, 40, :_reduce_32,
|
135
|
+
3, 46, :_reduce_33,
|
136
|
+
3, 46, :_reduce_34,
|
137
|
+
3, 46, :_reduce_35,
|
138
|
+
1, 46, :_reduce_none,
|
139
|
+
1, 46, :_reduce_none,
|
140
|
+
1, 46, :_reduce_38,
|
141
|
+
4, 47, :_reduce_39,
|
142
|
+
3, 47, :_reduce_40,
|
143
143
|
2, 47, :_reduce_41,
|
144
|
-
2,
|
144
|
+
2, 41, :_reduce_42,
|
145
|
+
2, 41, :_reduce_43,
|
145
146
|
1, 37, :_reduce_none,
|
146
147
|
0, 37, :_reduce_none,
|
147
|
-
2, 38, :_reduce_45,
|
148
148
|
2, 38, :_reduce_46,
|
149
149
|
2, 38, :_reduce_47,
|
150
150
|
2, 38, :_reduce_48,
|
151
|
+
2, 38, :_reduce_49,
|
151
152
|
1, 38, :_reduce_none,
|
152
153
|
1, 38, :_reduce_none,
|
153
154
|
1, 38, :_reduce_none,
|
154
155
|
1, 38, :_reduce_none,
|
155
|
-
1, 48, :
|
156
|
-
2,
|
157
|
-
2,
|
158
|
-
0,
|
159
|
-
1, 49, :_reduce_57,
|
156
|
+
1, 48, :_reduce_54,
|
157
|
+
2, 45, :_reduce_55,
|
158
|
+
2, 45, :_reduce_56,
|
159
|
+
0, 45, :_reduce_none,
|
160
160
|
1, 49, :_reduce_58,
|
161
161
|
1, 49, :_reduce_59,
|
162
162
|
1, 49, :_reduce_60,
|
163
163
|
1, 49, :_reduce_61,
|
164
164
|
1, 49, :_reduce_62,
|
165
165
|
1, 49, :_reduce_63,
|
166
|
-
|
166
|
+
1, 49, :_reduce_64,
|
167
|
+
3, 39, :_reduce_65,
|
167
168
|
1, 50, :_reduce_none,
|
168
169
|
2, 50, :_reduce_none,
|
169
170
|
1, 50, :_reduce_none ]
|
170
171
|
|
171
|
-
racc_reduce_n =
|
172
|
+
racc_reduce_n = 69
|
172
173
|
|
173
|
-
racc_shift_n =
|
174
|
+
racc_shift_n = 98
|
174
175
|
|
175
176
|
racc_token_table = {
|
176
177
|
false => 0,
|
@@ -267,13 +268,13 @@ Racc_token_to_s_table = [
|
|
267
268
|
"hcap_1toN",
|
268
269
|
"negation",
|
269
270
|
"function",
|
271
|
+
"pseudo",
|
270
272
|
"attrib",
|
271
273
|
"class",
|
272
274
|
"namespace",
|
273
275
|
"attrib_val_0or1",
|
274
276
|
"expr",
|
275
277
|
"an_plus_b",
|
276
|
-
"pseudo",
|
277
278
|
"attribute_id",
|
278
279
|
"eql_incl_dash",
|
279
280
|
"negation_arg" ]
|
@@ -361,6 +362,12 @@ def _reduce_13(val, _values, result)
|
|
361
362
|
end
|
362
363
|
|
363
364
|
def _reduce_14(val, _values, result)
|
365
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
366
|
+
|
367
|
+
result
|
368
|
+
end
|
369
|
+
|
370
|
+
def _reduce_15(val, _values, result)
|
364
371
|
result = Node.new(:CONDITIONAL_SELECTOR,
|
365
372
|
[
|
366
373
|
Node.new(:ELEMENT_NAME, ['*']),
|
@@ -371,7 +378,7 @@ def _reduce_14(val, _values, result)
|
|
371
378
|
result
|
372
379
|
end
|
373
380
|
|
374
|
-
def
|
381
|
+
def _reduce_16(val, _values, result)
|
375
382
|
result = Node.new(:CONDITIONAL_SELECTOR,
|
376
383
|
[Node.new(:ELEMENT_NAME, ['*']), val.first]
|
377
384
|
)
|
@@ -379,20 +386,20 @@ def _reduce_15(val, _values, result)
|
|
379
386
|
result
|
380
387
|
end
|
381
388
|
|
382
|
-
def
|
389
|
+
def _reduce_17(val, _values, result)
|
383
390
|
result = Node.new(val[1], [val.first, val.last])
|
384
391
|
|
385
392
|
result
|
386
393
|
end
|
387
394
|
|
388
|
-
# reduce
|
395
|
+
# reduce 18 omitted
|
389
396
|
|
390
|
-
def
|
397
|
+
def _reduce_19(val, _values, result)
|
391
398
|
result = Node.new(:CLASS_CONDITION, [val[1]])
|
392
399
|
result
|
393
400
|
end
|
394
401
|
|
395
|
-
def
|
402
|
+
def _reduce_20(val, _values, result)
|
396
403
|
result = Node.new(:ELEMENT_NAME,
|
397
404
|
[[val.first, val.last].compact.join(':')]
|
398
405
|
)
|
@@ -400,26 +407,26 @@ def _reduce_19(val, _values, result)
|
|
400
407
|
result
|
401
408
|
end
|
402
409
|
|
403
|
-
def
|
410
|
+
def _reduce_21(val, _values, result)
|
404
411
|
name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
|
405
412
|
result = Node.new(:ELEMENT_NAME, [name])
|
406
413
|
|
407
414
|
result
|
408
415
|
end
|
409
416
|
|
410
|
-
def
|
417
|
+
def _reduce_22(val, _values, result)
|
411
418
|
result = Node.new(:ELEMENT_NAME, val)
|
412
419
|
result
|
413
420
|
end
|
414
421
|
|
415
|
-
def
|
422
|
+
def _reduce_23(val, _values, result)
|
416
423
|
result = val[0]
|
417
424
|
result
|
418
425
|
end
|
419
426
|
|
420
|
-
# reduce
|
427
|
+
# reduce 24 omitted
|
421
428
|
|
422
|
-
def
|
429
|
+
def _reduce_25(val, _values, result)
|
423
430
|
result = Node.new(:ATTRIBUTE_CONDITION,
|
424
431
|
[Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || [])
|
425
432
|
)
|
@@ -427,7 +434,7 @@ def _reduce_24(val, _values, result)
|
|
427
434
|
result
|
428
435
|
end
|
429
436
|
|
430
|
-
def
|
437
|
+
def _reduce_26(val, _values, result)
|
431
438
|
result = Node.new(:ATTRIBUTE_CONDITION,
|
432
439
|
[val[1]] + (val[2] || [])
|
433
440
|
)
|
@@ -435,7 +442,7 @@ def _reduce_25(val, _values, result)
|
|
435
442
|
result
|
436
443
|
end
|
437
444
|
|
438
|
-
def
|
445
|
+
def _reduce_27(val, _values, result)
|
439
446
|
# Non standard, but hpricot supports it.
|
440
447
|
result = Node.new(:PSEUDO_CLASS,
|
441
448
|
[Node.new(:FUNCTION, ['nth-child(', val[1]])]
|
@@ -444,14 +451,8 @@ def _reduce_26(val, _values, result)
|
|
444
451
|
result
|
445
452
|
end
|
446
453
|
|
447
|
-
def _reduce_27(val, _values, result)
|
448
|
-
result = Node.new(:FUNCTION, [val.first.strip])
|
449
|
-
|
450
|
-
result
|
451
|
-
end
|
452
|
-
|
453
454
|
def _reduce_28(val, _values, result)
|
454
|
-
result = Node.new(:FUNCTION, [val.first.strip
|
455
|
+
result = Node.new(:FUNCTION, [val.first.strip])
|
455
456
|
|
456
457
|
result
|
457
458
|
end
|
@@ -475,7 +476,8 @@ def _reduce_31(val, _values, result)
|
|
475
476
|
end
|
476
477
|
|
477
478
|
def _reduce_32(val, _values, result)
|
478
|
-
|
479
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
480
|
+
|
479
481
|
result
|
480
482
|
end
|
481
483
|
|
@@ -489,11 +491,16 @@ def _reduce_34(val, _values, result)
|
|
489
491
|
result
|
490
492
|
end
|
491
493
|
|
492
|
-
|
494
|
+
def _reduce_35(val, _values, result)
|
495
|
+
result = [val.first, val.last]
|
496
|
+
result
|
497
|
+
end
|
493
498
|
|
494
499
|
# reduce 36 omitted
|
495
500
|
|
496
|
-
|
501
|
+
# reduce 37 omitted
|
502
|
+
|
503
|
+
def _reduce_38(val, _values, result)
|
497
504
|
if val[0] == 'even'
|
498
505
|
val = ["2","n","+","0"]
|
499
506
|
result = Node.new(:AN_PLUS_B, val)
|
@@ -511,7 +518,7 @@ def _reduce_37(val, _values, result)
|
|
511
518
|
result
|
512
519
|
end
|
513
520
|
|
514
|
-
def
|
521
|
+
def _reduce_39(val, _values, result)
|
515
522
|
if val[1] == 'n'
|
516
523
|
result = Node.new(:AN_PLUS_B, val)
|
517
524
|
else
|
@@ -521,7 +528,7 @@ def _reduce_38(val, _values, result)
|
|
521
528
|
result
|
522
529
|
end
|
523
530
|
|
524
|
-
def
|
531
|
+
def _reduce_40(val, _values, result)
|
525
532
|
# n+3, -n+3
|
526
533
|
if val[0] == 'n'
|
527
534
|
val.unshift("1")
|
@@ -537,7 +544,7 @@ def _reduce_39(val, _values, result)
|
|
537
544
|
result
|
538
545
|
end
|
539
546
|
|
540
|
-
def
|
547
|
+
def _reduce_41(val, _values, result)
|
541
548
|
if val[1] == 'n'
|
542
549
|
val << "+"
|
543
550
|
val << "0"
|
@@ -549,26 +556,20 @@ def _reduce_40(val, _values, result)
|
|
549
556
|
result
|
550
557
|
end
|
551
558
|
|
552
|
-
def
|
559
|
+
def _reduce_42(val, _values, result)
|
553
560
|
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
554
561
|
|
555
562
|
result
|
556
563
|
end
|
557
564
|
|
558
|
-
def
|
565
|
+
def _reduce_43(val, _values, result)
|
559
566
|
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
560
567
|
result
|
561
568
|
end
|
562
569
|
|
563
|
-
# reduce 43 omitted
|
564
|
-
|
565
570
|
# reduce 44 omitted
|
566
571
|
|
567
|
-
|
568
|
-
result = Node.new(:COMBINATOR, val)
|
569
|
-
|
570
|
-
result
|
571
|
-
end
|
572
|
+
# reduce 45 omitted
|
572
573
|
|
573
574
|
def _reduce_46(val, _values, result)
|
574
575
|
result = Node.new(:COMBINATOR, val)
|
@@ -588,7 +589,11 @@ def _reduce_48(val, _values, result)
|
|
588
589
|
result
|
589
590
|
end
|
590
591
|
|
591
|
-
|
592
|
+
def _reduce_49(val, _values, result)
|
593
|
+
result = Node.new(:COMBINATOR, val)
|
594
|
+
|
595
|
+
result
|
596
|
+
end
|
592
597
|
|
593
598
|
# reduce 50 omitted
|
594
599
|
|
@@ -596,70 +601,72 @@ end
|
|
596
601
|
|
597
602
|
# reduce 52 omitted
|
598
603
|
|
599
|
-
|
604
|
+
# reduce 53 omitted
|
605
|
+
|
606
|
+
def _reduce_54(val, _values, result)
|
600
607
|
result = Node.new(:ID, val)
|
601
608
|
result
|
602
609
|
end
|
603
610
|
|
604
|
-
def
|
611
|
+
def _reduce_55(val, _values, result)
|
605
612
|
result = [val.first, val[1]]
|
606
613
|
result
|
607
614
|
end
|
608
615
|
|
609
|
-
def
|
616
|
+
def _reduce_56(val, _values, result)
|
610
617
|
result = [val.first, val[1]]
|
611
618
|
result
|
612
619
|
end
|
613
620
|
|
614
|
-
# reduce
|
621
|
+
# reduce 57 omitted
|
615
622
|
|
616
|
-
def
|
623
|
+
def _reduce_58(val, _values, result)
|
617
624
|
result = :equal
|
618
625
|
result
|
619
626
|
end
|
620
627
|
|
621
|
-
def
|
628
|
+
def _reduce_59(val, _values, result)
|
622
629
|
result = :prefix_match
|
623
630
|
result
|
624
631
|
end
|
625
632
|
|
626
|
-
def
|
633
|
+
def _reduce_60(val, _values, result)
|
627
634
|
result = :suffix_match
|
628
635
|
result
|
629
636
|
end
|
630
637
|
|
631
|
-
def
|
638
|
+
def _reduce_61(val, _values, result)
|
632
639
|
result = :substring_match
|
633
640
|
result
|
634
641
|
end
|
635
642
|
|
636
|
-
def
|
643
|
+
def _reduce_62(val, _values, result)
|
637
644
|
result = :not_equal
|
638
645
|
result
|
639
646
|
end
|
640
647
|
|
641
|
-
def
|
648
|
+
def _reduce_63(val, _values, result)
|
642
649
|
result = :includes
|
643
650
|
result
|
644
651
|
end
|
645
652
|
|
646
|
-
def
|
653
|
+
def _reduce_64(val, _values, result)
|
647
654
|
result = :dash_match
|
648
655
|
result
|
649
656
|
end
|
650
657
|
|
651
|
-
def
|
658
|
+
def _reduce_65(val, _values, result)
|
652
659
|
result = Node.new(:NOT, [val[1]])
|
653
660
|
|
654
661
|
result
|
655
662
|
end
|
656
663
|
|
657
|
-
# reduce 65 omitted
|
658
|
-
|
659
664
|
# reduce 66 omitted
|
660
665
|
|
661
666
|
# reduce 67 omitted
|
662
667
|
|
668
|
+
# reduce 68 omitted
|
669
|
+
|
663
670
|
def _reduce_none(val, _values, result)
|
664
671
|
val[0]
|
665
672
|
end
|