review 5.1.1 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +6 -2
  3. data/.github/workflows/ruby-win.yml +6 -2
  4. data/.github/workflows/ruby.yml +6 -2
  5. data/.rubocop.yml +5 -319
  6. data/NEWS.ja.md +149 -0
  7. data/NEWS.md +149 -1
  8. data/README.md +9 -8
  9. data/bin/review +1 -1
  10. data/bin/review-catalog-converter +15 -15
  11. data/bin/review-check +7 -7
  12. data/bin/review-compile +14 -23
  13. data/bin/review-index +1 -1
  14. data/bin/review-preproc +29 -35
  15. data/bin/review-validate +2 -2
  16. data/doc/config.yml.sample +9 -1
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +29 -3
  19. data/doc/format.md +32 -3
  20. data/doc/writing_vertical.ja.md +6 -0
  21. data/lib/review/book/base.rb +3 -3
  22. data/lib/review/book/book_unit.rb +13 -3
  23. data/lib/review/book/chapter.rb +1 -1
  24. data/lib/review/book/index.rb +7 -4
  25. data/lib/review/book/part.rb +12 -13
  26. data/lib/review/book/volume.rb +1 -1
  27. data/lib/review/builder.rb +92 -65
  28. data/lib/review/catalog.rb +6 -5
  29. data/lib/review/compiler.rb +76 -57
  30. data/lib/review/configure.rb +5 -2
  31. data/lib/review/epub2html.rb +12 -12
  32. data/lib/review/epubmaker/content.rb +1 -1
  33. data/lib/review/epubmaker/epubcommon.rb +47 -45
  34. data/lib/review/epubmaker/epubv2.rb +2 -1
  35. data/lib/review/epubmaker/epubv3.rb +5 -4
  36. data/lib/review/epubmaker/producer.rb +6 -7
  37. data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
  38. data/lib/review/epubmaker.rb +56 -67
  39. data/lib/review/exception.rb +7 -0
  40. data/lib/review/extentions/string.rb +1 -1
  41. data/lib/review/htmlbuilder.rb +90 -34
  42. data/lib/review/htmlutils.rb +17 -17
  43. data/lib/review/i18n.rb +3 -3
  44. data/lib/review/i18n.yml +6 -0
  45. data/lib/review/idgxmlbuilder.rb +61 -39
  46. data/lib/review/idgxmlmaker.rb +27 -26
  47. data/lib/review/img_math.rb +12 -18
  48. data/lib/review/index_builder.rb +94 -53
  49. data/lib/review/init.rb +4 -4
  50. data/lib/review/latexbuilder.rb +84 -76
  51. data/lib/review/lineinput.rb +3 -3
  52. data/lib/review/location.rb +1 -1
  53. data/lib/review/loggable.rb +27 -0
  54. data/lib/review/logger.rb +69 -21
  55. data/lib/review/makerhelper.rb +8 -4
  56. data/lib/review/markdownbuilder.rb +21 -12
  57. data/lib/review/pdfmaker.rb +63 -42
  58. data/lib/review/plaintextbuilder.rb +16 -15
  59. data/lib/review/preprocessor/directive.rb +35 -0
  60. data/lib/review/preprocessor/line.rb +34 -0
  61. data/lib/review/preprocessor/repository.rb +177 -0
  62. data/lib/review/preprocessor.rb +94 -296
  63. data/lib/review/rstbuilder.rb +12 -3
  64. data/lib/review/template.rb +5 -1
  65. data/lib/review/textmaker.rb +32 -31
  66. data/lib/review/textutils.rb +5 -6
  67. data/lib/review/tocprinter.rb +12 -7
  68. data/lib/review/topbuilder.rb +96 -19
  69. data/lib/review/update.rb +16 -8
  70. data/lib/review/version.rb +1 -1
  71. data/lib/review/volumeprinter.rb +9 -9
  72. data/lib/review/webmaker.rb +45 -46
  73. data/lib/review/webtocprinter.rb +10 -10
  74. data/lib/review/yamlloader.rb +35 -2
  75. data/review.gemspec +2 -1
  76. data/samples/sample-book/src/config.yml +0 -1
  77. data/samples/sample-book/src/lib/tasks/review.rake +3 -1
  78. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
  79. data/samples/syntax-book/ch02.re +9 -0
  80. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
  81. data/templates/html/_titlepage.html.erb +9 -17
  82. data/templates/latex/config.erb +3 -0
  83. data/templates/latex/review-jlreq/review-base.sty +4 -5
  84. data/templates/latex/review-jlreq/review-jlreq.cls +39 -5
  85. data/templates/latex/review-jsbook/review-base.sty +9 -3
  86. data/templates/latex/review-jsbook/review-jsbook.cls +32 -5
  87. data/templates/opf/opf_manifest_epubv2.opf.erb +1 -1
  88. data/templates/opf/opf_manifest_epubv3.opf.erb +1 -1
  89. data/test/assets/syntax_book_index_detail.txt +10 -8
  90. data/test/assets/test_template.tex +4 -1
  91. data/test/assets/test_template_backmatter.tex +4 -1
  92. data/test/book_test_helper.rb +10 -10
  93. data/test/test_book_chapter.rb +25 -2
  94. data/test/test_builder.rb +10 -8
  95. data/test/test_epub3maker.rb +3 -3
  96. data/test/test_epubmaker.rb +27 -37
  97. data/test/test_epubmaker_cmd.rb +14 -3
  98. data/test/test_htmlbuilder.rb +111 -31
  99. data/test/test_idgxmlbuilder.rb +41 -33
  100. data/test/test_idgxmlmaker_cmd.rb +1 -1
  101. data/test/test_img_math.rb +11 -2
  102. data/test/test_index.rb +30 -4
  103. data/test/test_latexbuilder.rb +46 -25
  104. data/test/test_latexbuilder_v2.rb +18 -10
  105. data/test/test_markdownbuilder.rb +13 -0
  106. data/test/test_pdfmaker.rb +19 -0
  107. data/test/test_pdfmaker_cmd.rb +10 -10
  108. data/test/test_plaintextbuilder.rb +46 -22
  109. data/test/test_preprocessor.rb +188 -1
  110. data/test/test_rstbuilder.rb +13 -0
  111. data/test/test_textmaker_cmd.rb +1 -1
  112. data/test/test_topbuilder.rb +195 -29
  113. data/test/test_yamlloader.rb +28 -42
  114. metadata +11 -6
