review 3.2.0 → 4.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -4
- data/.travis.yml +1 -1
- data/NEWS.ja.md +97 -1
- data/NEWS.md +97 -1
- data/bin/review-catalog-converter +1 -1
- data/bin/review-check +5 -5
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +5 -5
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +7 -7
- data/bin/review-preproc +9 -9
- data/bin/review-validate +2 -2
- data/bin/review-vol +5 -5
- data/doc/config.yml.sample +14 -6
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +15 -5
- data/doc/format.md +30 -18
- data/doc/pdfmaker.ja.md +1 -1
- data/doc/pdfmaker.md +1 -1
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +23 -63
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +5 -0
- data/lib/review/book/index.rb +26 -65
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/part.rb +22 -2
- data/lib/review/builder.rb +60 -40
- data/lib/review/catalog.rb +12 -15
- data/lib/review/compiler.rb +68 -36
- data/lib/review/configure.rb +10 -7
- data/lib/review/epubmaker.rb +5 -2
- data/lib/review/htmlbuilder.rb +24 -71
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +101 -55
- data/lib/review/idgxmlmaker.rb +184 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +110 -26
- data/lib/review/latexbuilder.rb +76 -54
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +6 -4
- data/lib/review/markdownbuilder.rb +25 -38
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +15 -15
- data/lib/review/plaintextbuilder.rb +67 -76
- data/lib/review/preprocessor.rb +13 -13
- data/lib/review/rstbuilder.rb +31 -31
- data/lib/review/textmaker.rb +13 -3
- data/lib/review/textutils.rb +77 -2
- data/lib/review/tocparser.rb +17 -17
- data/lib/review/tocprinter.rb +8 -8
- data/lib/review/topbuilder.rb +76 -57
- data/lib/review/update.rb +16 -16
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +2 -2
- data/lib/review/yamlloader.rb +3 -0
- data/review.gemspec +4 -3
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +153 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/lib/tasks/review.rake +20 -9
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/lib/tasks/review.rake +7 -7
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +6 -0
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/review-base.sty +93 -31
- data/templates/latex/review-jlreq/review-jlreq.cls +6 -0
- data/templates/latex/review-jlreq/review-style.sty +3 -0
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +65 -10
- data/templates/latex/review-jsbook/review-jsbook.cls +4 -0
- data/templates/latex/review-jsbook/review-style.sty +4 -1
- data/test/assets/test_template.tex +11 -3
- data/test/assets/test_template_backmatter.tex +11 -3
- data/test/test_book.rb +65 -19
- data/test/test_catalog.rb +18 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/test_htmlbuilder.rb +144 -55
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +60 -18
- data/test/test_image_finder.rb +6 -6
- data/test/test_latexbuilder.rb +128 -24
- data/test/test_latexbuilder_v2.rb +23 -23
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +45 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +1 -1
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_plaintextbuilder.rb +31 -6
- data/test/test_rstbuilder.rb +33 -4
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +35 -7
- data/test/test_update.rb +17 -8
- data/test/test_yamlloader.rb +13 -0
- metadata +26 -2
data/test/test_logger.rb
CHANGED
|
@@ -14,7 +14,20 @@ class LoggerTest < Test::Unit::TestCase
|
|
|
14
14
|
msg = r.readline
|
|
15
15
|
STDERR.reopen(old_stderr)
|
|
16
16
|
|
|
17
|
-
assert_equal "WARN
|
|
17
|
+
assert_equal "WARN --: test\n", msg
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_logging_with_progname
|
|
22
|
+
old_stderr = STDERR.dup
|
|
23
|
+
IO.pipe do |r, w|
|
|
24
|
+
STDERR.reopen(w)
|
|
25
|
+
@logger = ReVIEW::Logger.new(STDERR, progname: 'review-dummy-cmd')
|
|
26
|
+
@logger.warn('test')
|
|
27
|
+
msg = r.readline
|
|
28
|
+
STDERR.reopen(old_stderr)
|
|
29
|
+
|
|
30
|
+
assert_equal "WARN review-dummy-cmd: test\n", msg
|
|
18
31
|
end
|
|
19
32
|
end
|
|
20
33
|
end
|
data/test/test_makerhelper.rb
CHANGED
|
@@ -12,8 +12,8 @@ class MakerHelperTest < Test::Unit::TestCase
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def teardown
|
|
15
|
-
FileUtils.rm_rf
|
|
16
|
-
FileUtils.rm_rf
|
|
15
|
+
FileUtils.rm_rf(@tmpdir1)
|
|
16
|
+
FileUtils.rm_rf(@tmpdir2)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def test_copy_images_to_dir
|
|
@@ -34,7 +34,7 @@ class MakerHelperTest < Test::Unit::TestCase
|
|
|
34
34
|
|
|
35
35
|
def test_copy_images_to_dir_convert
|
|
36
36
|
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM && (`convert -version` rescue nil) && (`gs --version` rescue nil)
|
|
37
|
-
FileUtils.cp
|
|
37
|
+
FileUtils.cp(File.join(assets_dir, 'black.eps'), File.join(@tmpdir1, 'foo.eps'))
|
|
38
38
|
|
|
39
39
|
image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2,
|
|
40
40
|
convert: { eps: :png })
|
|
@@ -26,6 +26,17 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
|
|
|
26
26
|
>
|
|
27
27
|
> buz
|
|
28
28
|
|
|
29
|
+
EOS
|
|
30
|
+
assert_equal expected, actual
|
|
31
|
+
|
|
32
|
+
@book.config['join_lines_by_lang'] = true
|
|
33
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
|
34
|
+
expected = <<-EOS
|
|
35
|
+
|
|
36
|
+
> foo bar
|
|
37
|
+
>
|
|
38
|
+
> buz
|
|
39
|
+
|
|
29
40
|
EOS
|
|
30
41
|
assert_equal expected, actual
|
|
31
42
|
end
|
|
@@ -49,6 +60,16 @@ EOS
|
|
|
49
60
|
|
|
50
61
|
foo2bar2
|
|
51
62
|
|
|
63
|
+
EOS
|
|
64
|
+
assert_equal expected, actual
|
|
65
|
+
|
|
66
|
+
@book.config['join_lines_by_lang'] = true
|
|
67
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
68
|
+
expected = <<-EOS
|
|
69
|
+
<p class="noindent">foo bar</p>
|
|
70
|
+
|
|
71
|
+
foo2 bar2
|
|
72
|
+
|
|
52
73
|
EOS
|
|
53
74
|
assert_equal expected, actual
|
|
54
75
|
end
|
|
@@ -105,29 +126,49 @@ EOS
|
|
|
105
126
|
end
|
|
106
127
|
|
|
107
128
|
def test_dlist
|
|
108
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
|
129
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
|
109
130
|
expected = <<-EOS
|
|
110
131
|
<dl>
|
|
111
132
|
<dt>foo</dt>
|
|
112
133
|
<dd>foo.bar.</dd>
|
|
113
134
|
</dl>
|
|
135
|
+
EOS
|
|
136
|
+
assert_equal expected, actual
|
|
137
|
+
|
|
138
|
+
@book.config['join_lines_by_lang'] = true
|
|
139
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
|
140
|
+
expected = <<-EOS
|
|
141
|
+
<dl>
|
|
142
|
+
<dt>foo</dt>
|
|
143
|
+
<dd>foo. bar.</dd>
|
|
144
|
+
</dl>
|
|
114
145
|
EOS
|
|
115
146
|
assert_equal expected, actual
|
|
116
147
|
end
|
|
117
148
|
|
|
118
149
|
def test_dlist_with_bracket
|
|
119
|
-
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
|
150
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
|
120
151
|
expected = <<-EOS
|
|
121
152
|
<dl>
|
|
122
153
|
<dt>foo[bar]</dt>
|
|
123
154
|
<dd>foo.bar.</dd>
|
|
124
155
|
</dl>
|
|
156
|
+
EOS
|
|
157
|
+
assert_equal expected, actual
|
|
158
|
+
|
|
159
|
+
@book.config['join_lines_by_lang'] = true
|
|
160
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
|
161
|
+
expected = <<-EOS
|
|
162
|
+
<dl>
|
|
163
|
+
<dt>foo[bar]</dt>
|
|
164
|
+
<dd>foo. bar.</dd>
|
|
165
|
+
</dl>
|
|
125
166
|
EOS
|
|
126
167
|
assert_equal expected, actual
|
|
127
168
|
end
|
|
128
169
|
|
|
129
170
|
def test_dlist_with_comment
|
|
130
|
-
source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
|
|
171
|
+
source = " : title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
|
|
131
172
|
actual = compile_block(source)
|
|
132
173
|
expected = <<-EOS
|
|
133
174
|
<dl>
|
|
@@ -189,7 +230,7 @@ BBB
|
|
|
189
230
|
|
|
190
231
|
def test_listnum
|
|
191
232
|
def @chapter.list(_id)
|
|
192
|
-
Book::
|
|
233
|
+
Book::Index::Item.new('test', 1)
|
|
193
234
|
end
|
|
194
235
|
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n\tbuz\n//}\n")
|
|
195
236
|
expected = <<-EOS
|
data/test/test_md2inaobuilder.rb
CHANGED
|
@@ -40,12 +40,22 @@ EOS
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def test_dlist
|
|
43
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
|
43
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
|
44
44
|
expected = <<-EOS
|
|
45
45
|
<dl>
|
|
46
46
|
<dt>foo</dt>
|
|
47
47
|
<dd>foo.bar.</dd>
|
|
48
48
|
</dl>
|
|
49
|
+
EOS
|
|
50
|
+
assert_equal expected, actual
|
|
51
|
+
|
|
52
|
+
@book.config['join_lines_by_lang'] = true
|
|
53
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
|
54
|
+
expected = <<-EOS
|
|
55
|
+
<dl>
|
|
56
|
+
<dt>foo</dt>
|
|
57
|
+
<dd>foo. bar.</dd>
|
|
58
|
+
</dl>
|
|
49
59
|
EOS
|
|
50
60
|
assert_equal expected, actual
|
|
51
61
|
end
|
|
@@ -59,9 +69,9 @@ BBB
|
|
|
59
69
|
EOS
|
|
60
70
|
|
|
61
71
|
assert_equal <<-EOS, actual
|
|
62
|
-
```
|
|
63
72
|
●リスト1::caption
|
|
64
73
|
|
|
74
|
+
```
|
|
65
75
|
AAA
|
|
66
76
|
BBB
|
|
67
77
|
```
|
data/test/test_pdfmaker.rb
CHANGED
data/test/test_pdfmaker_cmd.rb
CHANGED
|
@@ -176,11 +176,19 @@ EOS
|
|
|
176
176
|
def test_paragraph
|
|
177
177
|
actual = compile_block("foo\nbar\n")
|
|
178
178
|
assert_equal %Q(foobar\n), actual
|
|
179
|
+
|
|
180
|
+
@book.config['join_lines_by_lang'] = true
|
|
181
|
+
actual = compile_block("foo\nbar\n")
|
|
182
|
+
assert_equal %Q(foo bar\n), actual
|
|
179
183
|
end
|
|
180
184
|
|
|
181
185
|
def test_tabbed_paragraph
|
|
182
186
|
actual = compile_block("\tfoo\nbar\n")
|
|
183
187
|
assert_equal %Q(\tfoobar\n), actual
|
|
188
|
+
|
|
189
|
+
@book.config['join_lines_by_lang'] = true
|
|
190
|
+
actual = compile_block("\tfoo\nbar\n")
|
|
191
|
+
assert_equal %Q(\tfoo bar\n), actual
|
|
184
192
|
end
|
|
185
193
|
|
|
186
194
|
def test_flushright
|
|
@@ -189,6 +197,15 @@ EOS
|
|
|
189
197
|
foobar
|
|
190
198
|
buz
|
|
191
199
|
|
|
200
|
+
EOS
|
|
201
|
+
assert_equal expected, actual
|
|
202
|
+
|
|
203
|
+
@book.config['join_lines_by_lang'] = true
|
|
204
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
205
|
+
expected = <<-EOS
|
|
206
|
+
foo bar
|
|
207
|
+
buz
|
|
208
|
+
|
|
192
209
|
EOS
|
|
193
210
|
assert_equal expected, actual
|
|
194
211
|
end
|
|
@@ -198,6 +215,14 @@ EOS
|
|
|
198
215
|
expected = <<-EOS
|
|
199
216
|
foobar
|
|
200
217
|
foo2bar2
|
|
218
|
+
EOS
|
|
219
|
+
assert_equal expected, actual
|
|
220
|
+
|
|
221
|
+
@book.config['join_lines_by_lang'] = true
|
|
222
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
223
|
+
expected = <<-EOS
|
|
224
|
+
foo bar
|
|
225
|
+
foo2 bar2
|
|
201
226
|
EOS
|
|
202
227
|
assert_equal expected, actual
|
|
203
228
|
end
|
|
@@ -215,7 +240,7 @@ EOS
|
|
|
215
240
|
|
|
216
241
|
def test_list
|
|
217
242
|
def @chapter.list(_id)
|
|
218
|
-
Book::
|
|
243
|
+
Book::Index::Item.new('test', 1)
|
|
219
244
|
end
|
|
220
245
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
221
246
|
expected = <<-EOS
|
|
@@ -230,7 +255,7 @@ EOS
|
|
|
230
255
|
|
|
231
256
|
def test_listnum
|
|
232
257
|
def @chapter.list(_id)
|
|
233
|
-
Book::
|
|
258
|
+
Book::Index::Item.new('test', 1)
|
|
234
259
|
end
|
|
235
260
|
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
236
261
|
expected = <<-EOS
|
|
@@ -340,7 +365,7 @@ EOS
|
|
|
340
365
|
|
|
341
366
|
def test_bib
|
|
342
367
|
def @chapter.bibpaper(_id)
|
|
343
|
-
Book::
|
|
368
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
|
344
369
|
end
|
|
345
370
|
|
|
346
371
|
assert_equal '1 ', compile_inline('@<bib>{samplebib}')
|
|
@@ -376,7 +401,7 @@ EOS
|
|
|
376
401
|
|
|
377
402
|
def test_inline_table
|
|
378
403
|
def @chapter.table(_id)
|
|
379
|
-
Book::
|
|
404
|
+
Book::Index::Item.new('sampletable', 1)
|
|
380
405
|
end
|
|
381
406
|
actual = compile_block("@<table>{sampletest}\n")
|
|
382
407
|
assert_equal "表1.1\n", actual
|
|
@@ -489,7 +514,7 @@ EOS
|
|
|
489
514
|
|
|
490
515
|
def test_image
|
|
491
516
|
def @chapter.image(_id)
|
|
492
|
-
item = Book::
|
|
517
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
|
493
518
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
494
519
|
item
|
|
495
520
|
end
|
|
@@ -500,7 +525,7 @@ EOS
|
|
|
500
525
|
|
|
501
526
|
def test_image_with_metric
|
|
502
527
|
def @chapter.image(_id)
|
|
503
|
-
item = Book::
|
|
528
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
|
504
529
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
505
530
|
item
|
|
506
531
|
end
|
data/test/test_rstbuilder.rb
CHANGED
|
@@ -207,11 +207,19 @@ EOS
|
|
|
207
207
|
def test_paragraph
|
|
208
208
|
actual = compile_block("foo\nbar\n")
|
|
209
209
|
assert_equal %Q(foobar\n\n), actual
|
|
210
|
+
|
|
211
|
+
@book.config['join_lines_by_lang'] = true
|
|
212
|
+
actual = compile_block("foo\nbar\n")
|
|
213
|
+
assert_equal %Q(foo bar\n\n), actual
|
|
210
214
|
end
|
|
211
215
|
|
|
212
216
|
def test_tabbed_paragraph
|
|
213
217
|
actual = compile_block("\tfoo\nbar\n")
|
|
214
218
|
assert_equal %Q(\tfoobar\n\n), actual
|
|
219
|
+
|
|
220
|
+
@book.config['join_lines_by_lang'] = true
|
|
221
|
+
actual = compile_block("\tfoo\nbar\n")
|
|
222
|
+
assert_equal %Q(\tfoo bar\n\n), actual
|
|
215
223
|
end
|
|
216
224
|
|
|
217
225
|
def test_flushright
|
|
@@ -222,6 +230,17 @@ EOS
|
|
|
222
230
|
foobar
|
|
223
231
|
buz
|
|
224
232
|
|
|
233
|
+
EOS
|
|
234
|
+
assert_equal expected, actual
|
|
235
|
+
|
|
236
|
+
@book.config['join_lines_by_lang'] = true
|
|
237
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
238
|
+
expected = <<-EOS
|
|
239
|
+
.. flushright::
|
|
240
|
+
|
|
241
|
+
foo bar
|
|
242
|
+
buz
|
|
243
|
+
|
|
225
244
|
EOS
|
|
226
245
|
assert_equal expected, actual
|
|
227
246
|
end
|
|
@@ -233,6 +252,16 @@ foobar
|
|
|
233
252
|
|
|
234
253
|
foo2bar2
|
|
235
254
|
|
|
255
|
+
EOS
|
|
256
|
+
assert_equal expected, actual
|
|
257
|
+
|
|
258
|
+
@book.config['join_lines_by_lang'] = true
|
|
259
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
260
|
+
expected = <<-EOS
|
|
261
|
+
foo bar
|
|
262
|
+
|
|
263
|
+
foo2 bar2
|
|
264
|
+
|
|
236
265
|
EOS
|
|
237
266
|
assert_equal expected, actual
|
|
238
267
|
end
|
|
@@ -250,7 +279,7 @@ EOS
|
|
|
250
279
|
|
|
251
280
|
def test_list
|
|
252
281
|
def @chapter.list(_id)
|
|
253
|
-
Book::
|
|
282
|
+
Book::Index::Item.new('test', 1)
|
|
254
283
|
end
|
|
255
284
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
256
285
|
expected = <<-EOS
|
|
@@ -264,7 +293,7 @@ EOS
|
|
|
264
293
|
|
|
265
294
|
def test_listnum
|
|
266
295
|
def @chapter.list(_id)
|
|
267
|
-
Book::
|
|
296
|
+
Book::Index::Item.new('test', 1)
|
|
268
297
|
end
|
|
269
298
|
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
270
299
|
expected = <<-EOS
|
|
@@ -416,7 +445,7 @@ EOS
|
|
|
416
445
|
|
|
417
446
|
def test_image
|
|
418
447
|
def @chapter.image(_id)
|
|
419
|
-
item = Book::
|
|
448
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
|
420
449
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
421
450
|
item
|
|
422
451
|
end
|
|
@@ -435,7 +464,7 @@ EOS
|
|
|
435
464
|
|
|
436
465
|
def test_image_with_metric
|
|
437
466
|
def @chapter.image(_id)
|
|
438
|
-
item = Book::
|
|
467
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
|
439
468
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
440
469
|
item
|
|
441
470
|
end
|
data/test/test_textutils.rb
CHANGED
|
@@ -6,7 +6,12 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
|
6
6
|
|
|
7
7
|
def setup
|
|
8
8
|
@tu_nil = Object.new
|
|
9
|
-
@tu_nil.extend
|
|
9
|
+
@tu_nil.extend(ReVIEW::TextUtils)
|
|
10
|
+
@tu_nil.instance_eval { @book = Book::Base.new('.') }
|
|
11
|
+
def @tu_nil.config
|
|
12
|
+
@book.config
|
|
13
|
+
end
|
|
14
|
+
|
|
10
15
|
def @tu_nil.pre_paragraph
|
|
11
16
|
nil
|
|
12
17
|
end
|
|
@@ -16,7 +21,12 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
@tu_p = Object.new
|
|
19
|
-
@tu_p.extend
|
|
24
|
+
@tu_p.extend(ReVIEW::TextUtils)
|
|
25
|
+
@tu_p.instance_eval { @book = Book::Base.new('.') }
|
|
26
|
+
def @tu_p.config
|
|
27
|
+
@book.config
|
|
28
|
+
end
|
|
29
|
+
|
|
20
30
|
def @tu_p.pre_paragraph
|
|
21
31
|
'<p>'
|
|
22
32
|
end
|
|
@@ -63,6 +73,20 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
|
63
73
|
assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
|
|
64
74
|
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
|
|
65
75
|
assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
|
|
76
|
+
|
|
77
|
+
@tu_p.config['join_lines_by_lang'] = true
|
|
78
|
+
ret = @tu_p.split_paragraph(['abc'])
|
|
79
|
+
assert_equal ['<p>abc</p>'], ret
|
|
80
|
+
ret = @tu_p.split_paragraph(['abc', 'def'])
|
|
81
|
+
assert_equal ['<p>abc def</p>'], ret
|
|
82
|
+
ret = @tu_p.split_paragraph(['abc', '', 'def'])
|
|
83
|
+
assert_equal ['<p>abc</p>', '<p>def</p>'], ret
|
|
84
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def'])
|
|
85
|
+
assert_equal ['<p>abc</p>', '<p>def</p>'], ret
|
|
86
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
|
87
|
+
assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
|
|
88
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
|
|
89
|
+
assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
|
|
66
90
|
end
|
|
67
91
|
|
|
68
92
|
def test_split_paragraph_nil
|
|
@@ -76,5 +100,88 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
|
76
100
|
assert_equal ['abc', 'def'], ret
|
|
77
101
|
ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
|
78
102
|
assert_equal ['abc', 'defghi'], ret
|
|
103
|
+
|
|
104
|
+
@tu_nil.config['join_lines_by_lang'] = true
|
|
105
|
+
ret = @tu_nil.split_paragraph(['abc'])
|
|
106
|
+
assert_equal ['abc'], ret
|
|
107
|
+
ret = @tu_nil.split_paragraph(['abc', 'def'])
|
|
108
|
+
assert_equal ['abc def'], ret
|
|
109
|
+
ret = @tu_nil.split_paragraph(['abc', '', 'def'])
|
|
110
|
+
assert_equal ['abc', 'def'], ret
|
|
111
|
+
ret = @tu_nil.split_paragraph(['abc', '', '', 'def'])
|
|
112
|
+
assert_equal ['abc', 'def'], ret
|
|
113
|
+
ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
|
114
|
+
assert_equal ['abc', 'def ghi'], ret
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_split_paragraph_p_lang
|
|
118
|
+
ret = @tu_p.split_paragraph(['I', 'have.'])
|
|
119
|
+
assert_equal ['<p>Ihave.</p>'], ret
|
|
120
|
+
ret = @tu_p.split_paragraph(['I', 'have', '.'])
|
|
121
|
+
assert_equal ['<p>Ihave.</p>'], ret
|
|
122
|
+
ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
|
|
123
|
+
assert_equal ['<p>0123a4</p>'], ret
|
|
124
|
+
ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
|
|
125
|
+
assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
|
|
126
|
+
ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
|
|
127
|
+
assert_equal ['<p>こんにちは0814日</p>'], ret
|
|
128
|
+
ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
|
|
129
|
+
assert_equal ['<p>あaい?a</p>'], ret
|
|
130
|
+
ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
|
|
131
|
+
assert_equal ['<p>안녕하세요こんにちは</p>'], ret
|
|
132
|
+
ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
|
|
133
|
+
assert_equal ['<p>Hello안녕하세요처음뵙겠습니다</p>'], ret
|
|
134
|
+
ret = @tu_p.split_paragraph([''])
|
|
135
|
+
assert_equal ['<p></p>'], ret
|
|
136
|
+
# LaTeX
|
|
137
|
+
ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
|
|
138
|
+
assert_equal ['<p>\tag{a}A\tag{b}B</p>'], ret
|
|
139
|
+
ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
|
|
140
|
+
assert_equal ['<p>\tag{あ}い\tag{う}A\tag{え}\tag{b}\tag{お}\tag{か}</p>'], ret
|
|
141
|
+
# HTML/IDGXML
|
|
142
|
+
ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
|
|
143
|
+
assert_equal ['<p><b>a</b>A<b>b</b>B</p>'], ret
|
|
144
|
+
ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
|
|
145
|
+
assert_equal ['<p><b>あ</b>い<b>う</b>A<b>え</b><b>b</b><b>お</b><b>か</b></p>'], ret
|
|
146
|
+
# Text
|
|
147
|
+
ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
|
|
148
|
+
assert_equal ['<p>★a☆A★b☆B</p>'], ret
|
|
149
|
+
ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
|
|
150
|
+
assert_equal ['<p>★あ☆い★う☆A★え☆★b☆★お☆★か☆</p>'], ret
|
|
151
|
+
|
|
152
|
+
@tu_p.config['join_lines_by_lang'] = true
|
|
153
|
+
ret = @tu_p.split_paragraph(['I', 'have.'])
|
|
154
|
+
assert_equal ['<p>I have.</p>'], ret
|
|
155
|
+
ret = @tu_p.split_paragraph(['I', 'have', '.'])
|
|
156
|
+
assert_equal ['<p>I have .</p>'], ret # ...OK? (I have. ?)
|
|
157
|
+
ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
|
|
158
|
+
assert_equal ['<p>01 23 a 4</p>'], ret
|
|
159
|
+
ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
|
|
160
|
+
assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
|
|
161
|
+
ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
|
|
162
|
+
assert_equal ['<p>こんにちは0814日</p>'], ret
|
|
163
|
+
ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
|
|
164
|
+
assert_equal ['<p>あaい? a</p>'], ret
|
|
165
|
+
ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
|
|
166
|
+
assert_equal ['<p>안녕하세요こんにちは</p>'], ret
|
|
167
|
+
ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
|
|
168
|
+
assert_equal ['<p>Hello 안녕하세요 처음뵙겠습니다</p>'], ret
|
|
169
|
+
ret = @tu_p.split_paragraph([''])
|
|
170
|
+
assert_equal ['<p></p>'], ret
|
|
171
|
+
# LaTeX
|
|
172
|
+
ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
|
|
173
|
+
assert_equal ['<p>\tag{a} A \tag{b} B</p>'], ret
|
|
174
|
+
ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
|
|
175
|
+
assert_equal ['<p>\tag{あ}い\tag{う} A \tag{え} \tag{b} \tag{お} \tag{か}</p>'], ret # ...OK? (\tag{お}\tag{か}?)
|
|
176
|
+
# HTML/IDGXML
|
|
177
|
+
ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
|
|
178
|
+
assert_equal ['<p><b>a</b> A <b>b</b> B</p>'], ret
|
|
179
|
+
ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
|
|
180
|
+
assert_equal ['<p><b>あ</b>い<b>う</b> A <b>え</b> <b>b</b> <b>お</b> <b>か</b></p>'], ret # ...OK? (<b>お</b><b>か</b>?)
|
|
181
|
+
# Text
|
|
182
|
+
ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
|
|
183
|
+
assert_equal ['<p>★a☆ A ★b☆ B</p>'], ret
|
|
184
|
+
ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
|
|
185
|
+
assert_equal ['<p>★あ☆い★う☆ A ★え☆ ★b☆ ★お☆ ★か☆</p>'], ret # ...OK? (★お☆★か☆?)
|
|
79
186
|
end
|
|
80
187
|
end
|