review 5.6.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644d242fdcddb452c2cfd780a13a165ee89f49b11f349b682ad87c47255f8758
4
- data.tar.gz: 77636486441ca626f068bec8f1cabae980bb4832946d98ef6c5bc329bee30b56
3
+ metadata.gz: 11969067c8cb25999f37895ba330bd5c030c62402d1540510e241c6029c38d90
4
+ data.tar.gz: 4294e10f33abcb6063ea0098c3b7256374a5696d693fe2284dcb0fed4f2b2348
5
5
  SHA512:
6
- metadata.gz: 96d2d70825a306d384e832312527e956f23b81832a71fe766b102e6705b5b3dfad50c3cde19b767eaa124e79a6d5096a5cf9ee882ef1335cb96864d3dd4de992
7
- data.tar.gz: 06336e0ca7578002aa195d1a08d4f354da2842fe0eb0812d38825be48c68130d6a78da8df9ae064ba24d138f6f5bb11c9383bf8a3eb9d4ea06f8458c8813be44
6
+ metadata.gz: dddd61f8870c1f2e0d1117d3318cb456bcf49db10a12c4c93dc8b7638b08e5b6894efdfbdbd635d432196f82d40f906b29435f4f6e5ddbb78d2dcbd3829715af
7
+ data.tar.gz: 695257c02903d581c061cd7813e8951923a4a63986e879aa6e6ee31d963d627bf0e9512f85ffc56ca6a596a8f8f114ed012c3cce9daa7dd41072aabc89a9cb3d
@@ -0,0 +1,31 @@
1
+ name: Lint by RuboCop
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ['2.7', '3.0', '3.1', '3.2']
17
+ os: [ubuntu-latest]
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: fix ImageMagick policy.xml on Linux
25
+ if: runner.os == 'Linux'
26
+ run: sudo sed -i 's/none/read|write/g' /etc/ImageMagick-6/policy.xml
27
+ - name: Build and test with Rake
28
+ run: |
29
+ gem install bundler --no-document
30
+ bundle install --retry 3
31
+ bundle exec rubocop -P
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: ['2.5', '3.0', '3.1']
16
+ ruby: ['2.7', '3.2']
17
17
  os: [ubuntu-20.04]
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
16
+ ruby: [ '3.2', '3.1', '3.0', '2.7' ]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
16
+ ruby: ['2.7', '3.0', '3.1', '3.2']
17
17
  os: [ubuntu-latest, macOS-latest]
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -28,4 +28,4 @@ jobs:
28
28
  run: |
29
29
  gem install bundler --no-document
30
30
  bundle install --retry 3
