review 4.2.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-win.yml +11 -5
- data/.rubocop.yml +113 -24
- data/NEWS.ja.md +94 -0
- data/NEWS.md +94 -0
- data/bin/review-catalog-converter +1 -1
- data/bin/review-check +2 -4
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +8 -14
- data/bin/review-validate +1 -1
- data/doc/config.yml.sample +4 -1
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +83 -4
- data/doc/format.md +84 -7
- data/doc/makeindex.ja.md +2 -2
- data/doc/quickstart.ja.md +3 -3
- data/doc/quickstart.md +2 -2
- data/lib/epubmaker/content.rb +3 -2
- data/lib/epubmaker/epubcommon.rb +33 -25
- data/lib/epubmaker/epubv2.rb +5 -6
- data/lib/epubmaker/epubv3.rb +20 -18
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +61 -25
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +155 -0
- data/lib/review/book/chapter.rb +30 -26
- data/lib/review/book/index.rb +23 -185
- data/lib/review/book/index/item.rb +7 -1
- data/lib/review/book/part.rb +21 -9
- data/lib/review/book/volume.rb +1 -1
- data/lib/review/builder.rb +68 -13
- data/lib/review/catalog.rb +2 -2
- data/lib/review/compiler.rb +159 -73
- data/lib/review/configure.rb +22 -1
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +12 -23
- data/lib/review/htmlbuilder.rb +36 -7
- data/lib/review/htmlutils.rb +7 -10
- data/lib/review/i18n.rb +1 -1
- data/lib/review/idgxmlbuilder.rb +51 -6
- data/lib/review/idgxmlmaker.rb +9 -14
- data/lib/review/index_builder.rb +653 -0
- data/lib/review/init.rb +5 -13
- data/lib/review/latexbuilder.rb +65 -4
- data/lib/review/logger.rb +2 -2
- data/lib/review/makerhelper.rb +11 -0
- data/lib/review/markdownbuilder.rb +19 -1
- data/lib/review/pdfmaker.rb +17 -36
- data/lib/review/plaintextbuilder.rb +48 -2
- data/lib/review/preprocessor.rb +5 -5
- data/lib/review/rstbuilder.rb +25 -6
- data/lib/review/sec_counter.rb +13 -0
- data/lib/review/textmaker.rb +4 -12
- data/lib/review/tocprinter.rb +2 -3
- data/lib/review/topbuilder.rb +26 -0
- data/lib/review/update.rb +7 -7
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +2 -3
- data/lib/review/webmaker.rb +9 -20
- data/review.gemspec +2 -2
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/config.yml +1 -1
- data/templates/latex/config.erb +27 -23
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +31 -15
- data/templates/latex/review-jlreq/review-jlreq.cls +8 -24
- data/templates/latex/review-jsbook/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +34 -16
- data/templates/latex/review-jsbook/review-jsbook.cls +4 -2
- data/templates/web/html/layout-html5.html.erb +1 -1
- data/test/assets/test_template.tex +3 -3
- data/test/assets/test_template_backmatter.tex +3 -3
- data/test/book_test_helper.rb +11 -5
- data/test/test_book.rb +54 -63
- data/test/test_book_chapter.rb +93 -52
- data/test/test_builder.rb +24 -15
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +2 -2
- data/test/test_epubmaker.rb +8 -0
- data/test/test_helper.rb +4 -1
- data/test/test_htmlbuilder.rb +627 -56
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +358 -11
- data/test/test_idgxmlmaker_cmd.rb +1 -1
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +547 -10
- data/test/test_latexbuilder_v2.rb +43 -5
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +3 -0
- data/test/test_pdfmaker.rb +13 -12
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_plaintextbuilder.rb +422 -7
- data/test/test_review_ext.rb +2 -1
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +187 -10
- data/test/test_update.rb +10 -10
- data/test/test_webtocprinter.rb +12 -12
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +22 -18
- data/vendor/jsclasses/jis/jsbook.cls +22 -18
- data/vendor/jsclasses/jis/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +1 -13
- data/vendor/jsclasses/jis/jspf.cls +22 -18
- data/vendor/jsclasses/jis/jsreport.cls +22 -18
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +22 -18
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +1 -13
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +22 -18
- data/vendor/jsclasses/jsbook.cls +22 -18
- data/vendor/jsclasses/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +1 -13
- data/vendor/jsclasses/jspf.cls +22 -18
- data/vendor/jsclasses/jsreport.cls +22 -18
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +22 -18
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +1 -13
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +14 -6
- data/.rubocop_todo.yml +0 -7
- data/lib/review/book/compilable.rb +0 -174
@@ -229,6 +229,10 @@ EOS
|
|
229
229
|
|
230
230
|
@config['secnolevel'] = 3
|
231
231
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
232
|
+
assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
|
233
|
+
|
234
|
+
@config['chapterlink'] = nil
|
235
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
232
236
|
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
233
237
|
end
|
234
238
|
|
@@ -662,9 +666,11 @@ EOS
|
|
662
666
|
expected = <<-EOS
|
663
667
|
\\begin{reviewminicolumn}
|
664
668
|
\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}
|
669
|
+
|
665
670
|
test1
|
666
671
|
|
667
672
|
test\\textit{2}
|
673
|
+
|
668
674
|
\\end{reviewminicolumn}
|
669
675
|
EOS
|
670
676
|
assert_equal expected, actual
|
@@ -1285,13 +1291,17 @@ EOS
|
|
1285
1291
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1286
1292
|
expected = <<-EOS
|
1287
1293
|
\\begin{reviewminicolumn}
|
1294
|
+
|
1288
1295
|
A
|
1289
1296
|
|
1290
1297
|
B
|
1298
|
+
|
1291
1299
|
\\end{reviewminicolumn}
|
1292
1300
|
\\begin{reviewminicolumn}
|
1293
1301
|
\\reviewminicolumntitle{caption}
|
1302
|
+
|
1294
1303
|
A
|
1304
|
+
|
1295
1305
|
\\end{reviewminicolumn}
|
1296
1306
|
EOS
|
1297
1307
|
assert_equal expected, actual
|
@@ -1299,13 +1309,17 @@ EOS
|
|
1299
1309
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1300
1310
|
expected = <<-EOS
|
1301
1311
|
\\begin{reviewminicolumn}
|
1312
|
+
|
1302
1313
|
A
|
1303
1314
|
|
1304
1315
|
B
|
1316
|
+
|
1305
1317
|
\\end{reviewminicolumn}
|
1306
1318
|
\\begin{reviewminicolumn}
|
1307
1319
|
\\reviewminicolumntitle{caption}
|
1320
|
+
|
1308
1321
|
A
|
1322
|
+
|
1309
1323
|
\\end{reviewminicolumn}
|
1310
1324
|
EOS
|
1311
1325
|
assert_equal expected, actual
|
@@ -1313,13 +1327,17 @@ EOS
|
|
1313
1327
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1314
1328
|
expected = <<-EOS
|
1315
1329
|
\\begin{reviewminicolumn}
|
1330
|
+
|
1316
1331
|
A
|
1317
1332
|
|
1318
1333
|
B
|
1334
|
+
|
1319
1335
|
\\end{reviewminicolumn}
|
1320
1336
|
\\begin{reviewminicolumn}
|
1321
1337
|
\\reviewminicolumntitle{caption}
|
1338
|
+
|
1322
1339
|
A
|
1340
|
+
|
1323
1341
|
\\end{reviewminicolumn}
|
1324
1342
|
EOS
|
1325
1343
|
assert_equal expected, actual
|
@@ -1327,13 +1345,17 @@ EOS
|
|
1327
1345
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1328
1346
|
expected = <<-EOS
|
1329
1347
|
\\begin{reviewminicolumn}
|
1348
|
+
|
1330
1349
|
A
|
1331
1350
|
|
1332
1351
|
B
|
1352
|
+
|
1333
1353
|
\\end{reviewminicolumn}
|
1334
1354
|
\\begin{reviewminicolumn}
|
1335
1355
|
\\reviewminicolumntitle{caption}
|
1356
|
+
|
1336
1357
|
A
|
1358
|
+
|
1337
1359
|
\\end{reviewminicolumn}
|
1338
1360
|
EOS
|
1339
1361
|
assert_equal expected, actual
|
@@ -1341,13 +1363,17 @@ EOS
|
|
1341
1363
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1342
1364
|
expected = <<-EOS
|
1343
1365
|
\\begin{reviewminicolumn}
|
1366
|
+
|
1344
1367
|
A
|
1345
1368
|
|
1346
1369
|
B
|
1370
|
+
|
1347
1371
|
\\end{reviewminicolumn}
|
1348
1372
|
\\begin{reviewminicolumn}
|
1349
1373
|
\\reviewminicolumntitle{caption}
|
1374
|
+
|
1350
1375
|
A
|
1376
|
+
|
1351
1377
|
\\end{reviewminicolumn}
|
1352
1378
|
EOS
|
1353
1379
|
assert_equal expected, actual
|
@@ -1355,13 +1381,17 @@ EOS
|
|
1355
1381
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1356
1382
|
expected = <<-EOS
|
1357
1383
|
\\begin{reviewminicolumn}
|
1384
|
+
|
1358
1385
|
A
|
1359
1386
|
|
1360
1387
|
B
|
1388
|
+
|
1361
1389
|
\\end{reviewminicolumn}
|
1362
1390
|
\\begin{reviewminicolumn}
|
1363
1391
|
\\reviewminicolumntitle{caption}
|
1392
|
+
|
1364
1393
|
A
|
1394
|
+
|
1365
1395
|
\\end{reviewminicolumn}
|
1366
1396
|
EOS
|
1367
1397
|
assert_equal expected, actual
|
@@ -1369,13 +1399,17 @@ EOS
|
|
1369
1399
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1370
1400
|
expected = <<-EOS
|
1371
1401
|
\\begin{reviewminicolumn}
|
1402
|
+
|
1372
1403
|
A
|
1373
1404
|
|
1374
1405
|
B
|
1406
|
+
|
1375
1407
|
\\end{reviewminicolumn}
|
1376
1408
|
\\begin{reviewminicolumn}
|
1377
1409
|
\\reviewminicolumntitle{caption}
|
1410
|
+
|
1378
1411
|
A
|
1412
|
+
|
1379
1413
|
\\end{reviewminicolumn}
|
1380
1414
|
EOS
|
1381
1415
|
assert_equal expected, actual
|
@@ -1383,13 +1417,17 @@ EOS
|
|
1383
1417
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1384
1418
|
expected = <<-EOS
|
1385
1419
|
\\begin{reviewminicolumn}
|
1420
|
+
|
1386
1421
|
A
|
1387
1422
|
|
1388
1423
|
B
|
1424
|
+
|
1389
1425
|
\\end{reviewminicolumn}
|
1390
1426
|
\\begin{reviewminicolumn}
|
1391
1427
|
\\reviewminicolumntitle{caption}
|
1428
|
+
|
1392
1429
|
A
|
1430
|
+
|
1393
1431
|
\\end{reviewminicolumn}
|
1394
1432
|
EOS
|
1395
1433
|
assert_equal expected, actual
|
@@ -1506,18 +1544,18 @@ EOS
|
|
1506
1544
|
end
|
1507
1545
|
|
1508
1546
|
def test_inline_unknown
|
1509
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1547
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1510
1548
|
assert_equal ':1: error: unknown image: n', e.message
|
1511
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1549
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1512
1550
|
assert_equal ':1: error: unknown footnote: n', e.message
|
1513
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1551
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1514
1552
|
assert_equal ':1: error: unknown headline: n', e.message
|
1515
1553
|
%w[list table column].each do |name|
|
1516
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1554
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1517
1555
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
1518
1556
|
end
|
1519
1557
|
%w[chap chapref title].each do |name|
|
1520
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1558
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1521
1559
|
assert_equal ':1: error: key not found: "n"', e.message
|
1522
1560
|
end
|
1523
1561
|
end
|
data/test/test_logger.rb
CHANGED
@@ -6,26 +6,26 @@ class LoggerTest < Test::Unit::TestCase
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_logging
|
9
|
-
old_stderr =
|
9
|
+
old_stderr = $stderr.dup
|
10
10
|
IO.pipe do |r, w|
|
11
|
-
|
11
|
+
$stderr.reopen(w)
|
12
12
|
@logger = ReVIEW::Logger.new
|
13
13
|
@logger.warn('test')
|
14
14
|
msg = r.readline
|
15
|
-
|
15
|
+
$stderr.reopen(old_stderr)
|
16
16
|
|
17
17
|
assert_equal "WARN --: test\n", msg
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_logging_with_progname
|
22
|
-
old_stderr =
|
22
|
+
old_stderr = $stderr.dup
|
23
23
|
IO.pipe do |r, w|
|
24
|
-
|
25
|
-
@logger = ReVIEW::Logger.new(
|
24
|
+
$stderr.reopen(w)
|
25
|
+
@logger = ReVIEW::Logger.new($stderr, progname: 'review-dummy-cmd')
|
26
26
|
@logger.warn('test')
|
27
27
|
msg = r.readline
|
28
|
-
|
28
|
+
$stderr.reopen(old_stderr)
|
29
29
|
|
30
30
|
assert_equal "WARN review-dummy-cmd: test\n", msg
|
31
31
|
end
|
data/test/test_makerhelper.rb
CHANGED
@@ -32,18 +32,6 @@ class MakerHelperTest < Test::Unit::TestCase
|
|
32
32
|
assert image_files.include?(File.join(@tmpdir1, 'subdir/foo.png'))
|
33
33
|
end
|
34
34
|
|
35
|
-
def test_copy_images_to_dir_convert
|
36
|
-
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM && (`convert -version` rescue nil) && (`gs --version` rescue nil)
|
37
|
-
FileUtils.cp(File.join(assets_dir, 'black.eps'), File.join(@tmpdir1, 'foo.eps'))
|
38
|
-
|
39
|
-
image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2,
|
40
|
-
convert: { eps: :png })
|
41
|
-
|
42
|
-
assert File.exist?(File.join(@tmpdir2, 'foo.eps.png')), 'EPS to PNG conversion failed'
|
43
|
-
assert image_files.include?(File.join(@tmpdir1, 'foo.eps.png'))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
35
|
def test_copy_images_to_dir_with_exts
|
48
36
|
types = %w[png gif jpg jpeg svg pdf eps]
|
49
37
|
types4epub = %w[png gif jpg jpeg svg]
|
@@ -16,6 +16,7 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
|
|
16
16
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
17
17
|
location = Location.new(nil, nil)
|
18
18
|
@builder.bind(@compiler, @chapter, location)
|
19
|
+
I18n.setup(@config['language'])
|
19
20
|
end
|
20
21
|
|
21
22
|
def test_quote
|
@@ -47,7 +48,9 @@ EOS
|
|
47
48
|
<div class="memo">
|
48
49
|
<p class="caption">this is **test**<&>_</p>
|
49
50
|
test1
|
51
|
+
|
50
52
|
test*2*
|
53
|
+
|
51
54
|
</div>
|
52
55
|
EOS
|
53
56
|
assert_equal expected, actual
|
data/test/test_pdfmaker.rb
CHANGED
@@ -10,9 +10,10 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
10
10
|
@config.merge!(
|
11
11
|
'bookname' => 'sample',
|
12
12
|
'title' => 'Sample Book',
|
13
|
-
'
|
13
|
+
'aut' => 'anonymous',
|
14
|
+
'review_version' => 4,
|
14
15
|
'urnid' => 'http://example.jp/',
|
15
|
-
'date' => '
|
16
|
+
'date' => '2020-07-11',
|
16
17
|
'language' => 'ja',
|
17
18
|
'texcommand' => 'uplatex'
|
18
19
|
)
|
@@ -75,7 +76,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
75
76
|
Dir.mktmpdir do |dir|
|
76
77
|
coverfile = 'cover.html'
|
77
78
|
content = '<html><body>test</body></html>'
|
78
|
-
File.
|
79
|
+
File.write(File.join(dir, 'cover.tex'), content)
|
79
80
|
page = @maker.make_custom_page(File.join(dir, coverfile))
|
80
81
|
assert_equal(content, page)
|
81
82
|
end
|
@@ -144,7 +145,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
144
145
|
@maker.erb_config
|
145
146
|
tmpl = @maker.template_content
|
146
147
|
expect = File.read(File.join(assets_dir, 'test_template.tex'))
|
147
|
-
expect.gsub!(/\\def\\review@reviewversion{[
|
148
|
+
expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
|
148
149
|
assert_equal(expect, tmpl)
|
149
150
|
end
|
150
151
|
end
|
@@ -159,7 +160,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
159
160
|
@maker.erb_config
|
160
161
|
tmpl = @maker.template_content
|
161
162
|
expect = File.read(File.join(assets_dir, 'test_template.tex'))
|
162
|
-
expect.gsub!(/\\def\\review@reviewversion{[
|
163
|
+
expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
|
163
164
|
expect.sub!("\\makeatother\n", '\&' + "%% BEGIN: config-local.tex.erb\n\\def\\customvalue{\\#\\textunderscore{}TEST\\textunderscore{}}\n%% END: config-local.tex.erb\n")
|
164
165
|
assert_equal(expect, tmpl)
|
165
166
|
end
|
@@ -175,13 +176,13 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
175
176
|
Dir.mktmpdir do |dir|
|
176
177
|
Dir.chdir(dir) do
|
177
178
|
profile = "\\thispagestyle{empty}\\chapter*{Profile}\nsome profile\n"
|
178
|
-
File.
|
179
|
+
File.write(File.join(dir, 'profile.tex'), profile)
|
179
180
|
advfile = "\\thispagestyle{empty}\\chapter*{Ad}\nsome ad content\n"
|
180
|
-
File.
|
181
|
+
File.write(File.join(dir, 'advfile.tex'), advfile)
|
181
182
|
backcover = "\\clearpage\n\\thispagestyle{empty}\\AddToShipoutPictureBG{%\n\\AtPageLowerLeft{\\includegraphics[width=\\paperwidth,height=\\paperheight]{images/backcover.png}}\n}\n\\null"
|
182
|
-
File.
|
183
|
+
File.write(File.join(dir, 'backcover.tex'), backcover)
|
183
184
|
expect = File.read(File.join(assets_dir, 'test_template_backmatter.tex'))
|
184
|
-
expect.gsub!(/\\def\\review@reviewversion{[
|
185
|
+
expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
|
185
186
|
@maker.basedir = Dir.pwd
|
186
187
|
@maker.erb_config
|
187
188
|
tmpl = @maker.template_content
|
@@ -196,7 +197,7 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
196
197
|
@config['pht'] = ['Mrs.Smith']
|
197
198
|
@config['language'] = 'ja'
|
198
199
|
history = @maker.make_history_list
|
199
|
-
expect = ['
|
200
|
+
expect = ['2020年7月11日 発行']
|
200
201
|
assert_equal expect, history
|
201
202
|
end
|
202
203
|
|
@@ -207,9 +208,9 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
207
208
|
@config['language'] = 'ja'
|
208
209
|
@config['history'] =
|
209
210
|
[['2011-08-03 v1.0.0版発行',
|
210
|
-
'
|
211
|
+
'2020-07-11 v1.2.0版発行']]
|
211
212
|
history = @maker.make_history_list
|
212
|
-
expect = ['2011年8月3日 v1.0.0版発行', '
|
213
|
+
expect = ['2011年8月3日 v1.0.0版発行', '2020年7月11日 v1.2.0版発行']
|
213
214
|
assert_equal expect, history
|
214
215
|
end
|
215
216
|
|
data/test/test_pdfmaker_cmd.rb
CHANGED
@@ -30,7 +30,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
30
30
|
Dir.chdir(@tmpdir1) do
|
31
31
|
_o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_PDFMAKER} #{option} #{configfile}")
|
32
32
|
if !e.empty? && !s.success?
|
33
|
-
|
33
|
+
$stderr.puts e
|
34
34
|
end
|
35
35
|
assert s.success?
|
36
36
|
end
|
@@ -476,10 +476,10 @@ EOS
|
|
476
476
|
end
|
477
477
|
|
478
478
|
def test_empty_table
|
479
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
479
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
480
480
|
assert_equal ':2: error: no rows in the table', e.message
|
481
481
|
|
482
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
482
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
483
483
|
assert_equal ':3: error: no rows in the table', e.message
|
484
484
|
end
|
485
485
|
|
@@ -596,6 +596,147 @@ EOS
|
|
596
596
|
assert_equal expected, actual
|
597
597
|
end
|
598
598
|
|
599
|
+
def test_minicolumn_blocks
|
600
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
601
|
+
@builder.doc_status.clear
|
602
|
+
src = <<-EOS
|
603
|
+
//#{type}[#{type}1]{
|
604
|
+
|
605
|
+
//}
|
606
|
+
|
607
|
+
//#{type}[#{type}2]{
|
608
|
+
//}
|
609
|
+
EOS
|
610
|
+
|
611
|
+
expected = <<-EOS
|
612
|
+
#{type}1
|
613
|
+
|
614
|
+
#{type}2
|
615
|
+
|
616
|
+
EOS
|
617
|
+
assert_equal expected, compile_block(src)
|
618
|
+
|
619
|
+
src = <<-EOS
|
620
|
+
//#{type}[#{type}2]{
|
621
|
+
|
622
|
+
//}
|
623
|
+
|
624
|
+
//#{type}[#{type}3]{
|
625
|
+
|
626
|
+
//}
|
627
|
+
|
628
|
+
//#{type}[#{type}4]{
|
629
|
+
|
630
|
+
//}
|
631
|
+
|
632
|
+
//#{type}[#{type}5]{
|
633
|
+
|
634
|
+
//}
|
635
|
+
|
636
|
+
//#{type}[#{type}6]{
|
637
|
+
|
638
|
+
//}
|
639
|
+
EOS
|
640
|
+
|
641
|
+
expected = <<-EOS
|
642
|
+
#{type}2
|
643
|
+
|
644
|
+
#{type}3
|
645
|
+
|
646
|
+
#{type}4
|
647
|
+
|
648
|
+
#{type}5
|
649
|
+
|
650
|
+
#{type}6
|
651
|
+
|
652
|
+
EOS
|
653
|
+
assert_equal expected, compile_block(src)
|
654
|
+
|
655
|
+
src = <<-EOS
|
656
|
+
//#{type}{
|
657
|
+
|
658
|
+
* A
|
659
|
+
|
660
|
+
1. B
|
661
|
+
|
662
|
+
//}
|
663
|
+
|
664
|
+
//#{type}[OMITEND1]{
|
665
|
+
|
666
|
+
//emlist{
|
667
|
+
LIST
|
668
|
+
//}
|
669
|
+
|
670
|
+
//}
|
671
|
+
//#{type}[OMITEND2]{
|
672
|
+
//}
|
673
|
+
EOS
|
674
|
+
|
675
|
+
expected = <<-EOS
|
676
|
+
A
|
677
|
+
|
678
|
+
1 B
|
679
|
+
|
680
|
+
OMITEND1
|
681
|
+
|
682
|
+
LIST
|
683
|
+
|
684
|
+
OMITEND2
|
685
|
+
|
686
|
+
EOS
|
687
|
+
assert_equal expected, compile_block(src)
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
def test_minicolumn_blocks_nest_error1
|
692
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
693
|
+
@builder.doc_status.clear
|
694
|
+
src = <<-EOS
|
695
|
+
//#{type}{
|
696
|
+
|
697
|
+
//#{type}{
|
698
|
+
//}
|
699
|
+
|
700
|
+
//}
|
701
|
+
EOS
|
702
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
703
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
def test_minicolumn_blocks_nest_error2
|
708
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
709
|
+
@builder.doc_status.clear
|
710
|
+
src = <<-EOS
|
711
|
+
//#{type}{
|
712
|
+
|
713
|
+
//#{type}{
|
714
|
+
|
715
|
+
//}
|
716
|
+
|
717
|
+
//}
|
718
|
+
EOS
|
719
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
720
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
def test_minicolumn_blocks_nest_error3
|
725
|
+
%w[memo tip info warning important caution notice].each do |type|
|
726
|
+
@builder.doc_status.clear
|
727
|
+
src = <<-EOS
|
728
|
+
//#{type}{
|
729
|
+
|
730
|
+
//note{
|
731
|
+
//}
|
732
|
+
|
733
|
+
//}
|
734
|
+
EOS
|
735
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
736
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
599
740
|
def test_image
|
600
741
|
def @chapter.image(_id)
|
601
742
|
item = Book::Index::Item.new('sampleimg', 1)
|
@@ -628,18 +769,18 @@ EOS
|
|
628
769
|
end
|
629
770
|
|
630
771
|
def test_inline_unknown
|
631
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
772
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
632
773
|
assert_equal ':1: error: unknown image: n', e.message
|
633
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
774
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
634
775
|
assert_equal ':1: error: unknown footnote: n', e.message
|
635
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
776
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
636
777
|
assert_equal ':1: error: unknown headline: n', e.message
|
637
778
|
%w[list table column].each do |name|
|
638
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
779
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
639
780
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
640
781
|
end
|
641
782
|
%w[chap chapref title].each do |name|
|
642
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
783
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
643
784
|
assert_equal ':1: error: key not found: "n"', e.message
|
644
785
|
end
|
645
786
|
end
|
@@ -752,4 +893,278 @@ EOS
|
|
752
893
|
actual = compile_block(src)
|
753
894
|
assert_equal expected, actual
|
754
895
|
end
|
896
|
+
|
897
|
+
def test_nest_error_open
|
898
|
+
src = <<-EOS
|
899
|
+
//endchild
|
900
|
+
EOS
|
901
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
902
|
+
assert_equal ":1: error: //endchild is shown, but any opened //beginchild doesn't exist", e.message
|
903
|
+
end
|
904
|
+
|
905
|
+
def test_nest_error_close1
|
906
|
+
src = <<-EOS
|
907
|
+
//beginchild
|
908
|
+
EOS
|
909
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
910
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
911
|
+
end
|
912
|
+
|
913
|
+
def test_nest_error_close2
|
914
|
+
src = <<-EOS
|
915
|
+
* foo
|
916
|
+
|
917
|
+
//beginchild
|
918
|
+
|
919
|
+
1. foo
|
920
|
+
|
921
|
+
//beginchild
|
922
|
+
|
923
|
+
: foo
|
924
|
+
|
925
|
+
//beginchild
|
926
|
+
EOS
|
927
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
928
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
929
|
+
end
|
930
|
+
|
931
|
+
def test_nest_error_close3
|
932
|
+
src = <<-EOS
|
933
|
+
* foo
|
934
|
+
|
935
|
+
//beginchild
|
936
|
+
|
937
|
+
1. foo
|
938
|
+
|
939
|
+
//beginchild
|
940
|
+
|
941
|
+
: foo
|
942
|
+
|
943
|
+
//beginchild
|
944
|
+
|
945
|
+
//endchild
|
946
|
+
EOS
|
947
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
948
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
949
|
+
end
|
950
|
+
|
951
|
+
def test_nest_ul
|
952
|
+
src = <<-EOS
|
953
|
+
* UL1
|
954
|
+
|
955
|
+
//beginchild
|
956
|
+
|
957
|
+
1. UL1-OL1
|
958
|
+
2. UL1-OL2
|
959
|
+
|
960
|
+
* UL1-UL1
|
961
|
+
* UL1-UL2
|
962
|
+
|
963
|
+
: UL1-DL1
|
964
|
+
UL1-DD1
|
965
|
+
: UL1-DL2
|
966
|
+
UL1-DD2
|
967
|
+
|
968
|
+
//endchild
|
969
|
+
|
970
|
+
* UL2
|
971
|
+
|
972
|
+
//beginchild
|
973
|
+
|
974
|
+
UL2-PARA
|
975
|
+
|
976
|
+
//endchild
|
977
|
+
EOS
|
978
|
+
|
979
|
+
expected = <<-EOS
|
980
|
+
UL1
|
981
|
+
|
982
|
+
1 UL1-OL1
|
983
|
+
2 UL1-OL2
|
984
|
+
|
985
|
+
UL1-UL1
|
986
|
+
UL1-UL2
|
987
|
+
|
988
|
+
UL1-DL1
|
989
|
+
UL1-DD1
|
990
|
+
UL1-DL2
|
991
|
+
UL1-DD2
|
992
|
+
|
993
|
+
UL2
|
994
|
+
UL2-PARA
|
995
|
+
EOS
|
996
|
+
|
997
|
+
actual = compile_block(src)
|
998
|
+
assert_equal expected, actual
|
999
|
+
end
|
1000
|
+
|
1001
|
+
def test_nest_ol
|
1002
|
+
src = <<-EOS
|
1003
|
+
1. OL1
|
1004
|
+
|
1005
|
+
//beginchild
|
1006
|
+
|
1007
|
+
1. OL1-OL1
|
1008
|
+
2. OL1-OL2
|
1009
|
+
|
1010
|
+
* OL1-UL1
|
1011
|
+
* OL1-UL2
|
1012
|
+
|
1013
|
+
: OL1-DL1
|
1014
|
+
OL1-DD1
|
1015
|
+
: OL1-DL2
|
1016
|
+
OL1-DD2
|
1017
|
+
|
1018
|
+
//endchild
|
1019
|
+
|
1020
|
+
2. OL2
|
1021
|
+
|
1022
|
+
//beginchild
|
1023
|
+
|
1024
|
+
OL2-PARA
|
1025
|
+
|
1026
|
+
//endchild
|
1027
|
+
EOS
|
1028
|
+
|
1029
|
+
expected = <<-EOS
|
1030
|
+
1 OL1
|
1031
|
+
|
1032
|
+
1 OL1-OL1
|
1033
|
+
2 OL1-OL2
|
1034
|
+
|
1035
|
+
OL1-UL1
|
1036
|
+
OL1-UL2
|
1037
|
+
|
1038
|
+
OL1-DL1
|
1039
|
+
OL1-DD1
|
1040
|
+
OL1-DL2
|
1041
|
+
OL1-DD2
|
1042
|
+
|
1043
|
+
2 OL2
|
1044
|
+
OL2-PARA
|
1045
|
+
EOS
|
1046
|
+
|
1047
|
+
actual = compile_block(src)
|
1048
|
+
assert_equal expected, actual
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
def test_nest_dl
|
1052
|
+
src = <<-EOS
|
1053
|
+
: DL1
|
1054
|
+
|
1055
|
+
//beginchild
|
1056
|
+
|
1057
|
+
1. DL1-OL1
|
1058
|
+
2. DL1-OL2
|
1059
|
+
|
1060
|
+
* DL1-UL1
|
1061
|
+
* DL1-UL2
|
1062
|
+
|
1063
|
+
: DL1-DL1
|
1064
|
+
DL1-DD1
|
1065
|
+
: DL1-DL2
|
1066
|
+
DL1-DD2
|
1067
|
+
|
1068
|
+
//endchild
|
1069
|
+
|
1070
|
+
: DL2
|
1071
|
+
DD2
|
1072
|
+
|
1073
|
+
//beginchild
|
1074
|
+
|
1075
|
+
* DD2-UL1
|
1076
|
+
* DD2-UL2
|
1077
|
+
|
1078
|
+
DD2-PARA
|
1079
|
+
|
1080
|
+
//endchild
|
1081
|
+
EOS
|
1082
|
+
|
1083
|
+
expected = <<-EOS
|
1084
|
+
DL1
|
1085
|
+
|
1086
|
+
1 DL1-OL1
|
1087
|
+
2 DL1-OL2
|
1088
|
+
|
1089
|
+
DL1-UL1
|
1090
|
+
DL1-UL2
|
1091
|
+
|
1092
|
+
DL1-DL1
|
1093
|
+
DL1-DD1
|
1094
|
+
DL1-DL2
|
1095
|
+
DL1-DD2
|
1096
|
+
|
1097
|
+
DL2
|
1098
|
+
DD2
|
1099
|
+
|
1100
|
+
DD2-UL1
|
1101
|
+
DD2-UL2
|
1102
|
+
|
1103
|
+
DD2-PARA
|
1104
|
+
EOS
|
1105
|
+
|
1106
|
+
actual = compile_block(src)
|
1107
|
+
assert_equal expected, actual
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
def test_nest_multi
|
1111
|
+
src = <<-EOS
|
1112
|
+
1. OL1
|
1113
|
+
|
1114
|
+
//beginchild
|
1115
|
+
|
1116
|
+
1. OL1-OL1
|
1117
|
+
|
1118
|
+
//beginchild
|
1119
|
+
|
1120
|
+
* OL1-OL1-UL1
|
1121
|
+
|
1122
|
+
OL1-OL1-PARA
|
1123
|
+
|
1124
|
+
//endchild
|
1125
|
+
|
1126
|
+
2. OL1-OL2
|
1127
|
+
|
1128
|
+
* OL1-UL1
|
1129
|
+
|
1130
|
+
//beginchild
|
1131
|
+
|
1132
|
+
: OL1-UL1-DL1
|
1133
|
+
OL1-UL1-DD1
|
1134
|
+
|
1135
|
+
OL1-UL1-PARA
|
1136
|
+
|
1137
|
+
//endchild
|
1138
|
+
|
1139
|
+
* OL1-UL2
|
1140
|
+
|
1141
|
+
//endchild
|
1142
|
+
EOS
|
1143
|
+
expected = <<-EOS
|
1144
|
+
1 OL1
|
1145
|
+
|
1146
|
+
1 OL1-OL1
|
1147
|
+
|
1148
|
+
|
1149
|
+
OL1-OL1-UL1
|
1150
|
+
|
1151
|
+
OL1-OL1-PARA
|
1152
|
+
|
1153
|
+
2 OL1-OL2
|
1154
|
+
|
1155
|
+
OL1-UL1
|
1156
|
+
|
1157
|
+
|
1158
|
+
OL1-UL1-DL1
|
1159
|
+
OL1-UL1-DD1
|
1160
|
+
|
1161
|
+
OL1-UL1-PARA
|
1162
|
+
|
1163
|
+
OL1-UL2
|
1164
|
+
|
1165
|
+
EOS
|
1166
|
+
|
1167
|
+
actual = compile_block(src)
|
1168
|
+
assert_equal expected, actual
|
1169
|
+
end
|
755
1170
|
end
|