review 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-win.yml +39 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.rubocop.yml +50 -12
  5. data/.travis.yml +17 -8
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +358 -0
  8. data/NEWS.md +358 -1
  9. data/README.md +11 -8
  10. data/appveyor.yml +1 -3
  11. data/bin/review-catalog-converter +4 -4
  12. data/bin/review-check +8 -8
  13. data/bin/review-checkdep +1 -1
  14. data/bin/review-compile +12 -12
  15. data/bin/review-epubmaker +3 -35
  16. data/bin/review-idgxmlmaker +16 -0
  17. data/bin/review-index +2 -89
  18. data/bin/review-preproc +14 -19
  19. data/bin/review-validate +3 -3
  20. data/bin/review-vol +4 -78
  21. data/doc/LICENSE +1 -1
  22. data/doc/config.yml.sample +46 -12
  23. data/doc/config.yml.sample-simple +4 -2
  24. data/doc/format.ja.md +37 -13
  25. data/doc/format.md +35 -20
  26. data/doc/pdfmaker.ja.md +43 -1
  27. data/doc/pdfmaker.md +42 -1
  28. data/doc/quickstart.ja.md +46 -26
  29. data/doc/quickstart.md +38 -17
  30. data/lib/epubmaker/epubcommon.rb +10 -5
  31. data/lib/epubmaker/epubv2.rb +1 -1
  32. data/lib/epubmaker/epubv3.rb +1 -0
  33. data/lib/epubmaker/producer.rb +4 -2
  34. data/lib/review/book.rb +1 -1
  35. data/lib/review/book/base.rb +38 -79
  36. data/lib/review/book/chapter.rb +18 -3
  37. data/lib/review/book/compilable.rb +6 -5
  38. data/lib/review/book/index.rb +69 -101
  39. data/lib/review/book/index/item.rb +40 -0
  40. data/lib/review/book/page_metric.rb +7 -7
  41. data/lib/review/book/part.rb +28 -5
  42. data/lib/review/book/volume.rb +3 -4
  43. data/lib/review/builder.rb +105 -44
  44. data/lib/review/catalog.rb +13 -16
  45. data/lib/review/compiler.rb +84 -72
  46. data/lib/review/configure.rb +19 -8
  47. data/lib/review/epub2html.rb +37 -4
  48. data/lib/review/epubmaker.rb +62 -7
  49. data/lib/review/extentions/string.rb +0 -4
  50. data/lib/review/htmlbuilder.rb +102 -115
  51. data/lib/review/htmlutils.rb +2 -3
  52. data/lib/review/i18n.rb +2 -2
  53. data/lib/review/i18n.yml +9 -0
  54. data/lib/review/idgxmlbuilder.rb +153 -74
  55. data/lib/review/idgxmlmaker.rb +191 -0
  56. data/lib/review/init-web/finish.html +10 -0
  57. data/lib/review/init-web/index.html +190 -0
  58. data/lib/review/init-web/review-layout-design.js +691 -0
  59. data/lib/review/init.rb +125 -34
  60. data/lib/review/latexbuilder.rb +199 -88
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/location.rb +32 -0
  63. data/lib/review/logger.rb +4 -8
  64. data/lib/review/makerhelper.rb +24 -5
  65. data/lib/review/markdownbuilder.rb +31 -37
  66. data/lib/review/md2inaobuilder.rb +3 -5
  67. data/lib/review/pdfmaker.rb +44 -22
  68. data/lib/review/plaintextbuilder.rb +106 -85
  69. data/lib/review/preprocessor.rb +32 -41
  70. data/lib/review/rstbuilder.rb +33 -33
  71. data/lib/review/textmaker.rb +19 -3
  72. data/lib/review/textutils.rb +76 -2
  73. data/lib/review/tocprinter.rb +231 -102
  74. data/lib/review/topbuilder.rb +114 -61
  75. data/lib/review/update.rb +19 -19
  76. data/lib/review/version.rb +1 -1
  77. data/lib/review/volumeprinter.rb +99 -0
  78. data/lib/review/webmaker.rb +11 -4
  79. data/lib/review/webtocprinter.rb +38 -35
  80. data/lib/review/yamlloader.rb +26 -16
  81. data/review.gemspec +6 -4
  82. data/samples/sample-book/README.md +7 -2
  83. data/samples/sample-book/src/.gitignore +154 -0
  84. data/samples/sample-book/src/config-ebook.yml +4 -0
  85. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  86. data/samples/sample-book/src/config-jlreq.yml +6 -0
  87. data/samples/sample-book/src/config.yml +2 -2
  88. data/samples/sample-book/src/lib/tasks/review.rake +29 -14
  89. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  90. data/samples/syntax-book/ch01.re +4 -2
  91. data/samples/syntax-book/ch02.re +8 -16
  92. data/samples/syntax-book/ch03.re +3 -6
  93. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  94. data/samples/syntax-book/config-jlreq.yml +5 -0
  95. data/samples/syntax-book/config-print.yml +3 -0
  96. data/samples/syntax-book/config.yml +1 -1
  97. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  98. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  99. data/templates/latex/config.erb +16 -0
  100. data/templates/latex/layout.tex.erb +4 -0
  101. data/templates/latex/review-jlreq/review-base.sty +150 -61
  102. data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
  103. data/templates/latex/review-jlreq/review-style.sty +4 -1
  104. data/templates/latex/review-jsbook/README.md +39 -0
  105. data/templates/latex/review-jsbook/review-base.sty +101 -23
  106. data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
  107. data/templates/latex/review-jsbook/review-style.sty +5 -2
  108. data/templates/opf/epubv3.opf.erb +1 -0
  109. data/templates/web/html/layout-html5.html.erb +2 -2
  110. data/test/assets/test_template.tex +24 -3
  111. data/test/assets/test_template_backmatter.tex +24 -3
  112. data/test/test_book.rb +75 -21
  113. data/test/test_book_chapter.rb +4 -2
  114. data/test/test_book_part.rb +3 -3
  115. data/test/test_builder.rb +16 -0
  116. data/test/test_catalog.rb +24 -42
  117. data/test/test_catalog_converter_cmd.rb +1 -1
  118. data/test/test_epubmaker_cmd.rb +14 -7
  119. data/test/test_helper.rb +15 -7
  120. data/test/test_htmlbuilder.rb +909 -159
  121. data/test/test_i18n.rb +25 -25
  122. data/test/test_idgxmlbuilder.rb +395 -38
  123. data/test/test_idgxmlmaker_cmd.rb +46 -0
  124. data/test/test_image_finder.rb +52 -70
  125. data/test/test_index.rb +50 -10
  126. data/test/test_latexbuilder.rb +1194 -106
  127. data/test/test_latexbuilder_v2.rb +628 -97
  128. data/test/test_logger.rb +14 -1
  129. data/test/test_makerhelper.rb +3 -3
  130. data/test/test_markdownbuilder.rb +134 -16
  131. data/test/test_md2inaobuilder.rb +32 -9
  132. data/test/test_pdfmaker.rb +18 -1
  133. data/test/test_pdfmaker_cmd.rb +100 -6
  134. data/test/test_plaintextbuilder.rb +371 -25
  135. data/test/test_preprocessor.rb +2 -16
  136. data/test/test_rstbuilder.rb +249 -26
  137. data/test/test_textmaker_cmd.rb +54 -0
  138. data/test/test_textutils.rb +109 -2
  139. data/test/test_topbuilder.rb +546 -31
  140. data/test/test_update.rb +17 -8
  141. data/test/test_webtocprinter.rb +66 -34
  142. data/test/test_yamlloader.rb +13 -0
  143. data/vendor/jsclasses/LICENSE +1 -1
  144. data/vendor/jsclasses/jis/jsarticle.cls +53 -14
  145. data/vendor/jsclasses/jis/jsbook.cls +53 -14
  146. data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
  147. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  148. data/vendor/jsclasses/jis/jslogo.sty +3 -3
  149. data/vendor/jsclasses/jis/jspf.cls +52 -13
  150. data/vendor/jsclasses/jis/jsreport.cls +53 -14
  151. data/vendor/jsclasses/jis/kiyou.cls +53 -14
  152. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  153. data/vendor/jsclasses/jis/okumacro.sty +3 -4
  154. data/vendor/jsclasses/jsarticle.cls +53 -14
  155. data/vendor/jsclasses/jsbook.cls +53 -14
  156. data/vendor/jsclasses/jsclasses.dtx +84 -25
  157. data/vendor/jsclasses/jsclasses.pdf +0 -0
  158. data/vendor/jsclasses/jslogo.dtx +4 -4
  159. data/vendor/jsclasses/jslogo.pdf +0 -0
  160. data/vendor/jsclasses/jslogo.sty +3 -3
  161. data/vendor/jsclasses/jspf.cls +52 -13
  162. data/vendor/jsclasses/jsreport.cls +53 -14
  163. data/vendor/jsclasses/kiyou.cls +53 -14
  164. data/vendor/jsclasses/okumacro.dtx +4 -5
  165. data/vendor/jsclasses/okumacro.pdf +0 -0
  166. data/vendor/jsclasses/okumacro.sty +3 -4
  167. metadata +55 -10
  168. data/lib/review/tocparser.rb +0 -271
  169. data/samples/syntax-book/review-ext.rb +0 -14
  170. data/test/test_tocparser.rb +0 -25