31
- bundle exec rake
31
+ bundle exec rake test
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ AllCops:
5
5
  - tmp/*
6
6
  DisplayCopNames: true
7
7
  NewCops: enable
8
- TargetRubyVersion: 2.5
8
+ TargetRubyVersion: 2.7
9
9
 
10
10
  require:
11
11
  - rubocop-performance
@@ -38,6 +38,9 @@ Performance/StringInclude:
38
38
  Performance/CollectionLiteralInLoop:
39
39
  Enabled: false
40
40
 
41
+ Performance/MapCompact:
42
+ Enabled: false
43
+
41
44
  #### Style
42
45
 
43
46
  Style/AsciiComments:
@@ -109,7 +112,7 @@ Style/LineEndConcatenation:
109
112
  Enabled: false
110
113
 
111
114
  Style/MethodCallWithArgsParentheses:
112
- IgnoredMethods:
115
+ AllowedMethods:
113
116
  - 'require'
114
117
  - 'include'
115
118
  - 'file'
@@ -194,6 +197,9 @@ Style/OptionalBooleanParameter:
194
197
  Style/CombinableLoops:
195
198
  Enabled: false
196
199
 
200
+ Style/FetchEnvVar:
201
+ Enabled: false
202
+
197
203
  ### Layout
198
204
 
199
205
  Layout/BlockAlignment:
@@ -296,3 +302,8 @@ Naming/VariableNumber:
296
302
 
297
303
  Gemspec/RequiredRubyVersion:
298
304
  Enabled: false
305
+
306
+ Gemspec/DevelopmentDependencies:
307
+ EnforcedStyle: gemspec
308
+ Exclude:
309
+ - samples/syntax-book/Gemfile
data/NEWS.ja.md CHANGED
@@ -1,3 +1,25 @@
1
+ # Version 5.7.0
2
+ ## バグ修正
3
+ * Windows において、`review-init -w` の実行時にバインドアドレスを省略したときにエラーが発生するのを修正しました ([#1824])
4
+ * PDFMaker: `//blankline` でページをまたいだときに、ページの先頭に空行が入るのを抑制しました ([#1872])
5
+ * EPUBMaker: MathJax で数式を表現する際に、`<`, `>`, `&` を変換し、HTML のエラーが出ないようにしました ([#1876], [#1877])
6
+
7
+ ## 非互換の変更
8
+ * 動作検証済みバージョンを Ruby 2.7 以降としました ([#1871])
9
+ * EPUMaker: EPUB の検証ルールに従い、EPUB の目次に表紙へのリンクを含めました ([#1874])
10
+
11
+ ## その他
12
+ * Ruby 3.2 を動作検証テスト対象に含めました ([#1871])
13
+ * RuboCop 1.45.1 の指摘を反映しました ([#1878])
14
+
15
+ [#1824]: https://github.com/kmuto/review/issues/1824
16
+ [#1871]: https://github.com/kmuto/review/pull/1871
17
+ [#1872]: https://github.com/kmuto/review/issues/1872
18
+ [#1874]: https://github.com/kmuto/review/issues/1874
19
+ [#1876]: https://github.com/kmuto/review/pull/1876
20
+ [#1877]: https://github.com/kmuto/review/pull/1877
21
+ [#1878]: https://github.com/kmuto/review/pull/1878
22
+
1
23
  # Version 5.6.0
2
24
  ## 新機能
3
25
  * IDGXMLBuilder: `//texequation` と `@<m>` で `imgmath` math_formatに対応しました ([#1829])
data/NEWS.md CHANGED
@@ -1,3 +1,24 @@
1
+ # Version 5.7.0
2
+ ## Bug Fixes
3
+ * Fixed error when omitting a bind address of `review-init -w` on Windows ([#1824])
4
+ * EPUBMaker: escape `<`, `>`, and `&` when converting to MathJax to avoid HTML errors ([#1876], [#1877])
5
+
6
+ ## Breaking Changes
7
+ * Ruby 2.6 or earlier was excluded from the operation verification ([#1871])
8
+ * EPUMaker: included a link to the cover in the table of contents according to EPUB validation rules ([#1874])
9
+
10
+ ## Others
11
+ * Ruby 3.2 is now included in the testing target ([#1871])
12
+ * refactor code with RuboCop 1.45.1 ([#1878])
13
+
14
+ [#1824]: https://github.com/kmuto/review/issues/1824
15
+ [#1871]: https://github.com/kmuto/review/pull/1871
16
+ [#1872]: https://github.com/kmuto/review/issues/1872
17
+ [#1874]: https://github.com/kmuto/review/issues/1874
18
+ [#1876]: https://github.com/kmuto/review/pull/1876
19
+ [#1877]: https://github.com/kmuto/review/pull/1877
20
+ [#1878]: https://github.com/kmuto/review/pull/1878
21
+
1
22
  # Version 5.6.0
2
23
  ## New Features
3
24
  * IDGXMLBuilder: support `imgmath` math_format in `//texequation` and `@<m>` ([#1829])
data/README.md CHANGED
@@ -117,4 +117,4 @@ Exception:
117
117
 
118
118
  ## Copyright
119
119
 
120
- Copyright (c) 2006-2022 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
120
+ Copyright (c) 2006-2023 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2009-2022 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
2
+ # Copyright (c) 2009-2023 Minero Aoki, Kenshi Muto, Masayoshi Takahashi
3
3
  # 2002-2008 Minero Aoki
4
4
  #
5
5
  # This program is free software.
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2002-2022 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2002-2023 Minero Aoki, Kenshi Muto
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -234,7 +234,8 @@ module ReVIEW
234
234
  sepidx = nil
235
235
  rows = []
236
236
  lines.each_with_index do |line, idx|
237
- if /\A[=\-]{12}/ =~ line || /\A[={\-}]{12}/ =~ line
237
+ # {} is for LaTeX
238
+ if /\A[=-]{12}/ =~ line || /\A[={}-]{12}/ =~ line
238
239
  sepidx ||= idx
239
240
  next
240
241
  end
@@ -512,12 +513,7 @@ module ReVIEW
512
513
  end
513
514
 
514
515
  def inline_wb(s)
515
- translated = @dictionary[s]
516
- if translated
517
- inline_b(translated)
518
- else
519
- inline_b("[missing word: #{s}]")
520
- end
516
+ inline_b(@dictionary[s] || "[missing word: #{s}]")
521
517
  end
522
518
 
523
519
  def raw(str)
@@ -1,6 +1,6 @@
1
1
  # = epubcommon.rb -- super class for EPUBv2 and EPUBv3
2
2
  #
3
- # Copyright (c) 2010-2022 Kenshi Muto and Masayoshi Takahashi
3
+ # Copyright (c) 2010-2023 Kenshi Muto and Masayoshi Takahashi
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -231,6 +231,10 @@ module ReVIEW
231
231
  ReVIEW::Template.generate(path: template_name, binding: binding)
232
232
  end
233
233
 
234
+ def coveritem
235
+ []
236
+ end
237
+
234
238
  def hierarchy_ncx(type)
235
239
  require 'rexml/document'
236
240
  level = 1
@@ -264,7 +268,7 @@ module ReVIEW
264
268
  doc.context[:attribute_quote] = :quote
265
269
 
266
270
  e = doc.root.elements[1] # first <li/>
267
- contents.each do |item|
271
+ (coveritem + contents).each do |item|
268
272
  next if !item.notoc.nil? || item.level.nil? || item.file.nil? || item.title.nil? || item.level > toclevel
269
273
 
270
274
  if item.level == level
@@ -304,7 +308,7 @@ module ReVIEW
304
308
 
305
309
  def flat_ncx(type, indent = nil)
306
310
  s = %Q(<#{type} class="toc-h1">\n)
307
- contents.each do |item|
311
+ (coveritem + contents).each do |item|
308
312
  next if !item.notoc.nil? || item.level.nil? || item.file.nil? || item.title.nil? || item.level > config['toclevel'].to_i
309
313
 
310
314
  is = indent == true ? ' ' * item.level : ''
@@ -324,10 +328,12 @@ module ReVIEW
324
328
  FileUtils.mkdir_p("#{tmpdir}/OEBPS")
325
329
  File.write(File.join(tmpdir, opf_path), opf)
326
330
 
327
- if File.exist?("#{basedir}/#{config['cover']}")
328
- FileUtils.cp("#{basedir}/#{config['cover']}", "#{tmpdir}/OEBPS")
329
- else
330
- File.write("#{tmpdir}/OEBPS/#{config['cover']}", cover)
331
+ if config['cover']
332
+ if File.exist?("#{basedir}/#{config['cover']}")
333
+ FileUtils.cp("#{basedir}/#{config['cover']}", "#{tmpdir}/OEBPS")
334
+ else
335
+ File.write("#{tmpdir}/OEBPS/#{config['cover']}", cover)
336
+ end
331
337
  end
332
338
 
333
339
  if config['colophon'] && !config['colophon'].is_a?(String)
@@ -22,11 +22,6 @@ module ReVIEW
22
22
  CREATOR_ATTRIBUTES = %w[aut a-adp a-ann a-arr a-art a-asn a-aqt a-aft a-aui a-ant a-bkp a-clb a-cmm a-dsr a-edt a-ill a-lyr a-mdc a-mus a-nrt a-oth a-pht a-prt a-red a-rev a-spn a-ths a-trc a-trl]
23
23
  CONTRIBUTER_ATTRIBUTES = %w[adp ann arr art asn aqt aft aui ant bkp clb cmm dsr edt ill lyr mdc mus nrt oth pht prt red rev spn ths trc trl]
24
24
 
25
- # Construct object with parameter hash +config+ and message resource hash +res+.
26
- def initialize(producer) # rubocop:disable Lint/UselessMethodDefinition
27
- super
28
- end
29
-
30
25
  # Return opf file content.
31
26
  def opf
32
27
  @opf_metainfo = opf_metainfo
@@ -1,6 +1,6 @@
1
1
  # = epubv3.rb -- EPUB version 3 producer.
2
2
  #
3
- # Copyright (c) 2010-2022 Kenshi Muto
3
+ # Copyright (c) 2010-2023 Kenshi Muto
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -213,6 +213,14 @@ module ReVIEW
213
213
  ReVIEW::Template.generate(path: template_name, binding: binding)
214
214
  end
215
215
 
216
+ def coveritem
217
+ if config['cover']
218
+ [Content.new(file: config['cover'], title: ReVIEW::I18n.t('covertitle'), level: 1, chaptype: 'cover')]
219
+ else
220
+ []
221
+ end
222
+ end
223
+
216
224
  # Produce EPUB file +epubfile+.
217
225
  # +work_dir+ points the directory has contents.
218
226
  # +tmpdir+ defines temporary directory.
@@ -1,6 +1,6 @@
1
1
  # = producer.rb -- EPUB producer.
2
2
  #
3
- # Copyright (c) 2010-2021 Kenshi Muto
3
+ # Copyright (c) 2010-2023 Kenshi Muto
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -119,8 +119,7 @@ module ReVIEW
119
119
  epubfile = "#{current}/#{epubfile}"
120
120
  end
121
121
 
122
- # FIXME: error check
123
- File.unlink(epubfile) if File.exist?(epubfile)
122
+ FileUtils.rm_f(epubfile)
124
123
 
125
124
  begin
126
125
  @epub.produce(epubfile, work_dir, new_tmpdir, base_dir: base_dir)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2022 Kenshi Muto and Masayoshi Takahashi
1
+ # Copyright (c) 2010-2023 Kenshi Muto and Masayoshi Takahashi
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -106,9 +106,7 @@ module ReVIEW
106
106
  def build_path
107
107
  if @config['debug']
108
108
  path = File.expand_path("#{@config['bookname']}-epub", Dir.pwd)
109
- if File.exist?(path)
110
- FileUtils.rm_rf(path, secure: true)
111
- end
109
+ FileUtils.rm_rf(path, secure: true)
112
110
  Dir.mkdir(path)
113
111
  path
114
112
  else
@@ -656,7 +656,7 @@ module ReVIEW
656
656
  p = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
657
657
  print p.parse(lines.join("\n") + "\n", true)
658
658
  elsif @book.config['math_format'] == 'mathjax'
659
- puts "$$#{lines.join("\n")}$$"
659
+ puts "$$#{lines.join("\n").gsub('<', '\lt{}').gsub('>', '\gt{}').gsub('&', '&amp;')}$$"
660
660
  elsif @book.config['math_format'] == 'imgmath'
661
661
  fontsize = @book.config['imgmath_options']['fontsize'].to_f
662
662
  lineheight = @book.config['imgmath_options']['lineheight'].to_f
@@ -1051,7 +1051,7 @@ EOS
1051
1051
  parser = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
1052
1052
  %Q(<span class="equation">#{parser.parse(str, nil)}</span>)
1053
1053
  elsif @book.config['math_format'] == 'mathjax'
1054
- %Q(<span class="equation">\\( #{str} \\)</span>)
1054
+ %Q(<span class="equation">\\( #{str.gsub('<', '\lt{}').gsub('>', '\gt{}').gsub('&', '&amp;')} \\)</span>)
1055
1055
  elsif @book.config['math_format'] == 'imgmath'
1056
1056
  math_str = '$' + str + '$'
1057
1057
  key = Digest::SHA256.hexdigest(str)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-2022 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2008-2023 Minero Aoki, Kenshi Muto
2
2
  # 2002-2007 Minero Aoki
3
3
  #
4
4
  # This program is free software.
@@ -136,7 +136,8 @@ module ReVIEW
136
136
  when 5
137
137
  @subsubsubsection += 1
138
138
  print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) if @secttags
139
- when 6 # rubocop:disable Lint/EmptyWhen
139
+ when 6
140
+ # ignore
140
141
  else
141
142
  raise "caption level too deep or unsupported: #{level}"
142
143
  end
@@ -526,7 +527,7 @@ module ReVIEW
526
527
  sepidx = nil
527
528
  rows = []
528
529
  lines.each_with_index do |line, idx|
529
- if /\A[=\-]{12}/.match?(line)
530
+ if /\A[=-]{12}/.match?(line)
530
531
  sepidx ||= idx
531
532
  next
532
533
  end
@@ -1,3 +1,10 @@
1
+ #
2
+ # Copyright (c) 2021-2023 Masayoshi Takahashi, Kenshi Muto
3
+ #
4
+ # This program is free software.
5
+ # You can distribute/modify this program under the terms of
6
+ # the GNU LGPL, Lesser General Public License version 2.1.
7
+ #
1
8
  require 'fileutils'
2
9
  require 'shellwords'
3
10
  require 'review/loggable'
@@ -29,7 +36,7 @@ module ReVIEW
29
36
  # Re:VIEW 2 compatibility
30
37
 
31
38
  img_path = File.join(@math_dir, "_gen_#{key}.#{@config['imgmath_options']['format']}")
32
- Dir.mkdir(@math_dir) unless Dir.exist?(@math_dir)
39
+ FileUtils.mkdir_p(@math_dir)
33
40
  fontsize2 = (fontsize * 1.2).round.to_i
34
41
  texsrc = <<-EOB
35
42
  \\documentclass[12pt]{article}
@@ -63,7 +70,7 @@ module ReVIEW
63
70
  def make_math_images
64
71
  return if @math_maps.empty?
65
72
 
66
- Dir.mkdir(@math_dir) unless Dir.exist?(@math_dir)
73
+ FileUtils.mkdir_p(@math_dir)
67
74
  fontsize = @config['imgmath_options']['fontsize'].to_f
68
75
  lineheight = @config['imgmath_options']['lineheight'].to_f
69
76
 
data/lib/review/init.rb CHANGED
@@ -61,7 +61,7 @@ module ReVIEW
61
61
 
62
62
  def parse_options(args)
63
63
  @port = 18000
64
- @bind = '0'
64
+ @bind = '0.0.0.0'
65
65
 
66
66
  opts = OptionParser.new
67
67
  opts.version = ReVIEW::VERSION
@@ -97,7 +97,7 @@ module ReVIEW
97
97
  opts.on('', '--port port', 'port to use for Web based layout configuration. (default: 18000)') do |port|
98
98
  @port = port
99
99
  end
100
- opts.on('', '--bind bindaddress', 'address to use for Web based layout configuration. (default: 0 (any))') do |bind|
100
+ opts.on('', '--bind bindaddress', 'address to use for Web based layout configuration. (default: 0.0.0.0 (any))') do |bind|
101
101
  @bind = bind
102
102
  end
103
103
 
@@ -321,7 +321,7 @@ EOS
321
321
  AccessLog: [[File.open(IO::NULL, 'w'), '']]
322
322
  }
323
323
 
324
- bind_address = (@bind == '0') ? '<thishost>' : @bind
324
+ bind_address = (@bind == '0.0.0.0') ? '<thishost>' : @bind
325
325
  puts "Please access http://#{bind_address}:#{web_config[:Port]} from Web browser."
326
326
  begin
327
327
  @web_server = WEBrick::HTTPServer.new(web_config)
@@ -1038,7 +1038,7 @@ module ReVIEW
1038
1038
  end
1039
1039
 
1040
1040
  def blankline
1041
- puts '\vspace*{\baselineskip}'
1041
+ puts '\par\vspace{\baselineskip}\par'
1042
1042
  end
1043
1043
 
1044
1044
  def noindent
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2002-2020 Minero Aoki, Masayoshi Takahashi, Kenshi Muto
2
+ # Copyright (c) 2002-2023 Minero Aoki, Masayoshi Takahashi, Kenshi Muto
3
3
  #
4
4
  # This program is free software.
5
5
  # You can distribute/modify this program under the terms of
@@ -21,7 +21,7 @@ module ReVIEW
21
21
  end
22
22
 
23
23
  def inspect
24
- "\#<#{self.class} file=#{@input.inspect} line=#{lineno}>"
24
+ "#<#{self.class} file=#{@input.inspect} line=#{lineno}>"
25
25
  end
26
26
 
27
27
  def eof?
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2012-2020 Yuto HAYAMIZU, Kenshi Muto
1
+ # Copyright (c) 2012-2023 Yuto HAYAMIZU, Kenshi Muto
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -48,7 +48,7 @@ module ReVIEW
48
48
  if FileTest.directory?("#{from_dir}/#{fname}")
49
49
  image_files += copy_images_to_dir("#{from_dir}/#{fname}", "#{to_dir}/#{fname}", options)
50
50
  else
51
- FileUtils.mkdir_p(to_dir) unless File.exist?(to_dir)
51
+ FileUtils.mkdir_p(to_dir)
52
52
 
53
53
  is_converted = false
54
54
  (options[:convert] || {}).each do |orig_type, conv_type|
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2022 Kenshi Muto and Masayoshi Takahashi
1
+ # Copyright (c) 2010-2023 Kenshi Muto and Masayoshi Takahashi
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -69,9 +69,7 @@ module ReVIEW
69
69
  def build_path
70
70
  if @config['debug']
71
71
  path = "#{@config['bookname']}-pdf"
72
- if File.exist?(path)
73
- FileUtils.rm_rf(path, secure: true)
74
- end
72
+ FileUtils.rm_rf(path, secure: true)
75
73
  Dir.mkdir(path)
76
74
  path
77
75
  else
@@ -517,7 +515,7 @@ module ReVIEW
517
515
  dir.sort.each do |fname|
518
516
  next unless File.extname(fname).downcase == '.' + extname
519
517
 
520
- FileUtils.mkdir_p(copybase) unless Dir.exist?(copybase)
518
+ FileUtils.mkdir_p(copybase)
521
519
  if extname == 'erb'
522
520
  File.open(File.join(copybase, fname.sub(/\.erb\Z/, '')), 'w') do |f|
523
521
  f.print erb_content(File.join(dirname, fname))
data/lib/review/update.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2018-2022 Kenshi Muto
2
+ # Copyright (c) 2018-2023 Kenshi Muto
3
3
  #
4
4
  # This program is free software.
5
5
  # You can distribute or modify this program under the terms of
@@ -258,9 +258,7 @@ module ReVIEW
258
258
 
259
259
  def update_rakefile(dir)
260
260
  taskdir = File.join(dir, 'lib/tasks')
261
- unless File.exist?(taskdir)
262
- FileUtils.mkdir_p(taskdir)
263
- end
261
+ FileUtils.mkdir_p(taskdir)
264
262
 
265
263
  master_rakefile = File.join(@review_dir, 'samples/sample-book/src/Rakefile')
266
264
 
@@ -474,9 +472,7 @@ module ReVIEW
474
472
 
475
473
  def update_tex_stys(template, dir)
476
474
  texmacrodir = File.join(dir, 'sty')
477
- unless File.exist?(texmacrodir)
478
- FileUtils.mkdir(texmacrodir)
479
- end
475
+ FileUtils.mkdir_p(texmacrodir)
480
476
 
481
477
  tdir = File.join(@review_dir, 'templates/latex', template)
482
478
  Dir.glob(File.join(tdir, '*.*')).each do |master_styfile|
@@ -1,3 +1,3 @@
1
1
  module ReVIEW
2
- VERSION = '5.6.0'.freeze
2
+ VERSION = '5.7.0'.freeze
3
3
  end
@@ -36,9 +36,6 @@ module ReVIEW
36
36
  end
37
37
  end
38
38
 
39
- def initialize
40
- end
41
-
42
39
  # load YAML files
43
40
  #
44
41
  # `inherit: [3.yml, 6.yml]` in 7.yml; `inherit: [1.yml, 2.yml]` in 3.yml; `inherit: [4.yml, 5.yml]` in 6.yml
data/review.gemspec CHANGED
@@ -14,8 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.required_rubygems_version = Gem::Requirement.new('>= 0') if gem.respond_to?(:required_rubygems_version=)
15
15
  gem.metadata = { 'rubygems_mfa_required' => 'true' }
16
16
 
17
- gem.files = `git ls-files`.split("\n")
18
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.files = `git ls-files`.split("\n").reject { |f| f.match(/^test/) }
19
18
  gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
19
  gem.extra_rdoc_files = []
21
20
  gem.require_paths = ['lib']
@@ -28,7 +27,7 @@ Gem::Specification.new do |gem|
28
27
  gem.add_development_dependency('mini_magick')
29
28
  gem.add_development_dependency('pygments.rb')
30
29
  gem.add_development_dependency('rake')
31
- gem.add_development_dependency('rubocop', '~> 1.12.0')
30
+ gem.add_development_dependency('rubocop', '~> 1.45.1')
32
31
  gem.add_development_dependency('rubocop-performance')
33
32
  gem.add_development_dependency('rubocop-rake')
34
33
  gem.add_development_dependency('simplecov')
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'review', '4.2.0'
4
+ gem 'review', '~> 5.3.0'
@@ -7,7 +7,9 @@
7
7
  <%= @opf_manifest %>
8
8
  <%= @opf_toc %>
9
9
  <guide>
10
+ <% if @config['cover'].present? %>
10
11
  <reference type="cover" title="<%= ReVIEW::I18n.t('covertitle') %>" href="<%= @config['cover'] %>"/>
12
+ <% end %>
11
13
  <% if @config['titlepage'].present? %>
12
14
  <reference type="title-page" title="<%= ReVIEW::I18n.t('titlepagetitle') %>" href="titlepage.<%= @config['htmlext'] %>"/>
13
15
  <% end %>
@@ -7,7 +7,9 @@
7
7
  <%= @opf_manifest %>
8
8
  <%= @opf_toc %>
9
9
  <guide>
10
+ <% if @config['cover'].present? %>
10
11
  <reference type="cover" title="<%= ReVIEW::I18n.t('covertitle') %>" href="<%= @config['cover'] %>"/>
12
+ <% end %>
11
13
  <% if @config["titlepage"].present? %>
12
14
  <reference type="title-page" title="<%= ReVIEW::I18n.t('titlepagetitle') %>" href="titlepage.<%= @config['htmlext'] %>"/>
13
15
  <% end %>
@@ -1,6 +1,8 @@
1
1
  <manifest>
2
2
  <item id="ncx" href="<%= @config['bookname'] %>.ncx" media-type="application/x-dtbncx+xml"/>
3
+ <% if @config['cover'] %>
3
4
  <item id="<%= @config['bookname'] %>" href="<%= @config['cover'] %>" media-type="application/xhtml+xml"/>
5
+ <% end %>
4
6
  <% if @config['toc'] && @config['mytoc'] %>
5
7
  <item id="toc" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" media-type="application/xhtml+xml"/>
6
8
  <% end %>
@@ -1,6 +1,8 @@
1
1
  <manifest>
2
2
  <item properties="nav" id="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" href="<%= @config['bookname'] %>-toc.<%= @config['htmlext'] %>" media-type="application/xhtml+xml"/>
3
+ <% if @config['cover'] %>
3
4
  <item id="<%= @config['bookname'] %>" href="<%= @config['cover'] %>" media-type="application/xhtml+xml"/>
5
+ <% end %>
4
6
  <% if @coverimage %>
5
7
  <item properties="cover-image" id="cover-<%= @coverimage.id %>" href="<%= @coverimage.file %>" media-type="<%= @coverimage.media %>"/>
6
8
  <% end %>
@@ -3,7 +3,9 @@
3
3
  <% else %>
4
4
  <spine>
5
5
  <% end %>
6
+ <% if @config['cover'].present? %>
6
7
  <itemref idref="<%= @config['bookname'] %>" linear="<%= @cover_linear %>"/>
8
+ <% end %>
7
9
  <% toc = nil %>
8
10
  <% @tocx_contents.each do |item| %>
9
11
  <% if toc.nil? && item.chaptype != 'pre' %>