meteor 0.9.8.5 → 0.9.11
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 +5 -5
- data/.gitignore +1 -1
- data/Gemfile.lock +18 -0
- data/README.md +16 -9
- data/demo/{demo_html5.rb → html.rb} +8 -4
- data/demo/{demo_html4.rb → html4.rb} +5 -5
- data/demo/ml/sample_html.html +32 -0
- data/demo/ml/sample_html4.html +40 -0
- data/demo/ml/{sample_x5.html → sample_xhtml.html} +10 -10
- data/demo/ml/{sample_x4.html → sample_xhtml4.html} +10 -10
- data/demo/{demo_xhtml5.rb → xhtml.rb} +5 -5
- data/demo/{demo_xhtml4.rb → xhtml4.rb} +4 -4
- data/demo/{demo_xml.rb → xml.rb} +5 -1
- data/lib/meteor.rb +67 -64
- data/meteor.gemspec +4 -3
- metadata +26 -29
- data/demo/ml/sample_4.html +0 -40
- data/demo/ml/sample_5.html +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 746d2cf123fdfe0e16e35b98d0db6d93a589c6969e368deb3c1fa5d1f6e6f531
|
|
4
|
+
data.tar.gz: 650b5091644a51df83332dbaf7f12f3566a831d31eb782dabd251e5b605ed7e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0ee75c46b58f1d369b7accbd40bbc3019d93946cf27baf9b5d6df4dc16e721db0c028720b57dec879d73eed009233c80108b5e2744d56f5bd9eca56b94b93a5
|
|
7
|
+
data.tar.gz: d7be7688ccdf930853534596d04e0a8617d703f17a1b1fd4ea7910eab73d080b07f3ca40dca2b1433a42317a03bbdd41435b3903ef6ac8e3b812738ee94da4a5
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
data/README.md
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
|
|
2
|
-
Meteor
|
|
2
|
+
# Meteor
|
|
3
|
+
|
|
3
4
|
==================
|
|
4
|
-
A lightweight
|
|
5
|
+
A lightweight HTML & XML Parser
|
|
5
6
|
|
|
6
7
|
```shell
|
|
7
8
|
gem install meteor #gem installation
|
|
8
9
|
```
|
|
10
|
+
|
|
9
11
|
```shell
|
|
10
|
-
#archive installation
|
|
12
|
+
# archive installation
|
|
11
13
|
gem build meteor.gemspec
|
|
12
14
|
gem install meteor-*.gem
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
## Explanation
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
This libarary is lightweight HTML parser.
|
|
17
20
|
This can use as XML parser.
|
|
18
21
|
This may be false parser.
|
|
19
22
|
|
|
20
|
-
This libarary doesn't support all of XML spec.
|
|
21
|
-
This supports a range of
|
|
23
|
+
This libarary doesn't support all of HTML & XML spec.
|
|
24
|
+
This supports a range of HTML & XML spec
|
|
22
25
|
thought to be the need routinely.
|
|
23
26
|
|
|
24
|
-
軽量(簡易?)
|
|
27
|
+
軽量(簡易?)HTMLパーサです。
|
|
25
28
|
XMLパーサとしても使用可能です。
|
|
26
29
|
パーサもどきかもしれません。
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
HTML、XMLの仕様の全てをサポートしてはいません、
|
|
29
32
|
日常的に必要と思われる範囲をサポートしています。
|
|
30
33
|
|
|
31
34
|
This doesn't convert the whole into objects but
|
|
@@ -39,19 +42,23 @@ DOMのように全体をオブジェクトのツリー構造に変換するの
|
|
|
39
42
|
必要は全くありません。)
|
|
40
43
|
|
|
41
44
|
## API
|
|
45
|
+
|
|
42
46
|
http://rubydoc.info/github/asip/meteor/frames
|
|
43
47
|
|
|
44
48
|
## Gem
|
|
49
|
+
|
|
45
50
|
https://rubygems.org/gems/meteor
|
|
46
51
|
|
|
47
52
|
## Examples
|
|
53
|
+
|
|
48
54
|
https://github.com/asip/meteor/tree/master/demo
|
|
49
55
|
|
|
50
56
|
## License
|
|
57
|
+
|
|
51
58
|
Licensed under the LGPL V2.1.
|
|
52
59
|
|
|
53
60
|
## Author
|
|
54
61
|
Yasumasa Ashida (ys.ashida@gmail.com)
|
|
55
62
|
|
|
56
63
|
## Copyright
|
|
57
|
-
(c) 2008-
|
|
64
|
+
(c) 2008-2023 Yasumasa Ashida
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
#require 'rubygems'
|
|
5
5
|
require 'meteor'
|
|
6
6
|
|
|
7
|
-
Meteor::ElementFactory.link(:
|
|
8
|
-
root = Meteor::ElementFactory.element('/ml/
|
|
7
|
+
Meteor::ElementFactory.link(:html,"ml/sample_html.html", 'UTF-8')
|
|
8
|
+
root = Meteor::ElementFactory.element('/ml/sample_html')
|
|
9
9
|
|
|
10
10
|
start_time = Time.new.to_f
|
|
11
11
|
|
|
12
12
|
elm_hello = root.element(id: 'hello')
|
|
13
|
-
elm_hello['
|
|
14
|
-
#elm_hello['
|
|
13
|
+
elm_hello['class'] = 'red' #elm_hello.attr(class: 'red')
|
|
14
|
+
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
15
15
|
|
|
16
16
|
elm_hello2 = root.element(id: 'hello2')
|
|
17
17
|
elm_hello2.content = 'Hello,Tester' #elm_hello2.content('Hello,Tester')
|
|
@@ -87,8 +87,12 @@ elms = root.elements('tr', id: 'loop')
|
|
|
87
87
|
#elms = root.elements('input', id: 'radio1', type: 'radio')
|
|
88
88
|
#elms = root.css('input[id=radio1][type=radio]')
|
|
89
89
|
elms.each{|elm|
|
|
90
|
+
puts '-------'
|
|
91
|
+
puts 'doc----'
|
|
90
92
|
puts elm.document
|
|
93
|
+
puts 'attrs--'
|
|
91
94
|
puts elm.attributes
|
|
95
|
+
puts 'mixed--'
|
|
92
96
|
puts elm.mixed_content
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
#require 'rubygems'
|
|
5
5
|
require 'meteor'
|
|
6
6
|
|
|
7
|
-
#Meteor::ElementFactory.link(:
|
|
7
|
+
#Meteor::ElementFactory.link(:html4,'ml/sample_4.html', 'UTF-8')
|
|
8
8
|
Meteor::ElementFactory.options= {type: :html4}
|
|
9
|
-
Meteor::ElementFactory.link('ml/
|
|
9
|
+
Meteor::ElementFactory.link('ml/sample_html4.html')
|
|
10
10
|
|
|
11
|
-
root = Meteor::ElementFactory.element('/ml/
|
|
11
|
+
root = Meteor::ElementFactory.element('/ml/sample_html4')
|
|
12
12
|
|
|
13
13
|
start_time = Time.new.to_f
|
|
14
14
|
|
|
15
15
|
elm_hello = root.element(id: 'hello')
|
|
16
|
-
elm_hello['
|
|
17
|
-
#elm_hello['
|
|
16
|
+
elm_hello['class'] = 'red' #elm_hello.attr(class: 'red')
|
|
17
|
+
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
18
18
|
|
|
19
19
|
elm_hello2 = root.element(id: 'hello2')
|
|
20
20
|
elm_hello2.content = 'Hello,Tester' #elm_hello2.content('Hello,Tester')
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<html lang="ja">
|
|
2
|
+
<head>
|
|
3
|
+
<title>HTMLテスト</title>
|
|
4
|
+
<meta http-equiv="Content-Type" charset="utf-8" content="text/html; charset=UTF-8">
|
|
5
|
+
</head>
|
|
6
|
+
|
|
7
|
+
<body>
|
|
8
|
+
<div id="hello" class="black">Hello,World</div>
|
|
9
|
+
<div id="hello2">Hello,World</div>
|
|
10
|
+
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
11
|
+
<form>
|
|
12
|
+
<input id="text1" name="text1" type="text">
|
|
13
|
+
|
|
14
|
+
<input id="radio1" type="radio">
|
|
15
|
+
|
|
16
|
+
<select name="select1">
|
|
17
|
+
<option id="option1">オプション</option>
|
|
18
|
+
</select>
|
|
19
|
+
|
|
20
|
+
<select id="select2">
|
|
21
|
+
<option id="option2">オプション</option>
|
|
22
|
+
</select>
|
|
23
|
+
</form>
|
|
24
|
+
|
|
25
|
+
<table>
|
|
26
|
+
<tr id="loop">
|
|
27
|
+
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
28
|
+
</tr>
|
|
29
|
+
</table>
|
|
30
|
+
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<html lang="ja">
|
|
2
|
+
<head>
|
|
3
|
+
<title>HTMLテスト</title>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
5
|
+
</head>
|
|
6
|
+
|
|
7
|
+
<body>
|
|
8
|
+
<div id="hello" class="black">Hello,World</div>
|
|
9
|
+
<div id="hello2">Hello,World</div>
|
|
10
|
+
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
11
|
+
<form>
|
|
12
|
+
<input id="text1" type="text" >
|
|
13
|
+
|
|
14
|
+
<input id="radio1" type="radio" class="test">
|
|
15
|
+
|
|
16
|
+
<select id="select1">
|
|
17
|
+
<option id="option1">オプション</option>
|
|
18
|
+
</select>
|
|
19
|
+
|
|
20
|
+
<select id="select2">
|
|
21
|
+
<option id="option2">オプション</option>
|
|
22
|
+
</select>
|
|
23
|
+
</form>
|
|
24
|
+
|
|
25
|
+
<table>
|
|
26
|
+
<tr id="loop">
|
|
27
|
+
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
28
|
+
</tr>
|
|
29
|
+
</table>
|
|
30
|
+
|
|
31
|
+
<div id="sample" style="background-color: aliceblue;" >
|
|
32
|
+
<div>test</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div id="sample2" style="background-color: aliceblue;" class="test">
|
|
36
|
+
<div>test</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="ja">
|
|
3
3
|
<head>
|
|
4
4
|
<title>HTMLテスト</title>
|
|
5
5
|
<meta http-equiv="Content-Type" charset="utf-8" content="text/html; charset=UTF-8"/>
|
|
6
6
|
</head>
|
|
7
7
|
|
|
8
|
-
<body
|
|
9
|
-
<
|
|
10
|
-
<
|
|
8
|
+
<body>
|
|
9
|
+
<div id="hello" class="black">Hello,World</div>
|
|
10
|
+
<div id="hello2">Hello,World</div>
|
|
11
11
|
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
12
12
|
<form>
|
|
13
13
|
<input id="text1" type="text" />
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
<input id="radio1" type="radio" />
|
|
16
16
|
|
|
17
17
|
<select>
|
|
18
|
-
|
|
18
|
+
<option id="option1">オプション</option>
|
|
19
19
|
</select>
|
|
20
20
|
|
|
21
21
|
<select id="select2">
|
|
22
|
-
|
|
22
|
+
<option id="option2">オプション</option>
|
|
23
23
|
</select>
|
|
24
24
|
</form>
|
|
25
25
|
|
|
26
26
|
<table>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
<tr id="loop">
|
|
28
|
+
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
29
|
+
</tr>
|
|
30
30
|
</table>
|
|
31
31
|
|
|
32
32
|
</body>
|
|
33
|
-
</html>
|
|
33
|
+
</html>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="ja">
|
|
3
3
|
<head>
|
|
4
4
|
<title>HTMLテスト</title>
|
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
6
6
|
</head>
|
|
7
7
|
|
|
8
|
-
<body
|
|
9
|
-
<
|
|
10
|
-
<
|
|
8
|
+
<body>
|
|
9
|
+
<div id="hello" class="black">Hello,World</div>
|
|
10
|
+
<div id="hello2">Hello,World</div>
|
|
11
11
|
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
12
12
|
<form>
|
|
13
13
|
<input id="text1" type="text" />
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
<input id="radio1" type="radio" />
|
|
16
16
|
|
|
17
17
|
<select>
|
|
18
|
-
|
|
18
|
+
<option id="option1">オプション</option>
|
|
19
19
|
</select>
|
|
20
20
|
|
|
21
21
|
<select id="select2">
|
|
22
|
-
|
|
22
|
+
<option id="option2">オプション</option>
|
|
23
23
|
</select>
|
|
24
24
|
</form>
|
|
25
25
|
|
|
26
26
|
<table>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
<tr id="loop">
|
|
28
|
+
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
29
|
+
</tr>
|
|
30
30
|
</table>
|
|
31
31
|
|
|
32
32
|
</body>
|
|
33
|
-
</html>
|
|
33
|
+
</html>
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
#require 'rubygems'
|
|
5
5
|
require 'meteor'
|
|
6
6
|
|
|
7
|
-
Meteor::ElementFactory.link(:
|
|
8
|
-
root = Meteor::ElementFactory.element('/ml/
|
|
7
|
+
Meteor::ElementFactory.link(:xhtml,'ml/sample_xhtml.html', 'UTF-8')
|
|
8
|
+
root = Meteor::ElementFactory.element('/ml/sample_xhtml')
|
|
9
9
|
|
|
10
10
|
startTime = Time.new.to_f
|
|
11
11
|
|
|
12
12
|
elm_hello = root.element(id: 'hello')
|
|
13
|
-
elm_hello['
|
|
14
|
-
#elm_hello['
|
|
15
|
-
#elm_hello.attr(
|
|
13
|
+
elm_hello['class'] = 'red' #elm_hello.attr(class: "red")
|
|
14
|
+
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
15
|
+
#elm_hello.attr(class: nil)
|
|
16
16
|
|
|
17
17
|
elm_hello2 = root.element(id: 'hello2')
|
|
18
18
|
elm_hello2.content = "Hello,Tester" #elm_hello2.content("Hello,Tester")
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
#require 'rubygems'
|
|
5
5
|
require 'meteor'
|
|
6
6
|
|
|
7
|
-
Meteor::ElementFactory.link(:xhtml4,'ml/
|
|
8
|
-
root = Meteor::ElementFactory.element('/ml/
|
|
7
|
+
Meteor::ElementFactory.link(:xhtml4,'ml/sample_xhtml4.html', 'UTF-8')
|
|
8
|
+
root = Meteor::ElementFactory.element('/ml/sample_xhtml4')
|
|
9
9
|
|
|
10
10
|
startTime = Time.new.to_f
|
|
11
11
|
|
|
12
12
|
elm_hello = root.element("id","hello")
|
|
13
|
-
elm_hello['
|
|
14
|
-
#elm_hello['
|
|
13
|
+
elm_hello['class'] = 'red' #elm_hello.attr(class: "red")
|
|
14
|
+
#elm_hello['class'] = nil #elm_hello.remove_attr('class')
|
|
15
15
|
|
|
16
16
|
elm_hello2 = root.element(id: "hello2")
|
|
17
17
|
elm_hello2.content = "Hello,Tester" #elm_hello2.content("Hello,Tester")
|
data/demo/{demo_xml.rb → xml.rb}
RENAMED
|
@@ -101,9 +101,13 @@ puts root.document
|
|
|
101
101
|
#elms = root.elements("potato")
|
|
102
102
|
|
|
103
103
|
elms = root.elements("test") #elms = root.css('test')
|
|
104
|
-
elms.each{|elm|
|
|
104
|
+
elms.each{|elm, i|
|
|
105
|
+
puts '-------'
|
|
106
|
+
puts 'doc----'
|
|
105
107
|
puts elm.document
|
|
108
|
+
puts 'attrs--'
|
|
106
109
|
puts elm.attributes
|
|
110
|
+
puts 'mixed--'
|
|
107
111
|
puts elm.mixed_content
|
|
108
112
|
}
|
|
109
113
|
|
data/lib/meteor.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -* coding: UTF-8 -*-
|
|
2
2
|
# Meteor - A lightweight (X)HTML(5) & XML parser
|
|
3
3
|
#
|
|
4
|
-
# Copyright (C) 2008-
|
|
4
|
+
# Copyright (C) 2008-2021 Yasumasa Ashida.
|
|
5
5
|
#
|
|
6
6
|
# This program is free software; you can redistribute it and/or modify
|
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published by
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19
19
|
#
|
|
20
20
|
# @author Yasumasa Ashida
|
|
21
|
-
# @version 0.9.
|
|
21
|
+
# @version 0.9.9.0
|
|
22
22
|
#
|
|
23
23
|
|
|
24
24
|
module Meteor
|
|
25
25
|
|
|
26
|
-
VERSION = '0.9.
|
|
26
|
+
VERSION = '0.9.11'.freeze
|
|
27
27
|
|
|
28
28
|
#require 'fileutils'
|
|
29
29
|
|
|
@@ -37,11 +37,10 @@ module Meteor
|
|
|
37
37
|
SEVEN = 7
|
|
38
38
|
|
|
39
39
|
HTML = ZERO
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
XML = FIVE
|
|
40
|
+
XHTML = ONE
|
|
41
|
+
HTML4 = TWO
|
|
42
|
+
XHTML4 = THREE
|
|
43
|
+
XML = FOUR
|
|
45
44
|
|
|
46
45
|
#
|
|
47
46
|
# Element Class (要素クラス)
|
|
@@ -242,7 +241,7 @@ module Meteor
|
|
|
242
241
|
if @document_sync
|
|
243
242
|
@document_sync = false
|
|
244
243
|
case @parser.doc_type
|
|
245
|
-
when Parser::HTML, Parser::
|
|
244
|
+
when Parser::HTML, Parser::HTML4
|
|
246
245
|
if @cx
|
|
247
246
|
#@pattern_cc = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.name << SET_CX_4
|
|
248
247
|
@document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->"
|
|
@@ -255,7 +254,7 @@ module Meteor
|
|
|
255
254
|
#@document = "<#{@name}#{@attributes}>"
|
|
256
255
|
end
|
|
257
256
|
end
|
|
258
|
-
when Parser::
|
|
257
|
+
when Parser::XHTML, Parser::XHTML4, Parser::XML
|
|
259
258
|
if @cx
|
|
260
259
|
#@pattern_cc = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.name << SET_CX_4
|
|
261
260
|
@document = "<!-- @#{@name} #{@attributes} -->#{@mixed_content}<!-- /@#{@name} -->"
|
|
@@ -777,11 +776,10 @@ module Meteor
|
|
|
777
776
|
#
|
|
778
777
|
class Parser
|
|
779
778
|
HTML = ZERO
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
XML = FIVE
|
|
779
|
+
XHTML = ONE
|
|
780
|
+
HTML4 = TWO
|
|
781
|
+
XHTML4 = THREE
|
|
782
|
+
XML = FOUR
|
|
785
783
|
end
|
|
786
784
|
|
|
787
785
|
#
|
|
@@ -1013,14 +1011,14 @@ module Meteor
|
|
|
1013
1011
|
xhtml4 = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1014
1012
|
xhtml4.read(File.expand_path(relative_path, @root), enc)
|
|
1015
1013
|
@cache[relative_url] = xhtml4
|
|
1016
|
-
when Parser::HTML, :html,
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
@cache[relative_url] =
|
|
1020
|
-
when Parser::
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
@cache[relative_url] =
|
|
1014
|
+
when Parser::HTML, :html, :html5
|
|
1015
|
+
html = Meteor::Ml::Html::ParserImpl.new
|
|
1016
|
+
html.read(File.expand_path(relative_path, @root), enc)
|
|
1017
|
+
@cache[relative_url] = html
|
|
1018
|
+
when Parser::XHTML, :xhtml, :xhtml5
|
|
1019
|
+
xhtml = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1020
|
+
xhtml.read(File.expand_path(relative_path, @root), enc)
|
|
1021
|
+
@cache[relative_url] = xhtml
|
|
1024
1022
|
when Parser::XML, :xml
|
|
1025
1023
|
xml = Meteor::Ml::Xml::ParserImpl.new
|
|
1026
1024
|
xml.read(File.expand_path(relative_path, @root), enc)
|
|
@@ -1043,12 +1041,12 @@ module Meteor
|
|
|
1043
1041
|
case type
|
|
1044
1042
|
when Parser::HTML4, :html4
|
|
1045
1043
|
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
1046
|
-
when Parser::
|
|
1044
|
+
when Parser::XHTML4, :xhtml4
|
|
1047
1045
|
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1048
|
-
when Parser::HTML, :html,
|
|
1049
|
-
ps = Meteor::Ml::
|
|
1050
|
-
when Parser::
|
|
1051
|
-
ps = Meteor::Ml::
|
|
1046
|
+
when Parser::HTML, :html, :html5
|
|
1047
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
1048
|
+
when Parser::XHTML, :xhtml, :xhtml5
|
|
1049
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1052
1050
|
when Parser::XML, :xml
|
|
1053
1051
|
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
1054
1052
|
end
|
|
@@ -1073,12 +1071,12 @@ module Meteor
|
|
|
1073
1071
|
case @type
|
|
1074
1072
|
when Parser::HTML4, :html4
|
|
1075
1073
|
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
1076
|
-
when Parser::
|
|
1074
|
+
when Parser::XHTML4, :xhtml4
|
|
1077
1075
|
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1078
|
-
when Parser::HTML, :html
|
|
1079
|
-
ps = Meteor::Ml::
|
|
1080
|
-
when Parser::
|
|
1081
|
-
ps = Meteor::Ml::
|
|
1076
|
+
when Parser::HTML, :html
|
|
1077
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
1078
|
+
when Parser::XHTML, :xhtml
|
|
1079
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1082
1080
|
when Parser::XML, :xml
|
|
1083
1081
|
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
1084
1082
|
end
|
|
@@ -1104,10 +1102,10 @@ module Meteor
|
|
|
1104
1102
|
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
1105
1103
|
when Parser::XHTML, :xhtml
|
|
1106
1104
|
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1107
|
-
when Parser::HTML, :html
|
|
1108
|
-
ps = Meteor::Ml::
|
|
1109
|
-
when Parser::
|
|
1110
|
-
ps = Meteor::Ml::
|
|
1105
|
+
when Parser::HTML, :html
|
|
1106
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
1107
|
+
when Parser::XHTML, :xhtml
|
|
1108
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1111
1109
|
when Parser::XML, :xml
|
|
1112
1110
|
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
1113
1111
|
else
|
|
@@ -1161,10 +1159,10 @@ module Meteor
|
|
|
1161
1159
|
Meteor::Ml::Html4::ParserImpl.new(@pif)
|
|
1162
1160
|
when Meteor::Parser::XHTML4
|
|
1163
1161
|
Meteor::Ml::Xhtml4::ParserImpl.new(@pif)
|
|
1164
|
-
when Meteor::Parser::HTML
|
|
1165
|
-
Meteor::Ml::
|
|
1166
|
-
when Meteor::Parser::
|
|
1167
|
-
Meteor::Ml::
|
|
1162
|
+
when Meteor::Parser::HTML
|
|
1163
|
+
Meteor::Ml::Html::ParserImpl.new(@pif)
|
|
1164
|
+
when Meteor::Parser::XHTML
|
|
1165
|
+
Meteor::Ml::Xhtml::ParserImpl.new(@pif)
|
|
1168
1166
|
when Meteor::Parser::XML
|
|
1169
1167
|
Meteor::Ml::Xml::ParserImpl.new(@pif)
|
|
1170
1168
|
end
|
|
@@ -1216,12 +1214,12 @@ module Meteor
|
|
|
1216
1214
|
case type
|
|
1217
1215
|
when Parser::HTML4, :html
|
|
1218
1216
|
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
1219
|
-
when Parser::
|
|
1217
|
+
when Parser::XHTML4, :xhtml4
|
|
1220
1218
|
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1221
|
-
when Parser::HTML, :html
|
|
1222
|
-
ps = Meteor::Ml::
|
|
1223
|
-
when Parser::
|
|
1224
|
-
ps = Meteor::Ml::
|
|
1219
|
+
when Parser::HTML, :html
|
|
1220
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
1221
|
+
when Parser::XHTML, :xhtml
|
|
1222
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1225
1223
|
when Parser::XML, :xml
|
|
1226
1224
|
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
1227
1225
|
end
|
|
@@ -1245,10 +1243,10 @@ module Meteor
|
|
|
1245
1243
|
ps = Meteor::Ml::Html4::ParserImpl.new
|
|
1246
1244
|
when Parser::XHTML, :xhtml
|
|
1247
1245
|
ps = Meteor::Ml::Xhtml4::ParserImpl.new
|
|
1248
|
-
when Parser::HTML, :html
|
|
1249
|
-
ps = Meteor::Ml::
|
|
1250
|
-
when Parser::
|
|
1251
|
-
ps = Meteor::Ml::
|
|
1246
|
+
when Parser::HTML, :html
|
|
1247
|
+
ps = Meteor::Ml::Html::ParserImpl.new
|
|
1248
|
+
when Parser::XHTML, :xhtml
|
|
1249
|
+
ps = Meteor::Ml::Xhtml::ParserImpl.new
|
|
1252
1250
|
when Parser::XML, :xml
|
|
1253
1251
|
ps = Meteor::Ml::Xml::ParserImpl.new
|
|
1254
1252
|
end
|
|
@@ -1931,6 +1929,7 @@ module Meteor
|
|
|
1931
1929
|
if @res[1]
|
|
1932
1930
|
element_without_1(name)
|
|
1933
1931
|
else
|
|
1932
|
+
#puts '---element_with_1'
|
|
1934
1933
|
element_with_1(name)
|
|
1935
1934
|
end
|
|
1936
1935
|
#else
|
|
@@ -1946,6 +1945,8 @@ module Meteor
|
|
|
1946
1945
|
@elm_ = Meteor::Element.new(name)
|
|
1947
1946
|
|
|
1948
1947
|
unless @on_search
|
|
1948
|
+
#puts '--on_search=false'
|
|
1949
|
+
#puts @res.to_a
|
|
1949
1950
|
#属性
|
|
1950
1951
|
@elm_.attributes = @res[2]
|
|
1951
1952
|
#内容
|
|
@@ -1953,6 +1954,7 @@ module Meteor
|
|
|
1953
1954
|
#全体
|
|
1954
1955
|
@elm_.document = @res[0]
|
|
1955
1956
|
else
|
|
1957
|
+
#puts '--on_search=true'
|
|
1956
1958
|
#属性
|
|
1957
1959
|
@elm_.attributes = @res[1]
|
|
1958
1960
|
#内容
|
|
@@ -3099,12 +3101,13 @@ module Meteor
|
|
|
3099
3101
|
|
|
3100
3102
|
@element_cache.store(@elm_.object_id, @elm_)
|
|
3101
3103
|
|
|
3102
|
-
@on_search = false
|
|
3103
3104
|
#else
|
|
3104
3105
|
# break
|
|
3105
3106
|
#end
|
|
3106
3107
|
end
|
|
3107
|
-
|
|
3108
|
+
|
|
3109
|
+
@on_search = false
|
|
3110
|
+
|
|
3108
3111
|
elm_arr
|
|
3109
3112
|
end
|
|
3110
3113
|
|
|
@@ -3893,10 +3896,10 @@ module Meteor
|
|
|
3893
3896
|
Meteor::Ml::Html4::ParserImpl.new
|
|
3894
3897
|
when Parser::XHTML4
|
|
3895
3898
|
Meteor::Ml::Xhtml4::ParserImpl.new
|
|
3896
|
-
when Parser::HTML
|
|
3897
|
-
Meteor::Ml::
|
|
3898
|
-
when Parser::
|
|
3899
|
-
Meteor::Ml::
|
|
3899
|
+
when Parser::HTML
|
|
3900
|
+
Meteor::Ml::Html::ParserImpl.new
|
|
3901
|
+
when Parser::XHTML
|
|
3902
|
+
Meteor::Ml::Xhtml::ParserImpl.new
|
|
3900
3903
|
when Parser::XML
|
|
3901
3904
|
Meteor::Ml::Xml::ParserImpl.new
|
|
3902
3905
|
else
|
|
@@ -4676,7 +4679,7 @@ module Meteor
|
|
|
4676
4679
|
|
|
4677
4680
|
def escape(content)
|
|
4678
4681
|
#特殊文字の置換
|
|
4679
|
-
content.gsub
|
|
4682
|
+
content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
|
|
4680
4683
|
|
|
4681
4684
|
content
|
|
4682
4685
|
end
|
|
@@ -5116,7 +5119,7 @@ module Meteor
|
|
|
5116
5119
|
|
|
5117
5120
|
def escape(content)
|
|
5118
5121
|
#特殊文字の置換
|
|
5119
|
-
content.gsub
|
|
5122
|
+
content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
|
|
5120
5123
|
|
|
5121
5124
|
content
|
|
5122
5125
|
end
|
|
@@ -5176,10 +5179,10 @@ module Meteor
|
|
|
5176
5179
|
|
|
5177
5180
|
end
|
|
5178
5181
|
|
|
5179
|
-
module
|
|
5182
|
+
module Html
|
|
5180
5183
|
|
|
5181
5184
|
#
|
|
5182
|
-
#
|
|
5185
|
+
# HTML parser (HTMLパーサ)
|
|
5183
5186
|
#
|
|
5184
5187
|
class ParserImpl < Meteor::Ml::Html4::ParserImpl
|
|
5185
5188
|
|
|
@@ -5215,7 +5218,7 @@ module Meteor
|
|
|
5215
5218
|
@@match_tag = MATCH_TAG
|
|
5216
5219
|
@@match_tag_sng = MATCH_TAG_SNG
|
|
5217
5220
|
@@attr_logic = ATTR_LOGIC
|
|
5218
|
-
@doc_type = Parser::
|
|
5221
|
+
@doc_type = Parser::HTML
|
|
5219
5222
|
case args.length
|
|
5220
5223
|
when ZERO
|
|
5221
5224
|
#initialize_0
|
|
@@ -5320,10 +5323,10 @@ module Meteor
|
|
|
5320
5323
|
|
|
5321
5324
|
end
|
|
5322
5325
|
|
|
5323
|
-
module
|
|
5326
|
+
module Xhtml
|
|
5324
5327
|
|
|
5325
5328
|
#
|
|
5326
|
-
#
|
|
5329
|
+
# XHTML parser (XHTMLパーサ)
|
|
5327
5330
|
#
|
|
5328
5331
|
class ParserImpl < Meteor::Ml::Xhtml4::ParserImpl
|
|
5329
5332
|
|
|
@@ -5355,7 +5358,7 @@ module Meteor
|
|
|
5355
5358
|
def initialize(*args)
|
|
5356
5359
|
super()
|
|
5357
5360
|
@@attr_logic = ATTR_LOGIC
|
|
5358
|
-
@doc_type = Parser::
|
|
5361
|
+
@doc_type = Parser::XHTML
|
|
5359
5362
|
case args.length
|
|
5360
5363
|
when ZERO
|
|
5361
5364
|
#initialize_0
|
data/meteor.gemspec
CHANGED
|
@@ -11,15 +11,16 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.description = %q{A lightweight (X)HTML(5) & XML parser}
|
|
12
12
|
spec.summary = %q{A lightweight (X)HTML(5) & XML parser}
|
|
13
13
|
spec.homepage = %q{https://github.com/asip/meteor}
|
|
14
|
-
spec.license = 'LGPL-2.1'
|
|
14
|
+
spec.license = 'LGPL-2.1-only'
|
|
15
|
+
|
|
16
|
+
spec.required_ruby_version = ">=3.0"
|
|
15
17
|
|
|
16
18
|
spec.files = `git ls-files`.split($/)
|
|
17
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features|demo)/})
|
|
19
21
|
spec.require_paths = ["lib"]
|
|
20
22
|
|
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
|
22
24
|
#spec.add_development_dependency "rake"
|
|
23
|
-
spec.has_rdoc = 'yard'
|
|
24
25
|
|
|
25
26
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: meteor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yasumasa Ashida
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '2.2'
|
|
20
19
|
type: :development
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '2.2'
|
|
27
26
|
description: A lightweight (X)HTML(5) & XML parser
|
|
28
27
|
email: ys.ashida@gmail.com
|
|
29
28
|
executables: []
|
|
@@ -33,27 +32,27 @@ files:
|
|
|
33
32
|
- ".gitignore"
|
|
34
33
|
- ChangeLog
|
|
35
34
|
- Gemfile
|
|
35
|
+
- Gemfile.lock
|
|
36
36
|
- README.md
|
|
37
37
|
- Rakefile
|
|
38
|
-
- demo/
|
|
39
|
-
- demo/
|
|
40
|
-
- demo/demo_xhtml4.rb
|
|
41
|
-
- demo/demo_xhtml5.rb
|
|
42
|
-
- demo/demo_xml.rb
|
|
38
|
+
- demo/html.rb
|
|
39
|
+
- demo/html4.rb
|
|
43
40
|
- demo/ml/sample.xml
|
|
44
|
-
- demo/ml/
|
|
45
|
-
- demo/ml/
|
|
46
|
-
- demo/ml/
|
|
47
|
-
- demo/ml/
|
|
41
|
+
- demo/ml/sample_html.html
|
|
42
|
+
- demo/ml/sample_html4.html
|
|
43
|
+
- demo/ml/sample_xhtml.html
|
|
44
|
+
- demo/ml/sample_xhtml4.html
|
|
45
|
+
- demo/xhtml.rb
|
|
46
|
+
- demo/xhtml4.rb
|
|
47
|
+
- demo/xml.rb
|
|
48
48
|
- lib/meteor.rb
|
|
49
49
|
- meteor.gemspec
|
|
50
50
|
- test/meteor_test.rb
|
|
51
51
|
- test/test_helper.rb
|
|
52
52
|
homepage: https://github.com/asip/meteor
|
|
53
53
|
licenses:
|
|
54
|
-
- LGPL-2.1
|
|
54
|
+
- LGPL-2.1-only
|
|
55
55
|
metadata: {}
|
|
56
|
-
post_install_message:
|
|
57
56
|
rdoc_options: []
|
|
58
57
|
require_paths:
|
|
59
58
|
- lib
|
|
@@ -61,28 +60,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
61
60
|
requirements:
|
|
62
61
|
- - ">="
|
|
63
62
|
- !ruby/object:Gem::Version
|
|
64
|
-
version: '0'
|
|
63
|
+
version: '3.0'
|
|
65
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
65
|
requirements:
|
|
67
66
|
- - ">="
|
|
68
67
|
- !ruby/object:Gem::Version
|
|
69
68
|
version: '0'
|
|
70
69
|
requirements: []
|
|
71
|
-
|
|
72
|
-
rubygems_version: 2.6.8
|
|
73
|
-
signing_key:
|
|
70
|
+
rubygems_version: 3.6.9
|
|
74
71
|
specification_version: 4
|
|
75
72
|
summary: A lightweight (X)HTML(5) & XML parser
|
|
76
73
|
test_files:
|
|
77
|
-
- demo/
|
|
78
|
-
- demo/
|
|
79
|
-
- demo/demo_xhtml4.rb
|
|
80
|
-
- demo/demo_xhtml5.rb
|
|
81
|
-
- demo/demo_xml.rb
|
|
74
|
+
- demo/html.rb
|
|
75
|
+
- demo/html4.rb
|
|
82
76
|
- demo/ml/sample.xml
|
|
83
|
-
- demo/ml/
|
|
84
|
-
- demo/ml/
|
|
85
|
-
- demo/ml/
|
|
86
|
-
- demo/ml/
|
|
77
|
+
- demo/ml/sample_html.html
|
|
78
|
+
- demo/ml/sample_html4.html
|
|
79
|
+
- demo/ml/sample_xhtml.html
|
|
80
|
+
- demo/ml/sample_xhtml4.html
|
|
81
|
+
- demo/xhtml.rb
|
|
82
|
+
- demo/xhtml4.rb
|
|
83
|
+
- demo/xml.rb
|
|
87
84
|
- test/meteor_test.rb
|
|
88
85
|
- test/test_helper.rb
|
data/demo/ml/sample_4.html
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>HTMLテスト</title>
|
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
5
|
-
</head>
|
|
6
|
-
|
|
7
|
-
<body bgcolor="#FFFFFF" text="#000000">
|
|
8
|
-
<font id="hello" color="#000000">Hello,World</font>
|
|
9
|
-
<font id="hello2">Hello,World</font>
|
|
10
|
-
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
11
|
-
<form>
|
|
12
|
-
<input id="text1" type="text" >
|
|
13
|
-
|
|
14
|
-
<input id="radio1" type="radio" class="test">
|
|
15
|
-
|
|
16
|
-
<select id="select1">
|
|
17
|
-
<option id="option1">オプション</option>
|
|
18
|
-
</select>
|
|
19
|
-
|
|
20
|
-
<select id="select2">
|
|
21
|
-
<option id="option2">オプション</option>
|
|
22
|
-
</select>
|
|
23
|
-
</form>
|
|
24
|
-
|
|
25
|
-
<table>
|
|
26
|
-
<tr id="loop">
|
|
27
|
-
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
28
|
-
</tr>
|
|
29
|
-
</table>
|
|
30
|
-
|
|
31
|
-
<div id="sample" style="test" >
|
|
32
|
-
<div>test</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div id="sample" style="test" class="test">
|
|
36
|
-
<div>test</div>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
</body>
|
|
40
|
-
</html>
|
data/demo/ml/sample_5.html
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>HTMLテスト</title>
|
|
4
|
-
<meta http-equiv="Content-Type" charset="utf-8" content="text/html; charset=UTF-8">
|
|
5
|
-
</head>
|
|
6
|
-
|
|
7
|
-
<body bgcolor="#FFFFFF" text="#000000">
|
|
8
|
-
<font id="hello" color="#000000">Hello,World</font>
|
|
9
|
-
<font id="hello2">Hello,World</font>
|
|
10
|
-
<!-- @quark id="hello3" -->Hello,World<!-- /@quark -->
|
|
11
|
-
<form>
|
|
12
|
-
<input id="text1" type="text" >
|
|
13
|
-
|
|
14
|
-
<input id="radio1" type="radio">
|
|
15
|
-
|
|
16
|
-
<select>
|
|
17
|
-
<option id="option1">オプション</option>
|
|
18
|
-
</select>
|
|
19
|
-
|
|
20
|
-
<select id="select2">
|
|
21
|
-
<option id="option2">オプション</option>
|
|
22
|
-
</select>
|
|
23
|
-
</form>
|
|
24
|
-
|
|
25
|
-
<table>
|
|
26
|
-
<tr id="loop">
|
|
27
|
-
<td id="aa"></td><td id="bb"></td><td id="cc"></td>
|
|
28
|
-
</tr>
|
|
29
|
-
</table>
|
|
30
|
-
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|