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,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
@@ -401,10 +402,10 @@ module ReVIEW
401
402
  def inline_ruby(arg)
402
403
  base, *ruby = *arg.scan(/(?:(?:(?:\\\\)*\\,)|[^,\\]+)+/)
403
404
  if base
404
- base = base.gsub(/\\,/, ',')
405
+ base = base.gsub(/\\,/, ',').strip
405
406
  end
406
407
  if ruby
407
- ruby = ruby.join(',').gsub(/\\,/, ',')
408
+ ruby = ruby.join(',').gsub(/\\,/, ',').strip
408
409
  end
409
410
  compile_ruby(base, ruby)
410
411
  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)
data/lib/review/i18n.yml CHANGED
@@ -17,7 +17,14 @@ ja:
17
17
  hd_quote_without_number: "「%s」"
18
18
  appendix: 付録%pA
19
19
  numberless_image: "図:"
20
- memo_head: ■メモ
20
+ note_head: NOTE
21
+ tip_head: TIP
22
+ info_head: INFORMATION
23
+ warning_head: WARNING
24
+ important_head: IMPORTANT
25
+ caution_head: CAUTION
26
+ notice_head: NOTICE
27
+ memo_head: MEMO
21
28
  format_number: "%s.%d"
22
29
  format_number_header: "%s.%d:"
23
30
  format_number_without_chapter: "%d"
@@ -107,7 +114,14 @@ en:
107
114
  hd_quote_without_number: '"%s"'
108
115
  appendix: Appendix %s
109
116
  numberless_image: "Figure:"
110
- memo_head: Note
117
+ note_head: NOTE
118
+ tip_head: TIP
119
+ info_head: INFORMATION
120
+ warning_head: WARNING
121
+ important_head: IMPORTANT
122
+ caution_head: CAUTION
123
+ notice_head: NOTICE
124
+ memo_head: MEMO
111
125
  format_number: "%s.%d"
112
126
  format_number_header: "%s.%d:"
113
127
  format_number_without_chapter: "%d"
@@ -178,6 +192,14 @@ zh-TW:
178
192
  hd_quote_without_number: "「%s」"
179
193
  appendix: 附錄%s
180
194
  numberless_image: "圖:"
195
+ note_head: NOTE
196
+ tip_head: TIP
197
+ info_head: INFORMATION
198
+ warning_head: WARNING
199
+ important_head: IMPORTANT
200
+ caution_head: CAUTION
201
+ notice_head: NOTICE
202
+ memo_head: MEMO
181
203
  format_number: "%s.%d"
182
204
  format_number_header: "%s.%d:"
183
205
  format_number_without_chapter: "%d"
@@ -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
@@ -465,11 +466,22 @@ module ReVIEW
465
466
  puts caption_str if caption_top?('equation')
466
467
  end
467
468
 
468
- puts %Q(<replace idref="texblock-#{@texblockequation}">)
469
- puts '<pre>'
470
- print lines.join("\n")
471
- puts '</pre>'
472
- puts '</replace>'
469
+ if @book.config['math_format'] == 'imgmath'
470
+ fontsize = @book.config['imgmath_options']['fontsize'].to_f
471
+ lineheight = @book.config['imgmath_options']['lineheight'].to_f
472
+ math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
473
+ key = Digest::SHA256.hexdigest(math_str)
474
+ img_path = @img_math.defer_math_image(math_str, key)
475
+ puts '<equationimage>'
476
+ puts %Q(<Image href="file://#{img_path}" />)
477
+ puts '</equationimage>'
478
+ else
479
+ puts %Q(<replace idref="texblock-#{@texblockequation}">)
480
+ puts '<pre>'
481
+ puts lines.join("\n")
482
+ puts '</pre>'
483
+ puts '</replace>'
484
+ end
473
485
 
474
486
  if id
475
487
  puts caption_str unless caption_top?('equation')
@@ -515,7 +527,7 @@ module ReVIEW
515
527
  sepidx = nil
516
528
  rows = []
517
529
  lines.each_with_index do |line, idx|
518
- if /\A[=\-]{12}/.match?(line)
530
+ if /\A[=-]{12}/.match?(line)
519
531
  sepidx ||= idx
520
532
  next
521
533
  end
@@ -681,7 +693,7 @@ module ReVIEW
681
693
  end
682
694
 
683
695
  def compile_ruby(base, ruby)
