review 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +31 -0
  3. data/.github/workflows/ruby-win.yml +3 -3
  4. data/.github/workflows/ruby.yml +1 -1
  5. data/.rubocop.yml +15 -7
  6. data/NEWS.ja.md +108 -0
  7. data/NEWS.md +108 -0
  8. data/README.md +7 -6
  9. data/Rakefile +7 -2
  10. data/bin/review +2 -4
  11. data/bin/review-catalog-converter +3 -3
  12. data/bin/review-check +6 -8
  13. data/bin/review-checkdep +1 -4
  14. data/bin/review-compile +2 -5
  15. data/bin/review-epub2html +1 -4
  16. data/bin/review-epubmaker +3 -4
  17. data/bin/review-idgxmlmaker +1 -3
  18. data/bin/review-index +11 -5
  19. data/bin/review-init +1 -4
  20. data/bin/review-pdfmaker +1 -3
  21. data/bin/review-preproc +2 -4
  22. data/bin/review-textmaker +1 -3
  23. data/bin/review-update +1 -4
  24. data/bin/review-validate +3 -3
  25. data/bin/review-vol +1 -4
  26. data/bin/review-webmaker +1 -3
  27. data/doc/config.yml.sample +21 -5
  28. data/doc/config.yml.sample-simple +1 -1
  29. data/doc/format.ja.md +21 -10
  30. data/doc/format.md +21 -10
  31. data/doc/quickstart.ja.md +11 -1
  32. data/doc/quickstart.md +11 -2
  33. data/lib/review.rb +1 -1
  34. data/lib/review/book/base.rb +4 -0
  35. data/lib/review/book/book_unit.rb +3 -0
  36. data/lib/review/book/chapter.rb +3 -0
  37. data/lib/review/book/index.rb +1 -0
  38. data/lib/review/book/volume.rb +1 -0
  39. data/lib/review/builder.rb +8 -1
  40. data/lib/review/call_hook.rb +20 -0
  41. data/lib/review/catalog.rb +1 -0
  42. data/lib/review/compiler.rb +27 -10
  43. data/lib/review/configure.rb +64 -7
  44. data/lib/review/epubmaker.rb +93 -96
  45. data/lib/review/epubmaker/content.rb +113 -0
  46. data/lib/review/epubmaker/epubcommon.rb +372 -0
  47. data/lib/review/epubmaker/epubv2.rb +178 -0
  48. data/lib/review/epubmaker/epubv3.rb +231 -0
  49. data/lib/review/epubmaker/producer.rb +168 -0
  50. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  51. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  52. data/lib/review/exception.rb +6 -0
  53. data/lib/review/htmlbuilder.rb +36 -49
  54. data/lib/review/htmlutils.rb +1 -1
  55. data/lib/review/i18n.rb +1 -0
  56. data/lib/review/idgxmlbuilder.rb +33 -30
  57. data/lib/review/idgxmlmaker.rb +3 -1
  58. data/lib/review/img_math.rb +245 -0
  59. data/lib/review/index_builder.rb +1 -0
  60. data/lib/review/init.rb +4 -4
  61. data/lib/review/latexbox.rb +58 -0
  62. data/lib/review/latexbuilder.rb +30 -19
  63. data/lib/review/latexutils.rb +9 -1
  64. data/lib/review/lineinput.rb +112 -2
  65. data/lib/review/logger.rb +41 -2
  66. data/lib/review/makerhelper.rb +2 -205
  67. data/lib/review/markdownbuilder.rb +32 -1
  68. data/lib/review/pdfmaker.rb +31 -29
  69. data/lib/review/plaintextbuilder.rb +9 -1
  70. data/lib/review/preprocessor.rb +12 -6
  71. data/lib/review/rstbuilder.rb +1 -1
  72. data/lib/review/sec_counter.rb +1 -0
  73. data/lib/review/template.rb +6 -0
  74. data/lib/review/textmaker.rb +11 -7
  75. data/lib/review/textutils.rb +2 -10
  76. data/lib/review/tocprinter.rb +85 -68
  77. data/lib/review/topbuilder.rb +18 -11
  78. data/lib/review/update.rb +5 -6
  79. data/lib/review/version.rb +1 -1
  80. data/lib/review/volumeprinter.rb +4 -5
  81. data/lib/review/webmaker.rb +18 -13
  82. data/lib/review/webtocprinter.rb +10 -9
  83. data/lib/review/yamlloader.rb +2 -1
  84. data/review.gemspec +5 -3
  85. data/samples/sample-book/src/config-epub2.yml +1 -1
  86. data/samples/sample-book/src/config.yml +1 -1
  87. data/samples/sample-book/src/lib/tasks/review.rake +17 -1
  88. data/samples/syntax-book/ch01.re +1 -1
  89. data/samples/syntax-book/ch02.re +21 -6
  90. data/samples/syntax-book/ch03.re +1 -1
  91. data/samples/syntax-book/images/img3-2.png +0 -0
  92. data/templates/html/_colophon.html.erb +23 -0
  93. data/templates/html/_colophon_history.html.erb +9 -0
  94. data/templates/html/_cover.html.erb +10 -0
  95. data/templates/html/_part_body.html.erb +6 -0
  96. data/templates/html/_titlepage.html.erb +20 -0
  97. data/templates/html/layout-html5.html.erb +6 -0
  98. data/templates/html/layout-xhtml1.html.erb +6 -0
  99. data/templates/latex/config.erb +8 -0
  100. data/templates/latex/review-jlreq/review-base.sty +4 -5
  101. data/templates/latex/review-jlreq/review-jlreq.cls +10 -2
  102. data/templates/latex/review-jlreq/review-style.sty +6 -1
  103. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  104. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  105. data/templates/latex/review-jsbook/review-base.sty +5 -7
  106. data/templates/latex/review-jsbook/review-jsbook.cls +10 -2
  107. data/templates/latex/review-jsbook/review-style.sty +6 -1
  108. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  109. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  110. data/templates/opf/epubv2.opf.erb +7 -7
  111. data/templates/opf/epubv3.opf.erb +7 -7
  112. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  113. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  114. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  115. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  116. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  117. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  118. data/templates/web/html/layout-html5.html.erb +6 -5
  119. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  120. data/test/assets/header_listener.html +35 -0
  121. data/test/assets/img_math/img1.png +0 -0
  122. data/test/assets/img_math/img2.png +0 -0
  123. data/test/assets/img_math/img3.png +0 -0
  124. data/test/assets/syntax_book_index_detail.txt +58 -0
  125. data/test/assets/test_template.tex +4 -1
  126. data/test/assets/test_template_backmatter.tex +4 -1
  127. data/test/run_test.rb +1 -1
  128. data/test/test_book_chapter.rb +2 -2
  129. data/test/test_catalog_converter_cmd.rb +1 -1
  130. data/test/test_epub3maker.rb +168 -124
  131. data/test/test_epubmaker.rb +243 -131
  132. data/test/test_epubmaker_cmd.rb +2 -2
  133. data/test/test_helper.rb +5 -4
  134. data/test/test_htmlbuilder.rb +64 -6
  135. data/test/test_idgxmlbuilder.rb +13 -0
  136. data/test/test_idgxmlmaker_cmd.rb +7 -3
  137. data/test/test_img_math.rb +111 -0
  138. data/test/test_indexbuilder.rb +5 -5
  139. data/test/test_latexbuilder.rb +107 -4
  140. data/test/test_lineinput.rb +20 -93
  141. data/test/test_markdownbuilder.rb +29 -0
  142. data/test/test_pdfmaker.rb +71 -0
  143. data/test/test_pdfmaker_cmd.rb +2 -2
  144. data/test/test_plaintextbuilder.rb +10 -18
  145. data/test/test_reviewheaderlistener.rb +49 -0
  146. data/test/test_template.rb +12 -2
  147. data/test/test_textmaker_cmd.rb +5 -1
  148. data/test/test_tocprinter.rb +46 -0
  149. data/test/test_topbuilder.rb +6 -1
  150. data/test/test_update.rb +34 -34
  151. data/test/test_zip_exporter.rb +5 -6
  152. metadata +91 -17
  153. data/lib/epubmaker.rb +0 -23
  154. data/lib/epubmaker/content.rb +0 -111
  155. data/lib/epubmaker/epubcommon.rb +0 -449
  156. data/lib/epubmaker/epubv2.rb +0 -142
  157. data/lib/epubmaker/epubv3.rb +0 -235
  158. data/lib/epubmaker/producer.rb +0 -375
  159. data/lib/epubmaker/zip_exporter.rb +0 -81
  160. data/lib/lineinput.rb +0 -155