data/bin/review-preproc CHANGED
@@ -16,13 +16,17 @@ require 'review/version'
16
16
  require 'review/extentions'
17
17
  require 'review/logger'
18
18
  require 'review/lineinput'
19
+ require 'review/loggable'
19
20
  require 'stringio'
20
21
  require 'fileutils'
21
22
  require 'optparse'
23
+ require 'tempfile'
24
+
25
+ include ReVIEW::Loggable
22
26
 
23
27
  def sigmain
24
28
  Signal.trap(:INT) { exit 1 }
25
- if RUBY_PLATFORM !~ /mswin(?!ce)|mingw|cygwin|bccwin/
29
+ unless RUBY_PLATFORM.match?(/mswin(?!ce)|mingw|cygwin|bccwin/)
26
30
  Signal.trap(:PIPE, 'IGNORE')
27
31
  end
28
32
  main
@@ -30,16 +34,7 @@ rescue Errno::EPIPE
30
34
  exit 0
31
35
  end
32
36
 
33
- def main
34
- @logger = ReVIEW.logger
35
- if File.file?('review-preproc-ext.rb')
36
- if ENV['REVIEW_SAFE_MODE'].to_i & 2 > 0
37
- @logger.warn 'review-preproc-ext.rb is prohibited in safe mode. ignored.'
38
- else
39
- Kernel.load(File.expand_path('review-preproc-ext.rb'))
40
- end
41
- end
42
-
37
+ def parse_options
43
38
  param = {}
44
39
 
45
40
  mode = :output
@@ -57,32 +52,42 @@ def main
57
52
  begin
58
53
  opts.parse!
59
54
  rescue OptionParser::ParseError => e
