meteor 0.9.14 → 0.9.16
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 +8 -0
- data/Gemfile.lock +1 -1
- data/lib/meteor/core/kernel.rb +25 -16
- data/lib/meteor/ml/html/parser_impl.rb +2 -2
- data/lib/meteor/ml/html4/parser_impl.rb +15 -11
- data/lib/meteor/ml/xhtml4/parser_impl.rb +4 -6
- data/lib/meteor/ml/xml/parser_impl.rb +5 -5
- data/lib/meteor/parser_factory.rb +31 -99
- data/lib/meteor.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7d47ad0742865e6db6e46f77760be2e297d06801994d8946d5d214b62eabb2c
|
|
4
|
+
data.tar.gz: 9589c40343c33e537a172f2f7473eacb0c2e76cd68bc2718b8795c9400b7e1fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3499c0efa7aa62b76a5ad077855b1c8da0c715396ee0979a9c6103a3a8f7b85606558794be63b64c012864c53b915556ae165da6d282af616b6912342689fd0f
|
|
7
|
+
data.tar.gz: a4d2d9d1d8ec23285c94840934967c37ac7921813c951b8ec0c1e52ed3cb968cd678f080f646c0aa67676596b5abff91e24337820ef67ff10973364223042c4a
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
== 0.9.16 / 2026-06-18 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
2
|
+
|
|
3
|
+
* Refactoring
|
|
4
|
+
|
|
5
|
+
== 0.9.15 / 2026-06-18 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
6
|
+
|
|
7
|
+
* Fix ParserImpl#element
|
|
8
|
+
|
|
1
9
|
== 0.9.14 / 2026-06-17 Yasumasa Ashida <ys.ashida@gmail.com>
|
|
2
10
|
|
|
3
11
|
* Fix the content-type handling in the parsers
|
data/Gemfile.lock
CHANGED
data/lib/meteor/core/kernel.rb
CHANGED
|
@@ -369,7 +369,11 @@ module Meteor
|
|
|
369
369
|
# @param [true,false] quote flag (クオート・フラグ)
|
|
370
370
|
# @return [Meteor::Element] element (要素)
|
|
371
371
|
def element_3(name, attr_name, attr_value, quote = true)
|
|
372
|
-
|
|
372
|
+
if quote
|
|
373
|
+
quote_element_3(name, attr_name, attr_value)
|
|
374
|
+
else
|
|
375
|
+
quote_name(name)
|
|
376
|
+
end
|
|
373
377
|
|
|
374
378
|
@pattern_cc_1 = element_pattern_3
|
|
375
379
|
|
|
@@ -429,13 +433,12 @@ module Meteor
|
|
|
429
433
|
|
|
430
434
|
private :element_pattern_3
|
|
431
435
|
|
|
432
|
-
def
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
@_attr_value = Regexp.quote(attr_value)
|
|
436
|
+
def quote_element_3(name, attr_name, attr_value)
|
|
437
|
+
quote_name(name)
|
|
438
|
+
quote_attribute(attr_name, attr_value)
|
|
436
439
|
end
|
|
437
440
|
|
|
438
|
-
private :
|
|
441
|
+
private :quote_element_3
|
|
439
442
|
|
|
440
443
|
def element_with_3_1(name)
|
|
441
444
|
# puts @res.captures.length
|
|
@@ -594,7 +597,7 @@ module Meteor
|
|
|
594
597
|
#
|
|
595
598
|
def element_2(attr_name, attr_value)
|
|
596
599
|
|
|
597
|
-
|
|
600
|
+
quote_attribute(attr_name, attr_value)
|
|
598
601
|
|
|
599
602
|
element_pattern_2
|
|
600
603
|
|
|
@@ -665,12 +668,18 @@ module Meteor
|
|
|
665
668
|
|
|
666
669
|
private :element_2
|
|
667
670
|
|
|
668
|
-
def
|
|
671
|
+
def quote_name(name)
|
|
672
|
+
@_name = Regexp.quote(name)
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
private :quote_name
|
|
676
|
+
|
|
677
|
+
def quote_attribute(attr_name, attr_value)
|
|
669
678
|
@_attr_name = Regexp.quote(attr_name)
|
|
670
679
|
@_attr_value = Regexp.quote(attr_value)
|
|
671
680
|
end
|
|
672
681
|
|
|
673
|
-
private :
|
|
682
|
+
private :quote_attribute
|
|
674
683
|
|
|
675
684
|
def element_pattern_2
|
|
676
685
|
# # @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value << '(?:[^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>))'
|
|
@@ -681,7 +690,7 @@ module Meteor
|
|
|
681
690
|
private :element_pattern_2
|
|
682
691
|
|
|
683
692
|
=begin
|
|
684
|
-
|
|
693
|
+
def element_with_2_1
|
|
685
694
|
# puts @res.captures.length
|
|
686
695
|
case @res.captures.length
|
|
687
696
|
when FOUR
|
|
@@ -820,7 +829,7 @@ module Meteor
|
|
|
820
829
|
#
|
|
821
830
|
def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
822
831
|
|
|
823
|
-
|
|
832
|
+
quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
824
833
|
|
|
825
834
|
@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}>"
|
|
826
835
|
|
|
@@ -874,7 +883,7 @@ module Meteor
|
|
|
874
883
|
|
|
875
884
|
private :element_5
|
|
876
885
|
|
|
877
|
-
def
|
|
886
|
+
def quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
878
887
|
@_name = Regexp.quote(name)
|
|
879
888
|
@_attr_name1 = Regexp.quote(attr_name1)
|
|
880
889
|
@_attr_name2 = Regexp.quote(attr_name2)
|
|
@@ -882,7 +891,7 @@ module Meteor
|
|
|
882
891
|
@_attr_value2 = Regexp.quote(attr_value2)
|
|
883
892
|
end
|
|
884
893
|
|
|
885
|
-
private :
|
|
894
|
+
private :quote_element_5
|
|
886
895
|
|
|
887
896
|
def element_with_5_1(name)
|
|
888
897
|
|
|
@@ -1048,7 +1057,7 @@ module Meteor
|
|
|
1048
1057
|
#
|
|
1049
1058
|
def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1050
1059
|
|
|
1051
|
-
|
|
1060
|
+
quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1052
1061
|
|
|
1053
1062
|
element_pattern_4
|
|
1054
1063
|
|
|
@@ -1073,14 +1082,14 @@ module Meteor
|
|
|
1073
1082
|
|
|
1074
1083
|
private :element_4
|
|
1075
1084
|
|
|
1076
|
-
def
|
|
1085
|
+
def quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
1077
1086
|
@_attr_name1 = Regexp.quote(attr_name1)
|
|
1078
1087
|
@_attr_name2 = Regexp.quote(attr_name2)
|
|
1079
1088
|
@_attr_value1 = Regexp.quote(attr_value1)
|
|
1080
1089
|
@_attr_value2 = Regexp.quote(attr_value2)
|
|
1081
1090
|
end
|
|
1082
1091
|
|
|
1083
|
-
private :
|
|
1092
|
+
private :quote_element_4
|
|
1084
1093
|
|
|
1085
1094
|
def element_pattern_4
|
|
1086
1095
|
|
|
@@ -12,7 +12,7 @@ module Meteor
|
|
|
12
12
|
MATCH_TAG = ["br", "hr", "img", "input", "meta", "base", "embed", "command", "keygen"]
|
|
13
13
|
|
|
14
14
|
#[Array] non-nestable elements (入れ子にできない要素)
|
|
15
|
-
|
|
15
|
+
MATCH_TAG_NNE = [
|
|
16
16
|
"texarea",
|
|
17
17
|
"select",
|
|
18
18
|
"option",
|
|
@@ -57,7 +57,7 @@ module Meteor
|
|
|
57
57
|
def initialize(*args)
|
|
58
58
|
super()
|
|
59
59
|
@@match_tag = MATCH_TAG
|
|
60
|
-
@@
|
|
60
|
+
@@MATCH_TAG_NNE = MATCH_TAG_NNE
|
|
61
61
|
@@attr_logic = ATTR_LOGIC
|
|
62
62
|
@doc_type = Parser::HTML
|
|
63
63
|
case args.length
|
|
@@ -52,7 +52,7 @@ module Meteor
|
|
|
52
52
|
# @@pattern_true = Regexp.new("true")
|
|
53
53
|
# @@pattern_false = Regexp.new("false")
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
GET_ATTRS_MAP2 = "\\s(disabled|readonly|checked|selected|multiple)"
|
|
57
57
|
|
|
58
58
|
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
|
@@ -66,7 +66,6 @@ module Meteor
|
|
|
66
66
|
@@pattern_multiple_m = Regexp.new(MULTIPLE_M)
|
|
67
67
|
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
|
68
68
|
|
|
69
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
70
69
|
@@pattern_get_attrs_map2 = Regexp.new(GET_ATTRS_MAP2)
|
|
71
70
|
|
|
72
71
|
# @@pattern_match_tag = Regexp.new(@@match_tag)
|
|
@@ -95,9 +94,11 @@ module Meteor
|
|
|
95
94
|
|
|
96
95
|
PATTERN_ESCAPE = "[&\"'<> ]"
|
|
97
96
|
PATTERN_ESCAPE_CONTENT = "[&\"'<> \\n]"
|
|
98
|
-
|
|
99
97
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
100
98
|
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
|
99
|
+
|
|
100
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
101
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
101
102
|
@@pattern_br_2 = Regexp.new(BR)
|
|
102
103
|
|
|
103
104
|
#
|
|
@@ -214,7 +215,7 @@ module Meteor
|
|
|
214
215
|
# @return [Meteor::Element] element (要素)
|
|
215
216
|
#
|
|
216
217
|
def element_1(name)
|
|
217
|
-
|
|
218
|
+
quote_name(name)
|
|
218
219
|
|
|
219
220
|
# case of void element (空要素の場合(<->内容あり要素の場合))
|
|
220
221
|
if is_match(@@match_tag, name)
|
|
@@ -281,8 +282,11 @@ module Meteor
|
|
|
281
282
|
# @return [Meteor::Element] element (要素)
|
|
282
283
|
#
|
|
283
284
|
def element_3(name, attr_name, attr_value, quote = true)
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
if quote
|
|
286
|
+
quote_element_3(name, attr_name, attr_value)
|
|
287
|
+
else
|
|
288
|
+
quote_name(name)
|
|
289
|
+
end
|
|
286
290
|
|
|
287
291
|
# case of void element (空要素の場合(<->内容あり要素の場合))
|
|
288
292
|
if is_match(@@match_tag, name)
|
|
@@ -348,7 +352,7 @@ module Meteor
|
|
|
348
352
|
#
|
|
349
353
|
def element_2(attr_name, attr_value)
|
|
350
354
|
|
|
351
|
-
|
|
355
|
+
quote_attribute(attr_name, attr_value)
|
|
352
356
|
|
|
353
357
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s[^<>]*' << @_attr_name << '="' << @_attr_value
|
|
354
358
|
# @pattern_cc << '"[^<>]*>'
|
|
@@ -383,7 +387,7 @@ module Meteor
|
|
|
383
387
|
#
|
|
384
388
|
def element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
385
389
|
|
|
386
|
-
|
|
390
|
+
quote_element_5(name, attr_name1, attr_value1, attr_name2, attr_value2)
|
|
387
391
|
|
|
388
392
|
# 空要素の場合(<->内容あり要素の場合)
|
|
389
393
|
if is_match(@@match_tag, name)
|
|
@@ -466,7 +470,7 @@ module Meteor
|
|
|
466
470
|
# @return [Meteor::Element] element (要素)
|
|
467
471
|
#
|
|
468
472
|
def element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
469
|
-
|
|
473
|
+
quote_element_4(attr_name1, attr_value1, attr_name2, attr_value2)
|
|
470
474
|
|
|
471
475
|
# @pattern_cc = String.new('') << '<([^<>"]*)\\s([^<>]*(' << @_attr_name1 << '="' << @_attr_value1
|
|
472
476
|
# @pattern_cc << '"[^<>]*' << @_attr_name2 << '="' << @_attr_value2
|
|
@@ -647,14 +651,14 @@ module Meteor
|
|
|
647
651
|
private :remove_attrs_
|
|
648
652
|
|
|
649
653
|
def escape(content)
|
|
650
|
-
# 特殊文字の置換
|
|
654
|
+
# replace special character (特殊文字の置換)
|
|
651
655
|
content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
|
|
652
656
|
|
|
653
657
|
content
|
|
654
658
|
end
|
|
655
659
|
|
|
656
660
|
def escape_content(content, elm)
|
|
657
|
-
# 特殊文字の置換
|
|
661
|
+
# replace special character (特殊文字の置換)
|
|
658
662
|
content = content.gsub(@@pattern_escape_content, TABLE_FOR_ESCAPE_CONTENT_)
|
|
659
663
|
|
|
660
664
|
content
|
|
@@ -48,8 +48,6 @@ module Meteor
|
|
|
48
48
|
MULTIPLE_R = "multiple=\"[^\"]*\""
|
|
49
49
|
MULTIPLE_U = "multiple=\"multiple\""
|
|
50
50
|
|
|
51
|
-
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
52
|
-
|
|
53
51
|
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
|
54
52
|
@@pattern_selected_m1 = Regexp.new(SELECTED_M1)
|
|
55
53
|
@@pattern_selected_r = Regexp.new(SELECTED_R)
|
|
@@ -66,10 +64,6 @@ module Meteor
|
|
|
66
64
|
@@pattern_multiple_m1 = Regexp.new(MULTIPLE_M1)
|
|
67
65
|
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
|
68
66
|
|
|
69
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
70
|
-
|
|
71
|
-
@@pattern_br_2 = Regexp.new("<br\\/>")
|
|
72
|
-
|
|
73
67
|
# @@pattern_match_tag = Regexp.new(@@match_tag)
|
|
74
68
|
# @@pattern_match_tag2 = Regexp.new(@@match_tag_2)
|
|
75
69
|
|
|
@@ -99,6 +93,10 @@ module Meteor
|
|
|
99
93
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
100
94
|
@@pattern_escape_content = Regexp.new(PATTERN_ESCAPE_CONTENT)
|
|
101
95
|
|
|
96
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt|nbsp);"
|
|
97
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
98
|
+
@@pattern_br_2 = Regexp.new("<br\\/>")
|
|
99
|
+
|
|
102
100
|
#
|
|
103
101
|
# initializer (イニシャライザ)
|
|
104
102
|
# @overload initialize
|
|
@@ -11,10 +11,6 @@ module Meteor
|
|
|
11
11
|
# KAIGYO_CODE = "\r?\n|\r"
|
|
12
12
|
KAIGYO_CODE = ["\r\n", "\n", "\r"]
|
|
13
13
|
|
|
14
|
-
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt);"
|
|
15
|
-
|
|
16
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
17
|
-
|
|
18
14
|
TABLE_FOR_ESCAPE_ = {
|
|
19
15
|
"&" => "&",
|
|
20
16
|
"\"" => """,
|
|
@@ -22,9 +18,13 @@ module Meteor
|
|
|
22
18
|
"<" => "<",
|
|
23
19
|
">" => ">"
|
|
24
20
|
}
|
|
21
|
+
|
|
25
22
|
PATTERN_ESCAPE = "[&\\\"'<>]"
|
|
26
23
|
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
|
27
24
|
|
|
25
|
+
PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt);"
|
|
26
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
|
27
|
+
|
|
28
28
|
#
|
|
29
29
|
# initializer (イニシャライザ)
|
|
30
30
|
# @overload initialize
|
|
@@ -108,7 +108,7 @@ module Meteor
|
|
|
108
108
|
|
|
109
109
|
private :analyze_kaigyo_code
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
#
|
|
112
112
|
# analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
|
|
113
113
|
#
|
|
114
114
|
def analyze_content_type
|
|
@@ -59,9 +59,7 @@ module Meteor
|
|
|
59
59
|
# initializer (イニシャライザ)
|
|
60
60
|
#
|
|
61
61
|
def initialize_0
|
|
62
|
-
|
|
63
|
-
@root = "."
|
|
64
|
-
@enc = "UTF-8"
|
|
62
|
+
initialize_2
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
private :initialize_0
|
|
@@ -71,9 +69,7 @@ module Meteor
|
|
|
71
69
|
# @param [String] root root directory (基準ディレクトリ)
|
|
72
70
|
#
|
|
73
71
|
def initialize_1(root)
|
|
74
|
-
|
|
75
|
-
@root = root
|
|
76
|
-
@enc = "UTF-8"
|
|
72
|
+
initialize_2(root)
|
|
77
73
|
end
|
|
78
74
|
|
|
79
75
|
private :initialize_1
|
|
@@ -83,7 +79,7 @@ module Meteor
|
|
|
83
79
|
# @param [String] root root directory (基準ディレクトリ)
|
|
84
80
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
85
81
|
#
|
|
86
|
-
def initialize_2(root, enc)
|
|
82
|
+
def initialize_2(root = ".", enc = "UTF-8")
|
|
87
83
|
@cache = Hash.new
|
|
88
84
|
@root = root
|
|
89
85
|
@enc = enc
|
|
@@ -97,7 +93,7 @@ module Meteor
|
|
|
97
93
|
# @param [String] root root directory (基準ディレクトリ)
|
|
98
94
|
# @param [String] enc default character encoding (デフォルト文字エンコーディング)
|
|
99
95
|
#
|
|
100
|
-
def initialize_3(type, root, enc)
|
|
96
|
+
def initialize_3(type, root=".", enc = "UTF-8")
|
|
101
97
|
@cache = Hash.new
|
|
102
98
|
@type = type
|
|
103
99
|
@root = root
|
|
@@ -214,31 +210,11 @@ module Meteor
|
|
|
214
210
|
# @return [Meteor::Parser] parser(パーサ)
|
|
215
211
|
#
|
|
216
212
|
def link_3(type, relative_path, enc)
|
|
217
|
-
|
|
218
213
|
relative_url = path_to_url(relative_path)
|
|
219
214
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
html.read(File.expand_path(relative_path, @root), enc)
|
|
224
|
-
@cache[relative_url] = html
|
|
225
|
-
when Parser::XML, :xml
|
|
226
|
-
xml = Meteor::Ml::Xml::ParserImpl.new
|
|
227
|
-
xml.read(File.expand_path(relative_path, @root), enc)
|
|
228
|
-
@cache[relative_url] = xml
|
|
229
|
-
when Parser::XHTML, :xhtml, :xhtml5
|
|
230
|
-
xhtml = Meteor::Ml::Xhtml::ParserImpl.new
|
|
231
|
-
xhtml.read(File.expand_path(relative_path, @root), enc)
|
|
232
|
-
@cache[relative_url] = xhtml
|
|
233
|
-
when Parser::HTML4, :html4
|
|
234
|
-
html4 = Meteor::Ml::Html4::ParserImpl.new
|
|
235
|
-
html.read(File.expand_path(relative_path, @root), enc)
|
|
236
|
-
@cache[relative_url] = html4
|
|
237
|
-
when Parser::XHTML4, :xhtml4
|
|
238
|
-
xhtml4 = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
239
|
-
xhtml4.read(File.expand_path(relative_path, @root), enc)
|
|
240
|
-
@cache[relative_url] = xhtml4
|
|
241
|
-
end
|
|
215
|
+
ps = new_parser(type)
|
|
216
|
+
ps.read(File.expand_path(relative_path, @root), enc)
|
|
217
|
+
@cache[relative_url] = ps
|
|
242
218
|
end
|
|
243
219
|
|
|
244
220
|
private :link_3
|
|
@@ -250,22 +226,9 @@ module Meteor
|
|
|
250
226
|
# @return [Meteor::Parser] parser (パーサ)
|
|
251
227
|
#
|
|
252
228
|
def link_2_n(type, relative_path)
|
|
253
|
-
|
|
254
229
|
relative_url = path_to_url(relative_path)
|
|
255
230
|
|
|
256
|
-
|
|
257
|
-
when Parser::HTML, :html, :html5
|
|
258
|
-
ps = Meteor::Ml::Html::ParserImpl.new
|
|
259
|
-
when Parser::XML, :xml
|
|
260
|
-
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
261
|
-
when Parser::XHTML, :xhtml, :xhtml5
|
|
262
|
-
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
263
|
-
when Parser::HTML4, :html4
|
|
264
|
-
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
265
|
-
when Parser::XHTML4, :xhtml4
|
|
266
|
-
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
267
|
-
end
|
|
268
|
-
|
|
231
|
+
ps = new_parser(type)
|
|
269
232
|
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
270
233
|
@cache[relative_url] = ps
|
|
271
234
|
end
|
|
@@ -279,22 +242,9 @@ module Meteor
|
|
|
279
242
|
# @return [Meteor::Parser] parser (パーサ)
|
|
280
243
|
#
|
|
281
244
|
def link_2_s(relative_path, enc)
|
|
282
|
-
|
|
283
245
|
relative_url = path_to_url(relative_path)
|
|
284
246
|
|
|
285
|
-
|
|
286
|
-
when Parser::HTML, :html
|
|
287
|
-
ps = Meteor::Ml::Html::ParserImpl.new
|
|
288
|
-
when Parser::XML, :xml
|
|
289
|
-
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
290
|
-
when Parser::XHTML, :xhtml
|
|
291
|
-
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
292
|
-
when Parser::HTML4, :html4
|
|
293
|
-
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
294
|
-
when Parser::XHTML4, :xhtml4
|
|
295
|
-
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
296
|
-
end
|
|
297
|
-
|
|
247
|
+
ps = new_parser(@type)
|
|
298
248
|
ps.read(File.expand_path(relative_path, @root), enc)
|
|
299
249
|
@cache[relative_url] = ps
|
|
300
250
|
end
|
|
@@ -307,24 +257,9 @@ module Meteor
|
|
|
307
257
|
# @return [Meteor::Parser] parser (パーサ)
|
|
308
258
|
#
|
|
309
259
|
def link_1(relative_path)
|
|
310
|
-
|
|
311
260
|
relative_url = path_to_url(relative_path)
|
|
312
261
|
|
|
313
|
-
|
|
314
|
-
when Parser::HTML, :html
|
|
315
|
-
ps = Meteor::Ml::Html::ParserImpl.new
|
|
316
|
-
when Parser::XML, :xml
|
|
317
|
-
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
318
|
-
when Parser::XHTML, :xhtml
|
|
319
|
-
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
320
|
-
when Parser::HTML4, :html4
|
|
321
|
-
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
322
|
-
when Parser::XHTML4, :xhtml4
|
|
323
|
-
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
324
|
-
else
|
|
325
|
-
raise ArgumentError
|
|
326
|
-
end
|
|
327
|
-
|
|
262
|
+
ps = new_parser(@type)
|
|
328
263
|
ps.read(File.expand_path(relative_path, @root), @enc)
|
|
329
264
|
@cache[relative_url] = ps
|
|
330
265
|
end
|
|
@@ -423,18 +358,7 @@ module Meteor
|
|
|
423
358
|
# @return [Meteor::Parser] parser (パーサ)
|
|
424
359
|
#
|
|
425
360
|
def link_str_3(type, relative_url, doc)
|
|
426
|
-
|
|
427
|
-
when Parser::HTML, :html
|
|
428
|
-
ps = Meteor::Ml::Html::ParserImpl.new
|
|
429
|
-
when Parser::XML, :xml
|
|
430
|
-
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
431
|
-
when Parser::XHTML, :xhtml
|
|
432
|
-
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
433
|
-
when Parser::HTML4, :html4
|
|
434
|
-
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
435
|
-
when Parser::XHTML4, :xhtml4
|
|
436
|
-
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
437
|
-
end
|
|
361
|
+
ps = new_parser(@type)
|
|
438
362
|
|
|
439
363
|
ps.dcument = doc
|
|
440
364
|
ps.parse
|
|
@@ -450,18 +374,7 @@ module Meteor
|
|
|
450
374
|
# @return [Meteor::Parser] parser (パーサ)
|
|
451
375
|
#
|
|
452
376
|
def link_str_2(relative_url, doc)
|
|
453
|
-
|
|
454
|
-
when Parser::HTML, :html
|
|
455
|
-
ps = Meteor::Ml::Html::ParserImpl.new
|
|
456
|
-
when Parser::XML, :xml
|
|
457
|
-
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
458
|
-
when Parser::XHTML, :xhtml
|
|
459
|
-
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
460
|
-
when Parser::HTML4, :html4
|
|
461
|
-
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
462
|
-
when Parser::XHTML4, :xhtml4
|
|
463
|
-
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
464
|
-
end
|
|
377
|
+
ps = new_parser(@type)
|
|
465
378
|
|
|
466
379
|
ps.document = doc
|
|
467
380
|
ps.parse
|
|
@@ -472,6 +385,25 @@ module Meteor
|
|
|
472
385
|
|
|
473
386
|
alias :paraser_str :link_str
|
|
474
387
|
|
|
388
|
+
def new_parser(type)
|
|
389
|
+
case type
|
|
390
|
+
when Parser::HTML, :html
|
|
391
|
+
Meteor::Ml::Html::ParserImpl.new
|
|
392
|
+
when Parser::XML, :xml
|
|
393
|
+
Meteor::Ml::Xml::ParserImpl.new
|
|
394
|
+
when Parser::XHTML, :xhtml
|
|
395
|
+
Meteor::Ml::Xhtml::ParserImpl.new
|
|
396
|
+
when Parser::HTML4, :html4
|
|
397
|
+
Meteor::Ml::Html4::ParserImpl.new
|
|
398
|
+
when Parser::XHTML4, :xhtml4
|
|
399
|
+
Meteor::Ml::Xhtml4::ParserImpl.new
|
|
400
|
+
else
|
|
401
|
+
raise ArgumentError
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
private :new_parser
|
|
406
|
+
|
|
475
407
|
#
|
|
476
408
|
# set parser (パーサをセットする)
|
|
477
409
|
# @param [String,Symbol] key identifier (キー)
|
data/lib/meteor.rb
CHANGED
|
@@ -36,11 +36,11 @@ require "meteor/ml/xml/parser_impl"
|
|
|
36
36
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
37
37
|
#
|
|
38
38
|
# @author Yasumasa Ashida
|
|
39
|
-
# @version 0.9.
|
|
39
|
+
# @version 0.9.16
|
|
40
40
|
#
|
|
41
41
|
|
|
42
42
|
module Meteor
|
|
43
|
-
VERSION = "0.9.
|
|
43
|
+
VERSION = "0.9.16"
|
|
44
44
|
|
|
45
45
|
# require 'fileutils'
|
|
46
46
|
|