@@ -78,7 +78,7 @@ module ReVIEW
78
78
 
79
79
  def dd(lines)
80
80
  split_paragraph(lines).each do |paragraph|
81
- puts "\t#{paragraph.gsub(/\n/, '')}"
81
+ puts "\t#{paragraph.delete("\n")}"
82
82
  end
83
83
  end
84
84
 
@@ -228,15 +228,12 @@ module ReVIEW
228
228
  puts "◆→開始:#{@titles['texequation']}←◆"
229
229
  texequation_header(id, caption) if caption_top?('equation')
230
230
 
231
- if @book.config['imgmath']
231
+ if @book.config['math_format'] == 'imgmath'
232
232
  fontsize = @book.config['imgmath_options']['fontsize'].to_f
233
233
  lineheight = @book.config['imgmath_options']['lineheight'].to_f
234
234
  math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
235
235
  key = Digest::SHA256.hexdigest(math_str)
236
- math_dir = File.join(@book.config['imagedir'], '_review_math_text')
237
- Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
238
- img_path = File.join(math_dir, "_gen_#{key}.#{@book.config['imgmath_options']['format']}")
239
- defer_math_image(math_str, img_path, key)
236
+ img_path = @img_math.defer_math_image(math_str, key)
240
237
  puts "◆→math:#{File.basename(img_path)}←◆"
