review 5.1.1 → 5.4.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-tex.yml +6 -2
- data/.github/workflows/ruby-win.yml +6 -2
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +5 -319
- data/NEWS.ja.md +149 -0
- data/NEWS.md +149 -1
- data/README.md +9 -8
- data/bin/review +1 -1
- data/bin/review-catalog-converter +15 -15
- data/bin/review-check +7 -7
- data/bin/review-compile +14 -23
- data/bin/review-index +1 -1
- data/bin/review-preproc +29 -35
- data/bin/review-validate +2 -2
- data/doc/config.yml.sample +9 -1
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +29 -3
- data/doc/format.md +32 -3
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +3 -3
- data/lib/review/book/book_unit.rb +13 -3
- data/lib/review/book/chapter.rb +1 -1
- data/lib/review/book/index.rb +7 -4
- data/lib/review/book/part.rb +12 -13
- data/lib/review/book/volume.rb +1 -1
- data/lib/review/builder.rb +92 -65
- data/lib/review/catalog.rb +6 -5
- data/lib/review/compiler.rb +76 -57
- data/lib/review/configure.rb +5 -2
- data/lib/review/epub2html.rb +12 -12
- data/lib/review/epubmaker/content.rb +1 -1
- data/lib/review/epubmaker/epubcommon.rb +47 -45
- data/lib/review/epubmaker/epubv2.rb +2 -1
- data/lib/review/epubmaker/epubv3.rb +5 -4
- data/lib/review/epubmaker/producer.rb +6 -7
- data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
- data/lib/review/epubmaker.rb +56 -67
- data/lib/review/exception.rb +7 -0
- data/lib/review/extentions/string.rb +1 -1
- data/lib/review/htmlbuilder.rb +90 -34
- data/lib/review/htmlutils.rb +17 -17
- data/lib/review/i18n.rb +3 -3
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +61 -39
- data/lib/review/idgxmlmaker.rb +27 -26
- data/lib/review/img_math.rb +12 -18
- data/lib/review/index_builder.rb +94 -53
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbuilder.rb +84 -76
- data/lib/review/lineinput.rb +3 -3
- data/lib/review/location.rb +1 -1
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +69 -21
- data/lib/review/makerhelper.rb +8 -4
- data/lib/review/markdownbuilder.rb +21 -12
- data/lib/review/pdfmaker.rb +63 -42
- data/lib/review/plaintextbuilder.rb +16 -15
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +94 -296
- data/lib/review/rstbuilder.rb +12 -3
- data/lib/review/template.rb +5 -1
- data/lib/review/textmaker.rb +32 -31
- data/lib/review/textutils.rb +5 -6
- data/lib/review/tocprinter.rb +12 -7
- data/lib/review/topbuilder.rb +96 -19
- data/lib/review/update.rb +16 -8
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +9 -9
- data/lib/review/webmaker.rb +45 -46
- data/lib/review/webtocprinter.rb +10 -10
- data/lib/review/yamlloader.rb +35 -2
- data/review.gemspec +2 -1
- data/samples/sample-book/src/config.yml +0 -1
- data/samples/sample-book/src/lib/tasks/review.rake +3 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch02.re +9 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_titlepage.html.erb +9 -17
- data/templates/latex/config.erb +3 -0
- data/templates/latex/review-jlreq/review-base.sty +4 -5
- data/templates/latex/review-jlreq/review-jlreq.cls +39 -5
- data/templates/latex/review-jsbook/review-base.sty +9 -3
- data/templates/latex/review-jsbook/review-jsbook.cls +32 -5
- data/templates/opf/opf_manifest_epubv2.opf.erb +1 -1
- data/templates/opf/opf_manifest_epubv3.opf.erb +1 -1
- data/test/assets/syntax_book_index_detail.txt +10 -8
- data/test/assets/test_template.tex +4 -1
- data/test/assets/test_template_backmatter.tex +4 -1
- data/test/book_test_helper.rb +10 -10
- data/test/test_book_chapter.rb +25 -2
- data/test/test_builder.rb +10 -8
- data/test/test_epub3maker.rb +3 -3
- data/test/test_epubmaker.rb +27 -37
- data/test/test_epubmaker_cmd.rb +14 -3
- data/test/test_htmlbuilder.rb +111 -31
- data/test/test_idgxmlbuilder.rb +41 -33
- data/test/test_idgxmlmaker_cmd.rb +1 -1
- data/test/test_img_math.rb +11 -2
- data/test/test_index.rb +30 -4
- data/test/test_latexbuilder.rb +46 -25
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_markdownbuilder.rb +13 -0
- data/test/test_pdfmaker.rb +19 -0
- data/test/test_pdfmaker_cmd.rb +10 -10
- data/test/test_plaintextbuilder.rb +46 -22
- data/test/test_preprocessor.rb +188 -1
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +195 -29
- data/test/test_yamlloader.rb +28 -42
- metadata +11 -6
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -14,6 +14,8 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@config['tableopt'] = '10'
|
15
15
|
@book = Book::Base.new
|
16
16
|
@book.config = @config
|
17
|
+
@log_io = StringIO.new
|
18
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
17
19
|
@compiler = ReVIEW::Compiler.new(@builder)
|
18
20
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
19
21
|
location = Location.new(nil, nil)
|
@@ -169,10 +171,10 @@ EOS
|
|
169
171
|
|
170
172
|
def test_empty_table
|
171
173
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
172
|
-
assert_equal '
|
174
|
+
assert_equal 'no rows in the table', e.message
|
173
175
|
|
174
176
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
175
|
-
assert_equal '
|
177
|
+
assert_equal 'no rows in the table', e.message
|
176
178
|
end
|
177
179
|
|
178
180
|
def test_emtable
|
@@ -346,15 +348,15 @@ EOS
|
|
346
348
|
//}
|
347
349
|
EOS
|
348
350
|
|
349
|
-
if type == 'notice' # exception pattern
|
350
|
-
|
351
|
+
expected = if type == 'notice' # exception pattern
|
352
|
+
<<-EOS.chomp
|
351
353
|
<#{type}-t><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t>
|
352
354
|
EOS
|
353
|
-
|
354
|
-
|
355
|
+
else
|
356
|
+
<<-EOS.chomp
|
355
357
|
<#{type}><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}>
|
356
358
|
EOS
|
357
|
-
|
359
|
+
end
|
358
360
|
assert_equal expected, compile_block(src)
|
359
361
|
|
360
362
|
src = <<-EOS
|
@@ -410,17 +412,17 @@ LIST
|
|
410
412
|
//}
|
411
413
|
EOS
|
412
414
|
|
413
|
-
if type == 'notice' # exception pattern
|
414
|
-
|
415
|
+
expected = if type == 'notice' # exception pattern
|
416
|
+
<<-EOS.chomp
|
415
417
|
<#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
|
416
418
|
</pre></list></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}-t>
|
417
419
|
EOS
|
418
|
-
|
419
|
-
|
420
|
+
else
|
421
|
+
<<-EOS.chomp
|
420
422
|
<#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
|
421
423
|
</pre></list></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}>
|
422
424
|
EOS
|
423
|
-
|
425
|
+
end
|
424
426
|
assert_equal expected, compile_block(src)
|
425
427
|
end
|
426
428
|
end
|
@@ -436,8 +438,8 @@ EOS
|
|
436
438
|
|
437
439
|
//}
|
438
440
|
EOS
|
439
|
-
|
440
|
-
assert_match(/minicolumn cannot be nested:/,
|
441
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
442
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
441
443
|
end
|
442
444
|
end
|
443
445
|
|
@@ -453,8 +455,8 @@ EOS
|
|
453
455
|
|
454
456
|
//}
|
455
457
|
EOS
|
456
|
-
|
457
|
-
assert_match(/minicolumn cannot be nested:/,
|
458
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
459
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
458
460
|
end
|
459
461
|
end
|
460
462
|
|
@@ -469,8 +471,8 @@ EOS
|
|
469
471
|
|
470
472
|
//}
|
471
473
|
EOS
|
472
|
-
|
473
|
-
assert_match(/minicolumn cannot be nested:/,
|
474
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
475
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
474
476
|
end
|
475
477
|
end
|
476
478
|
|
@@ -1095,8 +1097,8 @@ EOS
|
|
1095
1097
|
* AA
|
1096
1098
|
EOS
|
1097
1099
|
|
1098
|
-
|
1099
|
-
|
1100
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1101
|
+
assert_match(/too many \*\./, @log_io.string)
|
1100
1102
|
end
|
1101
1103
|
|
1102
1104
|
def test_ul_nest4
|
@@ -1131,19 +1133,25 @@ EOS
|
|
1131
1133
|
end
|
1132
1134
|
|
1133
1135
|
def test_inline_unknown
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1136
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1137
|
+
assert_match(/unknown image: n/, @log_io.string)
|
1138
|
+
|
1139
|
+
@log_io.string = ''
|
1140
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1141
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
1142
|
+
|
1143
|
+
@log_io.string = ''
|
1144
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1145
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
1140
1146
|
%w[list table column].each do |name|
|
1141
|
-
|
1142
|
-
|
1147
|
+
@log_io.string = ''
|
1148
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1149
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
1143
1150
|
end
|
1144
1151
|
%w[chap chapref title].each do |name|
|
1145
|
-
|
1146
|
-
|
1152
|
+
@log_io.string = ''
|
1153
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1154
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
1147
1155
|
end
|
1148
1156
|
end
|
1149
1157
|
|
@@ -1283,7 +1291,7 @@ EOS
|
|
1283
1291
|
//beginchild
|
1284
1292
|
EOS
|
1285
1293
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1286
|
-
assert_equal ":1:
|
1294
|
+
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
1287
1295
|
end
|
1288
1296
|
|
1289
1297
|
def test_nest_error_close2
|
@@ -1301,7 +1309,7 @@ EOS
|
|
1301
1309
|
//beginchild
|
1302
1310
|
EOS
|
1303
1311
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1304
|
-
assert_equal ':12:
|
1312
|
+
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
1305
1313
|
end
|
1306
1314
|
|
1307
1315
|
def test_nest_error_close3
|
@@ -1321,7 +1329,7 @@ EOS
|
|
1321
1329
|
//endchild
|
1322
1330
|
EOS
|
1323
1331
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1324
|
-
assert_equal ':14:
|
1332
|
+
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
1325
1333
|
end
|
1326
1334
|
|
1327
1335
|
def test_nest_ul
|
@@ -21,7 +21,7 @@ class IDGXMLMakerCmdTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def common_buildidgxml(bookdir, configfile, targetfile, option)
|
24
|
-
|
24
|
+
unless /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
|
25
25
|
config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
|
26
26
|
builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
|
27
27
|
assert !File.exist?(builddir)
|
data/test/test_img_math.rb
CHANGED
@@ -30,7 +30,7 @@ class ImgMathTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_defer_math_image
|
33
|
-
unless support_latex_in_tests?
|
33
|
+
unless support_latex_in_tests? && support_pdftocairo_in_tests?
|
34
34
|
$stderr.puts 'skip test_defer_math_image'
|
35
35
|
return true
|
36
36
|
end
|
@@ -104,7 +104,16 @@ class ImgMathTest < Test::Unit::TestCase
|
|
104
104
|
begin
|
105
105
|
`uplatex -v`
|
106
106
|
true
|
107
|
-
rescue
|
107
|
+
rescue StandardError
|
108
|
+
false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def support_pdftocairo_in_tests?
|
113
|
+
begin
|
114
|
+
`pdftocairo -v`
|
115
|
+
true
|
116
|
+
rescue StandardError
|
108
117
|
false
|
109
118
|
end
|
110
119
|
end
|
data/test/test_index.rb
CHANGED
@@ -12,6 +12,8 @@ class IndexTest < Test::Unit::TestCase
|
|
12
12
|
@builder = TOPBuilder.new
|
13
13
|
@config = ReVIEW::Configure.create(config: { 'secnolevel' => 2, 'language' => 'ja' })
|
14
14
|
@book = Book::Base.new(config: @config)
|
15
|
+
@log_io = StringIO.new
|
16
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
15
17
|
@compiler = ReVIEW::Compiler.new(@builder)
|
16
18
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
17
19
|
location = Location.new(nil, nil)
|
@@ -21,16 +23,19 @@ class IndexTest < Test::Unit::TestCase
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def test_footnote_index
|
24
|
-
compile_block("//footnote[foo][bar]\n")
|
26
|
+
compile_block("@<fn>{foo}\n//footnote[foo][bar]\n")
|
25
27
|
fn = @chapter.footnote_index
|
26
28
|
items = fn.to_a
|
27
29
|
item = items[0]
|
28
30
|
assert_equal 'foo', item.id
|
29
31
|
assert_equal 'bar', item.content
|
32
|
+
|
33
|
+
compile_block("//footnote[foo][bar]\n")
|
34
|
+
assert_match(/ID foo is not referred/, @log_io.string)
|
30
35
|
end
|
31
36
|
|
32
37
|
def test_footnote_index_with_escape
|
33
|
-
compile_block('//footnote[foo][bar[\]buz]' + "\n")
|
38
|
+
compile_block("@<fn>{foo}\n" + '//footnote[foo][bar[\]buz]' + "\n")
|
34
39
|
fn = @chapter.footnote_index
|
35
40
|
items = fn.to_a
|
36
41
|
item = items[0]
|
@@ -39,7 +44,7 @@ class IndexTest < Test::Unit::TestCase
|
|
39
44
|
end
|
40
45
|
|
41
46
|
def test_footnote_index_with_escape2
|
42
|
-
compile_block('//footnote[foo][bar\\a\\$buz]' + "\n")
|
47
|
+
compile_block("@<fn>{foo}\n" + '//footnote[foo][bar\\a\\$buz]' + "\n")
|
43
48
|
fn = @chapter.footnote_index
|
44
49
|
items = fn.to_a
|
45
50
|
item = items[0]
|
@@ -48,7 +53,7 @@ class IndexTest < Test::Unit::TestCase
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def test_footnote_index_key?
|
51
|
-
compile_block('//footnote[foo][bar]' + "\n")
|
56
|
+
compile_block("@<fn>{foo}\n" + '//footnote[foo][bar]' + "\n")
|
52
57
|
fn = @chapter.footnote_index
|
53
58
|
assert_equal true, fn.key?('foo')
|
54
59
|
|
@@ -58,6 +63,27 @@ class IndexTest < Test::Unit::TestCase
|
|
58
63
|
# rubocop:enable Style/PreferredHashMethods
|
59
64
|
end
|
60
65
|
|
66
|
+
def test_endnote_index
|
67
|
+
compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
68
|
+
endnote = @chapter.endnote_index
|
69
|
+
items = endnote.to_a
|
70
|
+
item = items[0]
|
71
|
+
assert_equal 'foo', item.id
|
72
|
+
assert_equal 'bar', item.content
|
73
|
+
assert_equal true, endnote.key?('foo')
|
74
|
+
# rubocop:disable Style/PreferredHashMethods
|
75
|
+
assert_equal true, endnote.has_key?('foo')
|
76
|
+
# rubocop:enable Style/PreferredHashMethods
|
77
|
+
|
78
|
+
e = assert_raises(ReVIEW::ApplicationError) do
|
79
|
+
compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n")
|
80
|
+
end
|
81
|
+
assert_equal ':3: //endnote is found but //printendnotes is not found.', e.message
|
82
|
+
|
83
|
+
compile_block("//endnote[foo][bar]\n//printendnotes\n")
|
84
|
+
assert_match(/ID foo is not referred/, @log_io.string)
|
85
|
+
end
|
86
|
+
|
61
87
|
def test_headline_index
|
62
88
|
src = <<-EOB
|
63
89
|
= chap1
|
data/test/test_latexbuilder.rb
CHANGED
@@ -20,6 +20,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
20
20
|
@config['pdfmaker']['image_scale2width'] = nil
|
21
21
|
@book = Book::Base.new
|
22
22
|
@book.config = @config
|
23
|
+
@log_io = StringIO.new
|
24
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
23
25
|
@compiler = ReVIEW::Compiler.new(@builder)
|
24
26
|
@chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
|
25
27
|
location = Location.new(nil, nil)
|
@@ -255,6 +257,20 @@ EOS
|
|
255
257
|
assert_equal 'test \\reviewttb{inline test} test2', actual
|
256
258
|
end
|
257
259
|
|
260
|
+
def test_endnote
|
261
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
262
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
263
|
+
|
264
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
265
|
+
expected = <<-'EOS'
|
266
|
+
|
267
|
+
\endnote{bar}
|
268
|
+
|
269
|
+
\theendnotes
|
270
|
+
EOS
|
271
|
+
assert_equal expected, actual
|
272
|
+
end
|
273
|
+
|
258
274
|
def test_inline_hd_chap
|
259
275
|
def @chapter.headline_index
|
260
276
|
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
@@ -1372,7 +1388,7 @@ EOS
|
|
1372
1388
|
actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n")
|
1373
1389
|
expected = <<-EOS
|
1374
1390
|
\\begin{reviewdummyimage}
|
1375
|
-
|
1391
|
+
{-}{-}[[path = sample\\reviewbackslash{}textunderscore\\{\\}img\\reviewbackslash{}textunderscore\\{\\}nofile\\reviewbackslash{}textunderscore\\{\\} (not exist)]]{-}{-}
|
1376
1392
|
\\reviewindepimagecaption{図: sample photo}
|
1377
1393
|
\\end{reviewdummyimage}
|
1378
1394
|
EOS
|
@@ -1433,10 +1449,10 @@ EOS
|
|
1433
1449
|
|
1434
1450
|
def test_empty_table
|
1435
1451
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
1436
|
-
assert_equal '
|
1452
|
+
assert_equal 'no rows in the table', e.message
|
1437
1453
|
|
1438
1454
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
1439
|
-
assert_equal '
|
1455
|
+
assert_equal 'no rows in the table', e.message
|
1440
1456
|
end
|
1441
1457
|
|
1442
1458
|
def test_customize_cellwidth
|
@@ -2252,8 +2268,8 @@ EOS
|
|
2252
2268
|
|
2253
2269
|
//}
|
2254
2270
|
EOS
|
2255
|
-
|
2256
|
-
assert_match(/minicolumn cannot be nested:/,
|
2271
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2272
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2257
2273
|
end
|
2258
2274
|
end
|
2259
2275
|
|
@@ -2269,8 +2285,8 @@ EOS
|
|
2269
2285
|
|
2270
2286
|
//}
|
2271
2287
|
EOS
|
2272
|
-
|
2273
|
-
assert_match(/minicolumn cannot be nested:/,
|
2288
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2289
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2274
2290
|
end
|
2275
2291
|
end
|
2276
2292
|
|
@@ -2285,8 +2301,8 @@ EOS
|
|
2285
2301
|
|
2286
2302
|
//}
|
2287
2303
|
EOS
|
2288
|
-
|
2289
|
-
assert_match(/minicolumn cannot be nested:/,
|
2304
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2305
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2290
2306
|
end
|
2291
2307
|
end
|
2292
2308
|
|
@@ -2406,12 +2422,11 @@ EOS
|
|
2406
2422
|
|
2407
2423
|
def test_inline_w
|
2408
2424
|
Dir.mktmpdir do |dir|
|
2409
|
-
File.
|
2410
|
-
f.write <<EOB
|
2425
|
+
File.write(File.join(dir, 'words.csv'), <<EOB
|
2411
2426
|
"F","foo"
|
2412
2427
|
"B","bar""\\<>_@<b>{BAZ}"
|
2413
2428
|
EOB
|
2414
|
-
|
2429
|
+
)
|
2415
2430
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
2416
2431
|
|
2417
2432
|
io = StringIO.new
|
@@ -2427,19 +2442,25 @@ EOS
|
|
2427
2442
|
end
|
2428
2443
|
|
2429
2444
|
def test_inline_unknown
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2445
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
2446
|
+
assert_match(/unknown image: n/, @log_io.string)
|
2447
|
+
|
2448
|
+
@log_io.string = ''
|
2449
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
2450
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
2451
|
+
|
2452
|
+
@log_io.string = ''
|
2453
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
2454
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
2436
2455
|
%w[list table column].each do |name|
|
2437
|
-
|
2438
|
-
|
2456
|
+
@log_io.string = ''
|
2457
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2458
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
2439
2459
|
end
|
2440
2460
|
%w[chap chapref title].each do |name|
|
2441
|
-
|
2442
|
-
|
2461
|
+
@log_io.string = ''
|
2462
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2463
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
2443
2464
|
end
|
2444
2465
|
end
|
2445
2466
|
|
@@ -2588,7 +2609,7 @@ EOS
|
|
2588
2609
|
//beginchild
|
2589
2610
|
EOS
|
2590
2611
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2591
|
-
assert_equal ":1:
|
2612
|
+
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2592
2613
|
end
|
2593
2614
|
|
2594
2615
|
def test_nest_error_close2
|
@@ -2606,7 +2627,7 @@ EOS
|
|
2606
2627
|
//beginchild
|
2607
2628
|
EOS
|
2608
2629
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2609
|
-
assert_equal ':12:
|
2630
|
+
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
2610
2631
|
end
|
2611
2632
|
|
2612
2633
|
def test_nest_error_close3
|
@@ -2626,7 +2647,7 @@ EOS
|
|
2626
2647
|
//endchild
|
2627
2648
|
EOS
|
2628
2649
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2629
|
-
assert_equal ':14:
|
2650
|
+
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
2630
2651
|
end
|
2631
2652
|
|
2632
2653
|
def test_nest_ul
|
@@ -20,6 +20,8 @@ class LATEXBuidlerV2Test < Test::Unit::TestCase
|
|
20
20
|
@config['pdfmaker']['image_scale2width'] = nil
|
21
21
|
@book = Book::Base.new
|
22
22
|
@book.config = @config
|
23
|
+
@log_io = StringIO.new
|
24
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
23
25
|
@compiler = ReVIEW::Compiler.new(@builder)
|
24
26
|
@chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
|
25
27
|
location = Location.new(nil, nil)
|
@@ -1544,19 +1546,25 @@ EOS
|
|
1544
1546
|
end
|
1545
1547
|
|
1546
1548
|
def test_inline_unknown
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1549
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1550
|
+
assert_match(/unknown image: n/, @log_io.string)
|
1551
|
+
|
1552
|
+
@log_io.string = ''
|
1553
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1554
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
1555
|
+
|
1556
|
+
@log_io.string = ''
|
1557
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1558
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
1553
1559
|
%w[list table column].each do |name|
|
1554
|
-
|
1555
|
-
|
1560
|
+
@log_io.string = ''
|
1561
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1562
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
1556
1563
|
end
|
1557
1564
|
%w[chap chapref title].each do |name|
|
1558
|
-
|
1559
|
-
|
1565
|
+
@log_io.string = ''
|
1566
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1567
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
1560
1568
|
end
|
1561
1569
|
end
|
1562
1570
|
|
@@ -106,6 +106,19 @@ EOS
|
|
106
106
|
assert_equal %Q(test <span class="red">コメント</span> test2), actual
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_endnote
|
110
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
111
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
112
|
+
|
113
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
114
|
+
expected = <<-'EOS'
|
115
|
+
<sup>(1)</sup>
|
116
|
+
|
117
|
+
(1) bar
|
118
|
+
EOS
|
119
|
+
assert_equal expected, actual
|
120
|
+
end
|
121
|
+
|
109
122
|
def test_inline_hd_chap
|
110
123
|
def @chapter.headline_index
|
111
124
|
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
data/test/test_pdfmaker.rb
CHANGED
@@ -167,6 +167,25 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
def test_template_content_with_invalid_localconfig
|
171
|
+
Dir.mktmpdir do |dir|
|
172
|
+
Dir.chdir(dir) do
|
173
|
+
Dir.mkdir('layouts')
|
174
|
+
File.write(File.join('layouts', 'config-local.tex.erb'), %q(<%= not_existed_method %>\n))
|
175
|
+
@maker.basedir = Dir.pwd
|
176
|
+
@maker.erb_config
|
177
|
+
@maker.instance_eval do
|
178
|
+
def error!(msg)
|
179
|
+
msg
|
180
|
+
end
|
181
|
+
end
|
182
|
+
error_msg = @maker.template_content
|
183
|
+
assert_match(/template or configuration error:/, error_msg)
|
184
|
+
assert_match(/undefined local variable or method `not_existed_method'/, error_msg)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
170
189
|
def test_gettemplate_with_backmatter
|
171
190
|
@config.merge!(
|
172
191
|
'backcover' => 'backcover.tex',
|
data/test/test_pdfmaker_cmd.rb
CHANGED
@@ -21,7 +21,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def common_buildpdf(bookdir, templatedir, configfile, targetpdffile, option = nil)
|
24
|
-
|
24
|
+
unless /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
|
25
25
|
config = prepare_samplebook(@tmpdir1, bookdir, templatedir, configfile)
|
26
26
|
builddir = File.join(@tmpdir1, config['bookname'] + '-pdf')
|
27
27
|
assert !File.exist?(builddir)
|
@@ -41,7 +41,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
41
41
|
def test_pdfmaker_cmd_sample_jsbook_print
|
42
42
|
begin
|
43
43
|
`uplatex -v`
|
44
|
-
rescue
|
44
|
+
rescue StandardError
|
45
45
|
$stderr.puts 'skip test_pdfmaker_cmd_sample_jsbook_print'
|
46
46
|
return true
|
47
47
|
end
|
@@ -51,7 +51,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
51
51
|
def test_pdfmaker_cmd_sample_jsbook_ebook
|
52
52
|
begin
|
53
53
|
`uplatex -v`
|
54
|
-
rescue
|
54
|
+
rescue StandardError
|
55
55
|
$stderr.puts 'skip test_pdfmaker_cmd_sample_jsbook_ebook'
|
56
56
|
return true
|
57
57
|
end
|
@@ -61,7 +61,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
61
61
|
def test_pdfmaker_cmd_sample_jlreq_print
|
62
62
|
begin
|
63
63
|
`uplatex -v`
|
64
|
-
rescue
|
64
|
+
rescue StandardError
|
65
65
|
$stderr.puts 'skip test_pdfmaker_cmd_sample_jlreq_print'
|
66
66
|
return true
|
67
67
|
end
|
@@ -71,7 +71,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
71
71
|
def test_pdfmaker_cmd_sample_jlreq_ebook
|
72
72
|
begin
|
73
73
|
`uplatex -v`
|
74
|
-
rescue
|
74
|
+
rescue StandardError
|
75
75
|
$stderr.puts 'skip test_pdfmaker_cmd_sample_jlreq_ebook'
|
76
76
|
return true
|
77
77
|
end
|
@@ -81,7 +81,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
81
81
|
def test_pdfmaker_cmd_syntax_jsbook_print
|
82
82
|
begin
|
83
83
|
`uplatex -v`
|
84
|
-
rescue
|
84
|
+
rescue StandardError
|
85
85
|
$stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_print'
|
86
86
|
return true
|
87
87
|
end
|
@@ -91,7 +91,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
91
91
|
def test_pdfmaker_cmd_syntax_jsbook_print_buildonly
|
92
92
|
begin
|
93
93
|
`uplatex -v`
|
94
|
-
rescue
|
94
|
+
rescue StandardError
|
95
95
|
$stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_print_buildonly'
|
96
96
|
return true
|
97
97
|
end
|
@@ -101,7 +101,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
101
101
|
def test_pdfmaker_cmd_syntax_jsbook_ebook
|
102
102
|
begin
|
103
103
|
`uplatex -v`
|
104
|
-
rescue
|
104
|
+
rescue StandardError
|
105
105
|
$stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_ebook'
|
106
106
|
return true
|
107
107
|
end
|
@@ -111,7 +111,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
111
111
|
def test_pdfmaker_cmd_syntax_jlreq_ebook
|
112
112
|
begin
|
113
113
|
`uplatex -v`
|
114
|
-
rescue
|
114
|
+
rescue StandardError
|
115
115
|
$stderr.puts 'skip test_pdfmaker_cmd_syntax_jlreq_ebook'
|
116
116
|
return true
|
117
117
|
end
|
@@ -121,7 +121,7 @@ class PDFMakerCmdTest < Test::Unit::TestCase
|
|
121
121
|
def test_pdfmaker_cmd_syntax_jlreq_ebook_lualatex
|
122
122
|
begin
|
123
123
|
`lualatex -v`
|
124
|
-
rescue
|
124
|
+
rescue StandardError
|
125
125
|
$stderr.puts 'skip test_pdfmaker_cmd_syntax_jlreq_ebook_lualatex'
|
126
126
|
return true
|
127
127
|
end
|