@@ -3,8 +3,8 @@ require 'yaml'
3
3
  module ReVIEW
4
4
  class Catalog
5
5
  def initialize(file)
6
- if file.respond_to? :read
7
- @yaml = YAML.load(file.read)
6
+ if file.respond_to?(:read)
7
+ @yaml = YAML.safe_load(file.read, [Date])
8
8
  else ## as Object
9
9
  @yaml = file
10
10
  end
@@ -12,12 +12,11 @@ module ReVIEW
12
12
  end
13
13
 
14
14
  def predef
15
- return '' unless @yaml['PREDEF']
16
- @yaml['PREDEF'].join("\n")
15
+ @yaml['PREDEF'] || []
17
16
  end
18
17
 
19
18
  def chaps
20
- return '' unless @yaml['CHAPS']
19
+ return [] unless @yaml['CHAPS']
21
20
 
22
21
  @yaml['CHAPS'].map do |entry|
23
22
  if entry.is_a?(String)
@@ -25,11 +24,11 @@ module ReVIEW
25
24
  elsif entry.is_a?(Hash)
26
25
  entry.values # chaps in a part
27
26
  end
28
- end.flatten.join("\n")
27
+ end.flatten
29
28
  end
30
29
 
31
30
  def parts
32
- return '' unless @yaml['CHAPS']
31
+ return [] unless @yaml['CHAPS']
33
32
 