241
238
  else
242
239
  puts lines.join("\n")
@@ -274,6 +271,7 @@ module ReVIEW
274
271
 
275
272
  def comment(lines, comment = nil)
276
273
  return unless @book.config['draft']
274
+
277
275
  lines ||= []
278
276
  unless comment.blank?
279
277
  lines.unshift(comment)
@@ -367,6 +365,18 @@ module ReVIEW
367
365
  "@#{str}@◆→@〜@部分に下線←◆"
368
366
  end
369
367
 
368
+ def inline_ins(str)
369
+ "◆→開始:挿入表現←◆#{str}◆→終了:挿入表現←◆"
370
+ end
371
+
372
+ def inline_del(str)
373
+ "◆→開始:削除表現←◆#{str}◆→終了:削除表現←◆"
374
+ end
375
+
376
+ def inline_tcy(str)
377
+ "◆→開始:回転←◆#{str}◆→終了:縦回転←◆"
378
+ end
379
+
370
380
  def inline_icon(id)
371
381
  begin
372
382
  "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
@@ -397,13 +407,10 @@ module ReVIEW
397
407
  end
398
408
 
399
409
  def inline_m(str)
400
- if @book.config['imgmath']
410
+ if @book.config['math_format'] == 'imgmath'
401
411
  math_str = '$' + str + '$'
402
412
  key = Digest::SHA256.hexdigest(str)