684
- %Q(<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape(base.strip)}</aid:rb><aid:rt>#{escape(ruby.strip)}</aid:rt></aid:ruby></GroupRuby>)
696
+ %Q(<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>#{escape(base)}</aid:rb><aid:rt>#{escape(ruby)}</aid:rt></aid:ruby></GroupRuby>)
685
697
  end
686
698
 
687
699
  def compile_kw(word, alt)
@@ -835,7 +847,14 @@ module ReVIEW
835
847
 
836
848
  def inline_m(str)
837
849
  @texinlineequation += 1
838
- %Q(<replace idref="texinline-#{@texinlineequation}"><pre>#{escape(str)}</pre></replace>)
850
+ if @book.config['math_format'] == 'imgmath'
851
+ math_str = '$' + str + '$'
852
+ key = Digest::SHA256.hexdigest(str)
853
+ img_path = @img_math.defer_math_image(math_str, key)
854
+ %Q(<inlineequation><Image href="file://#{img_path}" type="inline" /></inlineequation>)
855
+ else
856
+ %Q(<replace idref="texinline-#{@texinlineequation}"><pre>#{escape(str)}</pre></replace>)
857
+ end
839
858
  end
840
859
 
841
860
  def noindent
@@ -16,6 +16,7 @@ require 'review/yamlloader'
16
16
  require 'review/idgxmlbuilder'
17
17
  require 'review/version'
18
18
  require 'review/makerhelper'
19
+ require 'review/img_math'
19
20
  require 'review/loggable'
20
21
 
21
22
  module ReVIEW
@@ -28,6 +29,7 @@ module ReVIEW
28
29
  def initialize
29
30
  @basedir = nil
30
31
  @logger = ReVIEW.logger
32
+ @img_math = nil
31
33
  @plaintext = nil
32
34
  @compile_errors = nil
33
35
  end
@@ -67,6 +69,7 @@ module ReVIEW
67
69
  end
68
70
 
69
71
  def remove_old_files(path)
72
+ @img_math.cleanup_mathimg
70
73
  FileUtils.rm_rf(path)
71
74
  end
72
75
 
@@ -81,6 +84,9 @@ module ReVIEW
81
84
  rescue ReVIEW::ConfigError => e
82
85
  error! e.message
83
86
  end
87
+
88
+ @img_math = ReVIEW::ImgMath.new(@config)
89
+
84
90
  I18n.setup(@config['language'])
85
91
  begin
86
92
  generate_idgxml_files(yamlfile)
@@ -90,6 +96,10 @@ module ReVIEW
90
96
 
91
97
  error! e.message
92
98
  end
99
+
100
+ if @config['math_format'] == 'imgmath'
101
+ @img_math.make_math_images
102
+ end
93
103
  end
94
104
 
95
105
  def generate_idgxml_files(yamlfile)
@@ -130,7 +140,7 @@ module ReVIEW
130
140
 
131
141
  def build_body(basetmpdir, _yamlfile)
132
142
  base_path = Pathname.new(@basedir)
133
- @converter = ReVIEW::Converter.new(@book, ReVIEW::IDGXMLBuilder.new)
143
+ @converter = ReVIEW::Converter.new(@book, ReVIEW::IDGXMLBuilder.new(img_math: @img_math))
134
144
  @book.parts.each do |part|
135
145
  if part.name.present?
136
146
  if part.file?
@@ -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
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2018-2021 Masanori Kado, Masayoshi Takahashi, Kenshi Muto
2
+ # Copyright (c) 2018-2022 Masanori Kado, Masayoshi Takahashi, Kenshi Muto
3
3
  #
4
4
  # This program is free software.
5
5
  # You can distribute or modify this program under the terms of
@@ -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
 
@@ -308,7 +308,12 @@ EOS
308
308
  end
309
309
 
310
310
  def start_webui
311
- require 'webrick'
311
+ begin
312
+ require 'webrick'
313
+ rescue LoadError
314
+ @logger.error 'not found webrick. Please install webrick gem.'
315
+ exit 1
316
+ end
312
317
  web_config = {
313
318
  BindAddress: @bind,
314
319
  Port: @port,
@@ -316,7 +321,7 @@ EOS
316
321
  AccessLog: [[File.open(IO::NULL, 'w'), '']]
317
322
  }
318
323
 
319
- bind_address = (@bind == '0') ? '<thishost>' : @bind
324
+ bind_address = (@bind == '0.0.0.0') ? '<thishost>' : @bind
320
325
  puts "Please access http://#{bind_address}:#{web_config[:Port]} from Web browser."
321
326
  begin
322
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
@@ -1350,7 +1350,7 @@ module ReVIEW
1350
1350
 
1351
1351
  def inline_icon(id)
1352
1352
  if @chapter.image(id).path
1353
- command = 'reviewincludegraphics'
1353
+ command = 'reviewicon'
1354
1354
  if @book.config.check_version('2', exception: false)
1355
1355
  command = 'includegraphics'
1356
1356
  end
@@ -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.5.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,10 +27,11 @@ 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')
35
34
  gem.add_development_dependency('test-unit')
36
35
  gem.add_development_dependency('unicode-eaw')
36
+ gem.add_development_dependency('webrick')
37
37
  end
@@ -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'
@@ -34,7 +34,9 @@
34
34
  \def\review@intn@table{<%= escape(I18n.t('table')) %>}
35
35
  \def\review@intn@equation{<%= escape(I18n.t('equation')) %>}
36
36
  \def\review@intn@columnname{<%= escape(I18n.t('columnname')) %>}
37
- \def\review@intn@memohead{<%= escape(I18n.t('memo_head')) %>}
37
+ <%- %w[note tip info warning important caution notice memo].each do |mini| -%>
38
+ \def\review@intn@<%= mini%>head{<%= escape(I18n.t("#{mini}_head")) %>}
39
+ <%- end -%>
38
40
  \def\review@intn@edition{<%= escape(I18n.t('edition')) %>}
39
41
  \def\review@intn@publishedby{<%= escape(I18n.t('published_by', @config.names_of('pbl').join(I18n.t('names_splitter'))))%>}
40
42
  \def\review@intn@captionprefix{<%= escape(I18n.t('caption_prefix')) %>}
@@ -127,6 +129,9 @@
127
129
  \ifdefined\reviewtcy\else% for 5.3.0 compatibility
128
130
  \DeclareRobustCommand{\reviewtcy}[1]{\rensuji{##1}}
129
131
  \fi
132
+ \ifdefined\reviewicon\else% for 5.6.0 compatibility
133
+ \DeclareRobustCommand{\reviewicon}[1]{\reviewincludegraphics{##1}}
134
+ \fi
130
135
  }
131
136
 
132
137
  \makeatother