review 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +31 -0
  3. data/.github/workflows/ruby-tex.yml +1 -1
  4. data/.github/workflows/ruby-win.yml +1 -1
  5. data/.github/workflows/ruby.yml +2 -2
  6. data/.rubocop.yml +13 -2
  7. data/NEWS.ja.md +22 -0
  8. data/NEWS.md +21 -0
  9. data/README.md +1 -1
  10. data/lib/review/book/base.rb +1 -1
  11. data/lib/review/builder.rb +4 -8
  12. data/lib/review/epubmaker/epubcommon.rb +13 -7
  13. data/lib/review/epubmaker/epubv2.rb +0 -5
  14. data/lib/review/epubmaker/epubv3.rb +9 -1
  15. data/lib/review/epubmaker/producer.rb +2 -3
  16. data/lib/review/epubmaker.rb +2 -4
  17. data/lib/review/htmlbuilder.rb +2 -2
  18. data/lib/review/idgxmlbuilder.rb +4 -3
  19. data/lib/review/img_math.rb +9 -2
  20. data/lib/review/init.rb +3 -3
  21. data/lib/review/latexbuilder.rb +1 -1
  22. data/lib/review/lineinput.rb +2 -2
  23. data/lib/review/makerhelper.rb +2 -2
  24. data/lib/review/pdfmaker.rb +3 -5
  25. data/lib/review/update.rb +3 -7
  26. data/lib/review/version.rb +1 -1
  27. data/lib/review/yamlloader.rb +0 -3
  28. data/review.gemspec +2 -3
  29. data/samples/syntax-book/Gemfile +1 -1
  30. data/templates/opf/epubv2.opf.erb +2 -0
  31. data/templates/opf/epubv3.opf.erb +2 -0
  32. data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
  33. data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
  34. data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
  35. metadata +10 -139
  36. data/test/assets/black.eps +0 -280
  37. data/test/assets/fit.png +0 -0
  38. data/test/assets/header_listener.html +0 -35
  39. data/test/assets/img_math/img1.png +0 -0
  40. data/test/assets/img_math/img2.png +0 -0
  41. data/test/assets/img_math/img3.png +0 -0
  42. data/test/assets/large.gif +0 -0
  43. data/test/assets/large.jpg +0 -0
  44. data/test/assets/large.png +0 -0
  45. data/test/assets/large.svg +0 -65
  46. data/test/assets/syntax_book_index_detail.txt +0 -60
  47. data/test/assets/test.xml.erb +0 -3
  48. data/test/assets/test_template.tex +0 -189
  49. data/test/assets/test_template_backmatter.tex +0 -200
  50. data/test/book_test_helper.rb +0 -44
  51. data/test/run_test.rb +0 -12
  52. data/test/test_book.rb +0 -588
  53. data/test/test_book_chapter.rb +0 -329
  54. data/test/test_book_part.rb +0 -53
  55. data/test/test_builder.rb +0 -128
  56. data/test/test_catalog.rb +0 -174
  57. data/test/test_catalog_converter_cmd.rb +0 -73
  58. data/test/test_compiler.rb +0 -52
  59. data/test/test_configure.rb +0 -91
  60. data/test/test_converter.rb +0 -21
  61. data/test/test_epub3maker.rb +0 -733
  62. data/test/test_epubmaker.rb +0 -931
  63. data/test/test_epubmaker_cmd.rb +0 -56
  64. data/test/test_extentions_hash.rb +0 -66
  65. data/test/test_helper.rb +0 -62
  66. data/test/test_htmlbuilder.rb +0 -3315
  67. data/test/test_htmltoc.rb +0 -29
  68. data/test/test_htmlutils.rb +0 -43
  69. data/test/test_i18n.rb +0 -300
  70. data/test/test_idgxmlbuilder.rb +0 -1529
  71. data/test/test_idgxmlmaker_cmd.rb +0 -50
  72. data/test/test_image_finder.rb +0 -81
  73. data/test/test_img_math.rb +0 -120
  74. data/test/test_index.rb +0 -287
  75. data/test/test_indexbuilder.rb +0 -52
  76. data/test/test_latexbuilder.rb +0 -2972
  77. data/test/test_latexbuilder_v2.rb +0 -1654
  78. data/test/test_lineinput.rb +0 -104
  79. data/test/test_location.rb +0 -30
  80. data/test/test_logger.rb +0 -33
  81. data/test/test_makerhelper.rb +0 -44
  82. data/test/test_markdownbuilder.rb +0 -371
  83. data/test/test_md2inaobuilder.rb +0 -90
  84. data/test/test_pdfmaker.rb +0 -354
  85. data/test/test_pdfmaker_cmd.rb +0 -130
  86. data/test/test_plaintextbuilder.rb +0 -1214
  87. data/test/test_preprocessor.rb +0 -196
  88. data/test/test_review_ext.rb +0 -30
  89. data/test/test_reviewheaderlistener.rb +0 -49
  90. data/test/test_rstbuilder.rb +0 -619
  91. data/test/test_sec_counter.rb +0 -156
  92. data/test/test_template.rb +0 -33
  93. data/test/test_textmaker_cmd.rb +0 -58
  94. data/test/test_textutils.rb +0 -187
  95. data/test/test_tocprinter.rb +0 -46
  96. data/test/test_topbuilder.rb +0 -1301
  97. data/test/test_update.rb +0 -473
  98. data/test/test_webtocprinter.rb +0 -195
  99. data/test/test_yamlloader.rb +0 -186
  100. data/test/test_zip_exporter.rb +0 -106