34
33
  part_list = @yaml['CHAPS'].map do |entry|
35
34
  if entry.is_a?(Hash)
@@ -37,7 +36,7 @@ module ReVIEW
37
36
  end
38
37
  end
39
38
 
40
- part_list.flatten.compact.join("\n")
39
+ part_list.flatten.compact
41
40
  end
42
41
 
43
42
  def replace_part(old_name, new_name)
@@ -50,18 +49,16 @@ module ReVIEW
50
49
  end
51
50
 
52
51
  def parts_with_chaps
53
- return '' unless @yaml['CHAPS']
52
+ return [] unless @yaml['CHAPS']
54
53
  @yaml['CHAPS'].flatten.compact
55
54
  end
56
55
 
57
56
  def appendix
58
- return '' unless @yaml['APPENDIX']
59
- @yaml['APPENDIX'].join("\n")
57
+ @yaml['APPENDIX'] || []
60
58
  end
61
59
 
62
60
  def postdef
63
- return '' unless @yaml['POSTDEF']
64
- @yaml['POSTDEF'].join("\n")
61
+ @yaml['POSTDEF'] || []
65
62
  end
66
63
 
67
64
  def to_s
@@ -71,7 +68,7 @@ module ReVIEW
71
68
  def validate!(config, basedir)
