review 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -1
- data/.travis.yml +16 -15
- data/NEWS.ja.md +75 -0
- data/NEWS.md +75 -0
- data/appveyor.yml +20 -2
- data/bin/review-catalog-converter +3 -3
- data/bin/review-check +3 -3
- data/bin/review-compile +6 -6
- data/bin/review-epubmaker +3 -35
- data/bin/review-index +5 -5
- data/bin/review-preproc +4 -4
- data/bin/review-vol +5 -5
- data/doc/format.ja.md +6 -4
- data/doc/format.md +3 -1
- data/lib/epubmaker/epubcommon.rb +1 -2
- data/lib/epubmaker/epubv2.rb +1 -1
- data/lib/epubmaker/epubv3.rb +1 -0
- data/lib/epubmaker/producer.rb +2 -1
- data/lib/review/book/base.rb +5 -5
- data/lib/review/book/index.rb +18 -5
- data/lib/review/builder.rb +8 -2
- data/lib/review/compiler.rb +11 -34
- data/lib/review/epub2html.rb +37 -4
- data/lib/review/epubmaker.rb +40 -3
- data/lib/review/htmlbuilder.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +9 -8
- data/lib/review/init.rb +7 -7
- data/lib/review/latexbuilder.rb +36 -14
- data/lib/review/location.rb +32 -0
- data/lib/review/markdownbuilder.rb +8 -1
- data/lib/review/plaintextbuilder.rb +9 -9
- data/lib/review/preprocessor.rb +2 -24
- data/lib/review/topbuilder.rb +4 -4
- data/lib/review/update.rb +3 -3
- data/lib/review/version.rb +1 -1
- data/lib/review/yamlloader.rb +23 -16
- data/review.gemspec +3 -2
- data/templates/latex/config.erb +4 -0
- data/templates/latex/review-jlreq/review-base.sty +45 -22
- data/templates/latex/review-jsbook/review-base.sty +20 -15
- data/templates/latex/review-jsbook/review-jsbook.cls +3 -3
- data/templates/opf/epubv3.opf.erb +1 -0
- data/test/assets/test_template.tex +4 -0
- data/test/assets/test_template_backmatter.tex +4 -0
- data/test/test_book.rb +1 -1
- data/test/test_builder.rb +16 -0
- data/test/test_catalog.rb +5 -0
- data/test/test_htmlbuilder.rb +471 -96
- data/test/test_idgxmlbuilder.rb +132 -17
- data/test/test_index.rb +40 -0
- data/test/test_latexbuilder.rb +668 -72
- data/test/test_latexbuilder_v2.rb +597 -68
- data/test/test_markdownbuilder.rb +90 -13
- data/test/test_md2inaobuilder.rb +20 -7
- data/test/test_plaintextbuilder.rb +241 -19
- data/test/test_preprocessor.rb +2 -16
- data/test/test_rstbuilder.rb +216 -22
- data/test/test_topbuilder.rb +334 -22
- metadata +20 -6
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -133,6 +133,14 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
133
133
|
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>), actual
|
134
134
|
end
|
135
135
|
|
136
|
+
def test_empty_table
|
137
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
|
138
|
+
assert_equal ':2: error: no rows in the table', e.message
|
139
|
+
|
140
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
|
141
|
+
assert_equal ':3: error: no rows in the table', e.message
|
142
|
+
end
|
143
|
+
|
136
144
|
def test_emtable
|
137
145
|
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
138
146
|
assert_equal %Q(<table><caption>foo</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
@@ -266,18 +274,39 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
266
274
|
def test_emlist_listinfo
|
267
275
|
@config['listinfo'] = true
|
268
276
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
269
|
-
|
277
|
+
expected = <<-EOS.chomp
|
278
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
279
|
+
</listinfo><listinfo line="2">test1.5
|
280
|
+
</listinfo><listinfo line="3">
|
281
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
282
|
+
</listinfo></pre></list>
|
283
|
+
EOS
|
284
|
+
assert_equal expected, actual
|
270
285
|
end
|
271
286
|
|
272
287
|
def test_emlist_with_tab
|
273
288
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
274
|
-
|
289
|
+
expected = <<-EOS.chomp
|
290
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
291
|
+
test1.5
|
292
|
+
|
293
|
+
test<i>2</i>
|
294
|
+
</pre></list>
|
295
|
+
EOS
|
296
|
+
assert_equal expected, actual
|
275
297
|
end
|
276
298
|
|
277
299
|
def test_emlist_with_4tab
|
278
300
|
@config['tabwidth'] = 4
|
279
301
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
280
|
-
|
302
|
+
expected = <<-EOS.chomp
|
303
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
304
|
+
test1.5
|
305
|
+
|
306
|
+
test<i>2</i>
|
307
|
+
</pre></list>
|
308
|
+
EOS
|
309
|
+
assert_equal expected, actual
|
281
310
|
end
|
282
311
|
|
283
312
|
def test_list
|
@@ -285,7 +314,14 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
285
314
|
Book::ListIndex::Item.new('samplelist', 1)
|
286
315
|
end
|
287
316
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
288
|
-
|
317
|
+
expected = <<-EOS.chomp
|
318
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1
|
319
|
+
test1.5
|
320
|
+
|
321
|
+
test<i>2</i>
|
322
|
+
</pre></codelist>
|
323
|
+
EOS
|
324
|
+
assert_equal expected, actual
|
289
325
|
end
|
290
326
|
|
291
327
|
def test_listnum
|
@@ -293,7 +329,14 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
293
329
|
Book::ListIndex::Item.new('samplelist', 1)
|
294
330
|
end
|
295
331
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
296
|
-
|
332
|
+
expected = <<-EOS.chomp
|
333
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1
|
334
|
+
<span type='lineno'> 2: </span>test1.5
|
335
|
+
<span type='lineno'> 3: </span>
|
336
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
337
|
+
</pre></codelist>
|
338
|
+
EOS
|
339
|
+
assert_equal expected, actual
|
297
340
|
end
|
298
341
|
|
299
342
|
def test_listnum_linenum
|
@@ -301,7 +344,14 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
301
344
|
Book::ListIndex::Item.new('samplelist', 1)
|
302
345
|
end
|
303
346
|
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
304
|
-
|
347
|
+
expected = <<-EOS.chomp
|
348
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1
|
349
|
+
<span type='lineno'>101: </span>test1.5
|
350
|
+
<span type='lineno'>102: </span>
|
351
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
352
|
+
</pre></codelist>
|
353
|
+
EOS
|
354
|
+
assert_equal expected, actual
|
305
355
|
end
|
306
356
|
|
307
357
|
def test_list_listinfo
|
@@ -310,25 +360,95 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
310
360
|
end
|
311
361
|
@config['listinfo'] = true
|
312
362
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
313
|
-
|
363
|
+
expected = <<-EOS.chomp
|
364
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
365
|
+
</listinfo><listinfo line="2">test1.5
|
366
|
+
</listinfo><listinfo line="3">
|
367
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
368
|
+
</listinfo></pre></codelist>
|
369
|
+
EOS
|
370
|
+
assert_equal expected, actual
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_cmd
|
374
|
+
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
375
|
+
expected = <<-EOS.chomp
|
376
|
+
<list type='cmd'><pre>lineA
|
377
|
+
lineB
|
378
|
+
</pre></list>
|
379
|
+
EOS
|
380
|
+
assert_equal expected, actual
|
381
|
+
|
382
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
383
|
+
expected = <<-EOS.chomp
|
384
|
+
<list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
|
385
|
+
lineB
|
386
|
+
</pre></list>
|
387
|
+
EOS
|
388
|
+
assert_equal expected, actual
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_source
|
392
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
393
|
+
expected = <<-EOS.chomp
|
394
|
+
<source><caption>foo/bar/test.rb</caption><pre>foo
|
395
|
+
bar
|
396
|
+
|
397
|
+
buz
|
398
|
+
</pre></source>
|
399
|
+
EOS
|
400
|
+
assert_equal expected, actual
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_source_empty_caption
|
404
|
+
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
405
|
+
expected = <<-EOS.chomp
|
406
|
+
<source><pre>foo
|
407
|
+
bar
|
408
|
+
|
409
|
+
buz
|
410
|
+
</pre></source>
|
411
|
+
EOS
|
412
|
+
assert_equal expected, actual
|
314
413
|
end
|
315
414
|
|
316
415
|
def test_insn
|
317
416
|
@config['listinfo'] = true
|
318
417
|
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
319
|
-
|
418
|
+
expected = <<-EOS.chomp
|
419
|
+
<insn><floattitle type="insn">this is <b>test</b><&>_</floattitle><listinfo line="1" begin="1">test1
|
420
|
+
</listinfo><listinfo line="2">test1.5
|
421
|
+
</listinfo><listinfo line="3">
|
422
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
423
|
+
</listinfo></insn>
|
424
|
+
EOS
|
425
|
+
assert_equal expected, actual
|
320
426
|
end
|
321
427
|
|
322
428
|
def test_box
|
323
429
|
@config['listinfo'] = true
|
324
430
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
325
|
-
|
431
|
+
expected = <<-EOS.chomp
|
432
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption><listinfo line="1" begin="1">test1
|
433
|
+
</listinfo><listinfo line="2">test1.5
|
434
|
+
</listinfo><listinfo line="3">
|
435
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
436
|
+
</listinfo></box>
|
437
|
+
EOS
|
438
|
+
assert_equal expected, actual
|
326
439
|
end
|
327
440
|
|
328
441
|
def test_box_non_listinfo
|
329
442
|
@config['listinfo'] = nil
|
330
443
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
331
|
-
|
444
|
+
expected = <<-EOS.chomp
|
445
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption>test1
|
446
|
+
test1.5
|
447
|
+
|
448
|
+
test<i>2</i>
|
449
|
+
</box>
|
450
|
+
EOS
|
451
|
+
assert_equal expected, actual
|
332
452
|
end
|
333
453
|
|
334
454
|
def test_flushright
|
@@ -577,15 +697,10 @@ EOS
|
|
577
697
|
src = <<-EOS
|
578
698
|
** AAA
|
579
699
|
* AA
|
580
|
-
* BBB
|
581
|
-
** BB
|
582
700
|
EOS
|
583
701
|
|
584
|
-
|
585
|
-
|
586
|
-
EOS
|
587
|
-
actual = compile_block(src)
|
588
|
-
assert_equal expected, actual
|
702
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
703
|
+
assert_equal ':1: error: too many *.', e.message
|
589
704
|
end
|
590
705
|
|
591
706
|
def test_ul_nest4
|
data/test/test_index.rb
CHANGED
@@ -208,4 +208,44 @@ class IndexTest < Test::Unit::TestCase
|
|
208
208
|
index = Book::HeadlineIndex.parse(src, chap)
|
209
209
|
assert_equal [1, 1, 1], index['sec1-1-1'].number
|
210
210
|
end
|
211
|
+
|
212
|
+
def test_headeline_index11
|
213
|
+
src = <<-EOB
|
214
|
+
= chap1
|
215
|
+
==[nodisp] sec01
|
216
|
+
==[notoc] sec02
|
217
|
+
== sec1
|
218
|
+
===[nodisp] sec1-0
|
219
|
+
=== sec1-1
|
220
|
+
==[nonum] sec03
|
221
|
+
== sec04
|
222
|
+
EOB
|
223
|
+
book = Book::Base.load
|
224
|
+
chap = Book::Chapter.new(book, 1, '-', nil)
|
225
|
+
index = Book::HeadlineIndex.parse(src, chap)
|
226
|
+
assert_equal nil, index['sec01'].number
|
227
|
+
assert_equal nil, index['sec02'].number
|
228
|
+
assert_equal [1], index['sec1'].number
|
229
|
+
assert_equal nil, index['sec1-0'].number
|
230
|
+
assert_equal [1, 1], index['sec1-1'].number
|
231
|
+
assert_equal nil, index['sec03'].number
|
232
|
+
assert_equal [2], index['sec04'].number
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_headeline_index12
|
236
|
+
src = <<-EOB
|
237
|
+
= chap1
|
238
|
+
== A
|
239
|
+
=== A2
|
240
|
+
==[nonum] B
|
241
|
+
=== B2
|
242
|
+
EOB
|
243
|
+
book = Book::Base.load
|
244
|
+
chap = Book::Chapter.new(book, 1, '-', nil)
|
245
|
+
index = Book::HeadlineIndex.parse(src, chap)
|
246
|
+
assert_equal [1], index['A'].number
|
247
|
+
assert_equal [1, 1], index['A2'].number
|
248
|
+
assert_equal nil, index['B'].number
|
249
|
+
assert_equal [1, 2], index['B2'].number
|
250
|
+
end
|
211
251
|
end
|
data/test/test_latexbuilder.rb
CHANGED
@@ -39,34 +39,62 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
39
39
|
|
40
40
|
def test_headline_level1
|
41
41
|
actual = compile_block("={test} this is test.\n")
|
42
|
-
|
42
|
+
expected = <<-EOS
|
43
|
+
\\chapter{this is test.}
|
44
|
+
\\label{chap:chap1}
|
45
|
+
EOS
|
46
|
+
assert_equal expected, actual
|
43
47
|
end
|
44
48
|
|
45
49
|
def test_headline_level1_without_secno
|
46
50
|
@config['secnolevel'] = 0
|
47
51
|
actual = compile_block("={test} this is test.\n")
|
48
|
-
|
52
|
+
expected = <<-EOS
|
53
|
+
\\chapter*{this is test.}
|
54
|
+
\\addcontentsline{toc}{chapter}{this is test.}
|
55
|
+
\\label{chap:chap1}
|
56
|
+
EOS
|
57
|
+
assert_equal expected, actual
|
49
58
|
end
|
50
59
|
|
51
60
|
def test_headline_level1_with_inlinetag
|
52
61
|
actual = compile_block(%Q(={test} this @<b>{is} test.<&"_>\n))
|
53
|
-
|
62
|
+
expected = <<-EOS
|
63
|
+
\\chapter{this \\reviewbold{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}
|
64
|
+
\\label{chap:chap1}
|
65
|
+
EOS
|
66
|
+
assert_equal expected, actual
|
54
67
|
end
|
55
68
|
|
56
69
|
def test_headline_level2
|
57
70
|
actual = compile_block("=={test} this is test.\n")
|
58
|
-
|
71
|
+
expected = <<-EOS
|
72
|
+
\\section{this is test.}
|
73
|
+
\\label{sec:1-1}
|
74
|
+
\\label{test}
|
75
|
+
EOS
|
76
|
+
assert_equal expected, actual
|
59
77
|
end
|
60
78
|
|
61
79
|
def test_headline_level3
|
62
80
|
actual = compile_block("==={test} this is test.\n")
|
63
|
-
|
81
|
+
expected = <<-EOS
|
82
|
+
\\subsection*{this is test.}
|
83
|
+
\\label{sec:1-0-1}
|
84
|
+
\\label{test}
|
85
|
+
EOS
|
86
|
+
assert_equal expected, actual
|
64
87
|
end
|
65
88
|
|
66
89
|
def test_headline_level3_with_secno
|
67
90
|
@config['secnolevel'] = 3
|
68
91
|
actual = compile_block("==={test} this is test.\n")
|
69
|
-
|
92
|
+
expected = <<-EOS
|
93
|
+
\\subsection{this is test.}
|
94
|
+
\\label{sec:1-0-1}
|
95
|
+
\\label{test}
|
96
|
+
EOS
|
97
|
+
assert_equal expected, actual
|
70
98
|
end
|
71
99
|
|
72
100
|
def test_label
|
@@ -169,6 +197,11 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
169
197
|
assert_equal 'abc\\reviewunderline{def}ghi', actual
|
170
198
|
end
|
171
199
|
|
200
|
+
def test_inline_bou
|
201
|
+
actual = compile_inline('傍点の@<bou>{テスト}です。')
|
202
|
+
assert_equal '傍点の\\reviewbou{テスト}です。', actual
|
203
|
+
end
|
204
|
+
|
172
205
|
def test_inline_m
|
173
206
|
@config['review_version'] = '3.0'
|
174
207
|
actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
|
@@ -275,46 +308,137 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
275
308
|
|
276
309
|
def test_dlist
|
277
310
|
actual = compile_block(": foo\n foo.\n bar.\n")
|
278
|
-
|
311
|
+
expected = <<-EOS
|
312
|
+
|
313
|
+
\\begin{description}
|
314
|
+
\\item[foo] \\mbox{} \\\\
|
315
|
+
foo.
|
316
|
+
bar.
|
317
|
+
\\end{description}
|
318
|
+
EOS
|
319
|
+
assert_equal expected, actual
|
279
320
|
end
|
280
321
|
|
281
322
|
def test_dlist_with_bracket
|
282
323
|
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
283
|
-
|
324
|
+
expected = <<-EOS
|
325
|
+
|
326
|
+
\\begin{description}
|
327
|
+
\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\
|
328
|
+
foo.
|
329
|
+
bar.
|
330
|
+
\\end{description}
|
331
|
+
EOS
|
332
|
+
assert_equal expected, actual
|
284
333
|
end
|
285
334
|
|
286
335
|
def test_dlist_beforeulol
|
287
336
|
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
|
288
|
-
|
337
|
+
expected = <<-EOS
|
338
|
+
|
339
|
+
\\begin{description}
|
340
|
+
\\item[foo] \\mbox{} \\\\
|
341
|
+
foo.
|
342
|
+
\\end{description}
|
343
|
+
|
344
|
+
para
|
345
|
+
|
346
|
+
\\begin{description}
|
347
|
+
\\item[foo] \\mbox{} \\\\
|
348
|
+
foo.
|
349
|
+
\\end{description}
|
350
|
+
|
351
|
+
\\begin{enumerate}
|
352
|
+
\\item bar
|
353
|
+
\\end{enumerate}
|
354
|
+
|
355
|
+
\\begin{description}
|
356
|
+
\\item[foo] \\mbox{} \\\\
|
357
|
+
foo.
|
358
|
+
\\end{description}
|
359
|
+
|
360
|
+
\\begin{itemize}
|
361
|
+
\\item bar
|
362
|
+
\\end{itemize}
|
363
|
+
EOS
|
364
|
+
assert_equal expected, actual
|
289
365
|
end
|
290
366
|
|
291
367
|
def test_cmd
|
292
368
|
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
|
293
|
-
|
369
|
+
expected = <<-EOS
|
370
|
+
|
371
|
+
\\begin{reviewlistblock}
|
372
|
+
\\begin{reviewcmd}
|
373
|
+
foo
|
374
|
+
bar
|
375
|
+
|
376
|
+
buz
|
377
|
+
\\end{reviewcmd}
|
378
|
+
\\end{reviewlistblock}
|
379
|
+
EOS
|
380
|
+
assert_equal expected, actual
|
294
381
|
end
|
295
382
|
|
296
383
|
def test_cmd_caption
|
297
384
|
actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
298
|
-
|
385
|
+
expected = <<-EOS
|
386
|
+
|
387
|
+
\\begin{reviewlistblock}
|
388
|
+
\\reviewcmdcaption{cap1}
|
389
|
+
\\begin{reviewcmd}
|
390
|
+
foo
|
391
|
+
bar
|
392
|
+
|
393
|
+
buz
|
394
|
+
\\end{reviewcmd}
|
395
|
+
\\end{reviewlistblock}
|
396
|
+
EOS
|
397
|
+
assert_equal expected, actual
|
299
398
|
end
|
300
399
|
|
301
400
|
def test_cmd_lst
|
302
401
|
@book.config['highlight'] = {}
|
303
402
|
@book.config['highlight']['latex'] = 'listings'
|
304
403
|
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
|
305
|
-
|
404
|
+
expected = <<-EOS
|
405
|
+
\\begin{reviewcmdlst}[language={}]
|
406
|
+
foo
|
407
|
+
bar
|
408
|
+
|
409
|
+
buz
|
410
|
+
\\end{reviewcmdlst}
|
411
|
+
EOS
|
412
|
+
assert_equal expected, actual
|
306
413
|
end
|
307
414
|
|
308
415
|
def test_emlist
|
309
416
|
actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
|
310
|
-
|
417
|
+
expected = <<-EOS
|
418
|
+
|
419
|
+
\\begin{reviewlistblock}
|
420
|
+
\\begin{reviewemlist}
|
421
|
+
foo
|
422
|
+
bar
|
423
|
+
|
424
|
+
buz
|
425
|
+
\\end{reviewemlist}
|
426
|
+
\\end{reviewlistblock}
|
427
|
+
EOS
|
428
|
+
assert_equal expected, actual
|
311
429
|
end
|
312
430
|
|
313
431
|
def test_emlist_lst
|
314
432
|
@book.config['highlight'] = {}
|
315
433
|
@book.config['highlight']['latex'] = 'listings'
|
316
434
|
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
317
|
-
|
435
|
+
expected = <<-EOS
|
436
|
+
|
437
|
+
\\begin{reviewemlistlst}[language={sql}]
|
438
|
+
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
439
|
+
\\end{reviewemlistlst}
|
440
|
+
EOS
|
441
|
+
assert_equal expected, actual
|
318
442
|
end
|
319
443
|
|
320
444
|
def test_emlist_lst_without_lang
|
@@ -322,45 +446,124 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
322
446
|
@book.config['highlight']['latex'] = 'listings'
|
323
447
|
@book.config['highlight']['lang'] = 'sql'
|
324
448
|
actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
325
|
-
|
449
|
+
expected = <<-EOS
|
450
|
+
|
451
|
+
\\begin{reviewemlistlst}[language={sql}]
|
452
|
+
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
453
|
+
\\end{reviewemlistlst}
|
454
|
+
EOS
|
455
|
+
assert_equal expected, actual
|
326
456
|
end
|
327
457
|
|
328
458
|
def test_emlist_caption
|
329
459
|
actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
330
|
-
|
460
|
+
expected = <<-EOS
|
461
|
+
|
462
|
+
\\begin{reviewlistblock}
|
463
|
+
\\reviewemlistcaption{cap1}
|
464
|
+
\\begin{reviewemlist}
|
465
|
+
foo
|
466
|
+
bar
|
467
|
+
|
468
|
+
buz
|
469
|
+
\\end{reviewemlist}
|
470
|
+
\\end{reviewlistblock}
|
471
|
+
EOS
|
472
|
+
assert_equal expected, actual
|
331
473
|
end
|
332
474
|
|
333
475
|
def test_emlist_empty_caption
|
334
476
|
actual = compile_block("//emlist[]{\nfoo\nbar\n\nbuz\n//}\n")
|
335
|
-
|
477
|
+
expected = <<-EOS
|
478
|
+
|
479
|
+
\\begin{reviewlistblock}
|
480
|
+
\\begin{reviewemlist}
|
481
|
+
foo
|
482
|
+
bar
|
483
|
+
|
484
|
+
buz
|
485
|
+
\\end{reviewemlist}
|
486
|
+
\\end{reviewlistblock}
|
487
|
+
EOS
|
488
|
+
assert_equal expected, actual
|
336
489
|
end
|
337
490
|
|
338
491
|
def test_emlist_with_tab
|
339
492
|
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
|
340
|
-
|
493
|
+
expected = <<-EOS
|
494
|
+
|
495
|
+
\\begin{reviewlistblock}
|
496
|
+
\\begin{reviewemlist}
|
497
|
+
foo
|
498
|
+
bar
|
499
|
+
|
500
|
+
buz
|
501
|
+
\\end{reviewemlist}
|
502
|
+
\\end{reviewlistblock}
|
503
|
+
EOS
|
504
|
+
assert_equal expected, actual
|
341
505
|
end
|
342
506
|
|
343
507
|
def test_emlist_with_tab4
|
344
508
|
@config['tabwidth'] = 4
|
345
509
|
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
|
346
|
-
|
510
|
+
expected = <<-EOS
|
511
|
+
|
512
|
+
\\begin{reviewlistblock}
|
513
|
+
\\begin{reviewemlist}
|
514
|
+
foo
|
515
|
+
bar
|
516
|
+
|
517
|
+
buz
|
518
|
+
\\end{reviewemlist}
|
519
|
+
\\end{reviewlistblock}
|
520
|
+
EOS
|
521
|
+
assert_equal expected, actual
|
347
522
|
end
|
348
523
|
|
349
524
|
def test_emlistnum_caption
|
350
525
|
actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
351
|
-
|
526
|
+
expected = <<-EOS
|
527
|
+
|
528
|
+
\\begin{reviewlistblock}
|
529
|
+
\\reviewemlistcaption{cap1}
|
530
|
+
\\begin{reviewemlist}
|
531
|
+
1: foo
|
532
|
+
2: bar
|
533
|
+
3:
|
534
|
+
4: buz
|
535
|
+
\\end{reviewemlist}
|
536
|
+
\\end{reviewlistblock}
|
537
|
+
EOS
|
538
|
+
assert_equal expected, actual
|
352
539
|
end
|
353
540
|
|
354
541
|
def test_list
|
355
542
|
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
356
|
-
|
543
|
+
expected = <<-EOS
|
544
|
+
\\begin{reviewlistblock}
|
545
|
+
\\reviewlistcaption{リスト1.1: cap1}
|
546
|
+
\\begin{reviewlist}
|
547
|
+
foo
|
548
|
+
bar
|
549
|
+
|
550
|
+
buz
|
551
|
+
\\end{reviewlist}
|
552
|
+
\\end{reviewlistblock}
|
553
|
+
EOS
|
554
|
+
assert_equal expected, actual
|
357
555
|
end
|
358
556
|
|
359
557
|
def test_list_lst
|
360
558
|
@book.config['highlight'] = {}
|
361
559
|
@book.config['highlight']['latex'] = 'listings'
|
362
560
|
actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
363
|
-
|
561
|
+
expected = <<-EOS
|
562
|
+
\\begin{reviewlistlst}[caption={cap1},language={sql}]
|
563
|
+
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
564
|
+
\\end{reviewlistlst}
|
565
|
+
EOS
|
566
|
+
assert_equal expected, actual
|
364
567
|
end
|
365
568
|
|
366
569
|
def test_list_lst_with_lang
|
@@ -368,78 +571,206 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
368
571
|
@book.config['highlight']['latex'] = 'listings'
|
369
572
|
@book.config['highlight']['lang'] = 'sql'
|
370
573
|
actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
371
|
-
|
574
|
+
expected = <<-EOS
|
575
|
+
\\begin{reviewlistlst}[caption={cap1},language={sql}]
|
576
|
+
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
577
|
+
\\end{reviewlistlst}
|
578
|
+
EOS
|
579
|
+
assert_equal expected, actual
|
372
580
|
end
|
373
581
|
|
374
582
|
def test_listnum
|
375
583
|
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
376
|
-
|
584
|
+
expected = <<-EOS
|
585
|
+
\\begin{reviewlistblock}
|
586
|
+
\\reviewlistcaption{リスト1.1: ruby}
|
587
|
+
\\begin{reviewlist}
|
588
|
+
1: class Foo
|
589
|
+
2: def foo
|
590
|
+
3: bar
|
591
|
+
4:
|
592
|
+
5: buz
|
593
|
+
6: end
|
594
|
+
7: end
|
595
|
+
\\end{reviewlist}
|
596
|
+
\\end{reviewlistblock}
|
597
|
+
EOS
|
598
|
+
assert_equal expected, actual
|
377
599
|
end
|
378
600
|
|
379
601
|
def test_listnum_linenum
|
380
602
|
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
381
|
-
|
603
|
+
expected = <<-EOS
|
604
|
+
\\begin{reviewlistblock}
|
605
|
+
\\reviewlistcaption{リスト1.1: ruby}
|
606
|
+
\\begin{reviewlist}
|
607
|
+
100: class Foo
|
608
|
+
101: def foo
|
609
|
+
102: bar
|
610
|
+
103:
|
611
|
+
104: buz
|
612
|
+
105: end
|
613
|
+
106: end
|
614
|
+
\\end{reviewlist}
|
615
|
+
\\end{reviewlistblock}
|
616
|
+
EOS
|
617
|
+
assert_equal expected, actual
|
382
618
|
end
|
383
619
|
|
384
620
|
def test_listnum_lst
|
385
621
|
@book.config['highlight'] = {}
|
386
622
|
@book.config['highlight']['latex'] = 'listings'
|
387
623
|
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
388
|
-
|
624
|
+
expected = <<-EOS
|
625
|
+
\\begin{reviewlistnumlst}[caption={ruby},language={}]
|
626
|
+
class Foo
|
627
|
+
def foo
|
628
|
+
bar
|
629
|
+
|
630
|
+
buz
|
631
|
+
end
|
632
|
+
end
|
633
|
+
\\end{reviewlistnumlst}
|
634
|
+
EOS
|
635
|
+
assert_equal expected, actual
|
389
636
|
end
|
390
637
|
|
391
638
|
def test_listnum_lst_linenum
|
392
639
|
@book.config['highlight'] = {}
|
393
640
|
@book.config['highlight']['latex'] = 'listings'
|
394
641
|
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
395
|
-
|
642
|
+
expected = <<-EOS
|
643
|
+
\\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]
|
644
|
+
class Foo
|
645
|
+
def foo
|
646
|
+
bar
|
647
|
+
|
648
|
+
buz
|
649
|
+
end
|
650
|
+
end
|
651
|
+
\\end{reviewlistnumlst}
|
652
|
+
EOS
|
653
|
+
assert_equal expected, actual
|
396
654
|
end
|
397
655
|
|
398
656
|
def test_source
|
399
657
|
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
400
|
-
|
658
|
+
expected = <<-EOS
|
659
|
+
\\begin{reviewlistblock}
|
660
|
+
\\reviewsourcecaption{foo/bar/test.rb}
|
661
|
+
\\begin{reviewsource}
|
662
|
+
foo
|
663
|
+
bar
|
664
|
+
|
665
|
+
buz
|
666
|
+
\\end{reviewsource}
|
667
|
+
\\end{reviewlistblock}
|
668
|
+
EOS
|
669
|
+
assert_equal expected, actual
|
401
670
|
end
|
402
671
|
|
403
672
|
def test_source_empty_caption
|
404
673
|
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
405
|
-
|
674
|
+
expected = <<-EOS
|
675
|
+
\\begin{reviewlistblock}
|
676
|
+
\\begin{reviewsource}
|
677
|
+
foo
|
678
|
+
bar
|
679
|
+
|
680
|
+
buz
|
681
|
+
\\end{reviewsource}
|
682
|
+
\\end{reviewlistblock}
|
683
|
+
EOS
|
684
|
+
assert_equal expected, actual
|
406
685
|
end
|
407
686
|
|
408
687
|
def test_source_lst
|
409
688
|
@book.config['highlight'] = {}
|
410
689
|
@book.config['highlight']['latex'] = 'listings'
|
411
690
|
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
412
|
-
|
691
|
+
expected = <<-EOS
|
692
|
+
\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
|
693
|
+
foo
|
694
|
+
bar
|
695
|
+
|
696
|
+
buz
|
697
|
+
\\end{reviewsourcelst}
|
698
|
+
EOS
|
699
|
+
assert_equal expected, actual
|
413
700
|
end
|
414
701
|
|
415
702
|
def test_quote
|
416
703
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
417
|
-
|
704
|
+
expected = <<-EOS
|
705
|
+
|
706
|
+
\\begin{quote}
|
707
|
+
foobar
|
708
|
+
|
709
|
+
buz
|
710
|
+
\\end{quote}
|
711
|
+
EOS
|
712
|
+
assert_equal expected, actual
|
418
713
|
end
|
419
714
|
|
420
715
|
def test_memo
|
421
716
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
422
|
-
|
717
|
+
expected = <<-EOS
|
718
|
+
\\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
|
719
|
+
test1
|
720
|
+
|
721
|
+
test\\reviewit{2}
|
722
|
+
\\end{reviewmemo}
|
723
|
+
EOS
|
724
|
+
assert_equal expected, actual
|
423
725
|
end
|
424
726
|
|
425
727
|
def test_flushright
|
426
728
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
427
|
-
|
729
|
+
expected = <<-EOS
|
730
|
+
|
731
|
+
\\begin{flushright}
|
732
|
+
foobar
|
733
|
+
|
734
|
+
buz
|
735
|
+
\\end{flushright}
|
736
|
+
EOS
|
737
|
+
assert_equal expected, actual
|
428
738
|
end
|
429
739
|
|
430
740
|
def test_centering
|
431
741
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
432
|
-
|
742
|
+
expected = <<-EOS
|
743
|
+
|
744
|
+
\\begin{center}
|
745
|
+
foobar
|
746
|
+
|
747
|
+
buz
|
748
|
+
\\end{center}
|
749
|
+
EOS
|
750
|
+
assert_equal expected, actual
|
433
751
|
end
|
434
752
|
|
435
753
|
def test_blankline
|
436
754
|
actual = compile_block("//blankline\nfoo\n")
|
437
|
-
|
755
|
+
expected = <<-EOS
|
756
|
+
\\vspace*{\\baselineskip}
|
757
|
+
|
758
|
+
foo
|
759
|
+
EOS
|
760
|
+
assert_equal expected, actual
|
438
761
|
end
|
439
762
|
|
440
763
|
def test_noindent
|
441
764
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
442
|
-
|
765
|
+
expected = <<-EOS
|
766
|
+
\\noindent
|
767
|
+
foo
|
768
|
+
bar
|
769
|
+
|
770
|
+
foo2
|
771
|
+
bar2
|
772
|
+
EOS
|
773
|
+
assert_equal expected, actual
|
443
774
|
end
|
444
775
|
|
445
776
|
def test_image
|
@@ -450,7 +781,14 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
450
781
|
end
|
451
782
|
|
452
783
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
453
|
-
|
784
|
+
expected = <<-EOS
|
785
|
+
\\begin{reviewimage}%%sampleimg
|
786
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
787
|
+
\\reviewimagecaption{sample photo}
|
788
|
+
\\label{image:chap1:sampleimg}
|
789
|
+
\\end{reviewimage}
|
790
|
+
EOS
|
791
|
+
assert_equal expected, actual
|
454
792
|
end
|
455
793
|
|
456
794
|
def test_image_with_metric
|
@@ -461,7 +799,14 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
461
799
|
end
|
462
800
|
|
463
801
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
464
|
-
|
802
|
+
expected = <<-EOS
|
803
|
+
\\begin{reviewimage}%%sampleimg
|
804
|
+
\\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
|
805
|
+
\\reviewimagecaption{sample photo}
|
806
|
+
\\label{image:chap1:sampleimg}
|
807
|
+
\\end{reviewimage}
|
808
|
+
EOS
|
809
|
+
assert_equal expected, actual
|
465
810
|
end
|
466
811
|
|
467
812
|
def test_image_with_metric_width
|
@@ -473,7 +818,14 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
473
818
|
|
474
819
|
@config['image_scale2width'] = true
|
475
820
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
476
|
-
|
821
|
+
expected = <<-EOS
|
822
|
+
\\begin{reviewimage}%%sampleimg
|
823
|
+
\\reviewincludegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
|
824
|
+
\\reviewimagecaption{sample photo}
|
825
|
+
\\label{image:chap1:sampleimg}
|
826
|
+
\\end{reviewimage}
|
827
|
+
EOS
|
828
|
+
assert_equal expected, actual
|
477
829
|
end
|
478
830
|
|
479
831
|
def test_image_with_metric2
|
@@ -484,7 +836,14 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
484
836
|
end
|
485
837
|
|
486
838
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
487
|
-
|
839
|
+
expected = <<-EOS
|
840
|
+
\\begin{reviewimage}%%sampleimg
|
841
|
+
\\reviewincludegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
|
842
|
+
\\reviewimagecaption{sample photo}
|
843
|
+
\\label{image:chap1:sampleimg}
|
844
|
+
\\end{reviewimage}
|
845
|
+
EOS
|
846
|
+
assert_equal expected, actual
|
488
847
|
end
|
489
848
|
|
490
849
|
def test_image_with_metric2_width
|
@@ -496,7 +855,14 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
496
855
|
|
497
856
|
@config['image_scale2width'] = true
|
498
857
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
499
|
-
|
858
|
+
expected = <<-EOS
|
859
|
+
\\begin{reviewimage}%%sampleimg
|
860
|
+
\\reviewincludegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}
|
861
|
+
\\reviewimagecaption{sample photo}
|
862
|
+
\\label{image:chap1:sampleimg}
|
863
|
+
\\end{reviewimage}
|
864
|
+
EOS
|
865
|
+
assert_equal expected, actual
|
500
866
|
end
|
501
867
|
|
502
868
|
def test_indepimage
|
@@ -507,7 +873,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
507
873
|
end
|
508
874
|
|
509
875
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
510
|
-
|
876
|
+
expected = <<-EOS
|
877
|
+
\\begin{reviewimage}%%sampleimg
|
878
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
879
|
+
\\reviewindepimagecaption{図: sample photo}
|
880
|
+
\\end{reviewimage}
|
881
|
+
EOS
|
882
|
+
assert_equal expected, actual
|
511
883
|
end
|
512
884
|
|
513
885
|
def test_indepimage_without_caption
|
@@ -519,7 +891,12 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
519
891
|
|
520
892
|
# FIXME: indepimage's caption should not be with a counter.
|
521
893
|
actual = compile_block("//indepimage[sampleimg]\n")
|
522
|
-
|
894
|
+
expected = <<-EOS
|
895
|
+
\\begin{reviewimage}%%sampleimg
|
896
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
897
|
+
\\end{reviewimage}
|
898
|
+
EOS
|
899
|
+
assert_equal expected, actual
|
523
900
|
end
|
524
901
|
|
525
902
|
def test_indepimage_with_metric
|
@@ -530,7 +907,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
530
907
|
end
|
531
908
|
|
532
909
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
533
|
-
|
910
|
+
expected = <<-EOS
|
911
|
+
\\begin{reviewimage}%%sampleimg
|
912
|
+
\\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
|
913
|
+
\\reviewindepimagecaption{図: sample photo}
|
914
|
+
\\end{reviewimage}
|
915
|
+
EOS
|
916
|
+
assert_equal expected, actual
|
534
917
|
end
|
535
918
|
|
536
919
|
def test_indepimage_with_metric_width
|
@@ -542,7 +925,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
542
925
|
|
543
926
|
@config['image_scale2width'] = true
|
544
927
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
545
|
-
|
928
|
+
expected = <<-EOS
|
929
|
+
\\begin{reviewimage}%%sampleimg
|
930
|
+
\\reviewincludegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
|
931
|
+
\\reviewindepimagecaption{図: sample photo}
|
932
|
+
\\end{reviewimage}
|
933
|
+
EOS
|
934
|
+
assert_equal expected, actual
|
546
935
|
end
|
547
936
|
|
548
937
|
def test_indepimage_with_metric2
|
@@ -553,7 +942,13 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
553
942
|
end
|
554
943
|
|
555
944
|
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
556
|
-
|
945
|
+
expected = <<-EOS
|
946
|
+
\\begin{reviewimage}%%sampleimg
|
947
|
+
\\reviewincludegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
|
948
|
+
\\reviewindepimagecaption{図: sample photo}
|
949
|
+
\\end{reviewimage}
|
950
|
+
EOS
|
951
|
+
assert_equal expected, actual
|
557
952
|
end
|
558
953
|
|
559
954
|
def test_indepimage_without_caption_but_with_metric
|
@@ -565,30 +960,93 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
565
960
|
|
566
961
|
# FIXME: indepimage's caption should not be with a counter.
|
567
962
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
568
|
-
|
963
|
+
expected = <<-EOS
|
964
|
+
\\begin{reviewimage}%%sampleimg
|
965
|
+
\\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
|
966
|
+
\\end{reviewimage}
|
967
|
+
EOS
|
968
|
+
assert_equal expected, actual
|
569
969
|
end
|
570
970
|
|
571
971
|
def test_table
|
572
972
|
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
573
|
-
|
574
|
-
|
973
|
+
expected = <<-EOS
|
974
|
+
\\begin{reviewtable}{|l|l|}
|
975
|
+
\\hline
|
976
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
977
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
978
|
+
\\end{reviewtable}
|
979
|
+
EOS
|
980
|
+
assert_equal expected, actual
|
981
|
+
|
982
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
983
|
+
expected = <<-EOS
|
984
|
+
\\begin{table}%%foo
|
985
|
+
\\reviewtablecaption{FOO}
|
986
|
+
\\label{table:chap1:foo}
|
987
|
+
\\begin{reviewtable}{|l|l|}
|
988
|
+
\\hline
|
989
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
990
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
991
|
+
\\end{reviewtable}
|
992
|
+
\\end{table}
|
993
|
+
EOS
|
994
|
+
assert_equal expected, actual
|
995
|
+
end
|
996
|
+
|
997
|
+
def test_empty_table
|
998
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
|
999
|
+
assert_equal ':2: error: no rows in the table', e.message
|
1000
|
+
|
1001
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
|
1002
|
+
assert_equal ':3: error: no rows in the table', e.message
|
575
1003
|
end
|
576
1004
|
|
577
1005
|
def test_customize_cellwidth
|
578
1006
|
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
579
|
-
|
1007
|
+
expected = <<-EOS
|
1008
|
+
\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
|
1009
|
+
\\hline
|
1010
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1011
|
+
\\end{reviewtable}
|
1012
|
+
EOS
|
1013
|
+
assert_equal expected, actual
|
580
1014
|
|
581
1015
|
actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
582
|
-
|
1016
|
+
expected = <<-EOS
|
1017
|
+
\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
|
1018
|
+
\\hline
|
1019
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1020
|
+
\\end{reviewtable}
|
1021
|
+
EOS
|
1022
|
+
assert_equal expected, actual
|
583
1023
|
|
584
1024
|
actual = compile_block("//tsize[|html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
585
|
-
|
1025
|
+
expected = <<-EOS
|
1026
|
+
\\begin{reviewtable}{|l|l|l|}
|
1027
|
+
\\hline
|
1028
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1029
|
+
\\end{reviewtable}
|
1030
|
+
EOS
|
1031
|
+
assert_equal expected, actual
|
586
1032
|
|
587
1033
|
actual = compile_block("//tsize[|latex|2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
588
|
-
|
1034
|
+
expected = <<-EOS
|
1035
|
+
\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
|
1036
|
+
\\hline
|
1037
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1038
|
+
\\end{reviewtable}
|
1039
|
+
EOS
|
1040
|
+
assert_equal expected, actual
|
589
1041
|
|
590
1042
|
actual = compile_block("//tsize[|latex||p{5mm}|cr|]\n//table{\nA\tB\tC\n//}\n")
|
591
|
-
|
1043
|
+
expected = <<-EOS
|
1044
|
+
\\begin{reviewtable}{|p{5mm}|cr|}
|
1045
|
+
\\hline
|
1046
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1047
|
+
\\end{reviewtable}
|
1048
|
+
EOS
|
1049
|
+
assert_equal expected, actual
|
592
1050
|
end
|
593
1051
|
|
594
1052
|
def test_separate_tsize
|
@@ -604,16 +1062,47 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
604
1062
|
|
605
1063
|
def test_break_tablecell
|
606
1064
|
actual = compile_block("//tsize[|latex||p{10mm}|cp{10mm}|]\n//table{\nA@<br>{}A\tB@<br>{}B\tC@<br>{}C\n//}\n")
|
607
|
-
|
1065
|
+
expected = <<-EOS
|
1066
|
+
\\begin{reviewtable}{|p{10mm}|cp{10mm}|}
|
1067
|
+
\\hline
|
1068
|
+
\\reviewth{A\\newline{}A} & \\shortstack[l]{B\\\\
|
1069
|
+
B} & C\\newline{}C \\\\ \\hline
|
1070
|
+
\\end{reviewtable}
|
1071
|
+
EOS
|
1072
|
+
assert_equal expected, actual
|
608
1073
|
|
609
1074
|
actual = compile_block("//tsize[|latex||p{10mm}|cp{10mm}|]\n//table{\n1@<br>{}1\t2@<br>{}2\t3\n------------\nA@<br>{}A\tB@<br>{}B\tC@<br>{}C\n//}\n")
|
610
|
-
|
1075
|
+
expected = <<-EOS
|
1076
|
+
\\begin{reviewtable}{|p{10mm}|cp{10mm}|}
|
1077
|
+
\\hline
|
1078
|
+
\\reviewth{1\\newline{}1} & \\reviewth{\\shortstack[l]{2\\\\
|
1079
|
+
2}} & \\reviewth{3} \\\\ \\hline
|
1080
|
+
A\\newline{}A & \\shortstack[l]{B\\\\
|
1081
|
+
B} & C\\newline{}C \\\\ \\hline
|
1082
|
+
\\end{reviewtable}
|
1083
|
+
EOS
|
1084
|
+
assert_equal expected, actual
|
611
1085
|
end
|
612
1086
|
|
613
1087
|
def test_emtable
|
614
1088
|
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
615
|
-
|
616
|
-
|
1089
|
+
expected = <<-EOS
|
1090
|
+
\\begin{table}%%
|
1091
|
+
\\reviewtablecaption*{foo}
|
1092
|
+
\\begin{reviewtable}{|l|l|}
|
1093
|
+
\\hline
|
1094
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1095
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1096
|
+
\\end{reviewtable}
|
1097
|
+
\\end{table}
|
1098
|
+
|
1099
|
+
\\begin{reviewtable}{|l|l|}
|
1100
|
+
\\hline
|
1101
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1102
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1103
|
+
\\end{reviewtable}
|
1104
|
+
EOS
|
1105
|
+
assert_equal expected, actual
|
617
1106
|
end
|
618
1107
|
|
619
1108
|
def test_imgtable
|
@@ -630,7 +1119,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
630
1119
|
\\reviewimgtablecaption{test for imgtable}
|
631
1120
|
\\label{table:chap1:sampleimg}
|
632
1121
|
\\begin{reviewimage}%%sampleimg
|
633
|
-
\\
|
1122
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
634
1123
|
\\end{reviewimage}
|
635
1124
|
\\end{table}
|
636
1125
|
EOS
|
@@ -651,7 +1140,14 @@ EOS
|
|
651
1140
|
end
|
652
1141
|
|
653
1142
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
654
|
-
|
1143
|
+
expected = <<-EOS
|
1144
|
+
[1] sample bib \\reviewbold{bold}
|
1145
|
+
\\label{bib:samplebib}
|
1146
|
+
|
1147
|
+
ab
|
1148
|
+
|
1149
|
+
EOS
|
1150
|
+
assert_equal expected, actual
|
655
1151
|
end
|
656
1152
|
|
657
1153
|
def test_bibpaper_without_body
|
@@ -660,7 +1156,12 @@ EOS
|
|
660
1156
|
end
|
661
1157
|
|
662
1158
|
actual = compile_block("//bibpaper[samplebib][sample bib]\n")
|
663
|
-
|
1159
|
+
expected = <<-EOS
|
1160
|
+
[1] sample bib
|
1161
|
+
\\label{bib:samplebib}
|
1162
|
+
|
1163
|
+
EOS
|
1164
|
+
assert_equal expected, actual
|
664
1165
|
end
|
665
1166
|
|
666
1167
|
def column_helper(review)
|
@@ -778,8 +1279,31 @@ EOS
|
|
778
1279
|
expected = <<-EOS
|
779
1280
|
|
780
1281
|
\\begin{itemize}
|
781
|
-
\\item AAA
|
782
|
-
|
1282
|
+
\\item AAA
|
1283
|
+
{-}AA
|
1284
|
+
\\item BBB
|
1285
|
+
{-}BB
|
1286
|
+
\\end{itemize}
|
1287
|
+
EOS
|
1288
|
+
actual = compile_block(src)
|
1289
|
+
assert_equal expected, actual
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
def test_cont_with_br
|
1293
|
+
src = <<-EOS
|
1294
|
+
* AAA@<br>{}
|
1295
|
+
-AA
|
1296
|
+
* BBB@<br>{}1@<br>{}
|
1297
|
+
-BB
|
1298
|
+
EOS
|
1299
|
+
expected = <<-EOS
|
1300
|
+
|
1301
|
+
\\begin{itemize}
|
1302
|
+
\\item AAA\\\\
|
1303
|
+
{-}AA
|
1304
|
+
\\item BBB\\\\
|
1305
|
+
1\\\\
|
1306
|
+
{-}BB
|
783
1307
|
\\end{itemize}
|
784
1308
|
EOS
|
785
1309
|
actual = compile_block(src)
|
@@ -871,35 +1395,107 @@ EOS
|
|
871
1395
|
|
872
1396
|
def test_major_blocks
|
873
1397
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
874
|
-
expected =
|
1398
|
+
expected = <<-EOS
|
1399
|
+
\\begin{reviewnote}
|
1400
|
+
A
|
1401
|
+
|
1402
|
+
B
|
1403
|
+
\\end{reviewnote}
|
1404
|
+
\\begin{reviewnote}[caption]
|
1405
|
+
A
|
1406
|
+
\\end{reviewnote}
|
1407
|
+
EOS
|
875
1408
|
assert_equal expected, actual
|
876
1409
|
|
877
1410
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
878
|
-
expected =
|
1411
|
+
expected = <<-EOS
|
1412
|
+
\\begin{reviewmemo}
|
1413
|
+
A
|
1414
|
+
|
1415
|
+
B
|
1416
|
+
\\end{reviewmemo}
|
1417
|
+
\\begin{reviewmemo}[caption]
|
1418
|
+
A
|
1419
|
+
\\end{reviewmemo}
|
1420
|
+
EOS
|
879
1421
|
assert_equal expected, actual
|
880
1422
|
|
881
1423
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
882
|
-
expected =
|
1424
|
+
expected = <<-EOS
|
1425
|
+
\\begin{reviewinfo}
|
1426
|
+
A
|
1427
|
+
|
1428
|
+
B
|
1429
|
+
\\end{reviewinfo}
|
1430
|
+
\\begin{reviewinfo}[caption]
|
1431
|
+
A
|
1432
|
+
\\end{reviewinfo}
|
1433
|
+
EOS
|
883
1434
|
assert_equal expected, actual
|
884
1435
|
|
885
1436
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
886
|
-
expected =
|
1437
|
+
expected = <<-EOS
|
1438
|
+
\\begin{reviewimportant}
|
1439
|
+
A
|
1440
|
+
|
1441
|
+
B
|
1442
|
+
\\end{reviewimportant}
|
1443
|
+
\\begin{reviewimportant}[caption]
|
1444
|
+
A
|
1445
|
+
\\end{reviewimportant}
|
1446
|
+
EOS
|
887
1447
|
assert_equal expected, actual
|
888
1448
|
|
889
1449
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
890
|
-
expected =
|
1450
|
+
expected = <<-EOS
|
1451
|
+
\\begin{reviewcaution}
|
1452
|
+
A
|
1453
|
+
|
1454
|
+
B
|
1455
|
+
\\end{reviewcaution}
|
1456
|
+
\\begin{reviewcaution}[caption]
|
1457
|
+
A
|
1458
|
+
\\end{reviewcaution}
|
1459
|
+
EOS
|
891
1460
|
assert_equal expected, actual
|
892
1461
|
|
893
1462
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
894
|
-
expected =
|
1463
|
+
expected = <<-EOS
|
1464
|
+
\\begin{reviewnotice}
|
1465
|
+
A
|
1466
|
+
|
1467
|
+
B
|
1468
|
+
\\end{reviewnotice}
|
1469
|
+
\\begin{reviewnotice}[caption]
|
1470
|
+
A
|
1471
|
+
\\end{reviewnotice}
|
1472
|
+
EOS
|
895
1473
|
assert_equal expected, actual
|
896
1474
|
|
897
1475
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
898
|
-
expected =
|
1476
|
+
expected = <<-EOS
|
1477
|
+
\\begin{reviewwarning}
|
1478
|
+
A
|
1479
|
+
|
1480
|
+
B
|
1481
|
+
\\end{reviewwarning}
|
1482
|
+
\\begin{reviewwarning}[caption]
|
1483
|
+
A
|
1484
|
+
\\end{reviewwarning}
|
1485
|
+
EOS
|
899
1486
|
assert_equal expected, actual
|
900
1487
|
|
901
1488
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
902
|
-
expected =
|
1489
|
+
expected = <<-EOS
|
1490
|
+
\\begin{reviewtip}
|
1491
|
+
A
|
1492
|
+
|
1493
|
+
B
|
1494
|
+
\\end{reviewtip}
|
1495
|
+
\\begin{reviewtip}[caption]
|
1496
|
+
A
|
1497
|
+
\\end{reviewtip}
|
1498
|
+
EOS
|
903
1499
|
assert_equal expected, actual
|
904
1500
|
end
|
905
1501
|
|
@@ -1133,7 +1729,7 @@ EOS
|
|
1133
1729
|
\\reviewimageref{A.1}{image:chap1:sampleimg}
|
1134
1730
|
|
1135
1731
|
\\begin{reviewimage}%%sampleimg
|
1136
|
-
\\
|
1732
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1137
1733
|
\\reviewimagecaption{FOO}
|
1138
1734
|
\\label{image:chap1:sampleimg}
|
1139
1735
|
\\end{reviewimage}
|