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,619 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/rstbuilder'
5
- require 'review/i18n'
6
-
7
- class RSTBuidlerTest < Test::Unit::TestCase
8
- include ReVIEW
9
-
10
- def setup
11
- @builder = RSTBuilder.new
12
- @config = ReVIEW::Configure.values
13
- @config['secnolevel'] = 2
14
- @config['language'] = 'ja'
15
- @book = Book::Base.new
16
- @book.config = @config
17
- @compiler = ReVIEW::Compiler.new(@builder)
18
- @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
19
- location = Location.new(nil, nil)
20
- @builder.bind(@compiler, @chapter, location)
21
-
22
- @builder.instance_eval do
23
- # to ignore lineno in original method
24
- def warn(msg)
25
- puts msg
26
- end
27
- end
28
- I18n.setup(@config['language'])
29
- end
30
-
31
- def test_headline_level1
32
- actual = compile_block("={test} this is test.\n")
33
- expected = <<-EOS
34
- .. _test:
35
-
36
- ==========================
37
- this is test.
38
- ==========================
39
-
40
- EOS
41
- assert_equal expected, actual
42
- end
43
-
44
- def test_headline_level1_without_secno
45
- @config['secnolevel'] = 0
46
- actual = compile_block("={test} this is test.\n")
47
- expected = <<-EOS
48
- .. _test:
49
-
50
- ==========================
51
- this is test.
52
- ==========================
53
-
54
- EOS
55
- assert_equal expected, actual
56
- end
57
-
58
- def test_headline_level2
59
- actual = compile_block("=={test} this is test.\n")
60
- expected = <<-EOS
61
- .. _test:
62
-
63
- this is test.
64
- ==========================
65
-
66
- EOS
67
- assert_equal expected, actual
68
- end
69
-
70
- def test_headline_level3
71
- actual = compile_block("==={test} this is test.\n")
72
- expected = <<-EOS
73
- .. _test:
74
-
75
- this is test.
76
- --------------------------
77
-
78
- EOS
79
- assert_equal expected, actual
80
- end
81
-
82
- def test_headline_level3_with_secno
83
- @config['secnolevel'] = 3
84
- actual = compile_block("==={test} this is test.\n")
85
- expected = <<-EOS
86
- .. _test:
87
-
88
- this is test.
89
- --------------------------
90
-
91
- EOS
92
- assert_equal expected, actual
93
- end
94
-
95
- def test_href
96
- actual = compile_inline('@<href>{http://github.com, GitHub}')
97
- assert_equal %Q( `GitHub <http://github.com>`_ ), actual
98
- end
99
-
100
- def test_href_without_label
101
- actual = compile_inline('@<href>{http://github.com}')
102
- assert_equal ' `http://github.com <http://github.com>`_ ', actual
103
- end
104
-
105
- def test_inline_raw
106
- actual = compile_inline('@<raw>{@<tt>{inline\}}')
107
- assert_equal '@<tt>{inline}', actual
108
- end
109
-
110
- def test_inline_ruby
111
- actual = compile_inline('@<ruby>{coffin,bed}')
112
- assert_equal ' :ruby:`coffin`<bed>`_ ', actual
113
-
114
- actual = compile_inline('@<ruby>{ coffin , bed }')
115
- assert_equal ' :ruby:`coffin`<bed>`_ ', actual
116
- end
117
-
118
- def test_inline_kw
119
- actual = compile_inline('@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}')
120
- assert_equal ' **ISO(International Organization for Standardization)** **Ruby<>** ', actual
121
- end
122
-
123
- def test_inline_maru
124
- actual = compile_inline('@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}')
125
- assert_equal ' :maru:`1` :maru:`20` :maru:`A` :maru:`z` ', actual
126
- end
127
-
128
- def test_inline_br
129
- actual = compile_inline('@<br>{}')
130
- assert_equal "\n", actual
131
- end
132
-
133
- def test_inline_i
134
- actual = compile_inline('test @<i>{inline test} test2')
135
- assert_equal 'test *inline test* test2', actual
136
- end
137
-
138
- def test_inline_i_and_escape
139
- actual = compile_inline('test @<i>{inline<&;\\ test} test2')
140
- assert_equal 'test *inline<&;\\ test* test2', actual
141
- end
142
-
143
- def test_inline_b
144
- actual = compile_inline('test @<b>{inline test} test2')
145
- assert_equal 'test **inline test** test2', actual
146
- end
147
-
148
- def test_inline_b_and_escape
149
- actual = compile_inline('test @<b>{inline<&;\\ test} test2')
150
- assert_equal 'test **inline<&;\\ test** test2', actual
151
- end
152
-
153
- def test_inline_tt
154
- actual = compile_inline('test @<tt>{inline test} test2@<tt>{\\}}')
155
- assert_equal 'test ``inline test`` test2 ``}`` ', actual
156
- end
157
-
158
- def test_inline_tti
159
- actual = compile_inline('test @<tti>{inline test} test2')
160
- assert_equal 'test ``inline test`` test2', actual
161
- end
162
-
163
- def test_inline_ttb
164
- actual = compile_inline('test @<ttb>{inline test} test2')
165
- assert_equal 'test ``inline test`` test2', actual
166
- end
167
-
168
- def test_inline_uchar
169
- actual = compile_inline('test @<uchar>{2460} test2')
170
- assert_equal 'test ① test2', actual
171
- end
172
-
173
- def test_inline_comment
174
- actual = compile_inline('test @<comment>{コメント} test2')
175
- assert_equal 'test test2', actual
176
- end
177
-
178
- def test_inline_comment_for_draft
179
- @config['draft'] = true
180
- actual = compile_inline('test @<comment>{コメント} test2')
181
- assert_equal 'test コメント test2', actual
182
- end
183
-
184
- def test_inline_in_table
185
- actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
186
- expected = <<-EOS
187
- * - ★1☆
188
- - ▲2☆
189
- * - ★3☆
190
- - ▲4☆<>&
191
-
192
- EOS
193
- assert_equal expected, actual
194
- end
195
-
196
- def test_emtable
197
- actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
198
- expected = <<-EOS
199
- .. list-table:: foo
200
- :header-rows: 1
201
-
202
- * - A
203
-
204
- * - A
205
-
206
- EOS
207
- assert_equal expected, actual
208
- end
209
-
210
- def test_paragraph
211
- actual = compile_block("foo\nbar\n")
212
- assert_equal %Q(foobar\n\n), actual
213
-
214
- @book.config['join_lines_by_lang'] = true
215
- actual = compile_block("foo\nbar\n")
216
- assert_equal %Q(foo bar\n\n), actual
217
- end
218
-
219
- def test_tabbed_paragraph
220
- actual = compile_block("\tfoo\nbar\n")
221
- assert_equal %Q(\tfoobar\n\n), actual
222
-
223
- @book.config['join_lines_by_lang'] = true
224
- actual = compile_block("\tfoo\nbar\n")
225
- assert_equal %Q(\tfoo bar\n\n), actual
226
- end
227
-
228
- def test_flushright
229
- actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
230
- expected = <<-EOS
231
- .. flushright::
232
-
233
- foobar
234
- buz
235
-
236
- EOS
237
- assert_equal expected, actual
238
-
239
- @book.config['join_lines_by_lang'] = true
240
- actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
241
- expected = <<-EOS
242
- .. flushright::
243
-
244
- foo bar
245
- buz
246
-
247
- EOS
248
- assert_equal expected, actual
249
- end
250
-
251
- def test_noindent
252
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
253
- expected = <<-EOS
254
- foobar
255
-
256
- foo2bar2
257
-
258
- EOS
259
- assert_equal expected, actual
260
-
261
- @book.config['join_lines_by_lang'] = true
262
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
263
- expected = <<-EOS
264
- foo bar
265
-
266
- foo2 bar2
267
-
268
- EOS
269
- assert_equal expected, actual
270
- end
271
-
272
- def test_comment
273
- actual = compile_block('//comment[コメント]')
274
- assert_equal "\n", actual
275
- end
276
-
277
- def test_comment_for_draft
278
- @config['draft'] = true
279
- actual = compile_block('//comment[コメント]')
280
- assert_equal "\n", actual
281
- end
282
-
283
- def test_list
284
- def @chapter.list(_id)
285
- Book::Index::Item.new('test', 1)
286
- end
287
- actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
288
- expected = <<-EOS
289
- .. _samplelist:
290
-
291
- -foo
292
- -bar
293
- EOS
294
- assert_equal expected, actual
295
- end
296
-
297
- def test_listnum
298
- def @chapter.list(_id)
299
- Book::Index::Item.new('test', 1)
300
- end
301
- actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
302
- expected = <<-EOS
303
- .. _test:
304
-
305
- 1
306
- 2
307
-
308
- EOS
309
- assert_equal expected, actual
310
- end
311
-
312
- def test_emlistnum
313
- actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
314
- expected = <<-EOS
315
- this is @<b>{test}<&>_
316
-
317
- .. code-block:: none
318
- :linenos:
319
-
320
- foo
321
- bar
322
-
323
- EOS
324
- assert_equal expected, actual
325
- end
326
-
327
- def test_major_blocks
328
- actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
329
- expected = <<-EOS
330
- .. note::
331
-
332
- A
333
-
334
- B
335
-
336
-
337
- .. note::
338
-
339
- caption
340
- A
341
-
342
-
343
- EOS
344
- assert_equal expected, actual
345
-
346
- actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
347
- expected = <<-EOS
348
- .. memo::
349
-
350
- A
351
-
352
- B
353
-
354
-
355
- .. memo::
356
-
357
- caption
358
- A
359
-
360
-
361
- EOS
362
- assert_equal expected, actual
363
-
364
- actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
365
- expected = <<-EOS
366
- .. info::
367
-
368
- A
369
-
370
- B
371
-
372
-
373
- .. info::
374
-
375
- caption
376
- A
377
-
378
-
379
- EOS
380
- assert_equal expected, actual
381
-
382
- actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
383
- expected = <<-EOS
384
- .. important::
385
-
386
- A
387
-
388
- B
389
-
390
-
391
- .. important::
392
-
393
- caption
394
- A
395
-
396
-
397
- EOS
398
- assert_equal expected, actual
399
-
400
- actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
401
- expected = <<-EOS
402
- .. caution::
403
-
404
- A
405
-
406
- B
407
-
408
-
409
- .. caution::
410
-
411
- caption
412
- A
413
-
414
-
415
- EOS
416
- assert_equal expected, actual
417
-
418
- actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
419
- expected = <<-EOS
420
- .. notice::
421
-
422
- A
423
-
424
- B
425
-
426
-
427
- .. notice::
428
-
429
- caption
430
- A
431
-
432
-
433
- EOS
434
- assert_equal expected, actual
435
-
436
- actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
437
- expected = <<-EOS
438
- .. warning::
439
-
440
- A
441
-
442
- B
443
-
444
-
445
- .. warning::
446
-
447
- caption
448
- A
449
-
450
-
451
- EOS
452
- assert_equal expected, actual
453
-
454
- actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
455
- expected = <<-EOS
456
- .. tip::
457
-
458
- A
459
-
460
- B
461
-
462
-
463
- .. tip::
464
-
465
- caption
466
- A
467
-
468
-
469
- EOS
470
- assert_equal expected, actual
471
- end
472
-
473
- def test_image
474
- def @chapter.image(_id)
475
- item = Book::Index::Item.new('sampleimg', 1)
476
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
477
- item
478
- end
479
-
480
- actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
481
- expected = <<-EOS
482
- .. _sampleimg:
483
-
484
- .. figure:: images/-/sampleimg.png
485
-
486
- sample photo
487
-
488
- EOS
489
- assert_equal expected, actual
490
- end
491
-
492
- def test_image_with_metric
493
- def @chapter.image(_id)
494
- item = Book::Index::Item.new('sampleimg', 1)
495
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
496
- item
497
- end
498
-
499
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
500
- expected = <<-EOS
501
- .. _sampleimg:
502
-
503
- .. figure:: images/-/sampleimg.png
504
- :scale:120.0%
505
-
506
- sample photo
507
-
508
- EOS
509
- assert_equal expected, actual
510
- end
511
-
512
- def test_texequation
513
- actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
514
- expected = <<-EOS
515
- .. math::
516
-
517
- \\sin 1^{2}
518
-
519
- EOS
520
- assert_equal expected, actual
521
- end
522
-
523
- def test_endnote
524
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
525
- assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
526
-
527
- actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
528
- expected = <<-'EOS'
529
- [(1)]_
530
-
531
- .. [(1)] bar
532
- EOS
533
- assert_equal expected, actual
534
- end
535
-
536
- def test_inline_raw0
537
- assert_equal 'normal', compile_inline('@<raw>{normal}')
538
- end
539
-
540
- def test_inline_raw1
541
- assert_equal 'body', compile_inline('@<raw>{|top|body}')
542
- end
543
-
544
- def test_inline_raw2
545
- assert_equal 'body', compile_inline('@<raw>{|top, latex|body}')
546
- end
547
-
548
- def test_inline_raw3
549
- assert_equal 'body', compile_inline('@<raw>{|idgxml, html|body}')
550
- end
551
-
552
- def test_inline_raw4
553
- assert_equal '|top body', compile_inline('@<raw>{|top body}')
554
- end
555
-
556
- def test_inline_raw5
557
- assert_equal "nor\nmal", compile_inline('@<raw>{|top|nor\\nmal}')
558
- end
559
-
560
- def test_block_raw0
561
- actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
562
- expected = %Q(<>!"\n& )
563
- assert_equal expected, actual
564
- end
565
-
566
- def test_block_raw1
567
- actual = compile_block(%Q(//raw[|top|<>!"\\n& ]\n))
568
- expected = ''
569
- assert_equal expected, actual
570
- end
571
-
572
- def test_block_raw2
573
- actual = compile_block(%Q(//raw[|top, latex|<>!"\\n& ]\n))
574
- expected = ''
575
- assert_equal expected, actual
576
- end
577
-
578
- def test_block_raw3
579
- actual = compile_block(%Q(//raw[|latex, idgxml|<>!"\\n& ]\n))
580
- expected = ''
581
- assert_equal expected, actual
582
- end
583
-
584
- def test_block_raw4
585
- actual = compile_block(%Q(//raw[|top <>!"\\n& ]\n))
586
- expected = %Q(|top <>!"\n& )
587
- assert_equal expected, actual
588
- end
589
-
590
- def column_helper(review)
591
- compile_block(review)
592
- end
593
-
594
- def test_column_ref
595
- review = <<-EOS
596
- ===[column]{foo} test
597
-
598
- inside column
599
-
600
- === next level
601
-
602
- this is @<column>{foo}.
603
- EOS
604
- expected = <<-EOS
605
- .. column:: test
606
-
607
- inside column
608
-
609
-
610
- next level
611
- --------------------
612
-
613
- this is コラム「test」.
614
-
615
- EOS
616
-
617
- assert_equal expected, column_helper(review)
618
- end
619
- end