403
- math_dir = File.join(@book.config['imagedir'], '_review_math_text')
404
- Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
405
- img_path = File.join(math_dir, "_gen_#{key}.#{@book.config['imgmath_options']['format']}")
406
- defer_math_image(math_str, img_path, key)
413
+ img_path = @img_math.defer_math_image(math_str, key)
407
414
  %Q(◆→TeX式ここから←◆◆→math:#{File.basename(img_path)}←◆◆→TeX式ここまで←◆)
408
415
  else
409
416
  %Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
data/lib/review/update.rb CHANGED
@@ -301,6 +301,7 @@ module ReVIEW
301
301
  if !config['htmlversion'].present? || config['htmlversion'].to_f >= HTML_VERSION.to_f
302
302
  next
303
303
  end
304
+
304
305
  if confirm("%s: Update '%s' to '%s' from '%s'?", [File.basename(yml), 'htmlversion', HTML_VERSION, config['htmlversion']])
305
306
  rewrite_yml(yml, 'htmlversion', HTML_VERSION)
306
307
  end
@@ -313,6 +314,7 @@ module ReVIEW
313
314
  if !config['chapter_quote'].present? || config['chapter_quote'].scan('%s').size != 1
314
315
  next
315
316
  end
317
+
316
318
  v = config['chapter_quote'].sub('%s', '%s %s')
317
319
  if confirm("%s: 'chapter_quote' now takes 2 values. Update '%s' to '%s'?", [File.basename(yml), config['chapter_quote'], v])
318
320
  rewrite_yml(yml, 'chapter_quote', v)
@@ -414,9 +416,7 @@ module ReVIEW
414
416
  opts << "paper=#{v.sub('j', '').sub('paper', '')}"
415
417
  when /[\d.]+ptj/ # not cared...
416
418
  opts << "fontsize=#{v.sub('j', '')}"
417
- when /[\d.]+pt/
418
- opts << "fontsize=#{v}"
419
- when /[\d.]+Q/
419
+ when /[\d.]+pt/, /[\d.]+Q/
420
420
  opts << "fontsize=#{v}"
421
421
  when 'landscape', 'oneside', 'twoside', 'vartwoside', 'onecolumn',
422
422
  'twocolumn', 'titlepage', 'notitlepage', 'openright',
@@ -442,9 +442,7 @@ module ReVIEW
442
442
  opts << "paper=#{v.sub('j', '').sub('paper', '')}"
443
443
  when /[\d.]+ptj/ # not cared...
444
444
  opts << "fontsize=#{v.sub('j', '')}"
445
- when /[\d.]+pt/
446
- opts << "fontsize=#{v}"
447
- when /[\d.]+Q/
445
+ when /[\d.]+pt/, /[\d.]+Q/
448
446
  opts << "fontsize=#{v}"
449
447
  when 'landscape', 'oneside', 'twoside', 'onecolumn', 'twocolumn', 'titlepage', 'notitlepage', 'openright', 'openany', 'leqno', 'fleqn', 'draft', 'final', 'report'
450
448
  # pass-through
@@ -516,6 +514,7 @@ module ReVIEW
516
514
  if !config['texcommand'] || config['texcommand'] !~ /\s+-/
517
515
  next
518
516
  end
517
+
519
518
  # option should be moved to texoptions
520
519
  cmd, opts = config['texcommand'].split(/\s+-/, 2)
521
520
  opts = "-#{opts}"
@@ -1,3 +1,3 @@
1
1
  module ReVIEW
2
- VERSION = '5.0.0'.freeze
2
+ VERSION = '5.1.0'.freeze
3
3
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2014-2020 Minero Aoki, Kenshi Muto
2
+ # Copyright (c) 2014-2021 Minero Aoki, Kenshi Muto
3
3
  # 2003-2014 Minero Aoki
4
4
  #
5
5
  # This program is free software.
@@ -22,18 +22,17 @@ module ReVIEW
22
22
 
23
23
  def initialize
24
24
  @logger = ReVIEW.logger
25
- @config = ReVIEW::Configure.values
26
25
  @yamlfile = 'config.yml'
27
26
  end
28
27
 
29
28
  def execute(*args)
30
29
  parse_options(args)
30
+ @config = ReVIEW::Configure.create(yamlfile: @yamlfile)
31
31
  @book = ReVIEW::Book::Base.new('.', config: @config)
32
32
  unless File.readable?(@yamlfile)
33
33
  @logger.error("No such fiile or can't open #{@yamlfile}.")
34
34
  exit 1
35
35
  end
36
- @book.load_config(@yamlfile)
37
36
  I18n.setup(@book.config['language'])
38
37
 
39
38
  begin
@@ -45,8 +44,8 @@ module ReVIEW
45
44
  print_chapter_volume(chap)
46
45
  end
47
46
  end
48
- rescue ReVIEW::FileNotFound, ReVIEW::CompileError => e
49
- @logger.error e
47
+ rescue ReVIEW::FileNotFound, ReVIEW::CompileError, ReVIEW::ApplicationError => e
48
+ @logger.error e.message
50
49
  exit 1
51
50
  end
52
51
  puts '============================='
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2016-2020 Masayoshi Takahashi, Masanori Kado, Kenshi Muto
1
+ # Copyright (c) 2016-2021 Masayoshi Takahashi, Masanori Kado, Kenshi Muto
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -20,6 +20,7 @@ require 'review/template'
20
20
  require 'review/tocprinter'
21
21
  require 'review/version'
22
22
  require 'review/makerhelper'
23
+ require 'review/img_math'
23
24
 
24
25
  module ReVIEW
25
26
  class WEBMaker
@@ -31,6 +32,7 @@ module ReVIEW
31
32
  def initialize
32
33
  @basedir = nil
33
34
  @logger = ReVIEW.logger
35
+ @img_math = nil
34
36
  end
35
37
 
36
38
  def error(msg)
@@ -74,7 +76,7 @@ module ReVIEW
74
76
  end
75
77
 
76
78
  def remove_old_files(path)
77
- cleanup_mathimg
79
+ @img_math.cleanup_mathimg
78
80
  FileUtils.rm_rf(path)
79
81
  end
80
82
 
@@ -87,11 +89,15 @@ module ReVIEW
87
89
  config: cmd_config)
88
90
 
89
91
  @config['htmlext'] = 'html'
92
+ @img_math = ReVIEW::ImgMath.new(@config)
93
+
90
94
  I18n.setup(@config['language'])
91
95
  begin
92
96
  generate_html_files(yamlfile)
97
+ @logger.success("built #{build_path}")
93
98
  rescue ApplicationError => e
94
99
  raise if @config['debug']
100
+
95
101
  error(e.message)
96
102
  end
97
103
  end
@@ -103,15 +109,15 @@ module ReVIEW
103
109
  Dir.mkdir(@path)
104
110
 
105
111
  @book = ReVIEW::Book::Base.new(@basedir, config: @config)
112
+ @converter = ReVIEW::Converter.new(@book, ReVIEW::HTMLBuilder.new(img_math: @img_math))
106
113
 
107
114
  copy_stylesheet(@path)
108
115
  copy_frontmatter(@path)
109
116
  build_body(@path, yamlfile)