72
69
  filenames = []
73
70
  if predef.present?
74
- filenames.concat(predef.split(/\n/))
71
+ filenames.concat(predef)
75
72
  end
76
73
  parts_with_chaps.each do |chap|
77
74
  if chap.is_a?(Hash)
@@ -86,10 +83,10 @@ module ReVIEW
86
83
  end
87
84
  end
88
85
  if appendix.present?
89
- filenames.concat(appendix.split(/\n/))
86
+ filenames.concat(appendix)
90
87
  end
91
88
  if postdef.present?
92
- filenames.concat(postdef.split(/\n/))
89
+ filenames.concat(postdef)
93
90
  end
94
91
  filenames.each do |filename|
95
92
  refile = File.join(basedir, config['contentdir'], filename)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2009-2018 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2009-2020 Minero Aoki, Kenshi Muto
2
2
  # Copyright (c) 2002-2007 Minero Aoki
3
3
  #
4
4
  # This program is free software.
@@ -9,39 +9,31 @@
9
9
  require 'review/extentions'
10
10
  require 'review/preprocessor'
11
11
  require 'review/exception'
12
+ require 'review/location'
12
13
  require 'strscan'
13
14
 
14
15
  module ReVIEW
15
- class Location
16
- def initialize(filename, f)
17
- @filename = filename
18
- @f = f
19
- end
20
-
21
- attr_reader :filename
22
-
23
- def lineno
24
- @f.lineno
25
- end
26
-
27
- def string
28
- begin
29
- "#{@filename}:#{@f.lineno}"
30
- rescue
31
- "#{@filename}:nil"
32
- end
33
- end
34
-
35
- alias_method :to_s, :string
36
- end
37
-
38
16
  class Compiler
39
17
  def initialize(strategy)
40
18
  @strategy = strategy
19
+
20
+ ## commands which do not parse block lines in compiler
21
+ @non_parsed_commands = %i[embed texequation graph]
22
+
23
+ ## to decide escaping/non-escaping for text
24
+ @command_name_stack = []
41
25
  end
42
26
 
43
27
  attr_reader :strategy
44
28
 
29
+ def non_escaped_commands
30
+ if @strategy.highlight?
31
+ %i[list emlist listnum emlistnum cmd]
32
+ else
33
+ []
34
+ end
35
+ end
36
+
45
37
  def compile(chap)
46
38
  @chapter = chap
47
39
  do_compile
@@ -88,11 +80,11 @@ module ReVIEW
88
80
  SYNTAX = {}
89
81
 
90
82
  def self.defblock(name, argc, optional = false, &block)
91
- defsyntax name, (optional ? :optional : :block), argc, &block
83
+ defsyntax(name, (optional ? :optional : :block), argc, &block)
92
84
  end
93
85
 
94
86
  def self.defsingle(name, argc, &block)
95
- defsyntax name, :line, argc, &block
87
+ defsyntax(name, :line, argc, &block)
96
88
  end
97
89
 
98
90
  def self.defsyntax(name, type, argc, &block)
@@ -131,7 +123,7 @@ module ReVIEW
131
123
  defblock :emlist, 0..2
132
124
  defblock :cmd, 0..1
133
125
  defblock :table, 0..2
134
- defblock :imgtable, 0..2
126
+ defblock :imgtable, 0..3
135
127
  defblock :emtable, 0..1
136
128
  defblock :quote, 0
137
129
  defblock :image, 2..3, true
@@ -239,32 +231,39 @@ module ReVIEW
239
231
 
240
232
  def do_compile
241
233
  f = LineInput.new(StringIO.new(@chapter.content))
242
- @strategy.bind self, @chapter, Location.new(@chapter.basename, f)
234
+ @strategy.bind(self, @chapter, Location.new(@chapter.basename, f))
235
+
243
236
  tagged_section_init