60
- @logger.error e.message
55
+ error e.message
61
56
  $stderr.puts opts.help
62
57
  exit 1
63
58
  end
64
59
 
65
- pp = ReVIEW::Preprocessor.new(ReVIEW::Repository.new(param), param)
66
- current_file = nil
60
+ [param, mode]
61
+ end
62
+
63
+ def main
64
+ @logger = ReVIEW.logger
65
+ if File.file?('review-preproc-ext.rb')
66
+ if ENV['REVIEW_SAFE_MODE'].to_i & 2 > 0
67
+ warn 'review-preproc-ext.rb is prohibited in safe mode. ignored.'
68
+ else
69
+ Kernel.load(File.expand_path('review-preproc-ext.rb'))
70
+ end
71
+ end
72
+
73
+ param, mode = parse_options
74
+ pp = ReVIEW::Preprocessor.new(param)
67
75
  ARGV.each do |path|
68
- current_file = path
69
76
  case mode
70
77
  when :output
71
- File.open(path) { |f| pp.process(f, $stdout) }
78
+ $stdout.write(pp.process(path))
72
79
  when :replace
73
- File.write("#{path}.pptmp", preproc(pp, path))
74
- File.rename("#{path}.pptmp", path)
80
+ output = pp.process(path)
81
+ File.write(path, output)
75
82
  when :diff, :check
76
- tmp = '/tmp/review.pptmp'
77
- begin
78
- File.write(tmp, preproc(pp, path))
83
+ Tempfile.create('review.pptmp') do |tmp_io|
84
+ tmp = tmp_io.path
85
+ tmp_io.write(pp.process(path))
79
86
  if mode == :check
80
87
  system("diff -qu #{path} #{tmp} >/dev/null || echo #{path}")
81
88
  else
82
89
  system("diff -u #{path} #{tmp}")
83
90
  end
84
- ensure
85
- FileUtils.rm_f(tmp)
86
91
  end
87
92
  else
88
93
  raise "must not happen: #{mode}"
@@ -91,18 +96,7 @@ def main
91
96
  rescue ReVIEW::Error => e
92
97
  raise if $DEBUG
93
98
 
94
- @logger.error e.message
95
- exit 1
96
- end
97
-
98
- def preproc(pp, path)
99
- buf = StringIO.new
100
- File.open(path) { |f| pp.process(f, buf) }
101
- buf.string
102
- end
103
-
104
- def File.write(path, str)
105
- File.open(path, 'w') { |f| f.write str }
99
+ error! e.message
106
100
  end
107
101
 
108
102
  sigmain
data/bin/review-validate CHANGED
@@ -41,7 +41,7 @@ ARGF.each do |line|
41
41
  unless %w[list emlist listnum emlistnum cmd image table].include?(block)
42
42
  @logger.warn "#{ln}: found '#{$1}' without the head space. Is it correct?"
43
43
  end
44
- elsif line =~ /\A\*\s+/
44
+ elsif /\A\*\s+/.match?(line)
45
45
  # itemize
46
46
  unless %w[list emlist listnum emlistnum cmd image table].include?(block)
47
47
  @logger.warn "#{ln}: found '*' without the head space. Is it correct?"
@@ -53,7 +53,7 @@ ARGF.each do |line|
53
53
  elsif block == 'table'
54
54
  next if line.start_with?('#@')
55
55
 
56
- if line !~ /\A-----/
56
+ unless line.start_with?('-----')
57
57
  # table
58
58
  colcount = line.split("\t").size
59
59
  if maxcolcount == 0
@@ -87,7 +87,7 @@ aut: ["青木峰郎", "武藤健志", "高橋征義", "角征典"]
87
87
  debug: null
88
88
 
89
89
  # 固有IDに使用するドメイン。指定しない場合には、時刻に基づくランダムUUIDが入る
90
- # urnid: urn:uuid:http://example.com/book-title/
90
+ # urnid: urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff
91
91
  #
92
92
  # ISBN。省略した場合はurnidが入る
93
93
  # isbn: null
@@ -341,6 +341,8 @@ epubmaker:
341
341
  #
