aozora2html 0.1.0

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.
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+ require 'aozora2html'
3
+
4
+ class JizumeTagTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(@parser).block_allowed_context?{true}
7
+ end
8
+
9
+ def test_jizume_new
10
+ tag = Jizume_tag.new(@parser,50)
11
+ assert_equal Jizume_tag, tag.class
12
+ assert_equal true, tag.kind_of?(Block_tag)
13
+ assert_equal true, tag.kind_of?(Multiline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Jizume_tag.new(@parser,50)
18
+ assert_equal "<div class=\"jizume_50\" style=\"width: 50em\">", tag.to_s
19
+ assert_equal "</div>", tag.close_tag
20
+ end
21
+
22
+ def teardown
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+ require 'stringio'
5
+
6
+ class JstreamTest < Test::Unit::TestCase
7
+ def test_new_error
8
+ strio = StringIO.new("aaa\nbbb\n")
9
+ orig_stdout = $stdout
10
+ out = StringIO.new
11
+ $stdout = out
12
+ assert_raises(SystemExit) do
13
+ Jstream.new(strio)
14
+ end
15
+ $stdout = orig_stdout
16
+ assert_equal "エラー(1行目):改行コードを、「CR+LF」にあらためてください. \r\n処理を停止します\n", out.string.encode("utf-8")
17
+ end
18
+
19
+ def test_read_char
20
+ strio = StringIO.new("aあ5\r\n%\\b\r\n".encode("Shift_JIS"))
21
+ stm = Jstream.new(strio)
22
+ assert_equal "a", stm.read_char.encode("utf-8")
23
+ assert_equal "あ", stm.read_char.encode("utf-8")
24
+ assert_equal "5", stm.read_char.encode("utf-8")
25
+ assert_equal "\r\n", stm.read_char.encode("utf-8")
26
+ assert_equal "%", stm.read_char.encode("utf-8")
27
+ assert_equal "\\", stm.read_char.encode("utf-8")
28
+ assert_equal "b", stm.read_char.encode("utf-8")
29
+ assert_equal "\r\n", stm.read_char.encode("utf-8")
30
+ assert_equal :eof, stm.read_char
31
+ assert_equal "\r\n", stm.read_char # XXX ??
32
+ assert_equal :eof, stm.read_char # XXX ??
33
+ end
34
+
35
+ def test_peek_char
36
+ strio = StringIO.new("aあ5\r\n%\\b\r\n".encode("Shift_JIS"))
37
+ stm = Jstream.new(strio)
38
+ assert_equal "a", stm.peek_char(0).encode("utf-8")
39
+ assert_equal "あ", stm.peek_char(1).encode("utf-8")
40
+ assert_equal "5", stm.peek_char(2).encode("utf-8")
41
+ assert_equal "\r\n", stm.peek_char(3).encode("utf-8")
42
+ assert_equal "\r\n", stm.peek_char(4).encode("utf-8") # XXX ??
43
+ assert_equal "\r\n", stm.peek_char(5).encode("utf-8") # XXX ??
44
+ assert_equal "\r\n", stm.peek_char(100).encode("utf-8") # XXX ??
45
+ assert_equal "a", stm.read_char.encode("utf-8")
46
+
47
+ assert_equal "あ", stm.peek_char(0).encode("utf-8")
48
+ assert_equal "あ", stm.read_char.encode("utf-8")
49
+ assert_equal "5", stm.read_char.encode("utf-8")
50
+ assert_equal "\r\n", stm.read_char.encode("utf-8")
51
+
52
+ assert_equal "%", stm.peek_char(0).encode("utf-8")
53
+ assert_equal "\\", stm.peek_char(1).encode("utf-8")
54
+ assert_equal "b", stm.peek_char(2).encode("utf-8")
55
+ assert_equal "\r\n", stm.peek_char(3).encode("utf-8")
56
+ end
57
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class KaeritenTagTest < Test::Unit::TestCase
6
+ def setup
7
+ stub(@parser).block_allowed_context?{true}
8
+ end
9
+
10
+ def test_kaeriten_new
11
+ tag = Kaeriten_tag.new(@parser,"aaa")
12
+ assert_equal Kaeriten_tag, tag.class
13
+ assert_equal true, tag.kind_of?(Inline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Kaeriten_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ assert_equal "<sub class=\"kaeriten\">テスト</sub>", tag.to_s.encode("utf-8")
19
+ end
20
+
21
+ def teardown
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+ require 'aozora2html'
3
+
4
+ class KeigakomiTagTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(@parser).block_allowed_context?{true}
7
+ end
8
+
9
+ def test_keigakomi_new
10
+ tag = Keigakomi_tag.new(@parser,2)
11
+ assert_equal Keigakomi_tag, tag.class
12
+ assert_equal true, tag.kind_of?(Block_tag)
13
+ assert_equal true, tag.kind_of?(Multiline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Keigakomi_tag.new(@parser)
18
+ assert_equal "<div class=\"keigakomi\" style=\"border: solid 1px\">", tag.to_s
19
+ assert_equal "</div>", tag.close_tag
20
+ end
21
+
22
+ def test_to_s2
23
+ tag = Keigakomi_tag.new(@parser,2)
24
+ assert_equal "<div class=\"keigakomi\" style=\"border: solid 2px\">", tag.to_s
25
+ assert_equal "</div>", tag.close_tag
26
+ end
27
+
28
+ def teardown
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+ require 'aozora2html'
3
+
4
+ class MultilineCaptionTagTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(@parser).block_allowed_context?{true}
7
+ end
8
+
9
+ def test_multiline_caption_new
10
+ tag = Multiline_caption_tag.new(@parser0)
11
+ assert_equal Multiline_caption_tag, tag.class
12
+ assert_equal true, tag.kind_of?(Block_tag)
13
+ assert_equal true, tag.kind_of?(Multiline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Multiline_caption_tag.new(@parser)
18
+ assert_equal "<div class=\"caption\">", tag.to_s
19
+ assert_equal "</div>", tag.close_tag
20
+ end
21
+
22
+ def teardown
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class MultilineMidashiTagTest < Test::Unit::TestCase
6
+ def setup
7
+ stub(@parser).block_allowed_context?{true}
8
+ stub(@parser).new_midashi_id{2}
9
+ end
10
+
11
+ def test_multiline_midashi_new
12
+ tag = Multiline_midashi_tag.new(@parser,"小".encode("shift_jis"),:normal)
13
+ assert_equal Multiline_midashi_tag, tag.class
14
+ assert_equal true, tag.kind_of?(Block_tag)
15
+ assert_equal true, tag.kind_of?(Multiline_tag)
16
+ end
17
+
18
+ def test_to_s
19
+ tag = Multiline_midashi_tag.new(@parser,"小".encode("shift_jis"),:normal)
20
+ assert_equal "<h5 class=\"ko-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\">", tag.to_s
21
+ assert_equal "</a></h5>", tag.close_tag
22
+ end
23
+
24
+ def test_to_s_chu
25
+ tag = Multiline_midashi_tag.new(@parser,"中".encode("shift_jis"),:dogyo)
26
+ assert_equal "<h4 class=\"dogyo-naka-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\">", tag.to_s
27
+ assert_equal "</a></h4>", tag.close_tag
28
+ end
29
+
30
+ def test_to_s_dai
31
+ tag = Multiline_midashi_tag.new(@parser,"大".encode("shift_jis"),:mado)
32
+ assert_equal "<h3 class=\"mado-o-midashi\"><a class=\"midashi_anchor\" id=\"midashi2\">", tag.to_s
33
+ assert_equal "</a></h3>", tag.close_tag
34
+ end
35
+
36
+ def teardown
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+ require 'aozora2html'
3
+
4
+ class MultilineStyleTagTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(@parser).block_allowed_context?{true}
7
+ end
8
+
9
+ def test_multiline_style_new
10
+ tag = Multiline_style_tag.new(@parser,"style1")
11
+ assert_equal Multiline_style_tag, tag.class
12
+ assert_equal true, tag.kind_of?(Block_tag)
13
+ assert_equal true, tag.kind_of?(Multiline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Multiline_style_tag.new(@parser,"s1")
18
+ assert_equal "<div class=\"s1\">", tag.to_s
19
+ assert_equal "</div>", tag.close_tag
20
+ end
21
+
22
+ def teardown
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+ require 'aozora2html'
3
+
4
+ class MultilineYokogumiTagTest < Test::Unit::TestCase
5
+ def setup
6
+ stub(@parser).block_allowed_context?{true}
7
+ end
8
+
9
+ def test_multiline_yokogumi_new
10
+ tag = Multiline_yokogumi_tag.new(@parser0)
11
+ assert_equal Multiline_yokogumi_tag, tag.class
12
+ assert_equal true, tag.kind_of?(Block_tag)
13
+ assert_equal true, tag.kind_of?(Multiline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Multiline_yokogumi_tag.new(@parser)
18
+ assert_equal "<div class=\"yokogumi\">", tag.to_s
19
+ assert_equal "</div>", tag.close_tag
20
+ end
21
+
22
+ def teardown
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class OkuriganaTagTest < Test::Unit::TestCase
6
+ def setup
7
+ stub(@parser).block_allowed_context?{true}
8
+ end
9
+
10
+ def test_okurigana_new
11
+ tag = Okurigana_tag.new(@parser,"aaa")
12
+ assert_equal Okurigana_tag, tag.class
13
+ assert_equal true, tag.kind_of?(Inline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Okurigana_tag.new(@parser,"テスト".encode("shift_jis"))
18
+ assert_equal "<sup class=\"okurigana\">テスト</sup>", tag.to_s.encode("utf-8")
19
+ end
20
+
21
+ def teardown
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'test_helper'
3
+ require 'aozora2html'
4
+
5
+ class RubyTagTest < Test::Unit::TestCase
6
+ def setup
7
+ stub(@parser).block_allowed_context?{true}
8
+ end
9
+
10
+ def test_ruby_new
11
+ tag = Ruby_tag.new(@parser,"aaa".encode("shift_jis"),"bb")
12
+ assert_equal Ruby_tag, tag.class
13
+ assert_equal true, tag.kind_of?(Inline_tag)
14
+ end
15
+
16
+ def test_to_s
17
+ tag = Ruby_tag.new(@parser,"テスト".encode("shift_jis"),"てすと".encode("shift_jis"))
18
+ assert_equal "<ruby><rb>テスト</rb><rp>(</rp><rt>てすと</rt><rp>)</rp></ruby>", tag.to_s.encode("utf-8")
19
+ end
20
+
21
+ def teardown
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aozora2html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - aozorahack team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit-rr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: converter from Aozora Bunko format into xhtml. It's based of t2hs.rb
98
+ from kumihan.aozora.gr.jp.
99
+ email:
100
+ - takahashimm@gmail.com
101
+ executables:
102
+ - aozora2html
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Guardfile
110
+ - README.md
111
+ - Rakefile
112
+ - aozora2html.gemspec
113
+ - bin/aozora2html
114
+ - lib/aozora2html.rb
115
+ - lib/aozora2html/version.rb
116
+ - lib/t2hs.rb
117
+ - sample/chukiichiran_kinyurei.html
118
+ - sample/chukiichiran_kinyurei.txt
119
+ - test/test_aozora2html.rb
120
+ - test/test_aozora_accent_parser.rb
121
+ - test/test_compat.rb
122
+ - test/test_dakuten_katakana_tag.rb
123
+ - test/test_decorate_tag.rb
124
+ - test/test_dir_tag.rb
125
+ - test/test_editor_note_tag.rb
126
+ - test/test_exception.rb
127
+ - test/test_font_size_tag.rb
128
+ - test/test_gaiji_tag.rb
129
+ - test/test_helper.rb
130
+ - test/test_img_tag.rb
131
+ - test/test_inline_caption_tag.rb
132
+ - test/test_inline_font_size_tag.rb
133
+ - test/test_inline_keigakomi_tag.rb
134
+ - test/test_inline_yokogumi_tag.rb
135
+ - test/test_jizume_tag.rb
136
+ - test/test_jstream.rb
137
+ - test/test_kaeriten_tag.rb
138
+ - test/test_keigakomi_tag.rb
139
+ - test/test_multiline_caption_tag.rb
140
+ - test/test_multiline_midashi_tag.rb
141
+ - test/test_multiline_style_tag.rb
142
+ - test/test_multiline_yokogumi_tag.rb
143
+ - test/test_okurigana_tag.rb
144
+ - test/test_ruby_tag.rb
145
+ homepage: https://github.com/aozorahack/aozora2html
146
+ licenses:
147
+ - CC0
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.4.5
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: converter from Aozora Bunko format into xhtml. It's based of t2hs.rb from
169
+ kumihan.aozora.gr.jp.
170
+ test_files:
171
+ - test/test_aozora2html.rb
172
+ - test/test_aozora_accent_parser.rb
173
+ - test/test_compat.rb
174
+ - test/test_dakuten_katakana_tag.rb
175
+ - test/test_decorate_tag.rb
176
+ - test/test_dir_tag.rb
177
+ - test/test_editor_note_tag.rb
178
+ - test/test_exception.rb
179
+ - test/test_font_size_tag.rb
180
+ - test/test_gaiji_tag.rb
181
+ - test/test_helper.rb
182
+ - test/test_img_tag.rb
183
+ - test/test_inline_caption_tag.rb
184
+ - test/test_inline_font_size_tag.rb
185
+ - test/test_inline_keigakomi_tag.rb
186
+ - test/test_inline_yokogumi_tag.rb
187
+ - test/test_jizume_tag.rb
188
+ - test/test_jstream.rb
189
+ - test/test_kaeriten_tag.rb
190
+ - test/test_keigakomi_tag.rb
191
+ - test/test_multiline_caption_tag.rb
192
+ - test/test_multiline_midashi_tag.rb
193
+ - test/test_multiline_style_tag.rb
194
+ - test/test_multiline_yokogumi_tag.rb
195
+ - test/test_okurigana_tag.rb
196
+ - test/test_ruby_tag.rb
197
+ has_rdoc: