review 5.5.0 → 5.7.0

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