110
117
  copy_backmatter(@path)
111
118
 
112
- math_dir = "./#{@config['imagedir']}/_review_math"
113
- if @config['imgmath'] && File.exist?("#{math_dir}/__IMGMATH_BODY__.map")
114
- make_math_images(math_dir)
119
+ if @config['math_format'] == 'imgmath'
120
+ @img_math.make_math_images
115
121
  end
116
122
 
117
123
  copy_images(@config['imagedir'], "#{@path}/#{@config['imagedir']}")
@@ -123,8 +129,6 @@ module ReVIEW
123
129
 
124
130
  def build_body(basetmpdir, _yamlfile)
125
131
  base_path = Pathname.new(@basedir)
126
- builder = ReVIEW::HTMLBuilder.new
127
- @converter = ReVIEW::Converter.new(@book, builder)
128
132
  @book.parts.each do |part|
129
133
  if part.name.present?
130
134
  if part.file?
@@ -152,8 +156,7 @@ module ReVIEW
152
156
 
153
157
  @language = @config['language']
154
158
  @stylesheets = @config['stylesheet']
155
- tmplfile = File.expand_path(template_name, ReVIEW::Template::TEMPLATE_DIR)
156
- f.write ReVIEW::Template.load(tmplfile).result(binding)
159
+ f.write ReVIEW::Template.generate(path: template_name, binding: binding)
157
160
  end
158
161
  end
159
162
 
@@ -196,6 +199,7 @@ module ReVIEW
196
199
 
197
200
  def copy_images(resdir, destdir)
198
201
  return nil unless File.exist?(resdir)
202
+
199
203
  allow_exts = @config['image_ext']
200
204
  FileUtils.mkdir_p(destdir)
201
205
  recursive_copy_files(resdir, destdir, allow_exts)
@@ -203,6 +207,7 @@ module ReVIEW
203
207
 
204
208
  def copy_resources(resdir, destdir, allow_exts = nil)
205
209
  return nil if !resdir || !File.exist?(resdir)
210
+
206
211
  allow_exts ||= @config['image_ext']
207
212
  FileUtils.mkdir_p(destdir)
208
213
  recursive_copy_files(resdir, destdir, allow_exts)
@@ -212,6 +217,7 @@ module ReVIEW
212
217
  Dir.open(resdir) do |dir|
213
218
  dir.each do |fname|
214
219
  next if fname.start_with?('.')
220
+
215
221
  if FileTest.directory?("#{resdir}/#{fname}")
216
222
  recursive_copy_files("#{resdir}/#{fname}", "#{destdir}/#{fname}", allow_exts)