@@ -1,1654 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/latexbuilder'
5
- require 'review/i18n'
6
-
7
- class LATEXBuidlerV2Test < Test::Unit::TestCase
8
- include ReVIEW
9
-
10
- def setup
11
- @builder = LATEXBuilder.new
12
- @config = ReVIEW::Configure.values
13
- @config.merge!(
14
- 'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
15
- 'toclevel' => 2,
16
- 'stylesheet' => nil, # for EPUBBuilder
17
- 'texcommand' => 'uplatex',
18
- 'review_version' => '2.0'
19
- )
20
- @config['pdfmaker']['image_scale2width'] = nil
21
- @book = Book::Base.new
22
- @book.config = @config
23
- @log_io = StringIO.new
24
- ReVIEW.logger = ReVIEW::Logger.new(@log_io)
25
- @compiler = ReVIEW::Compiler.new(@builder)
26
- @chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
27
- location = Location.new(nil, nil)
28
- @builder.bind(@compiler, @chapter, location)
29
- I18n.setup('ja')
30
- end
31
-
32
- def test_headline_level1
33
- actual = compile_block("={test} this is test.\n")
34
- expected = <<-EOS
35
- \\chapter{this is test.}
36
- \\label{chap:chap1}
37
- EOS
38
- assert_equal expected, actual
39
- end
40
-
41
- def test_headline_level1_without_secno
42
- @config['secnolevel'] = 0
43
- actual = compile_block("={test} this is test.\n")
44
- expected = <<-EOS
45
- \\chapter*{this is test.}
46
- \\addcontentsline{toc}{chapter}{this is test.}
47
- \\label{chap:chap1}
48
- EOS
49
- assert_equal expected, actual
50
- end
51
-
52
- def test_headline_level1_with_inlinetag
53
- actual = compile_block(%Q(={test} this @<b>{is} test.<&"_>\n))
54
- expected = <<-EOS
55
- \\chapter{this \\textbf{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}
56
- \\label{chap:chap1}
57
- EOS
58
- assert_equal expected, actual
59
- end
60
-
61
- def test_headline_level2
62
- actual = compile_block("=={test} this is test.\n")
63
- expected = <<-EOS
64
- \\section{this is test.}
65
- \\label{sec:1-1}
66
- \\label{test}
67
- EOS
68
- assert_equal expected, actual
69
- end
70
-
71
- def test_headline_level3
72
- actual = compile_block("==={test} this is test.\n")
73
- expected = <<-EOS
74
- \\subsection*{this is test.}
75
- \\label{sec:1-0-1}
76
- \\label{test}
77
- EOS
78
- assert_equal expected, actual
79
- end
80
-
81
- def test_headline_level3_with_secno
82
- @config['secnolevel'] = 3
83
- actual = compile_block("==={test} this is test.\n")
84
- expected = <<-EOS
85
- \\subsection{this is test.}
86
- \\label{sec:1-0-1}
87
- \\label{test}
88
- EOS
89
- assert_equal expected, actual
90
- end
91
-
92
- def test_label
93
- actual = compile_block("//label[label_test]\n")
94
- assert_equal %Q(\\label{label_test}\n), actual
95
- end
96
-
97
- def test_href
98
- actual = compile_inline('@<href>{http://github.com,GitHub}')
99
- assert_equal '\\href{http://github.com}{GitHub}', actual
100
- end
101
-
102
- def test_inline_href
103
- actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
104
- assert_equal '\\href{http://github.com}{Git,Hub}', actual
105
- end
106
-
107
- def test_href_without_label
108
- actual = compile_inline('@<href>{http://github.com}')
109
- assert_equal '\\url{http://github.com}', actual
110
- end
111
-
112
- def test_href_with_underscore
113
- actual = compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
114
- assert_equal '\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}', actual
115
- end
116
-
117
- def test_href_mailto
118
- actual = compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
119
- assert_equal '\\href{mailto:takahashim@example.com}{takahashim@example.com}', actual
120
- end
121
-
122
- def test_inline_br
123
- actual = compile_inline('@<br>{}')
124
- assert_equal %Q(\\\\\n), actual
125
- end
126
-
127
- def test_inline_br_with_other_strings
128
- actual = compile_inline('abc@<br>{}def')
129
- assert_equal %Q(abc\\\\\ndef), actual
130
- end
131
-
132
- def test_inline_i
133
- actual = compile_inline('abc@<i>{def}ghi')
134
- assert_equal 'abc\\textit{def}ghi', actual
135
- end
136
-
137
- def test_inline_i_and_escape
138
- actual = compile_inline('test @<i>{inline<&;\\ test} test2')
139
- assert_equal 'test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
140
- end
141
-
142
- def test_inline_dtp
143
- actual = compile_inline('abc@<dtp>{def}ghi')
144
- assert_equal 'abcghi', actual
145
- end
146
-
147
- def test_inline_code
148
- actual = compile_inline('abc@<code>{def}ghi')
149
- assert_equal 'abc\\texttt{def}ghi', actual
150
- end
151
-
152
- def test_inline_raw
153
- actual = compile_inline('@<raw>{@<tt>{inline!$%\\}}')
154
- assert_equal '@<tt>{inline!$%}', actual
155
- end
156
-
157
- def test_inline_sup
158
- actual = compile_inline('abc@<sup>{def}')
159
- assert_equal 'abc\\textsuperscript{def}', actual
160
- end
161
-
162
- def test_inline_sub
163
- actual = compile_inline('abc@<sub>{def}')
164
- assert_equal 'abc\\textsubscript{def}', actual
165
- end
166
-
167
- def test_inline_b
168
- actual = compile_inline('abc@<b>{def}')
169
- assert_equal 'abc\\textbf{def}', actual
170
- end
171
-
172
- def test_inline_b_and_escape
173
- actual = compile_inline('test @<b>{inline<&;\\ test} test2')
174
- assert_equal 'test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
175
- end
176
-
177
- def test_inline_em
178
- actual = compile_inline('abc@<em>{def}')
179
- assert_equal 'abc\\reviewem{def}', actual
180
- end
181
-
182
- def test_inline_strong
183
- actual = compile_inline('abc@<strong>{def}')
184
- assert_equal 'abc\\reviewstrong{def}', actual
185
- end
186
-
187
- def test_inline_u
188
- actual = compile_inline('abc@<u>{def}ghi')
189
- assert_equal 'abc\\reviewunderline{def}ghi', actual
190
- end
191
-
192
- def test_inline_m
193
- actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
194
- assert_equal 'abc $\\alpha^n = \\inf < 2$ ghi', actual
195
- end
196
-
197
- def test_inline_m2
198
- ## target text: @<m>{X = \{ {x_1\},{x_2\}, \cdots ,{x_n\} \\\}}
199
- actual = compile_inline('@<m>{X = \\{ {x_1\\},{x_2\\}, \\cdots ,{x_n\\} \\\\\\}}')
200
- ## expected text: $X = \{ {x_1},{x_2}, \cdots ,{x_n} \}$
201
- assert_equal ' $X = \\{ {x_1},{x_2}, \\cdots ,{x_n} \\}$ ', actual
202
- end
203
-
204
- def test_inline_tt
205
- actual = compile_inline('test @<tt>{inline test} test2')
206
- assert_equal 'test \\texttt{inline test} test2', actual
207
- end
208
-
209
- def test_inline_tt_endash
210
- actual = compile_inline('test @<tt>{in-line --test ---foo ----bar -----buz} --test2')
211
- assert_equal 'test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2', actual
212
- end
213
-
214
- def test_inline_tti
215
- actual = compile_inline('test @<tti>{inline test} test2')
216
- assert_equal 'test \\texttt{\\textit{inline test}} test2', actual
217
- end
218
-
219
- def test_inline_ttb
220
- actual = compile_inline('test @<ttb>{inline test} test2')
221
- assert_equal 'test \\texttt{\\textbf{inline test}} test2', actual
222
- end
223
-
224
- def test_inline_hd_chap
225
- def @chapter.headline_index
226
- item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
227
- idx = Book::HeadlineIndex.new(self)
228
- idx.add_item(item)
229
- idx
230
- end
231
-
232
- @config['secnolevel'] = 3
233
- actual = compile_inline('test @<hd>{chap1|test} test2')
234
- assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
235
-
236
- @config['chapterlink'] = nil
237
- actual = compile_inline('test @<hd>{chap1|test} test2')
238
- assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
239
- end
240
-
241
- def test_inline_pageref
242
- actual = compile_inline('test p.@<pageref>{p1}')
243
- assert_equal 'test p.\pageref{p1}', actual
244
- end
245
-
246
- def test_inline_ruby_comma
247
- actual = compile_inline('@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}')
248
- assert_equal '\\ruby{foo, bar, buz}{フー・バー・バズ}', actual
249
- end
250
-
251
- def test_inline_uchar
252
- actual = compile_inline('test @<uchar>{2460} test2')
253
- assert_equal 'test ① test2', actual
254
- end
255
-
256
- def test_inline_idx
257
- actual = compile_inline('@<idx>{__TEST%$}, @<hidx>{__TEST%$}')
258
- assert_equal '\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}', actual
259
- end
260
-
261
- def test_inline_idx_yomi
262
- require 'nkf'
263
- begin
264
- require 'MeCab'
265
- rescue LoadError
266
- $stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
267
- return true
268
- end
269
- tmpdir = Dir.mktmpdir
270
- File.write("#{tmpdir}/sample.dic", "強運\tはーどらっく\n")
271
- @book.config['pdfmaker']['makeindex'] = true
272
- @book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
273
- @builder.setup_index
274
- actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
275
- FileUtils.remove_entry_secure(tmpdir)
276
- assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
277
- end
278
-
279
- def test_jis_x_0201_kana
280
- # uplatex can handle half-width kana natively
281
- actual = compile_inline('foo・カンジ、テスト')
282
- assert_equal 'foo・カンジ、テスト', actual
283
- # assert_equal %Q(foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト), actual
284
- end
285
-
286
- def test_dlist
287
- actual = compile_block(" : foo\n foo.\n bar.\n")
288
- expected = <<-EOS
289
-
290
- \\begin{description}
291
- \\item[foo] \\mbox{} \\\\
292
- foo.
293
- bar.
294
- \\end{description}
295
- EOS
296
- assert_equal expected, actual
297
- end
298
-
299
- def test_dlist_with_bracket
300
- actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
301
- expected = <<-EOS
302
-
303
- \\begin{description}
304
- \\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\
305
- foo.
306
- bar.
307
- \\end{description}
308
- EOS
309
- assert_equal expected, actual
310
- end
311
-
312
- def test_dlist_beforeulol
313
- 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")
314
- expected = <<-EOS
315
-
316
- \\begin{description}
317
- \\item[foo] \\mbox{} \\\\
318
- foo.
319
- \\end{description}
320
-
321
- para
322
-
323
- \\begin{description}
324
- \\item[foo] \\mbox{} \\\\
325
- foo.
326
- \\end{description}
327
-
328
- \\begin{enumerate}
329
- \\item bar
330
- \\end{enumerate}
331
-
332
- \\begin{description}
333
- \\item[foo] \\mbox{} \\\\
334
- foo.
335
- \\end{description}
336
-
337
- \\begin{itemize}
338
- \\item bar
339
- \\end{itemize}
340
- EOS
341
- assert_equal expected, actual
342
- end
343
-
344
- def test_cmd
345
- actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
346
- expected = <<-EOS
347
-
348
- \\begin{reviewcmd}
349
- foo
350
- bar
351
-
352
- buz
353
- \\end{reviewcmd}
354
- EOS
355
- assert_equal expected, actual
356
- end
357
-
358
- def test_cmd_caption
359
- actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
360
- expected = <<-EOS
361
-
362
- \\reviewcmdcaption{cap1}
363
- \\begin{reviewcmd}
364
- foo
365
- bar
366
-
367
- buz
368
- \\end{reviewcmd}
369
- EOS
370
- assert_equal expected, actual
371
- end
372
-
373
- def test_cmd_lst
374
- @book.config['highlight'] = {}
375
- @book.config['highlight']['latex'] = 'listings'
376
- actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
377
- expected = <<-EOS
378
- \\vspace{-1.5em}\\begin{reviewcmdlst}[title={\\relax},language={}]
379
- foo
380
- bar
381
-
382
- buz
383
- \\end{reviewcmdlst}
384
- EOS
385
- assert_equal expected, actual
386
- end
387
-
388
- def test_emlist
389
- actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
390
- expected = <<-EOS
391
-
392
- \\begin{reviewemlist}
393
- foo
394
- bar
395
-
396
- buz
397
- \\end{reviewemlist}
398
- EOS
399
- assert_equal expected, actual
400
- end
401
-
402
- def test_emlist_lst
403
- @book.config['highlight'] = {}
404
- @book.config['highlight']['latex'] = 'listings'
405
- actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
406
- expected = <<-EOS
407
-
408
- \\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]
409
- SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
410
- \\end{reviewemlistlst}
411
- EOS
412
- assert_equal expected, actual
413
- end
414
-
415
- def test_emlist_lst_without_lang
416
- @book.config['highlight'] = {}
417
- @book.config['highlight']['latex'] = 'listings'
418
- @book.config['highlight']['lang'] = 'sql'
419
- actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
420
- expected = <<-EOS
421
-
422
- \\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]
423
- SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
424
- \\end{reviewemlistlst}
425
- EOS
426
- assert_equal expected, actual
427
- end
428
-
429
- def test_emlist_caption
430
- actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
431
- expected = <<-EOS
432
-
433
- \\reviewemlistcaption{cap1}
434
- \\begin{reviewemlist}
435
- foo
436
- bar
437
-
438
- buz
439
- \\end{reviewemlist}
440
- EOS
441
- assert_equal expected, actual
442
- end
443
-
444
- def test_emlist_empty_caption
445
- actual = compile_block("//emlist[]{\nfoo\nbar\n\nbuz\n//}\n")
446
- expected = <<-EOS
447
-
448
- \\begin{reviewemlist}
449
- foo
450
- bar
451
-
452
- buz
453
- \\end{reviewemlist}
454
- EOS
455
- assert_equal expected, actual
456
- end
457
-
458
- def test_emlist_with_tab
459
- actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
460
- expected = <<-EOS
461
-
462
- \\begin{reviewemlist}
463
- foo
464
- bar
465
-
466
- buz
467
- \\end{reviewemlist}
468
- EOS
469
- assert_equal expected, actual
470
- end
471
-
472
- def test_emlist_with_tab4
473
- @config['tabwidth'] = 4
474
- actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
475
- expected = <<-EOS
476
-
477
- \\begin{reviewemlist}
478
- foo
479
- bar
480
-
481
- buz
482
- \\end{reviewemlist}
483
- EOS
484
- assert_equal expected, actual
485
- end
486
-
487
- def test_emlistnum_caption
488
- actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
489
- expected = <<-EOS
490
-
491
- \\reviewemlistcaption{cap1}
492
- \\begin{reviewemlist}
493
- 1: foo
494
- 2: bar
495
- 3:
496
- 4: buz
497
- \\end{reviewemlist}
498
- EOS
499
- assert_equal expected, actual
500
- end
501
-
502
- def test_list
503
- actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
504
- expected = <<-EOS
505
- \\reviewlistcaption{リスト1.1: cap1}
506
- \\begin{reviewlist}
507
- foo
508
- bar
509
-
510
- buz
511
- \\end{reviewlist}
512
- EOS
513
- assert_equal expected, actual
514
- end
515
-
516
- def test_list_lst
517
- @book.config['highlight'] = {}
518
- @book.config['highlight']['latex'] = 'listings'
519
- actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
520
- expected = <<-EOS
521
- \\begin{reviewlistlst}[caption={cap1},language={sql}]
522
- SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
523
- \\end{reviewlistlst}
524
- EOS
525
- assert_equal expected, actual
526
- end
527
-
528
- def test_list_lst_with_lang
529
- @book.config['highlight'] = {}
530
- @book.config['highlight']['latex'] = 'listings'
531
- @book.config['highlight']['lang'] = 'sql'
532
- actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
533
- expected = <<-EOS
534
- \\begin{reviewlistlst}[caption={cap1},language={sql}]
535
- SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
536
- \\end{reviewlistlst}
537
- EOS
538
- assert_equal expected, actual
539
- end
540
-
541
- def test_listnum
542
- actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
543
- expected = <<-EOS
544
- \\reviewlistcaption{リスト1.1: ruby}
545
- \\begin{reviewlist}
546
- 1: class Foo
547
- 2: def foo
548
- 3: bar
549
- 4:
550
- 5: buz
551
- 6: end
552
- 7: end
553
- \\end{reviewlist}
554
- EOS
555
- assert_equal expected, actual
556
- end
557
-
558
- def test_listnum_linenum
559
- actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
560
- expected = <<-EOS
561
- \\reviewlistcaption{リスト1.1: ruby}
562
- \\begin{reviewlist}
563
- 100: class Foo
564
- 101: def foo
565
- 102: bar
566
- 103:
567
- 104: buz
568
- 105: end
569
- 106: end
570
- \\end{reviewlist}
571
- EOS
572
- assert_equal expected, actual
573
- end
574
-
575
- def test_listnum_lst
576
- @book.config['highlight'] = {}
577
- @book.config['highlight']['latex'] = 'listings'
578
- actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
579
- expected = <<-EOS
580
- \\begin{reviewlistnumlst}[caption={ruby},language={}]
581
- class Foo
582
- def foo
583
- bar
584
-
585
- buz
586
- end
587
- end
588
- \\end{reviewlistnumlst}
589
- EOS
590
- assert_equal expected, actual
591
- end
592
-
593
- def test_listnum_lst_linenum
594
- @book.config['highlight'] = {}
595
- @book.config['highlight']['latex'] = 'listings'
596
- actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
597
- expected = <<-EOS
598
- \\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]
599
- class Foo
600
- def foo
601
- bar
602
-
603
- buz
604
- end
605
- end
606
- \\end{reviewlistnumlst}
607
- EOS
608
- assert_equal expected, actual
609
- end
610
-
611
- def test_source
612
- actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
613
- expected = <<-EOS
614
- \\reviewsourcecaption{foo/bar/test.rb}
615
- \\begin{reviewsource}
616
- foo
617
- bar
618
-
619
- buz
620
- \\end{reviewsource}
621
- EOS
622
- assert_equal expected, actual
623
- end
624
-
625
- def test_source_empty_caption
626
- actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
627
- expected = <<-EOS
628
- \\begin{reviewsource}
629
- foo
630
- bar
631
-
632
- buz
633
- \\end{reviewsource}
634
- EOS
635
- assert_equal expected, actual
636
- end
637
-
638
- def test_source_lst
639
- @book.config['highlight'] = {}
640
- @book.config['highlight']['latex'] = 'listings'
641
- actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
642
- expected = <<-EOS
643
- \\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
644
- foo
645
- bar
646
-
647
- buz
648
- \\end{reviewsourcelst}
649
- EOS
650
- assert_equal expected, actual
651
- end
652
-
653
- def test_quote
654
- actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
655
- expected = <<-EOS
656
-
657
- \\begin{quote}
658
- foobar
659
-
660
- buz
661
- \\end{quote}
662
- EOS
663
- assert_equal expected, actual
664
- end
665
-
666
- def test_memo
667
- actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
668
- expected = <<-EOS
669
- \\begin{reviewminicolumn}
670
- \\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}
671
-
672
- test1
673
-
674
- test\\textit{2}
675
-
676
- \\end{reviewminicolumn}
677
- EOS
678
- assert_equal expected, actual
679
- end
680
-
681
- def test_flushright
682
- actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
683
- expected = <<-EOS
684
-
685
- \\begin{flushright}
686
- foobar
687
-
688
- buz
689
- \\end{flushright}
690
- EOS
691
- assert_equal expected, actual
692
- end
693
-
694
- def test_centering
695
- actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
696
- expected = <<-EOS
697
-
698
- \\begin{center}
699
- foobar
700
-
701
- buz
702
- \\end{center}
703
- EOS
704
- assert_equal expected, actual
705
- end
706
-
707
- def test_blankline
708
- actual = compile_block("//blankline\nfoo\n")
709
- expected = <<-EOS
710
- \\vspace*{\\baselineskip}
711
-
712
- foo
713
- EOS
714
- assert_equal expected, actual
715
- end
716
-
717
- def test_noindent
718
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
719
- expected = <<-EOS
720
- \\noindent
721
- foo
722
- bar
723
-
724
- foo2
725
- bar2
726
- EOS
727
- assert_equal expected, actual
728
- end
729
-
730
- def test_image
731
- def @chapter.image(_id)
732
- item = Book::Index::Item.new('sampleimg', 1)
733
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
734
- item
735
- end
736
-
737
- actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
738
- expected = <<-EOS
739
- \\begin{reviewimage}%%sampleimg
740
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
741
- \\caption{sample photo}
742
- \\label{image:chap1:sampleimg}
743
- \\end{reviewimage}
744
- EOS
745
- assert_equal expected, actual
746
- end
747
-
748
- def test_image_with_metric
749
- def @chapter.image(_id)
750
- item = Book::Index::Item.new('sampleimg', 1)
751
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
752
- item
753
- end
754
-
755
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
756
- expected = <<-EOS
757
- \\begin{reviewimage}%%sampleimg
758
- \\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}
759
- \\caption{sample photo}
760
- \\label{image:chap1:sampleimg}
761
- \\end{reviewimage}
762
- EOS
763
- assert_equal expected, actual
764
- end
765
-
766
- def test_image_with_metric_width
767
- def @chapter.image(_id)
768
- item = Book::Index::Item.new('sampleimg', 1)
769
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
770
- item
771
- end
772
-
773
- @config['pdfmaker']['image_scale2width'] = true
774
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
775
- expected = <<-EOS
776
- \\begin{reviewimage}%%sampleimg
777
- \\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
778
- \\caption{sample photo}
779
- \\label{image:chap1:sampleimg}
780
- \\end{reviewimage}
781
- EOS
782
- assert_equal expected, actual
783
- end
784
-
785
- def test_image_with_metric2
786
- def @chapter.image(_id)
787
- item = Book::Index::Item.new('sampleimg', 1)
788
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
789
- item
790
- end
791
-
792
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
793
- expected = <<-EOS
794
- \\begin{reviewimage}%%sampleimg
795
- \\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
796
- \\caption{sample photo}
797
- \\label{image:chap1:sampleimg}
798
- \\end{reviewimage}
799
- EOS
800
- assert_equal expected, actual
801
- end
802
-
803
- def test_image_with_metric2_width
804
- def @chapter.image(_id)
805
- item = Book::Index::Item.new('sampleimg', 1)
806
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
807
- item
808
- end
809
-
810
- @config['pdfmaker']['image_scale2width'] = true
811
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
812
- expected = <<-EOS
813
- \\begin{reviewimage}%%sampleimg
814
- \\includegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}
815
- \\caption{sample photo}
816
- \\label{image:chap1:sampleimg}
817
- \\end{reviewimage}
818
- EOS
819
- assert_equal expected, actual
820
- end
821
-
822
- def test_indepimage
823
- def @chapter.image(_id)
824
- item = Book::Index::Item.new('sampleimg', 1)
825
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
826
- item
827
- end
828
-
829
- actual = compile_block("//indepimage[sampleimg][sample photo]\n")
830
- expected = <<-EOS
831
- \\begin{reviewimage}%%sampleimg
832
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
833
- \\reviewindepimagecaption{図: sample photo}
834
- \\end{reviewimage}
835
- EOS
836
- assert_equal expected, actual
837
- end
838
-
839
- def test_indepimage_without_caption
840
- def @chapter.image(_id)
841
- item = Book::Index::Item.new('sampleimg', 1)
842
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
843
- item
844
- end
845
-
846
- # FIXME: indepimage's caption should not be with a counter.
847
- actual = compile_block("//indepimage[sampleimg]\n")
848
- expected = <<-EOS
849
- \\begin{reviewimage}%%sampleimg
850
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
851
- \\end{reviewimage}
852
- EOS
853
- assert_equal expected, actual
854
- end
855
-
856
- def test_indepimage_with_metric
857
- def @chapter.image(_id)
858
- item = Book::Index::Item.new('sampleimg', 1)
859
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
860
- item
861
- end
862
-
863
- actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
864
- expected = <<-EOS
865
- \\begin{reviewimage}%%sampleimg
866
- \\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}
867
- \\reviewindepimagecaption{図: sample photo}
868
- \\end{reviewimage}
869
- EOS
870
- assert_equal expected, actual
871
- end
872
-
873
- def test_indepimage_with_metric_width
874
- def @chapter.image(_id)
875
- item = Book::Index::Item.new('sampleimg', 1)
876
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
877
- item
878
- end
879
-
880
- @config['pdfmaker']['image_scale2width'] = true
881
- actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
882
- expected = <<-EOS
883
- \\begin{reviewimage}%%sampleimg
884
- \\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}
885
- \\reviewindepimagecaption{図: sample photo}
886
- \\end{reviewimage}
887
- EOS
888
- assert_equal expected, actual
889
- end
890
-
891
- def test_indepimage_with_metric2
892
- def @chapter.image(_id)
893
- item = Book::Index::Item.new('sampleimg', 1)
894
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
895
- item
896
- end
897
-
898
- actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
899
- expected = <<-EOS
900
- \\begin{reviewimage}%%sampleimg
901
- \\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}
902
- \\reviewindepimagecaption{図: sample photo}
903
- \\end{reviewimage}
904
- EOS
905
- assert_equal expected, actual
906
- end
907
-
908
- def test_indepimage_without_caption_but_with_metric
909
- def @chapter.image(_id)
910
- item = Book::Index::Item.new('sampleimg', 1)
911
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
912
- item
913
- end
914
-
915
- # FIXME: indepimage's caption should not be with a counter.
916
- actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
917
- expected = <<-EOS
918
- \\begin{reviewimage}%%sampleimg
919
- \\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}
920
- \\end{reviewimage}
921
- EOS
922
- assert_equal expected, actual
923
- end
924
-
925
- def test_table
926
- actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
927
- expected = <<-EOS
928
- \\begin{reviewtable}{|l|l|}
929
- \\hline
930
- \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
931
- ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
932
- \\end{reviewtable}
933
- EOS
934
- assert_equal expected, actual
935
-
936
- actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
937
- expected = <<-EOS
938
- \\begin{table}[h]%%foo
939
- \\reviewtablecaption{FOO}
940
- \\label{table:chap1:foo}
941
- \\begin{reviewtable}{|l|l|}
942
- \\hline
943
- \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
944
- ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
945
- \\end{reviewtable}
946
- \\end{table}
947
- EOS
948
- assert_equal expected, actual
949
- end
950
-
951
- def test_customize_cellwidth
952
- actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
953
- expected = <<-EOS
954
- \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
955
- \\hline
956
- \\reviewth{A} & B & C \\\\ \\hline
957
- \\end{reviewtable}
958
- EOS
959
- assert_equal expected, actual
960
-
961
- actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
962
- expected = <<-EOS
963
- \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
964
- \\hline
965
- \\reviewth{A} & B & C \\\\ \\hline
966
- \\end{reviewtable}
967
- EOS
968
- assert_equal expected, actual
969
-
970
- actual = compile_block("//tsize[|html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
971
- expected = <<-EOS
972
- \\begin{reviewtable}{|l|l|l|}
973
- \\hline
974
- \\reviewth{A} & B & C \\\\ \\hline
975
- \\end{reviewtable}
976
- EOS
977
- assert_equal expected, actual
978
-
979
- actual = compile_block("//tsize[|latex|2,3,5]\n//table{\nA\tB\tC\n//}\n")
980
- expected = <<-EOS
981
- \\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
982
- \\hline
983
- \\reviewth{A} & B & C \\\\ \\hline
984
- \\end{reviewtable}
985
- EOS
986
- assert_equal expected, actual
987
-
988
- actual = compile_block("//tsize[|latex||p{5mm}|cr|]\n//table{\nA\tB\tC\n//}\n")
989
- expected = <<-EOS
990
- \\begin{reviewtable}{|p{5mm}|cr|}
991
- \\hline
992
- \\reviewth{A} & B & C \\\\ \\hline
993
- \\end{reviewtable}
994
- EOS
995
- assert_equal expected, actual
996
- end
997
-
998
- def test_emtable
999
- actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1000
- expected = <<-EOS
1001
- \\begin{table}[h]%%
1002
- \\reviewtablecaption*{foo}
1003
- \\begin{reviewtable}{|l|l|}
1004
- \\hline
1005
- \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1006
- ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1007
- \\end{reviewtable}
1008
- \\end{table}
1009
-
1010
- \\begin{reviewtable}{|l|l|}
1011
- \\hline
1012
- \\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
1013
- ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
1014
- \\end{reviewtable}
1015
- EOS
1016
- assert_equal expected, actual
1017
- end
1018
-
1019
- def test_imgtable
1020
- def @chapter.image(_id)
1021
- item = Book::Index::Item.new('sampleimg', 1, 'sample img')
1022
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1023
- item
1024
- end
1025
-
1026
- actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1027
-
1028
- expected = <<-EOS
1029
- \\begin{table}[h]%%sampleimg
1030
- \\reviewimgtablecaption{test for imgtable}
1031
- \\label{table:chap1:sampleimg}
1032
- \\begin{reviewimage}%%sampleimg
1033
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1034
- \\end{reviewimage}
1035
- \\end{table}
1036
- EOS
1037
- assert_equal expected, actual
1038
- end
1039
-
1040
- def test_bib
1041
- def @chapter.bibpaper(_id)
1042
- Book::Index::Item.new('samplebib', 1, 'sample bib')
1043
- end
1044
-
1045
- assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
1046
- end
1047
-
1048
- def test_bibpaper
1049
- def @chapter.bibpaper(_id)
1050
- Book::Index::Item.new('samplebib', 1, 'sample bib')
1051
- end
1052
-
1053
- actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1054
- expected = <<-EOS
1055
- [1] sample bib \\textbf{bold}
1056
- \\label{bib:samplebib}
1057
-
1058
- ab
1059
-
1060
- EOS
1061
- assert_equal expected, actual
1062
- end
1063
-
1064
- def test_bibpaper_without_body
1065
- def @chapter.bibpaper(_id)
1066
- Book::Index::Item.new('samplebib', 1, 'sample bib')
1067
- end
1068
-
1069
- actual = compile_block("//bibpaper[samplebib][sample bib]\n")
1070
- expected = <<-EOS
1071
- [1] sample bib
1072
- \\label{bib:samplebib}
1073
-
1074
- EOS
1075
- assert_equal expected, actual
1076
- end
1077
-
1078
- def column_helper(review)
1079
- compile_block(review)
1080
- end
1081
-
1082
- def test_column_1
1083
- review = <<-EOS
1084
- ===[column] prev column
1085
-
1086
- inside prev column
1087
-
1088
- ===[column] test
1089
-
1090
- inside column
1091
-
1092
- ===[/column]
1093
- EOS
1094
- expected = <<-EOS
1095
-
1096
- \\begin{reviewcolumn}
1097
- \\hypertarget{column:chap1:1}{}
1098
- \\reviewcolumnhead{}{prev column}
1099
- \\addcontentsline{toc}{subsection}{prev column}
1100
-
1101
- inside prev column
1102
-
1103
- \\end{reviewcolumn}
1104
-
1105
- \\begin{reviewcolumn}
1106
- \\hypertarget{column:chap1:2}{}
1107
- \\reviewcolumnhead{}{test}
1108
- \\addcontentsline{toc}{subsection}{test}
1109
-
1110
- inside column
1111
-
1112
- \\end{reviewcolumn}
1113
- EOS
1114
- @config['toclevel'] = 3
1115
- assert_equal expected, column_helper(review)
1116
- end
1117
-
1118
- def test_column_2
1119
- review = <<-EOS
1120
- ===[column] test
1121
-
1122
- inside column
1123
-
1124
- === next level
1125
- EOS
1126
- expected = <<-EOS
1127
-
1128
- \\begin{reviewcolumn}
1129
- \\hypertarget{column:chap1:1}{}
1130
- \\reviewcolumnhead{}{test}
1131
-
1132
- inside column
1133
-
1134
- \\end{reviewcolumn}
1135
-
1136
- \\subsection*{next level}
1137
- \\label{sec:1-0-1}
1138
- EOS
1139
-
1140
- @config['toclevel'] = 1
1141
- assert_equal expected, column_helper(review)
1142
- end
1143
-
1144
- def test_column_3
1145
- review = <<-EOS
1146
- ===[column] test
1147
-
1148
- inside column
1149
-
1150
- ===[/column_dummy]
1151
- EOS
1152
- assert_raise(ReVIEW::ApplicationError) do
1153
- column_helper(review)
1154
- end
1155
- end
1156
-
1157
- def test_ul
1158
- src = <<-EOS
1159
- * AAA
1160
- * BBB
1161
- EOS
1162
- expected = <<-EOS
1163
-
1164
- \\begin{itemize}
1165
- \\item AAA
1166
- \\item BBB
1167
- \\end{itemize}
1168
- EOS
1169
- actual = compile_block(src)
1170
- assert_equal expected, actual
1171
- end
1172
-
1173
- def test_ul_with_bracket
1174
- src = <<-EOS
1175
- * AAA
1176
- * []BBB
1177
- EOS
1178
- expected = <<-EOS
1179
-
1180
- \\begin{itemize}
1181
- \\item AAA
1182
- \\item \\lbrack{}]BBB
1183
- \\end{itemize}
1184
- EOS
1185
- actual = compile_block(src)
1186
- assert_equal expected, actual
1187
- end
1188
-
1189
- def test_cont
1190
- src = <<-EOS
1191
- * AAA
1192
- -AA
1193
- * BBB
1194
- -BB
1195
- EOS
1196
- expected = <<-EOS
1197
-
1198
- \\begin{itemize}
1199
- \\item AAA
1200
- {-}AA
1201
- \\item BBB
1202
- {-}BB
1203
- \\end{itemize}
1204
- EOS
1205
- actual = compile_block(src)
1206
- assert_equal expected, actual
1207
- end
1208
-
1209
- def test_ul_nest1
1210
- src = <<-EOS
1211
- * AAA
1212
- ** AA
1213
- EOS
1214
-
1215
- expected = <<-EOS
1216
-
1217
- \\begin{itemize}
1218
- \\item AAA
1219
-
1220
- \\begin{itemize}
1221
- \\item AA
1222
- \\end{itemize}
1223
-
1224
- \\end{itemize}
1225
- EOS
1226
- actual = compile_block(src)
1227
- assert_equal expected, actual
1228
- end
1229
-
1230
- def test_ul_nest3
1231
- src = <<-EOS
1232
- * AAA
1233
- ** AA
1234
- * BBB
1235
- ** BB
1236
- EOS
1237
-
1238
- expected = <<-EOS
1239
-
1240
- \\begin{itemize}
1241
- \\item AAA
1242
-
1243
- \\begin{itemize}
1244
- \\item AA
1245
- \\end{itemize}
1246
-
1247
- \\item BBB
1248
-
1249
- \\begin{itemize}
1250
- \\item BB
1251
- \\end{itemize}
1252
-
1253
- \\end{itemize}
1254
- EOS
1255
- actual = compile_block(src)
1256
- assert_equal expected, actual
1257
- end
1258
-
1259
- def test_ol
1260
- src = <<-EOS
1261
- 3. AAA
1262
- 3. BBB
1263
- EOS
1264
-
1265
- expected = <<-EOS
1266
-
1267
- \\begin{enumerate}
1268
- \\item AAA
1269
- \\item BBB
1270
- \\end{enumerate}
1271
- EOS
1272
- actual = compile_block(src)
1273
- assert_equal expected, actual
1274
- end
1275
-
1276
- def test_ol_with_bracket
1277
- src = <<-EOS
1278
- 1. AAA
1279
- 2. []BBB
1280
- EOS
1281
- expected = <<-EOS
1282
-
1283
- \\begin{enumerate}
1284
- \\item AAA
1285
- \\item \\lbrack{}]BBB
1286
- \\end{enumerate}
1287
- EOS
1288
- actual = compile_block(src)
1289
- assert_equal expected, actual
1290
- end
1291
-
1292
- def test_major_blocks
1293
- actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
1294
- expected = <<-EOS
1295
- \\begin{reviewminicolumn}
1296
-
1297
- A
1298
-
1299
- B
1300
-
1301
- \\end{reviewminicolumn}
1302
- \\begin{reviewminicolumn}
1303
- \\reviewminicolumntitle{caption}
1304
-
1305
- A
1306
-
1307
- \\end{reviewminicolumn}
1308
- EOS
1309
- assert_equal expected, actual
1310
-
1311
- actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
1312
- expected = <<-EOS
1313
- \\begin{reviewminicolumn}
1314
-
1315
- A
1316
-
1317
- B
1318
-
1319
- \\end{reviewminicolumn}
1320
- \\begin{reviewminicolumn}
1321
- \\reviewminicolumntitle{caption}
1322
-
1323
- A
1324
-
1325
- \\end{reviewminicolumn}
1326
- EOS
1327
- assert_equal expected, actual
1328
-
1329
- actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
1330
- expected = <<-EOS
1331
- \\begin{reviewminicolumn}
1332
-
1333
- A
1334
-
1335
- B
1336
-
1337
- \\end{reviewminicolumn}
1338
- \\begin{reviewminicolumn}
1339
- \\reviewminicolumntitle{caption}
1340
-
1341
- A
1342
-
1343
- \\end{reviewminicolumn}
1344
- EOS
1345
- assert_equal expected, actual
1346
-
1347
- actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
1348
- expected = <<-EOS
1349
- \\begin{reviewminicolumn}
1350
-
1351
- A
1352
-
1353
- B
1354
-
1355
- \\end{reviewminicolumn}
1356
- \\begin{reviewminicolumn}
1357
- \\reviewminicolumntitle{caption}
1358
-
1359
- A
1360
-
1361
- \\end{reviewminicolumn}
1362
- EOS
1363
- assert_equal expected, actual
1364
-
1365
- actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
1366
- expected = <<-EOS
1367
- \\begin{reviewminicolumn}
1368
-
1369
- A
1370
-
1371
- B
1372
-
1373
- \\end{reviewminicolumn}
1374
- \\begin{reviewminicolumn}
1375
- \\reviewminicolumntitle{caption}
1376
-
1377
- A
1378
-
1379
- \\end{reviewminicolumn}
1380
- EOS
1381
- assert_equal expected, actual
1382
-
1383
- actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
1384
- expected = <<-EOS
1385
- \\begin{reviewminicolumn}
1386
-
1387
- A
1388
-
1389
- B
1390
-
1391
- \\end{reviewminicolumn}
1392
- \\begin{reviewminicolumn}
1393
- \\reviewminicolumntitle{caption}
1394
-
1395
- A
1396
-
1397
- \\end{reviewminicolumn}
1398
- EOS
1399
- assert_equal expected, actual
1400
-
1401
- actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
1402
- expected = <<-EOS
1403
- \\begin{reviewminicolumn}
1404
-
1405
- A
1406
-
1407
- B
1408
-
1409
- \\end{reviewminicolumn}
1410
- \\begin{reviewminicolumn}
1411
- \\reviewminicolumntitle{caption}
1412
-
1413
- A
1414
-
1415
- \\end{reviewminicolumn}
1416
- EOS
1417
- assert_equal expected, actual
1418
-
1419
- actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
1420
- expected = <<-EOS
1421
- \\begin{reviewminicolumn}
1422
-
1423
- A
1424
-
1425
- B
1426
-
1427
- \\end{reviewminicolumn}
1428
- \\begin{reviewminicolumn}
1429
- \\reviewminicolumntitle{caption}
1430
-
1431
- A
1432
-
1433
- \\end{reviewminicolumn}
1434
- EOS
1435
- assert_equal expected, actual
1436
- end
1437
-
1438
- def test_inline_raw0
1439
- assert_equal 'normal', compile_inline('@<raw>{normal}')
1440
- end
1441
-
1442
- def test_inline_raw1
1443
- assert_equal 'body', compile_inline('@<raw>{|latex|body}')
1444
- end
1445
-
1446
- def test_inline_raw2
1447
- assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
1448
- end
1449
-
1450
- def test_inline_raw3
1451
- assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
1452
- end
1453
-
1454
- def test_inline_raw4
1455
- assert_equal '|latex body', compile_inline('@<raw>{|latex body}')
1456
- end
1457
-
1458
- def test_inline_raw5
1459
- assert_equal "nor\nmal", compile_inline('@<raw>{|latex|nor\\nmal}')
1460
- end
1461
-
1462
- def test_inline_endash
1463
- actual = compile_inline('- -- --- ----')
1464
- assert_equal '{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}', actual
1465
- end
1466
-
1467
- def test_inline_imgref
1468
- def @chapter.image(_id)
1469
- item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
1470
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1471
- item
1472
- end
1473
-
1474
- actual = compile_block("@<imgref>{sampleimg}\n")
1475
- expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
1476
- assert_equal expected, actual
1477
- end
1478
-
1479
- def test_inline_imgref2
1480
- def @chapter.image(_id)
1481
- item = Book::Index::Item.new('sampleimg', 1)
1482
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1483
- item
1484
- end
1485
-
1486
- actual = compile_block("@<imgref>{sampleimg}\n")
1487
- expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
1488
- assert_equal expected, actual
1489
- end
1490
-
1491
- def test_block_raw0
1492
- actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
1493
- expected = %Q(<>!"\n& )
1494
- assert_equal expected, actual
1495
- end
1496
-
1497
- def test_block_raw1
1498
- actual = compile_block(%Q(//raw[|latex|<>!"\\n& ]\n))
1499
- expected = %Q(<>!"\n& )
1500
- assert_equal expected, actual
1501
- end
1502
-
1503
- def test_block_raw2
1504
- actual = compile_block(%Q(//raw[|html, latex|<>!"\\n& ]\n))
1505
- expected = %Q(<>!"\n& )
1506
- assert_equal expected, actual
1507
- end
1508
-
1509
- def test_block_raw3
1510
- actual = compile_block(%Q(//raw[|html, idgxml|<>!"\\n& ]\n))
1511
- expected = ''
1512
- assert_equal expected, actual
1513
- end
1514
-
1515
- def test_block_raw4
1516
- actual = compile_block(%Q(//raw[|latex <>!"\\n& ]\n))
1517
- expected = %Q(|latex <>!"\n& )
1518
- assert_equal expected, actual
1519
- end
1520
-
1521
- def test_comment
1522
- actual = compile_block('//comment[コメント]')
1523
- assert_equal '', actual
1524
- end
1525
-
1526
- def test_comment_for_draft
1527
- @config['draft'] = true
1528
- actual = compile_block('//comment[コメント]')
1529
- assert_equal %Q(\\pdfcomment{コメント}\n), actual
1530
- end
1531
-
1532
- def test_inline_comment
1533
- actual = compile_inline('test @<comment>{コメント} test2')
1534
- assert_equal 'test test2', actual
1535
- end
1536
-
1537
- def test_inline_comment_for_draft
1538
- @config['draft'] = true
1539
- actual = compile_inline('test @<comment>{コメント} test2')
1540
- assert_equal 'test \\pdfcomment{コメント} test2', actual
1541
- end
1542
-
1543
- def test_inline_fence
1544
- actual = compile_inline('test @<code>|@<code>{$サンプル$}|')
1545
- assert_equal 'test \\texttt{@\\textless{}code\\textgreater{}\\{\\textdollar{}サンプル\\textdollar{}\\}}', actual
1546
- end
1547
-
1548
- def test_inline_unknown
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)
1559
- %w[list table column].each do |name|
1560
- @log_io.string = ''
1561
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1562
- assert_match(/unknown #{name}: n/, @log_io.string)
1563
- end
1564
- %w[chap chapref title].each do |name|
1565
- @log_io.string = ''
1566
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1567
- assert_match(/key not found: "n"/, @log_io.string)
1568
- end
1569
- end
1570
-
1571
- def test_appendix_list
1572
- @chapter.instance_eval do
1573
- def on_appendix?
1574
- true
1575
- end
1576
- end
1577
- src = <<-EOS
1578
- @<list>{foo}
1579
- //list[foo][FOO]{
1580
- //}
1581
- EOS
1582
- expected = <<-EOS
1583
-
1584
- \\reviewlistref{A.1}
1585
-
1586
- \\reviewlistcaption{リストA.1: FOO}
1587
- \\begin{reviewlist}
1588
- \\end{reviewlist}
1589
- EOS
1590
- actual = compile_block(src)
1591
- assert_equal expected, actual
1592
- end
1593
-
1594
- def test_appendix_table
1595
- @chapter.instance_eval do
1596
- def on_appendix?
1597
- true
1598
- end
1599
- end
1600
- src = <<-EOS
1601
- @<table>{foo}
1602
- //table[foo][FOO]{
1603
- A B
1604
- //}
1605
- EOS
1606
- expected = <<-EOS
1607
-
1608
- \\reviewtableref{A.1}{table:chap1:foo}
1609
-
1610
- \\begin{table}[h]%%foo
1611
- \\reviewtablecaption{FOO}
1612
- \\label{table:chap1:foo}
1613
- \\begin{reviewtable}{|l|l|}
1614
- \\hline
1615
- \\reviewth{A} & B \\\\ \\hline
1616
- \\end{reviewtable}
1617
- \\end{table}
1618
- EOS
1619
- actual = compile_block(src)
1620
- assert_equal expected, actual
1621
- end
1622
-
1623
- def test_appendix_image
1624
- @chapter.instance_eval do
1625
- def on_appendix?
1626
- true
1627
- end
1628
- end
1629
-
1630
- def @chapter.image(_id)
1631
- item = Book::Index::Item.new('sampleimg', 1)
1632
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1633
- item
1634
- end
1635
-
1636
- src = <<-EOS
1637
- @<img>{sampleimg}
1638
- //image[sampleimg][FOO]{
1639
- //}
1640
- EOS
1641
- expected = <<-EOS
1642
-
1643
- \\reviewimageref{A.1}{image:chap1:sampleimg}
1644
-
1645
- \\begin{reviewimage}%%sampleimg
1646
- \\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
1647
- \\caption{FOO}
1648
- \\label{image:chap1:sampleimg}
1649
- \\end{reviewimage}
1650
- EOS
1651
- actual = compile_block(src)
1652
- assert_equal expected, actual
1653
- end
1654
- end