review 5.2.0 → 5.5.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 +1 -1
- data/.github/workflows/ruby-win.yml +1 -1
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -319
- data/NEWS.ja.md +116 -0
- data/NEWS.md +117 -0
- 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 +6 -8
- data/bin/review-index +1 -1
- data/bin/review-preproc +1 -1
- data/bin/review-validate +2 -2
- data/doc/config.yml.sample +7 -1
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +34 -4
- data/doc/format.md +32 -3
- 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 +82 -28
- data/lib/review/catalog.rb +6 -5
- data/lib/review/compiler.rb +20 -14
- 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 +3 -3
- data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
- data/lib/review/epubmaker.rb +35 -32
- data/lib/review/extentions/string.rb +1 -1
- data/lib/review/htmlbuilder.rb +65 -15
- 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 +42 -21
- data/lib/review/idgxmlmaker.rb +15 -13
- data/lib/review/img_math.rb +1 -0
- data/lib/review/index_builder.rb +100 -38
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbuilder.rb +69 -34
- data/lib/review/lineinput.rb +3 -3
- data/lib/review/location.rb +1 -1
- data/lib/review/logger.rb +21 -21
- data/lib/review/makerhelper.rb +3 -3
- data/lib/review/markdownbuilder.rb +16 -8
- data/lib/review/pdfmaker.rb +40 -21
- data/lib/review/plaintextbuilder.rb +8 -7
- data/lib/review/preprocessor/repository.rb +1 -1
- data/lib/review/preprocessor.rb +5 -5
- data/lib/review/rstbuilder.rb +11 -2
- data/lib/review/textmaker.rb +20 -18
- data/lib/review/textutils.rb +5 -6
- data/lib/review/tocprinter.rb +11 -6
- data/lib/review/topbuilder.rb +89 -12
- 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 +32 -32
- data/lib/review/webtocprinter.rb +10 -10
- data/lib/review/yamlloader.rb +36 -2
- data/review.gemspec +2 -0
- data/samples/sample-book/src/config.yml +0 -1
- data/samples/syntax-book/ch02.re +16 -1
- data/templates/html/_titlepage.html.erb +9 -17
- data/templates/latex/config.erb +3 -0
- data/templates/latex/review-jlreq/review-base.sty +2 -1
- data/templates/latex/review-jlreq/review-jlreq.cls +36 -3
- data/templates/latex/review-jsbook/review-base.sty +7 -1
- data/templates/latex/review-jsbook/review-jsbook.cls +31 -4
- 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 +5 -3
- data/test/test_epub3maker.rb +3 -3
- data/test/test_epubmaker.rb +14 -29
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_htmlbuilder.rb +80 -8
- data/test/test_idgxmlbuilder.rb +13 -13
- 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 +53 -6
- data/test/test_markdownbuilder.rb +45 -0
- data/test/test_pdfmaker.rb +19 -0
- data/test/test_pdfmaker_cmd.rb +10 -10
- data/test/test_plaintextbuilder.rb +45 -4
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +169 -11
- data/test/test_yamlloader.rb +28 -42
- metadata +19 -4
data/test/test_latexbuilder.rb
CHANGED
@@ -257,6 +257,20 @@ EOS
|
|
257
257
|
assert_equal 'test \\reviewttb{inline test} test2', actual
|
258
258
|
end
|
259
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
|
+
|
260
274
|
def test_inline_hd_chap
|
261
275
|
def @chapter.headline_index
|
262
276
|
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
@@ -274,6 +288,40 @@ EOS
|
|
274
288
|
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
275
289
|
end
|
276
290
|
|
291
|
+
def test_inline_sec
|
292
|
+
def @chapter.headline_index
|
293
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
|
294
|
+
idx = Book::HeadlineIndex.new(self)
|
295
|
+
idx.add_item(item)
|
296
|
+
idx
|
297
|
+
end
|
298
|
+
|
299
|
+
@config['secnolevel'] = 3
|
300
|
+
actual = compile_inline('test @<secref>{test}')
|
301
|
+
assert_equal 'test \reviewsecref{「1.1.1 te\textunderscore{}st\textless{}\textgreater{}」}{sec:1-1-1}', actual
|
302
|
+
actual = compile_inline('test @<sectitle>{test}')
|
303
|
+
assert_equal 'test \reviewsecref{te\textunderscore{}st\textless{}\textgreater{}}{sec:1-1-1}', actual
|
304
|
+
actual = compile_inline('test @<sec>{test}')
|
305
|
+
assert_equal 'test \reviewsecref{1.1.1}{sec:1-1-1}', actual
|
306
|
+
|
307
|
+
@config['secnolevel'] = 2
|
308
|
+
actual = compile_inline('test @<secref>{test}')
|
309
|
+
assert_equal 'test \reviewsecref{「te\textunderscore{}st\textless{}\textgreater{}」}{sec:1-1-1}', actual
|
310
|
+
actual = compile_inline('test @<sectitle>{test}')
|
311
|
+
assert_equal 'test \reviewsecref{te\textunderscore{}st\textless{}\textgreater{}}{sec:1-1-1}', actual
|
312
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
|
313
|
+
assert_match(/the target headline doesn't have a number/, @log_io.string)
|
314
|
+
|
315
|
+
@config['chapterlink'] = nil
|
316
|
+
@config['secnolevel'] = 3
|
317
|
+
actual = compile_inline('test @<secref>{test}')
|
318
|
+
assert_equal 'test 「1.1.1 te\textunderscore{}st\textless{}\textgreater{}」', actual
|
319
|
+
actual = compile_inline('test @<sectitle>{test}')
|
320
|
+
assert_equal 'test te\textunderscore{}st\textless{}\textgreater{}', actual
|
321
|
+
actual = compile_inline('test @<sec>{test}')
|
322
|
+
assert_equal 'test 1.1.1', actual
|
323
|
+
end
|
324
|
+
|
277
325
|
def test_inline_pageref
|
278
326
|
actual = compile_inline('test p.@<pageref>{p1}')
|
279
327
|
assert_equal 'test p.\pageref{p1}', actual
|
@@ -2408,12 +2456,11 @@ EOS
|
|
2408
2456
|
|
2409
2457
|
def test_inline_w
|
2410
2458
|
Dir.mktmpdir do |dir|
|
2411
|
-
File.
|
2412
|
-
f.write <<EOB
|
2459
|
+
File.write(File.join(dir, 'words.csv'), <<EOB
|
2413
2460
|
"F","foo"
|
2414
2461
|
"B","bar""\\<>_@<b>{BAZ}"
|
2415
2462
|
EOB
|
2416
|
-
|
2463
|
+
)
|
2417
2464
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
2418
2465
|
|
2419
2466
|
io = StringIO.new
|
@@ -2596,7 +2643,7 @@ EOS
|
|
2596
2643
|
//beginchild
|
2597
2644
|
EOS
|
2598
2645
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2599
|
-
assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2646
|
+
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2600
2647
|
end
|
2601
2648
|
|
2602
2649
|
def test_nest_error_close2
|
@@ -2614,7 +2661,7 @@ EOS
|
|
2614
2661
|
//beginchild
|
2615
2662
|
EOS
|
2616
2663
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2617
|
-
assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
|
2664
|
+
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
2618
2665
|
end
|
2619
2666
|
|
2620
2667
|
def test_nest_error_close3
|
@@ -2634,7 +2681,7 @@ EOS
|
|
2634
2681
|
//endchild
|
2635
2682
|
EOS
|
2636
2683
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2637
|
-
assert_equal '//beginchild of ol,ul misses //endchild', e.message
|
2684
|
+
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
2638
2685
|
end
|
2639
2686
|
|
2640
2687
|
def test_nest_ul
|
@@ -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')
|
@@ -135,6 +148,38 @@ EOS
|
|
135
148
|
assert_equal 'test 「1.1.1 te_st」 test2', actual
|
136
149
|
end
|
137
150
|
|
151
|
+
def test_inline_sec
|
152
|
+
def @chapter.headline_index
|
153
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
|
154
|
+
idx = Book::HeadlineIndex.new(self)
|
155
|
+
idx.add_item(item)
|
156
|
+
idx
|
157
|
+
end
|
158
|
+
|
159
|
+
@config['secnolevel'] = 3
|
160
|
+
actual = compile_inline('test @<secref>{test}')
|
161
|
+
assert_equal 'test <a href="#h1-1-1">「1.1.1 te_st<>」</a>', actual
|
162
|
+
actual = compile_inline('test @<sectitle>{test}')
|
163
|
+
assert_equal 'test te_st<>', actual
|
164
|
+
actual = compile_inline('test @<sec>{test}')
|
165
|
+
assert_equal 'test 1.1.1', actual
|
166
|
+
|
167
|
+
@config['secnolevel'] = 2
|
168
|
+
actual = compile_inline('test @<secref>{test}')
|
169
|
+
assert_equal 'test <a href="#h1-1-1">「te_st<>」</a>', actual
|
170
|
+
actual = compile_inline('test @<sectitle>{test}')
|
171
|
+
assert_equal 'test te_st<>', actual
|
172
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
|
173
|
+
@config['chapterlink'] = nil
|
174
|
+
@config['secnolevel'] = 3
|
175
|
+
actual = compile_inline('test @<secref>{test}')
|
176
|
+
assert_equal 'test 「1.1.1 te_st<>」', actual
|
177
|
+
actual = compile_inline('test @<sectitle>{test}')
|
178
|
+
assert_equal 'test te_st<>', actual
|
179
|
+
actual = compile_inline('test @<sec>{test}')
|
180
|
+
assert_equal 'test 1.1.1', actual
|
181
|
+
end
|
182
|
+
|
138
183
|
def test_ul_nest1
|
139
184
|
src = <<-EOS
|
140
185
|
* AAA
|
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
|
@@ -67,6 +67,31 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
67
67
|
assert_equal 'http://github.com', actual
|
68
68
|
end
|
69
69
|
|
70
|
+
def test_inline_sec
|
71
|
+
def @chapter.headline_index
|
72
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
|
73
|
+
idx = Book::HeadlineIndex.new(self)
|
74
|
+
idx.add_item(item)
|
75
|
+
idx
|
76
|
+
end
|
77
|
+
|
78
|
+
@config['secnolevel'] = 3
|
79
|
+
actual = compile_inline('test @<secref>{test}')
|
80
|
+
assert_equal 'test 「1.1.1 te_st<>」', actual
|
81
|
+
actual = compile_inline('test @<sectitle>{test}')
|
82
|
+
assert_equal 'test te_st<>', actual
|
83
|
+
actual = compile_inline('test @<sec>{test}')
|
84
|
+
assert_equal 'test 1.1.1', actual
|
85
|
+
|
86
|
+
@config['secnolevel'] = 2
|
87
|
+
actual = compile_inline('test @<secref>{test}')
|
88
|
+
assert_equal 'test 「te_st<>」', actual
|
89
|
+
actual = compile_inline('test @<sectitle>{test}')
|
90
|
+
assert_equal 'test te_st<>', actual
|
91
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
|
92
|
+
assert_match(/the target headline doesn't have a number/, @log_io.string)
|
93
|
+
end
|
94
|
+
|
70
95
|
def test_inline_raw
|
71
96
|
actual = compile_inline('@<raw>{@<tt>{inline\}}')
|
72
97
|
assert_equal '@<tt>{inline}', actual
|
@@ -762,6 +787,18 @@ EOS
|
|
762
787
|
assert_equal %Q(\\sin\n1^{2}\n\n), actual
|
763
788
|
end
|
764
789
|
|
790
|
+
def test_endnote
|
791
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
792
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
793
|
+
|
794
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
795
|
+
expected = <<-'EOS'
|
796
|
+
(1)
|
797
|
+
(1) bar
|
798
|
+
EOS
|
799
|
+
assert_equal expected, actual
|
800
|
+
end
|
801
|
+
|
765
802
|
def test_inline_unknown
|
766
803
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
767
804
|
assert_match(/unknown image: n/, @log_io.string)
|
@@ -770,6 +807,10 @@ EOS
|
|
770
807
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
771
808
|
assert_match(/unknown footnote: n/, @log_io.string)
|
772
809
|
|
810
|
+
@log_io.string = ''
|
811
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
812
|
+
assert_match(/unknown endnote: n/, @log_io.string)
|
813
|
+
|
773
814
|
@log_io.string = ''
|
774
815
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
775
816
|
assert_match(/unknown headline: n/, @log_io.string)
|
@@ -899,7 +940,7 @@ EOS
|
|
899
940
|
//endchild
|
900
941
|
EOS
|
901
942
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
902
|
-
assert_equal "//endchild is shown, but any opened //beginchild doesn't exist", e.message
|
943
|
+
assert_equal ":1: //endchild is shown, but any opened //beginchild doesn't exist", e.message
|
903
944
|
end
|
904
945
|
|
905
946
|
def test_nest_error_close1
|
@@ -907,7 +948,7 @@ EOS
|
|
907
948
|
//beginchild
|
908
949
|
EOS
|
909
950
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
910
|
-
assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
951
|
+
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
911
952
|
end
|
912
953
|
|
913
954
|
def test_nest_error_close2
|
@@ -925,7 +966,7 @@ EOS
|
|
925
966
|
//beginchild
|
926
967
|
EOS
|
927
968
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
928
|
-
assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
|
969
|
+
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
929
970
|
end
|
930
971
|
|
931
972
|
def test_nest_error_close3
|
@@ -945,7 +986,7 @@ EOS
|
|
945
986
|
//endchild
|
946
987
|
EOS
|
947
988
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
948
|
-
assert_equal '//beginchild of ol,ul misses //endchild', e.message
|
989
|
+
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
949
990
|
end
|
950
991
|
|
951
992
|
def test_nest_ul
|
data/test/test_rstbuilder.rb
CHANGED
@@ -513,6 +513,19 @@ EOS
|
|
513
513
|
|
514
514
|
\\sin 1^{2}
|
515
515
|
|
516
|
+
EOS
|
517
|
+
assert_equal expected, actual
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_endnote
|
521
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
522
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
523
|
+
|
524
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
525
|
+
expected = <<-'EOS'
|
526
|
+
[(1)]_
|
527
|
+
|
528
|
+
.. [(1)] bar
|
516
529
|
EOS
|
517
530
|
assert_equal expected, actual
|
518
531
|
end
|
data/test/test_textmaker_cmd.rb
CHANGED
@@ -21,7 +21,7 @@ class TEXTMakerCmdTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def common_buildtext(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'] + '-text')
|
27
27
|
assert !File.exist?(builddir)
|
data/test/test_topbuilder.rb
CHANGED
@@ -151,7 +151,8 @@ class TOPBuidlerTest < Test::Unit::TestCase
|
|
151
151
|
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
|
152
152
|
expected = <<-EOS
|
153
153
|
◆→開始:表←◆
|
154
|
-
|
154
|
+
★1☆\t▲2☆
|
155
|
+
------------
|
155
156
|
★3☆\t▲4☆<>&
|
156
157
|
◆→終了:表←◆
|
157
158
|
|
@@ -506,7 +507,8 @@ EOS
|
|
506
507
|
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
507
508
|
expected = <<-EOS
|
508
509
|
◆→開始:表←◆
|
509
|
-
|
510
|
+
aaa\tbbb
|
511
|
+
------------
|
510
512
|
ccc\tddd<>&
|
511
513
|
◆→終了:表←◆
|
512
514
|
|
@@ -518,7 +520,8 @@ EOS
|
|
518
520
|
◆→開始:表←◆
|
519
521
|
表1.1 FOO
|
520
522
|
|
521
|
-
|
523
|
+
aaa\tbbb
|
524
|
+
------------
|
522
525
|
ccc\tddd<>&
|
523
526
|
◆→終了:表←◆
|
524
527
|
|
@@ -529,12 +532,36 @@ EOS
|
|
529
532
|
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
530
533
|
expected = <<-EOS
|
531
534
|
◆→開始:表←◆
|
532
|
-
|
535
|
+
aaa\tbbb
|
536
|
+
------------
|
533
537
|
ccc\tddd<>&
|
534
538
|
|
535
539
|
表1.1 FOO
|
536
540
|
◆→終了:表←◆
|
537
541
|
|
542
|
+
EOS
|
543
|
+
assert_equal expected, actual
|
544
|
+
end
|
545
|
+
|
546
|
+
def test_table_th_bold
|
547
|
+
@config['textmaker']['th_bold'] = true
|
548
|
+
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
549
|
+
expected = <<-EOS
|
550
|
+
◆→開始:表←◆
|
551
|
+
★aaa☆\t★bbb☆
|
552
|
+
ccc\tddd<>&
|
553
|
+
◆→終了:表←◆
|
554
|
+
|
555
|
+
EOS
|
556
|
+
assert_equal expected, actual
|
557
|
+
|
558
|
+
actual = compile_block("//table{\naaa\tbbb\nccc\tddd<>&\n//}\n")
|
559
|
+
expected = <<-EOS
|
560
|
+
◆→開始:表←◆
|
561
|
+
★aaa☆\tbbb
|
562
|
+
★ccc☆\tddd<>&
|
563
|
+
◆→終了:表←◆
|
564
|
+
|
538
565
|
EOS
|
539
566
|
assert_equal expected, actual
|
540
567
|
end
|
@@ -561,6 +588,28 @@ EOS
|
|
561
588
|
◆→開始:表←◆
|
562
589
|
foo
|
563
590
|
|
591
|
+
aaa\tbbb
|
592
|
+
------------
|
593
|
+
ccc\tddd<>&
|
594
|
+
◆→終了:表←◆
|
595
|
+
|
596
|
+
◆→開始:表←◆
|
597
|
+
aaa\tbbb
|
598
|
+
------------
|
599
|
+
ccc\tddd<>&
|
600
|
+
◆→終了:表←◆
|
601
|
+
|
602
|
+
EOS
|
603
|
+
assert_equal expected, actual
|
604
|
+
end
|
605
|
+
|
606
|
+
def test_emtable_thbold
|
607
|
+
@config['textmaker']['th_bold'] = true
|
608
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
609
|
+
expected = <<-EOS
|
610
|
+
◆→開始:表←◆
|
611
|
+
foo
|
612
|
+
|
564
613
|
★aaa☆\t★bbb☆
|
565
614
|
ccc\tddd<>&
|
566
615
|
◆→終了:表←◆
|
@@ -570,6 +619,37 @@ ccc\tddd<>&
|
|
570
619
|
ccc\tddd<>&
|
571
620
|
◆→終了:表←◆
|
572
621
|
|
622
|
+
EOS
|
623
|
+
assert_equal expected, actual
|
624
|
+
end
|
625
|
+
|
626
|
+
def test_imgtable
|
627
|
+
def @chapter.image(_id)
|
628
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
629
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
630
|
+
item
|
631
|
+
end
|
632
|
+
|
633
|
+
actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
|
634
|
+
expected = <<-EOS
|
635
|
+
◆→開始:表←◆
|
636
|
+
表1.1 sample photo
|
637
|
+
|
638
|
+
◆→./images/chap1-sampleimg.png←◆
|
639
|
+
◆→終了:表←◆
|
640
|
+
|
641
|
+
EOS
|
642
|
+
assert_equal expected, actual
|
643
|
+
|
644
|
+
@config['caption_position']['table'] = 'bottom'
|
645
|
+
actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
|
646
|
+
expected = <<-EOS
|
647
|
+
◆→開始:表←◆
|
648
|
+
◆→./images/chap1-sampleimg.png←◆
|
649
|
+
|
650
|
+
表1.1 sample photo
|
651
|
+
◆→終了:表←◆
|
652
|
+
|
573
653
|
EOS
|
574
654
|
assert_equal expected, actual
|
575
655
|
end
|
@@ -578,7 +658,8 @@ EOS
|
|
578
658
|
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
579
659
|
expected = <<-EOS
|
580
660
|
◆→開始:表←◆
|
581
|
-
|
661
|
+
1 2 3 4| 5
|
662
|
+
------------
|
582
663
|
a b c d |e
|
583
664
|
◆→終了:表←◆
|
584
665
|
|
@@ -590,7 +671,8 @@ EOS
|
|
590
671
|
actual = compile_block(src)
|
591
672
|
expected = <<-EOS
|
592
673
|
◆→開始:表←◆
|
593
|
-
|
674
|
+
1 2 3 4| 5
|
675
|
+
------------
|
594
676
|
a b c d |e
|
595
677
|
◆→終了:表←◆
|
596
678
|
|
@@ -601,7 +683,8 @@ EOS
|
|
601
683
|
actual = compile_block(src)
|
602
684
|
expected = <<-EOS
|
603
685
|
◆→開始:表←◆
|
604
|
-
|
686
|
+
1 2 3 4| 5
|
687
|
+
------------
|
605
688
|
a b c d |e
|
606
689
|
◆→終了:表←◆
|
607
690
|
|
@@ -612,7 +695,8 @@ EOS
|
|
612
695
|
actual = compile_block(src)
|
613
696
|
expected = <<-EOS
|
614
697
|
◆→開始:表←◆
|
615
|
-
|
698
|
+
1 2 3 4 5
|
699
|
+
------------
|
616
700
|
a b c d e
|
617
701
|
◆→終了:表←◆
|
618
702
|
|
@@ -965,6 +1049,63 @@ EOS
|
|
965
1049
|
図1.1 sample photo
|
966
1050
|
◆→終了:図←◆
|
967
1051
|
|
1052
|
+
EOS
|
1053
|
+
assert_equal expected, actual
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
def test_image_dummy
|
1057
|
+
actual = compile_block("//image[dummy][sample photo]{\nDUMMY\n//}\n")
|
1058
|
+
expected = <<-EOS
|
1059
|
+
◆→開始:図←◆
|
1060
|
+
DUMMY
|
1061
|
+
|
1062
|
+
図1.1 sample photo
|
1063
|
+
◆→終了:図←◆
|
1064
|
+
|
1065
|
+
EOS
|
1066
|
+
assert_equal expected, actual
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
def test_indepimage
|
1070
|
+
def @chapter.image(_id)
|
1071
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
1072
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1073
|
+
item
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
|
1077
|
+
expected = <<-EOS
|
1078
|
+
◆→開始:図←◆
|
1079
|
+
◆→./images/chap1-sampleimg.png←◆
|
1080
|
+
|
1081
|
+
図 sample photo
|
1082
|
+
◆→終了:図←◆
|
1083
|
+
|
1084
|
+
EOS
|
1085
|
+
assert_equal expected, actual
|
1086
|
+
|
1087
|
+
@config['caption_position']['image'] = 'top'
|
1088
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
|
1089
|
+
expected = <<-EOS
|
1090
|
+
◆→開始:図←◆
|
1091
|
+
図 sample photo
|
1092
|
+
|
1093
|
+
◆→./images/chap1-sampleimg.png←◆
|
1094
|
+
◆→終了:図←◆
|
1095
|
+
|
1096
|
+
EOS
|
1097
|
+
assert_equal expected, actual
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
def test_indepimage_dummy
|
1101
|
+
actual = compile_block("//indepimage[dummy][sample photo]{\nDUMMY\n//}\n")
|
1102
|
+
expected = <<-EOS
|
1103
|
+
◆→開始:図←◆
|
1104
|
+
DUMMY
|
1105
|
+
|
1106
|
+
図 sample photo
|
1107
|
+
◆→終了:図←◆
|
1108
|
+
|
968
1109
|
EOS
|
969
1110
|
assert_equal expected, actual
|
970
1111
|
end
|
@@ -983,12 +1124,11 @@ EOS
|
|
983
1124
|
|
984
1125
|
def test_inline_w
|
985
1126
|
Dir.mktmpdir do |dir|
|
986
|
-
File.
|
987
|
-
f.write <<EOB
|
1127
|
+
File.write(File.join(dir, 'words.csv'), <<EOB
|
988
1128
|
"F","foo"
|
989
1129
|
"B","bar""\\<>_@<b>{BAZ}"
|
990
1130
|
EOB
|
991
|
-
|
1131
|
+
)
|
992
1132
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
993
1133
|
|
994
1134
|
io = StringIO.new
|
@@ -999,6 +1139,20 @@ EOB
|
|
999
1139
|
end
|
1000
1140
|
end
|
1001
1141
|
|
1142
|
+
def test_endnote
|
1143
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
1144
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
1145
|
+
|
1146
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
1147
|
+
expected = <<-'EOS'
|
1148
|
+
【後注1】
|
1149
|
+
◆→開始:後注←◆
|
1150
|
+
【後注1】bar
|
1151
|
+
◆→終了:後注←◆
|
1152
|
+
EOS
|
1153
|
+
assert_equal expected, actual
|
1154
|
+
end
|
1155
|
+
|
1002
1156
|
def test_inline_unknown
|
1003
1157
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1004
1158
|
assert_match(/unknown image: n/, @log_io.string)
|
@@ -1007,6 +1161,10 @@ EOB
|
|
1007
1161
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1008
1162
|
assert_match(/unknown footnote: n/, @log_io.string)
|
1009
1163
|
|
1164
|
+
@log_io.string = ''
|
1165
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
1166
|
+
assert_match(/unknown endnote: n/, @log_io.string)
|
1167
|
+
|
1010
1168
|
@log_io.string = ''
|
1011
1169
|
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1012
1170
|
assert_match(/unknown headline: n/, @log_io.string)
|