342
342
  # 脚注に「戻る」リンクを追加する(trueで追加)。脚注の記号および戻るリンクの記号はlocale.ymlで変更可能
343
343
  # back_footnote: null
344
+ # 見出しに応じて<section>で囲むようにする(trueで<section>を利用)
345
+ # use_section: null
344
346
  # epubmaker:階層を使うものはここまで
345
347
 
346
348
  # LaTeX用のスタイルファイル(styディレクトリ以下に置くこと)
@@ -440,3 +442,9 @@ pdfmaker:
440
442
  # options_with_caption: "colbacktitle=black!25!white"
441
443
  #
442
444
  # pdfmaker:階層を使うものはここまで
445
+ # textmaker:
446
+ # 表見出しの表現の設定
447
+ # nullの場合は区切り線(------------)で見出し行と通常の行を分ける。
448
+ # trueの場合は見出しを★〜☆で囲み(太字と同様)、区切り線を入れない。
449
+ # th_bold: null
450
+ # textmaker:階層を使うものはここまで
@@ -25,7 +25,7 @@ date: 2018-11-11
25
25
  history: [["2012-01-30"],["2016-04-20","2016-05-03"],["2018-11-11"]]
26
26
  rights: (C) 2016-2020 Re:VIEW Commiters, some rights reserved.
27
27
  description: sample config.yml file for Re:VIEW book
28
- urnid: urn:uuid:http://reviewml.org/review-sample-book
28
+ # urnid: urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff
29
29
  # isbn: null
30
30
 
31
31
  ## Book Structure
data/doc/format.ja.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Re:VIEW フォーマットの文法について解説します。Re:VIEW フォーマットはアスキー社(現カドカワ)の EWB を基本としながら、一部に RD や各種 Wiki の文法を取り入れて簡素化しています。
4
4
 
5
- このドキュメントは、Re:VIEW 5.1 に基づいています。
5
+ このドキュメントは、Re:VIEW 5.3 に基づいています。
6
6
 
7
7
  ## 段落
8
8
 