244
237
  while f.next?
245
238
  case f.peek
246
239
  when /\A\#@/
247
240
  f.gets # Nothing to do
248
241
  when /\A=+[\[\s\{]/
249
- compile_headline f.gets
242
+ compile_headline(f.gets)
250
243
  when /\A\s+\*/
251
- compile_ulist f
244
+ compile_ulist(f)
252
245
  when /\A\s+\d+\./
253
- compile_olist f
246
+ compile_olist(f)
247
+ when /\A\s+:\s/
248
+ compile_dlist(f)
254
249
  when /\A\s*:\s/
255
- compile_dlist f
250
+ warn 'Definition list starting with `:` is deprecated. It should start with ` : `.'
251
+ compile_dlist(f)
256
252
  when %r{\A//\}}
257
253
  f.gets
258
254
  error 'block end seen but not opened'
259
255
  when %r{\A//[a-z]+}
256
+ # @command_name_stack.push(name) ## <- move into read_command() to use name
260
257
  name, args, lines = read_command(f)
261
258
  syntax = syntax_descriptor(name)
262
259
  unless syntax
263
260
  error "unknown command: //#{name}"
264
- compile_unknown_command args, lines
261
+ compile_unknown_command(args, lines)
262
+ @command_name_stack.pop
265
263
  next
266
264
  end
267
- compile_command syntax, args, lines
265
+ compile_command(syntax, args, lines)
266
+ @command_name_stack.pop
268
267
  when %r{\A//}
269
268
  line = f.gets
270
269
  warn "`//' seen but is not valid command: #{line.strip.inspect}"
@@ -277,7 +276,7 @@ module ReVIEW
277
276
  f.gets
278
277
  next
279
278
  end
280
- compile_paragraph f
279
+ compile_paragraph(f)
281
280
  end
282
281
  end
283
282
  close_all_tagged_section
@@ -318,7 +317,7 @@ module ReVIEW
318
317
  end
319
318
  @headline_indexs[index] += 1
320
319
  close_current_tagged_section(level)
321
- @strategy.headline level, label, caption
320
+ @strategy.headline(level, label, caption)
322
321
  end
323
322
  end
324
323
 
@@ -329,7 +328,7 @@ module ReVIEW
329
328
  end
330
329
 
331
330
  def headline(level, label, caption)
332
- @strategy.headline level, label, caption
331
+ @strategy.headline(level, label, caption)
333
332
  end
334
333
 
335
334
  def tagged_section_init
@@ -340,17 +339,17 @@ module ReVIEW
340
339
  mid = "#{tag}_begin"
341
340
  unless @strategy.respond_to?(mid)
342
341
  error "strategy does not support tagged section: #{tag}"
343
- headline level, label, caption
342
+ headline(level, label, caption)
344
343
  return
345
344
  end
346
- @tagged_section.push [tag, level]
347
- @strategy.__send__ mid, level, label, caption
345
+ @tagged_section.push([tag, level])
346
+ @strategy.__send__(mid, level, label, caption)
348
347
  end
349
348
 
350
349
  def close_tagged_section(tag, level)
351
350
  mid = "#{tag}_end"
352
351
  if @strategy.respond_to?(mid)
353
- @strategy.__send__ mid, level
352
+ @strategy.__send__(mid, level)
354
353
  else
355
354
  error "strategy does not support block op: #{mid}"
356
355
  end
@@ -369,7 +368,7 @@ module ReVIEW
369
368
 
370
369
  buf = [text(line.sub(/\*+/, '').strip)]
371
370
  f.while_match(/\A\s+(?!\*)\S/) do |cont|
372
- buf.push text(cont.strip)
371
+ buf.push(text(cont.strip))
373
372
  end
374
373
 
375
374
  line =~ /\A\s+(\*+)/
@@ -377,16 +376,15 @@ module ReVIEW
377
376
  if level == current_level
378
377
  @strategy.ul_item_end
379
378
  # body
380
- @strategy.ul_item_begin buf
379
+ @strategy.ul_item_begin(buf)
381
380
  elsif level < current_level # down
382
381
  level_diff = current_level - level
383
- level = current_level
384
- (1..(level_diff - 1)).to_a.reverse_each do |i|
385
- @strategy.ul_begin { i }
386
- @strategy.ul_item_begin []
382
+ if level_diff != 1
383
+ error 'too many *.'
387
384
  end
385
+ level = current_level
388
386
  @strategy.ul_begin { level }
389
- @strategy.ul_item_begin buf
387
+ @strategy.ul_item_begin(buf)
390
388
  elsif level > current_level # up
391
389
  level_diff = level - current_level
392
390
  level = current_level
@@ -396,7 +394,7 @@ module ReVIEW
396
394
  end
397
395
  @strategy.ul_item_end
398
396
  # body
399
- @strategy.ul_item_begin buf
397
+ @strategy.ul_item_begin(buf)
400
398
  end
401
399
  end
402
400
 
@@ -414,9 +412,9 @@ module ReVIEW
414
412
  num = line.match(/(\d+)\./)[1]
415
413
  buf = [text(line.sub(/\d+\./, '').strip)]
416
414
  f.while_match(/\A\s+(?!\d+\.)\S/) do |cont|
417
- buf.push text(cont.strip)
415
+ buf.push(text(cont.strip))
418
416
  end
419
- @strategy.ol_item buf, num
417
+ @strategy.ol_item(buf, num)
420
418
  end
421
419
  @strategy.ol_end
422
420
  end
@@ -424,7 +422,10 @@ module ReVIEW
424
422
  def compile_dlist(f)
425
423
  @strategy.dl_begin
426
424
  while /\A\s*:/ =~ f.peek
427
- @strategy.dt text(f.gets.sub(/\A\s*:/, '').strip)
425
+ # defer compile_inline to handle footnotes
426
+ @strategy.doc_status[:dt] = true
427
+ @strategy.dt(text(f.gets.sub(/\A\s*:/, '').strip))
428
+ @strategy.doc_status[:dt] = nil
428
429
  desc = f.break(/\A(\S|\s*:|\s+\d+\.\s|\s+\*\s)/).map { |line| text(line.strip) }
429
430
  @strategy.dd(desc)
430
431
  f.skip_blank_lines
@@ -437,15 +438,16 @@ module ReVIEW
437
438
  buf = []
438
439
  f.until_match(%r{\A//|\A\#@}) do |line|
439
440
  break if line.strip.empty?
440
- buf.push text(line.sub(/^(\t+)\s*/) { |m| '<!ESCAPETAB!>' * m.size }.strip.gsub('<!ESCAPETAB!>', "\t"))
441
+ buf.push(text(line.sub(/^(\t+)\s*/) { |m| '<!ESCAPETAB!>' * m.size }.strip.gsub('<!ESCAPETAB!>', "\t")))
441
442
  end
442
- @strategy.paragraph buf
443
+ @strategy.paragraph(buf)
443
444
  end
444
445
 
445
446
  def read_command(f)
446
447
  line = f.gets
447
448
  name = line.slice(/[a-z]+/).to_sym
448
- ignore_inline = (name == :embed)
449
+ ignore_inline = @non_parsed_commands.include?(name)
450
+ @command_name_stack.push(name)
449
451
  args = parse_args(line.sub(%r{\A//[a-z]+}, '').rstrip.chomp('{'), name)
450
452
  @strategy.doc_status[name] = true
451
453
  lines = block_open?(line) ? read_block(f, ignore_inline) : nil
@@ -462,12 +464,12 @@ module ReVIEW
462
464
  buf = []
463
465
  f.until_match(%r{\A//\}}) do |line|
464
466
  if ignore_inline
465
- buf.push line
467
+ buf.push(line.chomp)
466
468
  elsif line !~ /\A\#@/
467
- buf.push text(line.rstrip)
469
+ buf.push(text(line.rstrip, true))
468
470
  end
469
471
  end
470
- unless %r{\A//\}} =~ f.peek
472
+ unless f.peek.to_s.start_with?('//}')
471
473
  error "unexpected EOF (block begins at: #{head})"
472
474
  return buf
473
475
  end
@@ -496,27 +498,27 @@ module ReVIEW
496
498
  def compile_command(syntax, args, lines)
497
499
  unless @strategy.respond_to?(syntax.name)
498
500
  error "strategy does not support command: //#{syntax.name}"
499
- compile_unknown_command args, lines
501
+ compile_unknown_command(args, lines)
500
502
  return
501
503
  end
502
504
  begin
503
- syntax.check_args args
504
- rescue CompileError => err
505
- error err.message
505
+ syntax.check_args(args)
506
+ rescue CompileError => e
507
+ error e.message
506
508
  args = ['(NoArgument)'] * syntax.min_argc
507
509
  end
508
510
  if syntax.block_allowed?
509
- compile_block syntax, args, lines
511
+ compile_block(syntax, args, lines)
510
512
  else
511
513
  if lines
512
514
  error "block is not allowed for command //#{syntax.name}; ignore"
513
515
  end
514
- compile_single syntax, args
516
+ compile_single(syntax, args)
515
517
  end
516
518
  end
517
519
 
518
520
  def compile_unknown_command(args, lines)
519
- @strategy.unknown_command args, lines
521
+ @strategy.unknown_command(args, lines)
520
522
  end
521
523
 
522
524
  def compile_block(syntax, args, lines)
@@ -550,7 +552,12 @@ module ReVIEW
550
552
  str.gsub("\x01", '@').gsub("\x02", '\\').gsub("\x03", '{').gsub("\x04", '}')
551
553
  end
552
554
 
553
- def text(str)
555
+ def in_non_escaped_command?
556
+ current_command = @command_name_stack.last
557
+ current_command && non_escaped_commands.include?(current_command)
558
+ end
559
+
560
+ def text(str, block_mode = false)
554
561
  return '' if str.empty?
555
562
  words = replace_fence(str).split(/(@<\w+>\{(?:[^\}\\]|\\.)*?\})/, -1)
556
563
  words.each do |w|
@@ -558,14 +565,19 @@ module ReVIEW
558
565
  error "`@<xxx>' seen but is not valid inline op: #{w}"
559
566
  end
560
567
  end
561
- result = @strategy.nofunc_text(revert_replace_fence(words.shift))
568
+ result = ''
562
569
  until words.empty?
570
+ if in_non_escaped_command? && block_mode
571
+ result << revert_replace_fence(words.shift)
572
+ else
573
+ result << @strategy.nofunc_text(revert_replace_fence(words.shift))
574
+ end
575
+ break if words.empty?
563
576
  result << compile_inline(revert_replace_fence(words.shift.gsub(/\\\}/, '}').gsub(/\\\\/, '\\')))
564
- result << @strategy.nofunc_text(revert_replace_fence(words.shift))
565
577
  end
566
578
  result
567
- rescue => err
568
- error err.message
579
+ rescue => e
580
+ error e.message
569
581
  end
570
582
  public :text # called from strategy
571
583
 
@@ -578,8 +590,8 @@ module ReVIEW
578
590
  raise "strategy does not support inline op: @<#{op}>"
579
591
  end
580
592
  @strategy.__send__("inline_#{op}", arg)
581
- rescue => err
582
- error err.message
593
+ rescue => e
594
+ error e.message
583
595
  @strategy.nofunc_text(str)
584
596
  end
585
597
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2012-2018 Masanori Kado, Masayoshi Takahashi, Kenshi Muto
2
+ # Copyright (c) 2012-2020 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
@@ -15,10 +15,10 @@ module ReVIEW
15
15
  def self.values
16
16
  conf = Configure[
17
17
  # These parameters can be overridden by YAML file.
18
- 'bookname' => 'example', # it defines epub file name also
18
+ 'bookname' => 'book', # it defines epub file name also
19
19
  'booktitle' => 'Re:VIEW Sample Book',
20
20
  'title' => nil,
21
- 'aut' => nil, # author
21
+ 'aut' => ['anonymous'], # author
22
22
  'prt' => nil, # printer(publisher)
23
23
  'asn' => nil, # associated name
24
24
  'ant' => nil, # bibliographic antecedent
@@ -32,7 +32,7 @@ module ReVIEW
32
32
  'rights' => nil, # Copyright messages
33
33
  'description' => nil, # Description
34
34
  'urnid' => "urn:uid:#{SecureRandom.uuid}", # Identifier
35
- 'stylesheet' => 'stylesheet.css', # stylesheet file
35
+ 'stylesheet' => [], # stylesheet file
36
36
  'coverfile' => nil, # content file of body of cover page
37
37
  'mytoc' => nil, # whether make own table of contents or not
38
38
  'params' => '', # specify review2html parameters
@@ -65,6 +65,8 @@ module ReVIEW
65
65
  'words_file' => nil,
66
66
  'colophon_order' => %w[aut csl trl dsr ill cov edt pbl contact prt],
67
67
  'externallink' => true,
68
+ 'join_lines_by_lang' => nil, # experimental. default should be nil
69
+ 'table_row_separator' => 'tabs',
68
70
  # for IDGXML
69
71
  'tableopt' => nil,
70
72
  'listinfo' => nil,
@@ -73,22 +75,25 @@ module ReVIEW
73
75
  'structuredxml' => nil,
74
76
  'pt_to_mm_unit' => 0.3528, # DTP: 1pt = 0.3528mm, JIS: 1pt = 0.3514mm
75
77
  # for LaTeX
76
- 'image_scale2width' => true,
77
78
  'footnotetext' => nil,
78
79
  'texcommand' => 'uplatex',
79
- 'texoptions' => '-interaction=nonstopmode -file-line-error',
80
+ 'texoptions' => '-interaction=nonstopmode -file-line-error -halt-on-error',
80
81
  '_texdocumentclass' => ['review-jsbook', ''],
82
+ 'texstyle' => ['reviewmacro'],
81
83
  'dvicommand' => 'dvipdfmx',
82
84
  'dvioptions' => '-d 5 -z 9',
83
85
  # for PDFMaker
84
86
  'pdfmaker' => {
87
+ 'image_scale2width' => true,
85
88
  'makeindex' => nil, # Make index page
86
89
  'makeindex_command' => 'mendex', # works only when makeindex is true
87
90
  'makeindex_options' => '-f -r -I utf8',
88
91
  'makeindex_sty' => nil,
89
92
  'makeindex_dic' => nil,
90
93
  'makeindex_mecab' => true,
91
- 'makeindex_mecab_opts' => '-Oyomi'
94
+ 'makeindex_mecab_opts' => '-Oyomi',
95
+ 'use_cover_nombre' => true,
96
+ 'use_original_image_size' => nil
92
97
  },
93
98
  'imgmath_options' => {
94
99
  'format' => 'png',
@@ -99,8 +104,14 @@ module ReVIEW
99
104
  'preamble_file' => nil,
100
105
  'fontsize' => 10,
101
106
  'lineheight' => 10 * 1.2,
102
- 'pdfcrop_pixelize_cmd' => 'pdftocairo -png -r 90 -f %p -l %p -singlefile %i %O',
107
+ 'pdfcrop_pixelize_cmd' => 'pdftocairo -%t -r 90 -f %p -l %p -singlefile %i %O',
103
108
  'dvipng_cmd' => 'dvipng -T tight -z 9 -p %p -l %p -o %o %i'
109
+ },
110
+ 'caption_position' => {
111
+ 'list' => 'top',
112
+ 'image' => 'bottom',
113
+ 'table' => 'top',
114
+ 'equation' => 'top'
104
115
  }
105
116
  ]
106
117
  conf.maker = nil