217
223
  elsif fname =~ /\.(#{allow_exts.join('|')})\Z/i
@@ -263,8 +269,7 @@ module ReVIEW
263
269
  @toc = ReVIEW::WEBTOCPrinter.book_to_string(@book)
264
270
  @next = @book.chapters[0]
265
271
  @next_title = @next ? @next.title : ''
266
- tmplfile = File.expand_path(template_name, ReVIEW::Template::TEMPLATE_DIR)
267
- f.write ReVIEW::Template.load(tmplfile).result(binding)
272
+ f.write ReVIEW::Template.generate(path: template_name, binding: binding)
268
273
  end
269
274
  end
270
275
 
@@ -284,8 +289,7 @@ module ReVIEW
284
289
 
285
290
  @language = @config['language']
286
291
  @stylesheets = @config['stylesheet']
287
- tmplfile = File.expand_path(template_name, ReVIEW::Template::TEMPLATE_DIR)
288
- f.write ReVIEW::Template.load(tmplfile).result(binding)
292
+ f.write ReVIEW::Template.generate(path: template_name, binding: binding)
289
293
  end
290
294
  end
291
295
 
@@ -300,6 +304,7 @@ module ReVIEW
300
304
 
301
305
  def copy_file_with_param(name, target_file = nil)
302
306
  return if @config[name].nil? || !File.exist?(@config[name])
307
+
303
308
  target_file ||= File.basename(@config[name])
304
309
  FileUtils.cp(@config[name], File.join(@path, target_file))
305
310
  end
@@ -1,5 +1,6 @@
1
1
  require 'review/tocprinter'
2
2
  require 'review/i18n'
3
+ require 'review/htmlutils'
3
4
 
4
5
  module ReVIEW
5
6
  class WEBTOCPrinter < TOCPrinter
@@ -24,28 +25,28 @@ EOT
24
25
 
25
26
  path = ''
26
27
  result_array.each do |result|
27
- unless result[:headline]
28
- result[:headline] = '-'
28
+ unless result.headline
29
+ result.headline = '-'
29
30
  end
30
31
 
31
- if result[:name]
32
- path = "#{result[:name]}.#{@book.config['htmlext']}"
32
+ if result.name
33
+ path = "#{result.name}.#{@book.config['htmlext']}"
33
34
  next
34
35
  end
35
36
 
36
- if result[:part]
37
- if result[:part] == 'end'
37
+ if result.part
38
+ if result.part == 'end'
38
39
  content << "</ul></li>\n"
39
40
  end
40
41
  next
41
42
  end
42
43
 
43
44
  if path.start_with?('.')
44
- content << "<li>#{escape(result[:headline])}"
45
+ content << "<li>#{escape(result.headline)}"
45
46
  else
46
- content << %Q(<li><a href="#{path}">#{escape(result[:headline])}</a>)
47
+ content << %Q(<li><a href="#{path}">#{escape(result.headline)}</a>)
47
48
  end
48
- if result[:level] == 0
49
+ if result.level == 0
49
50
  content << "\n<ul>" # part
50
51
  else
51
52
  content << "</li>\n"
@@ -18,9 +18,10 @@ module ReVIEW
18
18
  while file_queue.present?
19
19
  current_file = file_queue.shift
20
20
  current_yaml = YAML.load_file(current_file)
21
- if current_yaml.class == FalseClass
21
+ if current_yaml.instance_of?(FalseClass)
22
22
  raise "#{File.basename(current_file)} is malformed."
23
23
  end
24
+
24
25
  yaml = current_yaml.deep_merge(yaml)
25
26
 
26
27
  if yaml.key?('inherit')
data/review.gemspec CHANGED
@@ -7,12 +7,11 @@ Gem::Specification.new do |gem|
7
7
  gem.platform = Gem::Platform::RUBY
8
8
  gem.license = 'LGPL'
9
9
  gem.authors = %w[kmuto takahashim]
10
- gem.email = 'kmuto@debian.org'
10
+ gem.email = 'kmuto@kmuto.jp'
11
11
  gem.homepage = 'http://github.com/kmuto/review'
12
12
  gem.summary = 'Re:VIEW: a easy-to-use digital publishing system'
13
13
  gem.description = 'Re:VIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX.'
14
14
  gem.required_rubygems_version = Gem::Requirement.new('>= 0') if gem.respond_to?(:required_rubygems_version=)
15
- gem.date = '2020-10-29'
16
15
 
17
16
  gem.files = `git ls-files`.split("\n")
18
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -23,10 +22,13 @@ Gem::Specification.new do |gem|
23
22
  gem.add_dependency('image_size')
24
23
  gem.add_dependency('rouge')
25
24
  gem.add_dependency('rubyzip')
25
+ gem.add_dependency('tty-logger')
26
+ gem.add_development_dependency('mini_magick')
26
27
  gem.add_development_dependency('pygments.rb')
27
28
  gem.add_development_dependency('rake')
28
- gem.add_development_dependency('rubocop', '~> 0.92.0')
29
+ gem.add_development_dependency('rubocop', '~> 1.10.0')
29
30
  gem.add_development_dependency('rubocop-performance')
31
+ gem.add_development_dependency('rubocop-rake')
30
32
  gem.add_development_dependency('simplecov')
31
33
  gem.add_development_dependency('test-unit')
32
34
  gem.add_development_dependency('unicode-eaw')
@@ -11,7 +11,7 @@ language: ja
11
11
  # 書名
12
12
  booktitle: Re:VIEWサンプル書籍
13
13
  # 固有IDに使用するドメイン。省略した場合は時刻に基づくランダムUUIDが入る
14
- urnid: urn:uid:http://tatsu-zine.com/books/review-sample-book/1.0.0/
14
+ urnid: urn:uuid:http://tatsu-zine.com/books/review-sample-book/1.0.0/
15
15
  # ISBN。省略した場合はurnidが入る
16
16
  # isbn: null
17
17
  # 著者名。["高橋征義", "John Doe"] のように配列を使うことで複数指定可
@@ -3,7 +3,7 @@ review_version: 5.0
3
3
  bookname: book
4
4
  language: ja
5
5
  booktitle: Re:VIEWサンプル書籍
6
- urnid: urn:uid:http://reviewml.com/books/review-sample-book/
6
+ urnid: urn:uuid:http://reviewml.com/books/review-sample-book/
7
7
  # isbn: null
8
8
  aut: Re:VIEW Writers
9
9
  pbl: Re:VIEW Publishers
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2006-2020 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
1
+ # Copyright (c) 2006-2021 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
@@ -36,6 +36,11 @@ WEB_OPTIONS = ENV['REVIEW_WEB_OPTIONS'] || ''
36
36
  IDGXML_OPTIONS = ENV['REVIEW_IDGXML_OPTIONS'] || ''
37
37
  TEXT_OPTIONS = ENV['REVIEW_TEXT_OPTIONS'] || ''
38
38
 
39
+ REVIEW_VSCLI = ENV['REVIEW_VSCLI'] || 'vivliostyle'
40
+ REVIEW_VSCLI_USESANDBOX = ENV['REVIEW_VSCLI_USESANDBOX'] ? '' : '--no-sandbox'
41
+ REVIEW_VSCLI_PDF = ENV['REVIEW_VSCLI_PDF'] || BOOK_PDF
42
+ REVIEW_VSCLI_OPTIONS = ENV['REVIEW_VSCLI_OPTIONS'] || ''
43
+
39
44
  def build(mode, chapter)
40
45
  sh("review-compile --target=#{mode} --footnotetext --stylesheet=style.css #{chapter} > tmp")
41
46
  mode_ext = { 'html' => 'html', 'latex' => 'tex', 'idgxml' => 'xml', 'top' => 'txt', 'plaintext' => 'txt' }
@@ -125,4 +130,15 @@ file IDGXMLROOT => SRC do
125
130
  FileUtils.rm_rf([IDGXMLROOT])
126
131
  end
127
132
 
133
+ desc 'run vivliostyle'
134
+ task 'vivliostyle:preview': BOOK_EPUB do
135
+ sh "#{REVIEW_VSCLI} preview #{REVIEW_VSCLI_USESANDBOX} #{REVIEW_VSCLI_OPTIONS} #{BOOK_EPUB}"
136
+ end
137
+
138
+ task 'vivliostyle:build': BOOK_EPUB do
139
+ sh "#{REVIEW_VSCLI} build #{REVIEW_VSCLI_USESANDBOX} #{REVIEW_VSCLI_OPTIONS} -o #{REVIEW_VSCLI_PDF} #{BOOK_EPUB}"
140
+ end
141
+
142
+ task vivliostyle: 'vivliostyle:build'
143
+
128
144
  CLEAN.include([BOOK, BOOK_PDF, BOOK_EPUB, BOOK + '-pdf', BOOK + '-epub', WEBROOT, 'images/_review_math', 'images/_review_math_text', TEXTROOT, IDGXMLROOT])
@@ -119,7 +119,7 @@ olnumで一応番号が変更可能なことを期待していますが、Webブ
119
119
  //emlist{
120
120
  @<b>{bold太字}@<i>{italicイタ}
121
121
 
122
- : Alpha@<embed>{@}<b>{bold太字}@<embed>{@}<i>{italicイタ}@<embed>{@}<tt>{等幅code}@<fn>{foot1}
122
+ : Alpha@<embed>{@}<b>{bold太字}@<embed>{@}<i>{italicイタ}@<embed>{@}<tt>{等幅code}
123
123
  @<embed>{@}<i>{DEC}の作っていた@<embed>{@}<b>{RISC CPU}。@<embed>{@}<i>{italicイタ}@<embed>{@}<tt>{等幅code}
124
124
  浮動小数点数演算が速い。
125
125
  : POWER
@@ -255,7 +255,7 @@ Tips。@<b>{太字bold}@<i>{italicイタ}@<tt>{等幅code}
255
255
  #@# doorquote、bpo、talk、graph、address、box、linebreak、pagebreak、hr、comment、abbr、acronym、dfn、kbd、q、samp、var、big、small、del、ins、recipe、dtp、raw、embed、include
256
256
 
257
257
  == LaTeX式
258
- LaTeX式はTeX紙面以外は保証されません。EPUBではMathML(@<tt>{mathml: true})を使えますが、表現や互換性が不足しており、LaTeXをバックエンドとして画像化する@<tt>{imgmath: true}のほうがよさそうです。
258
+ LaTeX式はTeX紙面以外は保証されません。EPUBではMathML(@<tt>{math_format: mathml})を使えますが、表現や互換性が不足しており、LaTeXをバックエンドとして画像化する@<tt>{math_format: imgmath}のほうがよさそうです。
259
259
 
260
260
  //texequation{
261
261
  \sum_{i=1}^nf_n(x)
@@ -285,7 +285,7 @@ a_{m1} & \cdots & a_{mn}
285
285
  #@# 場所ラベル定義
286
286
 
287
287
  === 書体
288
- 本文での……キーワード@<kw>{キーワード, keyword}@<fn>{kw}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
288
+ 本文での……キーワード@<kw>{キーワード, keyword}@<fn>{kw}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
289
289
 
290
290
  傍点@<embed>{@}<bou>{bou傍点}、ルビ@<embed>{@}<ruby>{愕然, がくぜん}、縦中横@<embed>{@}<tcy>{90}、はTeXでは現状、別パッケージが必要です。
291
291
  #@# FIXME:TEXでの文字スタイル。外部パッケージが必要
@@ -299,24 +299,25 @@ a_{m1} & \cdots & a_{mn}
299
299
 
300
300
  //footnote[kw][キーワードのカッコは太字にしないほうがいいのかなと思いつつあります(手元の案件では太字にしないよう挙動を変えてしまっているほうが多い)。]
301
301
 
302
- * 箇条書き内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
302
+ * 箇条書き内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
303
303
 
304
304
  //tsize[|latex|p{120mm}]
305
305
  //table{
306
- 表内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
306
+ 表内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}
307
307
  //}
308
308
 
309
309
  コードブロック内では対応装飾は減らしてよいと考えます。代わりにballoonが追加されます。
310
310
 
311
- //emlist[キャプション内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}]{
311
+ //emlist[キャプション内での……キーワード@<kw>{キーワード, keyword}、太字@<b>{b太字}、イタリック@<i>{iイタリック}、等幅@<tt>{tt等幅}、強調@<strong>{strong強調}、強調@<em>{em強調}、下線@<u>{u下線}、等幅@<code>{code等幅}、等幅太字@<ttb>{ttb等幅太字}、等幅イタリック@<tti>{tti等幅イタリック}、網カケ@<ami>{amiアミ}、挿入@<ins>{ins挿入}、削除@<del>{del削除}、16進UTF文字指定@<uchar>{3042}、インラインアイコン@<icon>{inlineicon}]{
312
312
  コードブロック内での……
313
313
  太字@<b>{b太字}
314
314
  イタリック@<i>{iイタリック}
315
315
  下線@<u>{u下線}
316
316
  網カケ@<ami>{amiアミ} @<balloon>{ふきだし説明}
317
+ 挿入@<ins>{ins挿入}、削除@<del>{del削除}
317
318
  //}
318
319
 
319
- === 見出し内 @<b>{BOLD},@<i>{ITALIC},@<tt>{TT},@<strong>{STRONG},@<em>{EM},@<code>{CODE},@<ttb>{TTB},@<tti>{TTI},@<ami>{AMI},@<bou>{BOU},@<kw>{KW},@<u>{UNDERLINE}
320
+ === 見出し内 @<b>{BOLD},@<i>{ITALIC},@<tt>{TT},@<strong>{STRONG},@<em>{EM},@<code>{CODE},@<ttb>{TTB},@<tti>{TTI},@<ami>{AMI},@<bou>{BOU},@<kw>{KW},@<u>{UNDERLINE},@<ins>{INS}、@<del>{DEL}
320
321
 
321
322
  ==={crossref} 参照
322
323
  #@# FIXME:任意ラベルを使うと、EPUBチェックエラーになることがある?
@@ -339,10 +340,24 @@ labelで定義したラベルへの参照の例です。EPUBだと@<href>{#inlin
339
340
  #@# FIXME:EPUB側にTeXのほうを寄せるようにRe:VIEWコードを直す
340
341
  #@# FIXME:TeXではpagerefがほしい、ということがありそう。EPUBとの整合性を検討
341
342
 
343
+ 説明箇条書きはTeXで特殊な扱いをしているため、参照の確認を以下でしておきます。
344
+
345
+ : @<chap>{ch01}
346
+ 章番号
347
+ : @<title>{ch01}
348
+ 章題
349
+ : @<chapref>{ch01}
350
+ 章番号+題
351
+ : @<hd>{ch02|crossref}
352
+
353
+ : @<column>{ch03|column2}
354
+ コラム参照
355
+
342
356
  === 参考文献
343
357
  参考文献@<tt>{bib.re}ファイルへの文献参照は、@<bib>{lins}とします。
344
358
 
345
359
  === 索引
346
360
  @<hidx>{索引}@<hidx>{index}索引はTeXとIDGXML以外では妥当な動作を定義していません。idx@<hidx>{索引<<>>idx}は文中にも表示し、hidx@<hidx>{索引<<>>hidx}は文中からは隠した形の索引にします。読みは@<idx>{Mecab}があればそちらを使いますが、@<idx>{辞書ファイル}を直接定義することもできます。@<hidx>{!<>"$&()~=|,./\{\}?_[]*:;+%#()'`^}
361
+ @<hidx>{|}@<hidx>{{}@<hidx>$}$
347
362
 
348
363
  idx, hidxいずれも=見出しの中には入れないようにし、後続の段落先頭にhidxで入れるように注意します(入れてしまうと目次などがおかしくなります)。