meteor 0.9.31 → 0.9.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/demo/xhtml.rb +3 -3
- data/demo/xhtml4.rb +3 -3
- data/lib/meteor/attribute_map.rb +6 -6
- data/lib/meteor/core/kernel.rb +150 -150
- data/lib/meteor/core/util/pattern_cache.rb +6 -6
- data/lib/meteor/element.rb +10 -10
- data/lib/meteor/exception/no_such_element_exception.rb +15 -15
- data/lib/meteor/ml/html/parser_impl.rb +14 -14
- data/lib/meteor/ml/html4/parser_impl.rb +49 -49
- data/lib/meteor/ml/xhtml/parser_impl.rb +14 -14
- data/lib/meteor/ml/xhtml4/parser_impl.rb +15 -15
- data/lib/meteor/ml/xml/parser_impl.rb +6 -6
- data/lib/meteor/parsers.rb +43 -43
- data/lib/meteor.rb +2 -2
- metadata +1 -1
data/lib/meteor/core/kernel.rb
CHANGED
|
@@ -225,16 +225,16 @@ module Meteor
|
|
|
225
225
|
if !attrs
|
|
226
226
|
case elm
|
|
227
227
|
when String, Symbol
|
|
228
|
-
|
|
228
|
+
element_one(elm.to_s)
|
|
229
229
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
230
230
|
when Meteor::Element
|
|
231
231
|
shadow(elm)
|
|
232
232
|
when Hash
|
|
233
233
|
if elm.size == ONE
|
|
234
|
-
|
|
234
|
+
element_two(elm.keys[0].to_s, elm.values[0])
|
|
235
235
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
236
236
|
elsif elm.size == TWO
|
|
237
|
-
|
|
237
|
+
element_four(elm.keys[0].to_s, elm.values[0], elm.keys[1].to_s, elm.values[1])
|
|
238
238
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
239
239
|
else
|
|
240
240
|
raise ArgumentError
|
|
@@ -244,10 +244,10 @@ module Meteor
|
|
|
244
244
|
end
|
|
245
245
|
elsif attrs.is_a?(Hash)
|
|
246
246
|
if attrs.size == ONE
|
|
247
|
-
|
|
247
|
+
element_three(elm.to_s, attrs.keys[0].to_s, attrs.values[0])
|
|
248
248
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
249
249
|
elsif attrs.size == TWO
|
|
250
|
-
|
|
250
|
+
element_five(elm.to_s, attrs.keys[0].to_s, attrs.values[0], attrs.keys[1].to_s, attrs.values[1])
|
|
251
251
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
252
252
|
else
|
|
253
253
|
@elm_ = nil
|
|
@@ -256,17 +256,17 @@ module Meteor
|
|
|
256
256
|
elsif attrs.is_a?(String) || attrs.is_a?(Symbol)
|
|
257
257
|
case args.length
|
|
258
258
|
when ZERO
|
|
259
|
-
|
|
259
|
+
element_two(elm.to_s, attrs.to_s)
|
|
260
260
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
261
261
|
|
|
262
262
|
when ONE
|
|
263
|
-
|
|
263
|
+
element_three(elm.to_s, attrs.to_s, args[0])
|
|
264
264
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
265
265
|
when TWO
|
|
266
|
-
|
|
266
|
+
element_four(elm.to_s, attrs.to_s, args[0].to_s, args[1])
|
|
267
267
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
268
268
|
when THREE
|
|
269
|
-
|
|
269
|
+
element_five(elm.to_s, attrs.to_s, args[0], args[1].to_s, args[2])
|
|
270
270
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
271
271
|
else
|
|
272
272
|
@elm_ = nil
|
|
@@ -283,7 +283,7 @@ module Meteor
|
|
|
283
283
|
# @param [String,Symbol] name tag name (タグ名)
|
|
284
284
|
# @return [Meteor::Element] element(要素)
|
|
285
285
|
#
|
|
286
|
-
def
|
|
286
|
+
def element_one(name)
|
|
287
287
|
quote_name(name)
|
|
288
288
|
|
|
289
289
|
# element search pattern (要素検索用パターン)
|
|
@@ -295,10 +295,10 @@ module Meteor
|
|
|
295
295
|
|
|
296
296
|
if @res
|
|
297
297
|
if @res[1]
|
|
298
|
-
|
|
298
|
+
element_void_one(name)
|
|
299
299
|
else
|
|
300
300
|
# puts '---element_normal_1'
|
|
301
|
-
|
|
301
|
+
element_normal_one(name)
|
|
302
302
|
end
|
|
303
303
|
# else
|
|
304
304
|
end
|
|
@@ -306,9 +306,9 @@ module Meteor
|
|
|
306
306
|
@elm_
|
|
307
307
|
end
|
|
308
308
|
|
|
309
|
-
private :
|
|
309
|
+
private :element_one
|
|
310
310
|
|
|
311
|
-
def
|
|
311
|
+
def element_normal_one(name)
|
|
312
312
|
@elm_ = Meteor::Element.new(name)
|
|
313
313
|
|
|
314
314
|
if @on_search
|
|
@@ -340,9 +340,9 @@ module Meteor
|
|
|
340
340
|
@elm_
|
|
341
341
|
end
|
|
342
342
|
|
|
343
|
-
private :
|
|
343
|
+
private :element_normal_one
|
|
344
344
|
|
|
345
|
-
def
|
|
345
|
+
def element_void_one(name)
|
|
346
346
|
# element (要素)
|
|
347
347
|
@elm_ = Meteor::Element.new(name)
|
|
348
348
|
# attribute (属性)
|
|
@@ -361,7 +361,7 @@ module Meteor
|
|
|
361
361
|
@elm_
|
|
362
362
|
end
|
|
363
363
|
|
|
364
|
-
private :
|
|
364
|
+
private :element_void_one
|
|
365
365
|
|
|
366
366
|
#
|
|
367
367
|
# get element using tag name and attribute(name="value") (要素のタグ名と属性(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -370,20 +370,20 @@ module Meteor
|
|
|
370
370
|
# @param [String] attr_value attribute value (属性値)
|
|
371
371
|
# @param [true,false] quote flag (クオート・フラグ)
|
|
372
372
|
# @return [Meteor::Element] element (要素)
|
|
373
|
-
def
|
|
373
|
+
def element_three(name, attr_name, attr_value, quote = true)
|
|
374
374
|
if quote
|
|
375
|
-
|
|
375
|
+
quote_element_three(name, attr_name, attr_value)
|
|
376
376
|
else
|
|
377
377
|
quote_name(name)
|
|
378
378
|
end
|
|
379
379
|
|
|
380
|
-
@pattern_cc_1 =
|
|
380
|
+
@pattern_cc_1 = element_pattern_three
|
|
381
381
|
|
|
382
382
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
|
383
383
|
@res1 = @pattern.match(@root.document)
|
|
384
384
|
|
|
385
385
|
if @res1 && @res1[1] || !@res1
|
|
386
|
-
@res2 =
|
|
386
|
+
@res2 = element_normal_three_two
|
|
387
387
|
@pattern_cc_2 = @pattern_cc
|
|
388
388
|
|
|
389
389
|
# puts @res2.captures.length
|
|
@@ -395,27 +395,27 @@ module Meteor
|
|
|
395
395
|
@res = @res1
|
|
396
396
|
# @pattern_cc = @pattern_cc_1
|
|
397
397
|
if @res[1]
|
|
398
|
-
|
|
398
|
+
element_void_three(name)
|
|
399
399
|
else
|
|
400
|
-
|
|
400
|
+
element_normal_three_one(name)
|
|
401
401
|
end
|
|
402
402
|
elsif @res1.begin(0) > @res2.begin(0)
|
|
403
403
|
@res = @res2
|
|
404
404
|
# @pattern_cc = @pattern_cc_2
|
|
405
|
-
|
|
405
|
+
element_normal_three_one(name)
|
|
406
406
|
end
|
|
407
407
|
elsif @res1 && !@res2
|
|
408
408
|
@res = @res1
|
|
409
409
|
# @pattern_cc = @pattern_cc_1
|
|
410
410
|
if @res[1]
|
|
411
|
-
|
|
411
|
+
element_void_three(name)
|
|
412
412
|
else
|
|
413
|
-
|
|
413
|
+
element_normal_three_one(name)
|
|
414
414
|
end
|
|
415
415
|
elsif @res2 && !@res1
|
|
416
416
|
@res = @res2
|
|
417
417
|
# @pattern_cc = @pattern_cc_2
|
|
418
|
-
|
|
418
|
+
element_normal_three_one(name)
|
|
419
419
|
else
|
|
420
420
|
puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
|
|
421
421
|
|
|
@@ -425,22 +425,22 @@ module Meteor
|
|
|
425
425
|
@elm_
|
|
426
426
|
end
|
|
427
427
|
|
|
428
|
-
private :
|
|
428
|
+
private :element_three
|
|
429
429
|
|
|
430
|
-
def
|
|
430
|
+
def element_pattern_three
|
|
431
431
|
"<#{@_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)\\/>|<#{@_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(#{@_name}[^<>]*>)).)*)<\\/#{@_name}>"
|
|
432
432
|
end
|
|
433
433
|
|
|
434
|
-
private :
|
|
434
|
+
private :element_pattern_three
|
|
435
435
|
|
|
436
|
-
def
|
|
436
|
+
def quote_element_three(name, attr_name, attr_value)
|
|
437
437
|
quote_name(name)
|
|
438
438
|
quote_attribute(attr_name, attr_value)
|
|
439
439
|
end
|
|
440
440
|
|
|
441
|
-
private :
|
|
441
|
+
private :quote_element_three
|
|
442
442
|
|
|
443
|
-
def
|
|
443
|
+
def element_normal_three_one(name)
|
|
444
444
|
# puts @res.captures.length
|
|
445
445
|
case @res.captures.length
|
|
446
446
|
when FOUR
|
|
@@ -488,13 +488,13 @@ module Meteor
|
|
|
488
488
|
# element (要素)
|
|
489
489
|
@elm_ = Meteor::Element.new(name)
|
|
490
490
|
@elm_.attributes = @res[1].chop
|
|
491
|
-
if @on_search
|
|
492
|
-
# attribute (属性)
|
|
493
|
-
# content (内容)
|
|
494
|
-
else
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
end
|
|
491
|
+
# if @on_search
|
|
492
|
+
# # attribute (属性)
|
|
493
|
+
# # content (内容)
|
|
494
|
+
# else
|
|
495
|
+
# # attribute (属性)
|
|
496
|
+
# # content (内容)
|
|
497
|
+
# end
|
|
498
498
|
@elm_.mixed_content = @res[3]
|
|
499
499
|
# document (全体)
|
|
500
500
|
@elm_.document = @res[0]
|
|
@@ -509,10 +509,10 @@ module Meteor
|
|
|
509
509
|
@elm_
|
|
510
510
|
end
|
|
511
511
|
|
|
512
|
-
private :
|
|
512
|
+
private :element_normal_three_one
|
|
513
513
|
|
|
514
|
-
def
|
|
515
|
-
|
|
514
|
+
def element_normal_three_two
|
|
515
|
+
element_pattern_normal_three_two
|
|
516
516
|
|
|
517
517
|
return nil if @sbuf.length == ZERO || @cnt != ZERO
|
|
518
518
|
|
|
@@ -522,9 +522,9 @@ module Meteor
|
|
|
522
522
|
@res
|
|
523
523
|
end
|
|
524
524
|
|
|
525
|
-
private :
|
|
525
|
+
private :element_normal_three_two
|
|
526
526
|
|
|
527
|
-
def
|
|
527
|
+
def element_pattern_normal_three_two
|
|
528
528
|
# @pattern_cc_1 = String.new('') << "<" << @_name << '(\\s[^<>]*' << @_attr_name << '="'
|
|
529
529
|
# @pattern_cc_1 << @_attr_value << '(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))'
|
|
530
530
|
@pattern_cc_1 = "<#{@_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))"
|
|
@@ -558,15 +558,15 @@ module Meteor
|
|
|
558
558
|
@pattern_cc = @sbuf
|
|
559
559
|
end
|
|
560
560
|
|
|
561
|
-
private :
|
|
561
|
+
private :element_pattern_normal_three_two
|
|
562
562
|
|
|
563
|
-
def
|
|
564
|
-
|
|
563
|
+
def element_void_three(name)
|
|
564
|
+
element_void_three_one(name, '"[^<>]*)\\/>')
|
|
565
565
|
end
|
|
566
566
|
|
|
567
|
-
private :
|
|
567
|
+
private :element_void_three
|
|
568
568
|
|
|
569
|
-
def
|
|
569
|
+
def element_void_three_one(name, closer)
|
|
570
570
|
# element (要素)
|
|
571
571
|
@elm_ = Meteor::Element.new(name)
|
|
572
572
|
# attribute (属性)
|
|
@@ -582,7 +582,7 @@ module Meteor
|
|
|
582
582
|
@elm_
|
|
583
583
|
end
|
|
584
584
|
|
|
585
|
-
private :
|
|
585
|
+
private :element_void_three_one
|
|
586
586
|
|
|
587
587
|
#
|
|
588
588
|
# get element using attribute(name="value") (属性(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -590,16 +590,16 @@ module Meteor
|
|
|
590
590
|
# @param [String] attr_value attribute value (属性値)
|
|
591
591
|
# @return [Meteor::Element] element (要素)
|
|
592
592
|
#
|
|
593
|
-
def
|
|
593
|
+
def element_two(attr_name, attr_value)
|
|
594
594
|
quote_attribute(attr_name, attr_value)
|
|
595
595
|
|
|
596
|
-
|
|
596
|
+
element_pattern_two
|
|
597
597
|
|
|
598
598
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
|
599
599
|
@res = @pattern.match(@root.document)
|
|
600
600
|
|
|
601
601
|
if @res
|
|
602
|
-
|
|
602
|
+
element_three(@res[1], attr_name, attr_value)
|
|
603
603
|
else
|
|
604
604
|
puts(Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message) if @error_check
|
|
605
605
|
|
|
@@ -612,7 +612,7 @@ module Meteor
|
|
|
612
612
|
# @res1 = @pattern.match(@root.document)
|
|
613
613
|
#
|
|
614
614
|
# if @res1 && @res1[1] || !@res1
|
|
615
|
-
# @res2 =
|
|
615
|
+
# @res2 = element_normal_two_two
|
|
616
616
|
# @pattern_cc_2 = @pattern_cc
|
|
617
617
|
#
|
|
618
618
|
# # puts @res2.captures.length
|
|
@@ -624,27 +624,27 @@ module Meteor
|
|
|
624
624
|
# @res = @res1
|
|
625
625
|
# # @pattern_cc = @pattern_cc_1
|
|
626
626
|
# if @res[1]
|
|
627
|
-
#
|
|
627
|
+
# element_void_two
|
|
628
628
|
# else
|
|
629
|
-
#
|
|
629
|
+
# element_normal_two_one
|
|
630
630
|
# end
|
|
631
631
|
# elsif @res1.begin(0) > @res2.begin(0)
|
|
632
632
|
# @res = @res2
|
|
633
633
|
# # @pattern_cc = @pattern_cc_2
|
|
634
|
-
#
|
|
634
|
+
# element_normal_two_one
|
|
635
635
|
# end
|
|
636
636
|
# elsif @res1 && !@res2
|
|
637
637
|
# @res = @res1
|
|
638
638
|
# # @pattern_cc = @pattern_cc_1
|
|
639
639
|
# if @res[1]
|
|
640
|
-
#
|
|
640
|
+
# element_void_two
|
|
641
641
|
# else
|
|
642
|
-
#
|
|
642
|
+
# element_normal_two_one
|
|
643
643
|
# end
|
|
644
644
|
# elsif @res2 && !@res1
|
|
645
645
|
# @res = @res2
|
|
646
646
|
# # @pattern_cc = @pattern_cc_2
|
|
647
|
-
#
|
|
647
|
+
# element_normal_two_one
|
|
648
648
|
# else
|
|
649
649
|
# if @error_check
|
|
650
650
|
# puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
|
|
@@ -655,7 +655,7 @@ module Meteor
|
|
|
655
655
|
@elm_
|
|
656
656
|
end
|
|
657
657
|
|
|
658
|
-
private :
|
|
658
|
+
private :element_two
|
|
659
659
|
|
|
660
660
|
def quote_name(name)
|
|
661
661
|
@_name = Regexp.quote(name)
|
|
@@ -670,15 +670,15 @@ module Meteor
|
|
|
670
670
|
|
|
671
671
|
private :quote_attribute
|
|
672
672
|
|
|
673
|
-
def
|
|
673
|
+
def element_pattern_two
|
|
674
674
|
# # @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value << '(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'
|
|
675
675
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value << '"'
|
|
676
676
|
@pattern_cc = "<([^<>\"]*)\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\""
|
|
677
677
|
end
|
|
678
678
|
|
|
679
|
-
private :
|
|
679
|
+
private :element_pattern_two
|
|
680
680
|
|
|
681
|
-
# def
|
|
681
|
+
# def element_normal_two_one
|
|
682
682
|
# # puts @res.captures.length
|
|
683
683
|
# case @res.captures.length
|
|
684
684
|
# when FOUR
|
|
@@ -740,9 +740,9 @@ module Meteor
|
|
|
740
740
|
# @elm_
|
|
741
741
|
# end
|
|
742
742
|
#
|
|
743
|
-
# private :
|
|
743
|
+
# private :element_normal_two_one
|
|
744
744
|
#
|
|
745
|
-
# def
|
|
745
|
+
# def element_normal_two_two
|
|
746
746
|
# # @pattern_cc_1 = String.new('') << "<" << @_name << '(\\s[^<>]*' << @_attr_name << '="'
|
|
747
747
|
# # @pattern_cc_1 << @_attr_value << '(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))'
|
|
748
748
|
# @pattern_cc_1 = "<([^<>\"]*)(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))"
|
|
@@ -753,7 +753,7 @@ module Meteor
|
|
|
753
753
|
#
|
|
754
754
|
# @cnt = 0
|
|
755
755
|
#
|
|
756
|
-
#
|
|
756
|
+
# create_element_pattern_two(2)
|
|
757
757
|
#
|
|
758
758
|
# @pattern_cc = @sbuf
|
|
759
759
|
#
|
|
@@ -765,9 +765,9 @@ module Meteor
|
|
|
765
765
|
# @res = @pattern.match(@root.document)
|
|
766
766
|
# end
|
|
767
767
|
#
|
|
768
|
-
# private :
|
|
768
|
+
# private :element_normal_two_two
|
|
769
769
|
#
|
|
770
|
-
# def
|
|
770
|
+
# def create_pattern_two(args_cnt)
|
|
771
771
|
# @pattern_cc_1b = String.new('') << "<" << @_name << '(\\s[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'
|
|
772
772
|
#
|
|
773
773
|
# # @pattern_cc_1_1 = String.new('') << "<" << @_name << '(\\s[^<>]*' << @_attr_name << '="'
|
|
@@ -782,13 +782,13 @@ module Meteor
|
|
|
782
782
|
# @pattern_1b = Meteor::Core::Util::PatternCache.get(@pattern_cc_1b)
|
|
783
783
|
# end
|
|
784
784
|
#
|
|
785
|
-
# def
|
|
786
|
-
#
|
|
785
|
+
# def element_void_two
|
|
786
|
+
# element_void_two_one('"[^<>]*\\/>')
|
|
787
787
|
# end
|
|
788
788
|
#
|
|
789
|
-
# private :
|
|
789
|
+
# private :element_void_two
|
|
790
790
|
#
|
|
791
|
-
# def
|
|
791
|
+
# def element_void_two_one(closer)
|
|
792
792
|
# # element (要素)
|
|
793
793
|
# @elm_ = Element.new(@res[1])
|
|
794
794
|
# # attribute (属性)
|
|
@@ -803,7 +803,7 @@ module Meteor
|
|
|
803
803
|
# @elm_
|
|
804
804
|
# end
|
|
805
805
|
#
|
|
806
|
-
# private :
|
|
806
|
+
# private :element_void_two_one
|
|
807
807
|
|
|
808
808
|
#
|
|
809
809
|
# get element using tag name and attribute1,2(name="value") (要素のタグ名と属性1・属性2(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -814,8 +814,8 @@ module Meteor
|
|
|
814
814
|
# @param [String] attr_value2 attribute value2 (属性値2)
|
|
815
815
|
# @return [Meteor::Element] element (要素)
|
|
816
816
|
#
|
|
817
|
-
def
|
|
818
|
-
|
|
817
|
+
def element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
818
|
+
quote_element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
819
819
|
|
|
820
820
|
@pattern_cc_1 = "<#{@_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)\\/>|<#{@_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_name}[^<>]*>)).)*)<\\/#{@_name}>"
|
|
821
821
|
|
|
@@ -823,7 +823,7 @@ module Meteor
|
|
|
823
823
|
@res1 = @pattern.match(@root.document)
|
|
824
824
|
|
|
825
825
|
if @res1 && @res1[1] || !@res1
|
|
826
|
-
@res2 =
|
|
826
|
+
@res2 = element_normal_five_two
|
|
827
827
|
@pattern_cc_2 = @pattern_cc
|
|
828
828
|
|
|
829
829
|
# puts @res2.captures.length
|
|
@@ -835,27 +835,27 @@ module Meteor
|
|
|
835
835
|
@res = @res1
|
|
836
836
|
# @pattern_cc = @pattern_cc_1
|
|
837
837
|
if @res[1]
|
|
838
|
-
|
|
838
|
+
element_void_five(name)
|
|
839
839
|
else
|
|
840
|
-
|
|
840
|
+
element_normal_five_one(name)
|
|
841
841
|
end
|
|
842
842
|
elsif @res1.begin(0) > @res2.begin(0)
|
|
843
843
|
@res = @res2
|
|
844
844
|
# @pattern_cc = @pattern_cc_2
|
|
845
|
-
|
|
845
|
+
element_normal_five_one(name)
|
|
846
846
|
end
|
|
847
847
|
elsif @res1 && !@res2
|
|
848
848
|
@res = @res1
|
|
849
849
|
# @pattern_cc = @pattern_cc_1
|
|
850
850
|
if @res[1]
|
|
851
|
-
|
|
851
|
+
element_void_five(name)
|
|
852
852
|
else
|
|
853
|
-
|
|
853
|
+
element_normal_five_one(name)
|
|
854
854
|
end
|
|
855
855
|
elsif @res2 && !@res1
|
|
856
856
|
@res = @res2
|
|
857
857
|
# @pattern_cc = @pattern_cc_2
|
|
858
|
-
|
|
858
|
+
element_normal_five_one(name)
|
|
859
859
|
else
|
|
860
860
|
puts(Meteor::Exception::NoSuchElementException.new(name, attr_name, attr_value).message) if @error_check
|
|
861
861
|
|
|
@@ -865,9 +865,9 @@ module Meteor
|
|
|
865
865
|
@elm_
|
|
866
866
|
end
|
|
867
867
|
|
|
868
|
-
private :
|
|
868
|
+
private :element_five
|
|
869
869
|
|
|
870
|
-
def
|
|
870
|
+
def quote_element_five(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
871
871
|
quote_name(name)
|
|
872
872
|
@_attr_name1 = Regexp.quote(attr_name1)
|
|
873
873
|
@_attr_name2 = Regexp.quote(attr_name2)
|
|
@@ -875,9 +875,9 @@ module Meteor
|
|
|
875
875
|
@_attr_value2 = Regexp.quote(attr_value2)
|
|
876
876
|
end
|
|
877
877
|
|
|
878
|
-
private :
|
|
878
|
+
private :quote_element_five
|
|
879
879
|
|
|
880
|
-
def
|
|
880
|
+
def element_normal_five_one(name)
|
|
881
881
|
# puts @res.captures.length
|
|
882
882
|
case @res.captures.length
|
|
883
883
|
when FOUR
|
|
@@ -942,10 +942,10 @@ module Meteor
|
|
|
942
942
|
@elm_
|
|
943
943
|
end
|
|
944
944
|
|
|
945
|
-
private :
|
|
945
|
+
private :element_normal_five_one
|
|
946
946
|
|
|
947
|
-
def
|
|
948
|
-
|
|
947
|
+
def element_normal_five_two
|
|
948
|
+
element_pattern_normal_five_two
|
|
949
949
|
|
|
950
950
|
return nil if @sbuf.length == ZERO || @cnt != ZERO
|
|
951
951
|
|
|
@@ -955,9 +955,9 @@ module Meteor
|
|
|
955
955
|
@res
|
|
956
956
|
end
|
|
957
957
|
|
|
958
|
-
private :
|
|
958
|
+
private :element_normal_five_two
|
|
959
959
|
|
|
960
|
-
def
|
|
960
|
+
def element_pattern_normal_five_two
|
|
961
961
|
# @pattern_cc_1 = String.new('') << "<" << @_name << '(\\s[^<>]*(?:' << @_attr_name1 << '="'
|
|
962
962
|
# @pattern_cc_1 << @_attr_value1 << '"[^<>]*' << @_attr_name2 << '="'
|
|
963
963
|
# @pattern_cc_1 << @_attr_value2 << '"|' << @_attr_name2 << '="'
|
|
@@ -996,15 +996,15 @@ module Meteor
|
|
|
996
996
|
@pattern_cc = @sbuf
|
|
997
997
|
end
|
|
998
998
|
|
|
999
|
-
private :
|
|
999
|
+
private :element_pattern_normal_five_two
|
|
1000
1000
|
|
|
1001
|
-
def
|
|
1002
|
-
|
|
1001
|
+
def element_void_five(name)
|
|
1002
|
+
element_void_five_one(name, '")[^<>]*)\\/>')
|
|
1003
1003
|
end
|
|
1004
1004
|
|
|
1005
|
-
private :
|
|
1005
|
+
private :element_void_five
|
|
1006
1006
|
|
|
1007
|
-
def
|
|
1007
|
+
def element_void_five_one(name, closer)
|
|
1008
1008
|
# element (要素)
|
|
1009
1009
|
@elm_ = Meteor::Element.new(name)
|
|
1010
1010
|
# attribute (属性)
|
|
@@ -1024,7 +1024,7 @@ module Meteor
|
|
|
1024
1024
|
@elm_
|
|
1025
1025
|
end
|
|
1026
1026
|
|
|
1027
|
-
private :
|
|
1027
|
+
private :element_void_five_one
|
|
1028
1028
|
|
|
1029
1029
|
#
|
|
1030
1030
|
# get element using attribute1,2(name="value") (属性1・属性2(属性名="属性値")で検索し、要素を取得する)
|
|
@@ -1034,8 +1034,8 @@ module Meteor
|
|
|
1034
1034
|
# @param [String]attr_value2 attribute value2 (属性値2)
|
|
1035
1035
|
# @return [Meteor::Element] element (要素)
|
|
1036
1036
|
#
|
|
1037
|
-
def
|
|
1038
|
-
|
|
1037
|
+
def element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1038
|
+
quote_element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1039
1039
|
|
|
1040
1040
|
element_pattern_4
|
|
1041
1041
|
|
|
@@ -1043,8 +1043,8 @@ module Meteor
|
|
|
1043
1043
|
@res = @pattern.match(@root.document)
|
|
1044
1044
|
|
|
1045
1045
|
if @res
|
|
1046
|
-
# @elm_ =
|
|
1047
|
-
|
|
1046
|
+
# @elm_ = element_five(@res[1], attr_name1, attr_value1,attr_name2, attr_value2)
|
|
1047
|
+
element_five(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1048
1048
|
else
|
|
1049
1049
|
if @error_check
|
|
1050
1050
|
puts(
|
|
@@ -1058,18 +1058,18 @@ module Meteor
|
|
|
1058
1058
|
@elm_
|
|
1059
1059
|
end
|
|
1060
1060
|
|
|
1061
|
-
private :
|
|
1061
|
+
private :element_four
|
|
1062
1062
|
|
|
1063
|
-
def
|
|
1063
|
+
def quote_element_four(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1064
1064
|
@_attr_name1 = Regexp.quote(attr_name1)
|
|
1065
1065
|
@_attr_name2 = Regexp.quote(attr_name2)
|
|
1066
1066
|
@_attr_value1 = Regexp.quote(attr_value1)
|
|
1067
1067
|
@_attr_value2 = Regexp.quote(attr_value2)
|
|
1068
1068
|
end
|
|
1069
1069
|
|
|
1070
|
-
private :
|
|
1070
|
+
private :quote_element_four
|
|
1071
1071
|
|
|
1072
|
-
def
|
|
1072
|
+
def element_pattern_four
|
|
1073
1073
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="'
|
|
1074
1074
|
# @pattern_cc << @_attr_value1 << '"[^<>]*' << @_attr_name2 << '="'
|
|
1075
1075
|
# @pattern_cc << @_attr_value2 << '"|' << @_attr_name2 << '="'
|
|
@@ -1078,7 +1078,7 @@ module Meteor
|
|
|
1078
1078
|
@pattern_cc = "<([^<>\"]*)\\s[^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")"
|
|
1079
1079
|
end
|
|
1080
1080
|
|
|
1081
|
-
private :
|
|
1081
|
+
private :element_pattern_four
|
|
1082
1082
|
|
|
1083
1083
|
def create_element_pattern
|
|
1084
1084
|
@position = 0
|
|
@@ -1142,7 +1142,7 @@ module Meteor
|
|
|
1142
1142
|
|
|
1143
1143
|
private :create_element_pattern
|
|
1144
1144
|
|
|
1145
|
-
# def
|
|
1145
|
+
# def create_element_pattern_two(args_cnt)
|
|
1146
1146
|
# @position = 0
|
|
1147
1147
|
#
|
|
1148
1148
|
# while (@res = @pattern.match(@root.document, @position)) || @cnt > ZERO
|
|
@@ -1177,7 +1177,7 @@ module Meteor
|
|
|
1177
1177
|
# @position = @res.end(0)
|
|
1178
1178
|
# @_name = @res[1]
|
|
1179
1179
|
#
|
|
1180
|
-
#
|
|
1180
|
+
# create_pattern_two(args_cnt)
|
|
1181
1181
|
#
|
|
1182
1182
|
# @sbuf << @pattern_cc_1_1
|
|
1183
1183
|
# @cnt += ONE
|
|
@@ -1308,15 +1308,15 @@ module Meteor
|
|
|
1308
1308
|
|
|
1309
1309
|
case args.size
|
|
1310
1310
|
when ONE
|
|
1311
|
-
@elm_ =
|
|
1311
|
+
@elm_ = element_one(*args)
|
|
1312
1312
|
when TWO
|
|
1313
|
-
@elm_ =
|
|
1313
|
+
@elm_ = element_two(*args)
|
|
1314
1314
|
when THREE
|
|
1315
|
-
@elm_ =
|
|
1315
|
+
@elm_ = element_three(*args)
|
|
1316
1316
|
when FOUR
|
|
1317
|
-
@elm_ =
|
|
1317
|
+
@elm_ = element_four(*args)
|
|
1318
1318
|
when FIVE
|
|
1319
|
-
@elm_ =
|
|
1319
|
+
@elm_ = element_five(*args)
|
|
1320
1320
|
end
|
|
1321
1321
|
|
|
1322
1322
|
return elm_arr unless @elm_
|
|
@@ -1336,23 +1336,23 @@ module Meteor
|
|
|
1336
1336
|
case args.size
|
|
1337
1337
|
when ONE
|
|
1338
1338
|
if @elm_.normal
|
|
1339
|
-
|
|
1339
|
+
element_normal_one(@elm_.name)
|
|
1340
1340
|
else
|
|
1341
|
-
|
|
1341
|
+
element_void_one(@elm_.name)
|
|
1342
1342
|
end
|
|
1343
1343
|
|
|
1344
1344
|
when TWO, THREE
|
|
1345
1345
|
if @elm_.normal
|
|
1346
|
-
|
|
1346
|
+
element_normal_three_one(@elm_.name)
|
|
1347
1347
|
else
|
|
1348
|
-
|
|
1348
|
+
element_void_three(@elm_.name)
|
|
1349
1349
|
end
|
|
1350
1350
|
|
|
1351
1351
|
when FOUR, FIVE
|
|
1352
1352
|
if @elm_.normal
|
|
1353
|
-
|
|
1353
|
+
element_normal_five_one(@elm_.name)
|
|
1354
1354
|
else
|
|
1355
|
-
|
|
1355
|
+
element_void_five(@elm_.name)
|
|
1356
1356
|
end
|
|
1357
1357
|
end
|
|
1358
1358
|
|
|
@@ -1439,7 +1439,7 @@ module Meteor
|
|
|
1439
1439
|
when ONE
|
|
1440
1440
|
if !args[0].nil?
|
|
1441
1441
|
elm.document_sync = true
|
|
1442
|
-
|
|
1442
|
+
set_attribute_three(elm, attr.to_s, args[0])
|
|
1443
1443
|
else
|
|
1444
1444
|
remove_attr(elm, attr.to_s)
|
|
1445
1445
|
end
|
|
@@ -1447,14 +1447,14 @@ module Meteor
|
|
|
1447
1447
|
elsif attr.is_a?(Hash) && attr.size == 1
|
|
1448
1448
|
if !attr.values[0].nil?
|
|
1449
1449
|
elm.document_sync = true
|
|
1450
|
-
|
|
1450
|
+
set_attribute_three(elm, attr.keys[0].to_s, attr.values[0])
|
|
1451
1451
|
else
|
|
1452
1452
|
remove_attr(elm, attr.keys[0].to_s)
|
|
1453
1453
|
end
|
|
1454
1454
|
# elsif attrs.kind_of?(Hash) && attrs.size >= 1
|
|
1455
1455
|
# elm.document_sync = true
|
|
1456
1456
|
# attrs.each{|name,value|
|
|
1457
|
-
#
|
|
1457
|
+
# set_attribute_three(elm,name,value)
|
|
1458
1458
|
# }
|
|
1459
1459
|
else
|
|
1460
1460
|
raise ArgumentError
|
|
@@ -1468,7 +1468,7 @@ module Meteor
|
|
|
1468
1468
|
# @param [String,true,false] attr_value attribute value (属性値)
|
|
1469
1469
|
# @return [Meteor::Element] element (要素)
|
|
1470
1470
|
#
|
|
1471
|
-
def
|
|
1471
|
+
def set_attribute_three(elm, attr_name, attr_value)
|
|
1472
1472
|
unless elm.cx
|
|
1473
1473
|
attr_value = escape(attr_value.to_s)
|
|
1474
1474
|
# update attributes (属性群の更新)
|
|
@@ -1478,7 +1478,7 @@ module Meteor
|
|
|
1478
1478
|
elm
|
|
1479
1479
|
end
|
|
1480
1480
|
|
|
1481
|
-
private :
|
|
1481
|
+
private :set_attribute_three
|
|
1482
1482
|
|
|
1483
1483
|
def edit_attrs_(elm, attr_name, attr_value)
|
|
1484
1484
|
# attribute search (属性検索)
|
|
@@ -1553,7 +1553,7 @@ module Meteor
|
|
|
1553
1553
|
|
|
1554
1554
|
if args[0].size == 1
|
|
1555
1555
|
elm.document_sync = true
|
|
1556
|
-
|
|
1556
|
+
set_attribute_three(elm, args[0].keys[0].to_s, args[0].values[0])
|
|
1557
1557
|
elsif args[0].size >= 1
|
|
1558
1558
|
set_attrs(elm, args[0])
|
|
1559
1559
|
else
|
|
@@ -1592,7 +1592,7 @@ module Meteor
|
|
|
1592
1592
|
unless elm.cx
|
|
1593
1593
|
elm.document_sync = true
|
|
1594
1594
|
attr_map.each do |name, value|
|
|
1595
|
-
|
|
1595
|
+
set_attribute_three(elm, name.to_s, value)
|
|
1596
1596
|
end
|
|
1597
1597
|
end
|
|
1598
1598
|
|
|
@@ -1689,20 +1689,20 @@ module Meteor
|
|
|
1689
1689
|
case args.length
|
|
1690
1690
|
when ONE
|
|
1691
1691
|
# if args[0].kind_of?(Meteor::Element)
|
|
1692
|
-
|
|
1692
|
+
get_content_one(args[0])
|
|
1693
1693
|
# else
|
|
1694
1694
|
# raise ArgumentError
|
|
1695
1695
|
# end
|
|
1696
1696
|
when TWO
|
|
1697
1697
|
# if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String)
|
|
1698
1698
|
args[0].document_sync = true
|
|
1699
|
-
|
|
1699
|
+
set_content_two(args[0], args[1].to_s)
|
|
1700
1700
|
# else
|
|
1701
1701
|
# raise ArgumentError
|
|
1702
1702
|
# end
|
|
1703
1703
|
when THREE
|
|
1704
1704
|
args[0].document_sync = true
|
|
1705
|
-
|
|
1705
|
+
set_content_three(args[0], args[1].to_s, args[2])
|
|
1706
1706
|
else
|
|
1707
1707
|
raise ArgumentError
|
|
1708
1708
|
end
|
|
@@ -1715,14 +1715,14 @@ module Meteor
|
|
|
1715
1715
|
# @param [true,false] entity_ref entity reference flag (エンティティ参照フラグ)
|
|
1716
1716
|
# @return [Meteor::Element] element (要素)
|
|
1717
1717
|
#
|
|
1718
|
-
def
|
|
1718
|
+
def set_content_three(elm, content, entity_ref = true)
|
|
1719
1719
|
escape_content(content, elm) if entity_ref || !elm.raw_content
|
|
1720
1720
|
|
|
1721
1721
|
elm.mixed_content = content
|
|
1722
1722
|
elm
|
|
1723
1723
|
end
|
|
1724
1724
|
|
|
1725
|
-
private :
|
|
1725
|
+
private :set_content_three
|
|
1726
1726
|
|
|
1727
1727
|
#
|
|
1728
1728
|
# set content of element (要素の内容をセットする)
|
|
@@ -1730,22 +1730,22 @@ module Meteor
|
|
|
1730
1730
|
# @param [String] content content of element (要素の内容)
|
|
1731
1731
|
# @return [Meteor::Element] element (要素)
|
|
1732
1732
|
#
|
|
1733
|
-
def
|
|
1734
|
-
#
|
|
1733
|
+
def set_content_two(elm, content)
|
|
1734
|
+
# set_content_three(elm, content)
|
|
1735
1735
|
escape_content(content, elm) unless elm.raw_content
|
|
1736
1736
|
|
|
1737
1737
|
elm.mixed_content = content
|
|
1738
1738
|
elm
|
|
1739
1739
|
end
|
|
1740
1740
|
|
|
1741
|
-
private :
|
|
1741
|
+
private :set_content_two
|
|
1742
1742
|
|
|
1743
1743
|
#
|
|
1744
1744
|
# get content of element (要素の内容を取得する)
|
|
1745
1745
|
# @param [Meteor::Element] elm element (要素)
|
|
1746
1746
|
# @return [String] content (内容)
|
|
1747
1747
|
#
|
|
1748
|
-
def
|
|
1748
|
+
def get_content_one(elm)
|
|
1749
1749
|
if !elm.cx
|
|
1750
1750
|
unescape_content(elm.mixed_content, elm) if elm.normal
|
|
1751
1751
|
else
|
|
@@ -1753,7 +1753,7 @@ module Meteor
|
|
|
1753
1753
|
end
|
|
1754
1754
|
end
|
|
1755
1755
|
|
|
1756
|
-
private :
|
|
1756
|
+
private :get_content_one
|
|
1757
1757
|
|
|
1758
1758
|
#
|
|
1759
1759
|
# remove attribute of element (要素の属性を消す)
|
|
@@ -1804,10 +1804,10 @@ module Meteor
|
|
|
1804
1804
|
def cxtag(*args)
|
|
1805
1805
|
case args.length
|
|
1806
1806
|
when ONE
|
|
1807
|
-
|
|
1807
|
+
cxtag_one(args[0].to_s)
|
|
1808
1808
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
1809
1809
|
when TWO
|
|
1810
|
-
|
|
1810
|
+
cxtag_two(args[0].to_s, args[1].to_s)
|
|
1811
1811
|
@element_cache.store(@elm_.object_id, @elm_) if @elm_
|
|
1812
1812
|
else
|
|
1813
1813
|
raise ArgumentError
|
|
@@ -1820,7 +1820,7 @@ module Meteor
|
|
|
1820
1820
|
# @param [String] id id attribute value (ID属性値)
|
|
1821
1821
|
# @return [Meteor::Element] element (要素)
|
|
1822
1822
|
#
|
|
1823
|
-
def
|
|
1823
|
+
def cxtag_two(name, id)
|
|
1824
1824
|
quote_name(name)
|
|
1825
1825
|
@_id = Regexp.quote(id)
|
|
1826
1826
|
|
|
@@ -1858,14 +1858,14 @@ module Meteor
|
|
|
1858
1858
|
@elm_
|
|
1859
1859
|
end
|
|
1860
1860
|
|
|
1861
|
-
private :
|
|
1861
|
+
private :cxtag_two
|
|
1862
1862
|
|
|
1863
1863
|
#
|
|
1864
1864
|
# get cx(comment extension) tag using id attribute (ID属性(id="ID属性値")で検索し、CX(コメント拡張)タグを取得する)
|
|
1865
1865
|
# @param [String] id id attribute value (ID属性値)
|
|
1866
1866
|
# @return [Meteor::Element] element (要素)
|
|
1867
1867
|
#
|
|
1868
|
-
def
|
|
1868
|
+
def cxtag_one(id)
|
|
1869
1869
|
@_id = Regexp.quote(id)
|
|
1870
1870
|
|
|
1871
1871
|
@pattern_cc = String.new('') << '<!--\\s@([^<>]*)\\s[^<>]*id="' << @_id << '"'
|
|
@@ -1885,7 +1885,7 @@ module Meteor
|
|
|
1885
1885
|
@elm_
|
|
1886
1886
|
end
|
|
1887
1887
|
|
|
1888
|
-
private :
|
|
1888
|
+
private :cxtag_one
|
|
1889
1889
|
|
|
1890
1890
|
#
|
|
1891
1891
|
# replace element (要素を置換する)
|
|
@@ -1914,7 +1914,7 @@ module Meteor
|
|
|
1914
1914
|
# item.copy.parser.element_cache.clear
|
|
1915
1915
|
item.copy = nil
|
|
1916
1916
|
else
|
|
1917
|
-
|
|
1917
|
+
edit_document_one(item)
|
|
1918
1918
|
# edit_pattern_(item)
|
|
1919
1919
|
end
|
|
1920
1920
|
else
|
|
@@ -1927,19 +1927,19 @@ module Meteor
|
|
|
1927
1927
|
|
|
1928
1928
|
protected :reflect
|
|
1929
1929
|
|
|
1930
|
-
def
|
|
1931
|
-
|
|
1930
|
+
def edit_document_one(elm)
|
|
1931
|
+
edit_document_two(elm, '/>')
|
|
1932
1932
|
end
|
|
1933
1933
|
|
|
1934
|
-
private :
|
|
1934
|
+
private :edit_document_one
|
|
1935
1935
|
|
|
1936
|
-
def
|
|
1936
|
+
def edit_document_two(elm, _closer)
|
|
1937
1937
|
# replace tag (タグ置換)
|
|
1938
1938
|
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
|
1939
1939
|
@root.document.sub!(@pattern, elm.document)
|
|
1940
1940
|
end
|
|
1941
1941
|
|
|
1942
|
-
private :
|
|
1942
|
+
private :edit_document_two
|
|
1943
1943
|
|
|
1944
1944
|
#
|
|
1945
1945
|
# reflect (反映する)
|