@@ -396,7 +396,7 @@ plot sin(x)
396
396
  * Gnuplot ( http://www.gnuplot.info/ ) : `gnuplot` コマンドへのパスを OS に設定すること
397
397
  * Blockdiag ( http://blockdiag.com/ ) : `blockdiag` コマンドへのパスを OS に設定すること。PDF を生成する場合は ReportLab もインストールすること
398
398
  * aafigure ( https://launchpad.net/aafigure ) : `aafigure` コマンドへのパスを OS に設定すること
399
- * PlantUML ( http://plantuml.com/ ) : `java` コマンドへのパスを OS に設定し、`plantuml.jar` が作業フォルダにあること
399
+ * PlantUML ( http://plantuml.com/ ) : `java` コマンドへのパスを OS に設定し、`plantuml.jar` が作業フォルダ、または `/usr/share/plantuml` あるいは `/usr/share/java` フォルダにあること
400
400
 
401
401
  ## 表
402
402
 
@@ -524,6 +524,7 @@ Re:VIEW 5.0 以降では、囲み記事に箇条書きや図表・リストを
524
524
  ```
525
525
  パッケージは本書のサポートサイトから入手できます@<fn>{site}。
526
526
  各自ダウンロードしてインストールしておいてください。
527
+
527
528
  //footnote[site][本書のサポートサイト: http://i.loveruby.net/ja/stdcompiler ]
528
529
  ```
529
530
 
@@ -538,6 +539,31 @@ TeX PDF において、コラム以外の `//note` などの囲み記事の中
538
539
 
539
540
  ただし、通常の脚注(footnote)ではなく、footnotemark と footnotetext を使うため、本文と脚注が別ページに分かれる可能性があるなど、いろいろな制約があります。また、採番が別々になるため、footnote と footnotemark/footnotetext を両立させることはできません。
540
541
 
542
+ ## 後注
543
+
544
+ 後注(最後にまとめて出力される注釈)は、「`//endnote`」を使って記述します。
545
+
546
+ ```
547
+ パッケージは本書のサポートサイトから入手できます@<endnote>{site}。
548
+ 各自ダウンロードしてインストールしておいてください。
549
+
550
+ //endnote[site][本書のサポートサイト: http://i.loveruby.net/ja/stdcompiler ]
551
+ ```
552
+
553
+ 本文中のインライン命令「`@<endnote>{site}`」は後注番号に置換され、「本書のサポートサイト……」という文は後注として内部に保存されます。
554
+
555
+ 保存されている後注を書き出すには、書き出したい箇所(通常は章の末尾)に「`//printendnotes`」を置きます。
556
+
557
+ ```
558
+
559
+
560
+ ==== 注釈
561
+
562
+ //printendnotes
563
+ ```
564
+
565
+ 後注の管理は章 (re ファイル) 単位であり、複数の章にまたがった後注を作ることはできません。
566
+
541
567
  ## 参考文献の定義
542
568
 
543
569
  参考文献は同一ディレクトリ内の `bib.re` ファイルに定義します。
@@ -686,7 +712,7 @@ imgmath_options:
686
712
  math_format: imgmath
687
713
  imgmath_options:
688
714
  format: svg
689
- pdfcrop_pixelize_cmd: "pdftocairo -svg -r 90 -f %p -l %p -singlefile %i %o"
715
+ pdfcrop_pixelize_cmd: "pdftocairo -%t -r 90 -f %p -l %p %i %o"
690
716
  ```
691
717
 
692
718
  デフォルトでは、pdfcrop_pixelize_cmd に指定するコマンドは、1ページあたり1数式からなる複数ページの PDF のファイル名を `%i` プレースホルダで受け取り、`%p` プレースホルダのページ数に基づいて `%o`(拡張子あり)または `%O`(拡張子なし)の画像ファイルに書き出す、という仕組みになっています。
data/doc/format.md CHANGED
@@ -4,7 +4,7 @@ The document is a brief guide for Re:VIEW markup syntax.
4
4
 
5
5
  Re:VIEW is based on EWB of ASCII (now KADOKAWA), influenced RD and other Wiki system's syntax.
6
6
 
7
- This document explains about the format of Re:VIEW 5.1.
7
+ This document explains about the format of Re:VIEW 5.3.
8
8
 
9
9
  ## Paragraph
10
10
 
@@ -423,7 +423,7 @@ Before using these tools, you should installed them and configured path appropri
423
423
  * Gnuplot ( http://www.gnuplot.info/ ) : set path to `gnuplot` command
424
424
  * Blockdiag ( http://blockdiag.com/ ) : set path to `blockdiag` command. Install ReportLab also to make a PDF
425
425
  * aafigure ( https://launchpad.net/aafigure ) : set path to `aafigure` command
426
- * PlantUML ( http://plantuml.com/ ) : set path to `java` command. place `plantuml.jar` on working folder
426
+ * PlantUML ( http://plantuml.com/ ) : set path to `java` command. place `plantuml.jar` on working folder, `/usr/share/plantuml` or `/usr/share/java`.
427
427
 
428
428
  ## Tables
429
429
 
@@ -551,6 +551,7 @@ Usage:
551
551
  ```
552
552
  You can get the packages from support site for the book.@<fn>{site}
553
553
  You should get and install it before reading the book.
554
+
554
555
  //footnote[site][support site of the book: http://i.loveruby.net/ja/stdcompiler ]
555
556
  ```
556
557
 
@@ -572,6 +573,34 @@ Note that with this option, Re:VIEW use footnotemark and footnotetext instead of
572
573
  There are some constraints to use this option.
573
574
  You cannot use footnote and footnotemark/footnotetext at the same time.
574
575
 
576
+ ## Endnotes
577
+
578
+ You can use `//endnote` to write endnotes.
579
+
580
+ Usage:
581
+
582
+ ```
583
+ You can get the packages from support site for the book.@<endnote>{site}
584
+ You should get and install it before reading the book.
585
+
586
+ //endnote[site][support site of the book: http://i.loveruby.net/ja/stdcompiler ]
587
+ ```
588
+
589
+ `@<endnote>{site}` in source are replaced by endnote marks, and the phrase "support site of .."
590
+ is stored for printing later.
591
+
592
+ To print stored endnotes, place "`//printendnotes`" where you want to write down them (usually at the end of the chapter).
593
+
594
+ ```
595
+ ...
596
+
597
+ ==== Endnote
598
+
599
+ //printendnotes
600
+ ```
601
+
602
+ It is not possible to create an endnote that spans multiple chapters.
603
+
575
604
  ## Bibliography
576
605
 
577
606
  When you want to use a bibliography, you should write them in the file `bib.re`.
@@ -719,7 +748,7 @@ For example, to make SVG:
719
748
  math_format: imgmath
720
749
  imgmath_options:
721
750
  format: svg
722
- pdfcrop_pixelize_cmd: "pdftocairo -svg -r 90 -f %p -l %p -singlefile %i %o"
751
+ pdfcrop_pixelize_cmd: "pdftocairo -%t -r 90 -f %p -l %p %i %o"
723
752
  ```
724
753
 
725
754
  By default, the command specified in `pdfcrop_pixelize_cmd` takes the filename of multi-page PDF consisting of one formula per page.
@@ -35,6 +35,12 @@ body {
35
35
  -epub-writing-mode: vertical-rl;
36
36
  writing-mode: tb-rl;
37
37
  }
38
+
39
+ span.tcy {
40
+ -webkit-text-combine: horizontal;
41
+ -ms-text-combine-horizontal: all;
42
+ text-combine-upright: all;
43
+ }
38
44
  ```
39
45
 
40
46
  また、縦書きの書籍は通常、「左開き」(右ページから左ページへ進む)となるので、config.yml の direction パラメータを設定します。
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2009-2019 Minero Aoki, Kenshi Muto
2
+ # Copyright (c) 2009-2022 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
3
3
  # 2002-2008 Minero Aoki
4
4
  #
5
5
  # This program is free software.
@@ -214,7 +214,7 @@ module ReVIEW
214
214
  end
215
215
 
216
216
  def load_config(filename)
217
- new_conf = YAML.load_file(filename)
217
+ new_conf = YAMLLoader.safe_load_file(filename)
218
218
  @config.merge!(new_conf)
219
219
  end
220
220
 
@@ -408,7 +408,7 @@ module ReVIEW
408
408
  end
409
409
 
410
410
  def filename_join(*args)
411
- File.join(args.reject(&:nil?))
411
+ File.join(args.compact)
412
412
  end
413
413
  end
414
414
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2009-2017 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2009-2021 Minero Aoki, Kenshi Muto
2
2
  # 2002-2008 Minero Aoki
3
3
  #
4
4
  # This program is free software.
@@ -18,7 +18,8 @@ module ReVIEW
18
18
  attr_reader :lines
19
19
  attr_accessor :content
20
20
 
21
- attr_reader :list_index, :table_index, :equation_index, :footnote_index,
21
+ attr_reader :list_index, :table_index, :equation_index,
22
+ :footnote_index, :endnote_index,
22
23
  :numberless_image_index, :image_index, :icon_index, :indepimage_index,
23
24
  :headline_index, :column_index
24
25
 
@@ -56,6 +57,7 @@ module ReVIEW
56
57
  @table_index = @indexes.table_index
57
58
  @equation_index = @indexes.equation_index
58
59
  @footnote_index = @indexes.footnote_index
60
+ @endnote_index = @indexes.endnote_index
59
61
  @headline_index = @indexes.headline_index
60
62
  @column_index = @indexes.column_index
61
63
  if use_bib
@@ -84,7 +86,7 @@ module ReVIEW
84
86
  return @title unless content
85
87
 
86
88
  content.each_line do |line|
87
- if line =~ /\A=+/
89
+ if /\A=+/.match?(line)
88
90
  @title = line.sub(/\A=+(\[.+?\])?(\{.+?\})?/, '').strip
89
91
  break
90
92
  end
@@ -116,6 +118,14 @@ module ReVIEW
116
118
  footnote_index[id]
117
119
  end
118
120
 
121
+ def endnote(id)
122
+ endnote_index[id]
123
+ end
124
+
125
+ def endnotes
126
+ endnote_index
127
+ end
128
+
119
129
  def image(id)
120
130
  return image_index[id] if image_index.key?(id)
121
131
  return icon_index[id] if icon_index.key?(id)
@@ -42,7 +42,7 @@ module ReVIEW
42
42
  if @io
43
43
  begin
44
44
  @content = @io.read
45
- rescue
45
+ rescue StandardError
46
46
  @content = nil
47
47
  end
48
48
  else
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-2019 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2008-2021 Minero Aoki, Kenshi Muto
2
2
  # 2002-2007 Minero Aoki
3
3
  #
4
4
  # This program is free software.
@@ -45,7 +45,7 @@ module ReVIEW
45
45
 
46
46
  def [](id)
47
47
  @index.fetch(id)
48
- rescue
48
+ rescue StandardError
49
49
  index_keys = @index.keys.map { |i| i.split('|').last }.flatten # unfold all ids
50
50
  if index_keys.each_with_object(Hash.new(0)) { |i, h| h[i] += 1 }. # number of occurrences
51
51
  select { |k, v| k == id && v > 1 }.present? # detect duplicated
@@ -84,14 +84,14 @@ module ReVIEW
84
84
  begin
85
85
  chapter = chapter_item.content
86
86
  chapter.format_number
87
- rescue # part
87
+ rescue StandardError # part
88
88
  I18n.t('part', chapter.number)
89
89
  end
90
90
  end
91
91
 
92
92
  def title(id)
93
93
  @index.fetch(id).content.title
94
- rescue # non-file part
94
+ rescue StandardError # non-file part
95
95
  @index.fetch(id).content.name
96
96
  end
97
97
 
@@ -125,6 +125,9 @@ module ReVIEW
125
125
  class FootnoteIndex < Index
126
126
  end
127
127
 
128
+ class EndnoteIndex < Index
129
+ end
130
+
128
131
  class ImageIndex < Index
129
132
  def self.item_type
130
133
  '(image|graph|imgtable)'
@@ -14,11 +14,11 @@ module ReVIEW
14
14
  def self.mkpart_from_namelistfile(book, path)
15
15
  chaps = []
16
16
  File.read(path, mode: 'rt:BOM|utf-8').split.each_with_index do |name, number|
17
- if path =~ /PREDEF/
18
- chaps << Chapter.mkchap(book, name)
19
- else
20
- chaps << Chapter.mkchap(book, name, number + 1)
21
- end
17
+ chaps << if /PREDEF/.match?(path)
18
+ Chapter.mkchap(book, name)
19
+ else
20
+ Chapter.mkchap(book, name, number + 1)
21
+ end
22
22
  end
23
23
  Part.mkpart(chaps)
24
24
  end
@@ -47,11 +47,11 @@ module ReVIEW
47
47
  else
48
48
  @content = ''
49
49
  end
50
- if file?
51
- @title = nil
52
- else
53
- @title = name
54
- end
50
+ @title = if file?
51
+ nil
52
+ else
53
+ name
54
+ end
55
55
  @volume = nil
56
56
 
57
57
  super()
@@ -78,11 +78,10 @@ module ReVIEW
78
78
 
79
79
  def volume
80
80
  if @number && file?
81
- vol = Volume.count_file(File.join(@book.config['contentdir'], @path))
81
+ Volume.count_file(File.join(@book.config['contentdir'], @path))
82
82
  else
83
- vol = Volume.new(0, 0, 0)
83
+ Volume.new(0, 0, 0)
84
84
  end
85
- vol
86
85
  end
87
86
 
88
87
  def file?
@@ -12,7 +12,7 @@ module ReVIEW
12
12
  def self.count_file(path)
13
13
  b = c = l = 0
14
14
  File.foreach(path) do |line|
15
- next if /\A\#@/ =~ line
15
+ next if /\A\#@/.match?(line)
16
16
 
17
17
  text = line.gsub(/\s+/, '')
18
18
  b += text.bytesize