review 5.2.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +1 -1
  3. data/.github/workflows/ruby-win.yml +1 -1
  4. data/.github/workflows/ruby.yml +1 -1
  5. data/.rubocop.yml +1 -319
  6. data/NEWS.ja.md +116 -0
  7. data/NEWS.md +117 -0
  8. data/README.md +9 -8
  9. data/bin/review +1 -1
  10. data/bin/review-catalog-converter +15 -15
  11. data/bin/review-check +7 -7
  12. data/bin/review-compile +6 -8
  13. data/bin/review-index +1 -1
  14. data/bin/review-preproc +1 -1
  15. data/bin/review-validate +2 -2
  16. data/doc/config.yml.sample +7 -1
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +34 -4
  19. data/doc/format.md +32 -3
  20. data/lib/review/book/base.rb +3 -3
  21. data/lib/review/book/book_unit.rb +13 -3
  22. data/lib/review/book/chapter.rb +1 -1
  23. data/lib/review/book/index.rb +7 -4
  24. data/lib/review/book/part.rb +12 -13
  25. data/lib/review/book/volume.rb +1 -1
  26. data/lib/review/builder.rb +82 -28
  27. data/lib/review/catalog.rb +6 -5
  28. data/lib/review/compiler.rb +20 -14
  29. data/lib/review/configure.rb +5 -2
  30. data/lib/review/epub2html.rb +12 -12
  31. data/lib/review/epubmaker/content.rb +1 -1
  32. data/lib/review/epubmaker/epubcommon.rb +47 -45
  33. data/lib/review/epubmaker/epubv2.rb +2 -1
  34. data/lib/review/epubmaker/epubv3.rb +5 -4
  35. data/lib/review/epubmaker/producer.rb +3 -3
  36. data/lib/review/epubmaker/reviewheaderlistener.rb +1 -1
  37. data/lib/review/epubmaker.rb +35 -32
  38. data/lib/review/extentions/string.rb +1 -1
  39. data/lib/review/htmlbuilder.rb +65 -15
  40. data/lib/review/htmlutils.rb +17 -17
  41. data/lib/review/i18n.rb +3 -3
  42. data/lib/review/i18n.yml +6 -0
  43. data/lib/review/idgxmlbuilder.rb +42 -21
  44. data/lib/review/idgxmlmaker.rb +15 -13
  45. data/lib/review/img_math.rb +1 -0
  46. data/lib/review/index_builder.rb +100 -38
  47. data/lib/review/init.rb +4 -4
  48. data/lib/review/latexbuilder.rb +69 -34
  49. data/lib/review/lineinput.rb +3 -3
  50. data/lib/review/location.rb +1 -1
  51. data/lib/review/logger.rb +21 -21
  52. data/lib/review/makerhelper.rb +3 -3
  53. data/lib/review/markdownbuilder.rb +16 -8
  54. data/lib/review/pdfmaker.rb +40 -21
  55. data/lib/review/plaintextbuilder.rb +8 -7
  56. data/lib/review/preprocessor/repository.rb +1 -1
  57. data/lib/review/preprocessor.rb +5 -5
  58. data/lib/review/rstbuilder.rb +11 -2
  59. data/lib/review/textmaker.rb +20 -18
  60. data/lib/review/textutils.rb +5 -6
  61. data/lib/review/tocprinter.rb +11 -6
  62. data/lib/review/topbuilder.rb +89 -12
  63. data/lib/review/update.rb +16 -8
  64. data/lib/review/version.rb +1 -1
  65. data/lib/review/volumeprinter.rb +9 -9
  66. data/lib/review/webmaker.rb +32 -32
  67. data/lib/review/webtocprinter.rb +10 -10
  68. data/lib/review/yamlloader.rb +36 -2
  69. data/review.gemspec +2 -0
  70. data/samples/sample-book/src/config.yml +0 -1
  71. data/samples/syntax-book/ch02.re +16 -1
  72. data/templates/html/_titlepage.html.erb +9 -17
  73. data/templates/latex/config.erb +3 -0
  74. data/templates/latex/review-jlreq/review-base.sty +2 -1
  75. data/templates/latex/review-jlreq/review-jlreq.cls +36 -3
  76. data/templates/latex/review-jsbook/review-base.sty +7 -1
  77. data/templates/latex/review-jsbook/review-jsbook.cls +31 -4
  78. data/templates/opf/opf_manifest_epubv2.opf.erb +1 -1
  79. data/templates/opf/opf_manifest_epubv3.opf.erb +1 -1
  80. data/test/assets/syntax_book_index_detail.txt +10 -8
  81. data/test/assets/test_template.tex +4 -1
  82. data/test/assets/test_template_backmatter.tex +4 -1
  83. data/test/book_test_helper.rb +10 -10
  84. data/test/test_book_chapter.rb +25 -2
  85. data/test/test_builder.rb +5 -3
  86. data/test/test_epub3maker.rb +3 -3
  87. data/test/test_epubmaker.rb +14 -29
  88. data/test/test_epubmaker_cmd.rb +2 -2
  89. data/test/test_htmlbuilder.rb +80 -8
  90. data/test/test_idgxmlbuilder.rb +13 -13
  91. data/test/test_idgxmlmaker_cmd.rb +1 -1
  92. data/test/test_img_math.rb +11 -2
  93. data/test/test_index.rb +30 -4
  94. data/test/test_latexbuilder.rb +53 -6
  95. data/test/test_markdownbuilder.rb +45 -0
  96. data/test/test_pdfmaker.rb +19 -0
  97. data/test/test_pdfmaker_cmd.rb +10 -10
  98. data/test/test_plaintextbuilder.rb +45 -4
  99. data/test/test_rstbuilder.rb +13 -0
  100. data/test/test_textmaker_cmd.rb +1 -1
  101. data/test/test_topbuilder.rb +169 -11
  102. data/test/test_yamlloader.rb +28 -42
  103. metadata +19 -4
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2021 Kenshi Muto
1
+ # Copyright (c) 2019-2022 Kenshi Muto
2
2
  #
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
@@ -74,9 +74,13 @@ module ReVIEW
74
74
  cmd_config, yamlfile = parse_opts(args)
75
75
  error! "#{yamlfile} not found." unless File.exist?(yamlfile)
76
76
 
77
- @config = ReVIEW::Configure.create(maker: 'idgxmlmaker',
78
- yamlfile: yamlfile,
79
- config: cmd_config)
77
+ begin
78
+ @config = ReVIEW::Configure.create(maker: 'idgxmlmaker',
79
+ yamlfile: yamlfile,
80
+ config: cmd_config)
81
+ rescue ReVIEW::ConfigError => e
82
+ error! e.message
83
+ end
80
84
  I18n.setup(@config['language'])
81
85
  begin
82
86
  generate_idgxml_files(yamlfile)
@@ -119,7 +123,7 @@ module ReVIEW
119
123
  if s.success?
120
124
  File.write(xmlfile, o) # override
121
125
  end
122
- rescue => e
126
+ rescue StandardError => e
123
127
  warn("filter error for #{xmlfile}: #{e.message}")
124
128
  end
125
129
  end
@@ -159,13 +163,11 @@ module ReVIEW
159
163
  end
160
164
 
161
165
  def build_chap(chap, base_path, basetmpdir, ispart)
162
- filename = ''
163
-
164
- if ispart.present?
165
- filename = chap.path
166
- else
167
- filename = Pathname.new(chap.path).relative_path_from(base_path).to_s
168
- end
166
+ filename = if ispart.present?
167
+ chap.path
168
+ else
169
+ Pathname.new(chap.path).relative_path_from(base_path).to_s
170
+ end
169
171
  id = File.basename(filename).sub(/\.re\Z/, '')
170
172
  if @buildonly && !@buildonly.include?(id)
171
173
  warn "skip #{id}.re"
@@ -177,7 +179,7 @@ module ReVIEW
177
179
  begin
178
180
  @converter.convert(filename, File.join(basetmpdir, xmlfile))
179
181
  apply_filter(File.join(basetmpdir, xmlfile))
180
- rescue => e
182
+ rescue StandardError => e
181
183
  @compile_errors = true
182
184
  error "compile error in #{filename} (#{e.class})"
183
185
  error e.message
@@ -104,6 +104,7 @@ module ReVIEW
104
104
  end
105
105
  rescue CompileError
106
106
  FileUtils.cp([tex_path,
107
+ File.join(File.dirname(tex_path), '__IMGMATH_BODY__.tex'),
107
108
  File.join(File.dirname(tex_path), '__IMGMATH__.log')],
108
109
  math_real_dir)
109
110
  error! "LaTeX math compile error. See #{math_real_dir}/__IMGMATH__.log for details."
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-2020 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
1
+ # Copyright (c) 2008-2022 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
2
2
  # KADO Masanori
3
3
  #
4
4
  # This program is free software.
@@ -13,7 +13,8 @@ require 'review/sec_counter'
13
13
 
14
14
  module ReVIEW
15
15
  class IndexBuilder < Builder
16
- attr_reader :list_index, :table_index, :equation_index, :footnote_index,
16
+ attr_reader :list_index, :table_index, :equation_index,
17
+ :footnote_index, :endnote_index,
17
18
  :numberless_image_index, :image_index, :icon_index, :indepimage_index,
18
19
  :headline_index, :column_index, :bibpaper_index
19
20
 
@@ -53,11 +54,16 @@ module ReVIEW
53
54
  def builder_init_file
54
55
  super
55
56
  @headline_stack = []
57
+ @crossref = {
58
+ footnote: {},
59
+ endnote: {}
60
+ }
56
61
 
57
62
  @list_index = ReVIEW::Book::ListIndex.new
58
63
  @table_index = ReVIEW::Book::TableIndex.new
59
64
  @equation_index = ReVIEW::Book::EquationIndex.new
60
65
  @footnote_index = ReVIEW::Book::FootnoteIndex.new
66
+ @endnote_index = ReVIEW::Book::EndnoteIndex.new
61
67
  @headline_index = ReVIEW::Book::HeadlineIndex.new(@chapter)
62
68
  @column_index = ReVIEW::Book::ColumnIndex.new
63
69
  @chapter_index = ReVIEW::Book::ChapterIndex.new
@@ -73,6 +79,14 @@ module ReVIEW
73
79
  private :builder_init_file
74
80
 
75
81
  def result
82
+ %i[footnote endnote].each do |name|
83
+ @crossref[name].each_pair do |k, v|
84
+ if v == 0
85
+ warn "#{@chapter.basename}: #{name} ID #{k} is not referred."
86
+ end
87
+ end
88
+ end
89
+
76
90
  nil
77
91
  end
78
92
 
@@ -87,11 +101,7 @@ module ReVIEW
87
101
 
88
102
  cursor = level - 2
89
103
 
90
- if label
91
- @headline_stack[cursor] = label
92
- else
93
- @headline_stack[cursor] = caption
94
- end
104
+ @headline_stack[cursor] = (label || caption)
95
105
  if @headline_stack.size > cursor + 1
96
106
  @headline_stack = @headline_stack.take(cursor + 1)
97
107
  end
@@ -100,6 +110,7 @@ module ReVIEW
100
110
 
101
111
  item = ReVIEW::Book::Index::Item.new(item_id, @sec_counter.number_list, caption)
102
112
  @headline_index.add_item(item)
113
+ compile_inline(caption)
103
114
  end
104
115
 
105
116
  def nonum_begin(level, label, caption)
@@ -108,11 +119,7 @@ module ReVIEW
108
119
 
109
120
  cursor = level - 2
110
121
 
111
- if label
112
- @headline_stack[cursor] = label
113
- else
114
- @headline_stack[cursor] = caption
115
- end
122
+ @headline_stack[cursor] = (label || caption)
116
123
  if @headline_stack.size > cursor + 1
117
124
  @headline_stack = @headline_stack.take(cursor + 1)
118
125
  end
@@ -132,11 +139,7 @@ module ReVIEW
132
139
 
133
140
  cursor = level - 2
134
141
 
135
- if label
136
- @headline_stack[cursor] = label
137
- else
138
- @headline_stack[cursor] = caption
139
- end
142
+ @headline_stack[cursor] = (label || caption)
140
143
  if @headline_stack.size > cursor + 1
141
144
  @headline_stack = @headline_stack.take(cursor + 1)
142
145
  end
@@ -156,11 +159,7 @@ module ReVIEW
156
159
 
157
160
  cursor = level - 2
158
161
 
159
- if label
160
- @headline_stack[cursor] = label
161
- else
162
- @headline_stack[cursor] = caption
163
- end
162
+ @headline_stack[cursor] = (label || caption)
164
163
  if @headline_stack.size > cursor + 1
165
164
  @headline_stack = @headline_stack.take(cursor + 1)
166
165
  end
@@ -247,56 +246,73 @@ module ReVIEW
247
246
 
248
247
  alias_method :lead, :read
249
248
 
250
- def list(_lines, id, _caption, _lang = nil)
249
+ def list(lines, id, caption, _lang = nil)
251
250
  check_id(id)
252
251
  item = ReVIEW::Book::Index::Item.new(id, @list_index.size + 1)
253
252
  @list_index.add_item(item)
253
+ compile_inline(caption)
254
+ lines.each { |line| compile_inline(line) }
254
255
  end
255
256
 
256
- def source(_lines, _caption = nil, _lang = nil)
257
+ def source(lines, caption = nil, _lang = nil)
258
+ compile_inline(caption)
259
+ lines.each { |line| compile_inline(line) }
257
260
  end
258
261
 
259
- def listnum(_lines, id, _caption, _lang = nil)
262
+ def listnum(lines, id, caption, _lang = nil)
260
263
  check_id(id)
261
264
  item = ReVIEW::Book::Index::Item.new(id, @list_index.size + 1)
262
265
  @list_index.add_item(item)
266
+ compile_inline(caption)
267
+ lines.each { |line| compile_inline(line) }
263
268
  end
264
269
 
265
- def emlist(lines, caption = nil, lang = nil)
270
+ def emlist(lines, caption = nil, _lang = nil)
271
+ compile_inline(caption)
272
+ lines.each { |line| compile_inline(line) }
266
273
  end
267
274
 
268
- def emlistnum(lines, caption = nil, lang = nil)
275
+ def emlistnum(lines, caption = nil, _lang = nil)
276
+ compile_inline(caption)
277
+ lines.each { |line| compile_inline(line) }
269
278
  end
270
279
 
271
280
  def cmd(lines, caption = nil)
281
+ compile_inline(caption)
282
+ lines.each { |line| compile_inline(line) }
272
283
  end
273
284
 
274
285
  def quote(lines)
286
+ lines.each { |line| compile_inline(line) }
275
287
  end
276
288
 
277
289
  def image(_lines, id, caption, _metric = nil)
278
290
  check_id(id)
279
291
  item = ReVIEW::Book::Index::Item.new(id, @image_index.size + 1, caption)
280
292
  @image_index.add_item(item)
293
+ compile_inline(caption)
281
294
  end
282
295
 
283
- def table(_lines, id = nil, caption = nil)
296
+ def table(lines, id = nil, caption = nil)
284
297
  check_id(id)
285
298
  if id
286
299
  item = ReVIEW::Book::Index::Item.new(id, @table_index.size + 1, caption)
287
300
  @table_index.add_item(item)
288
301
  end
302
+ compile_inline(caption)
303
+ lines.each { |line| compile_inline(line) }
289
304
  end
290
305
 
291
- def emtable(_lines, _caption = nil)
306
+ def emtable(_lines, caption = nil)
292
307
  # item = ReVIEW::Book::TableIndex::Item.new(id, @table_index.size + 1)
293
308
  # @table_index << item
309
+ compile_inline(caption)
294
310
  end
295
311
 
296
312
  def comment(lines, comment = nil)
297
313
  end
298
314
 
299
- def imgtable(_lines, id, _caption = nil, _metric = nil)
315
+ def imgtable(_lines, id, caption = nil, _metric = nil)
300
316
  check_id(id)
301
317
  item = ReVIEW::Book::Index::Item.new(id, @table_index.size + 1)
302
318
  @table_index.add_item(item)
@@ -304,24 +320,37 @@ module ReVIEW
304
320
  ## to find image path
305
321
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
306
322
  @indepimage_index.add_item(item)
323
+ compile_inline(caption)
307
324
  end
308
325
 
309
326
  def footnote(id, str)
310
327
  check_id(id)
328
+ @crossref[:footnote][id] ||= 0
311
329
  item = ReVIEW::Book::Index::Item.new(id, @footnote_index.size + 1, str)
312
330
  @footnote_index.add_item(item)
331
+ compile_inline(str)
313
332
  end
314
333
 
315
- def indepimage(_lines, id, _caption = '', _metric = nil)
334
+ def endnote(id, str)
335
+ check_id(id)
336
+ @crossref[:endnote][id] ||= 0
337
+ item = ReVIEW::Book::Index::Item.new(id, @endnote_index.size + 1, str)
338
+ @endnote_index.add_item(item)
339
+ compile_inline(str)
340
+ end
341
+
342
+ def indepimage(_lines, id, caption = '', _metric = nil)
316
343
  check_id(id)
317
344
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
318
345
  @indepimage_index.add_item(item)
346
+ compile_inline(caption)
319
347
  end
320
348
 
321
- def numberlessimage(_lines, id, _caption = '', _metric = nil)
349
+ def numberlessimage(_lines, id, caption = '', _metric = nil)
322
350
  check_id(id)
323
351
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
324
352
  @indepimage_index.add_item(item)
353
+ compile_inline(caption)
325
354
  end
326
355
 
327
356
  def hr
@@ -334,10 +363,12 @@ module ReVIEW
334
363
  def blankline
335
364
  end
336
365
 
337
- def flushright(_lines)
366
+ def flushright(lines)
367
+ lines.each { |line| compile_inline(line) }
338
368
  end
339
369
 
340
370
  def centering(lines)
371
+ lines.each { |line| compile_inline(line) }
341
372
  end
342
373
 
343
374
  def olnum(_num)
@@ -346,12 +377,16 @@ module ReVIEW
346
377
  def pagebreak
347
378
  end
348
379
 
349
- def bpo(_lines)
380
+ def bpo(lines)
381
+ lines.each { |line| compile_inline(line) }
350
382
  end
351
383
 
352
384
  def noindent
353
385
  end
354
386
 
387
+ def printendnotes
388
+ end
389
+
355
390
  def compile_inline(s)
356
391
  @compiler.text(s)
357
392
  end
@@ -388,7 +423,13 @@ module ReVIEW
388
423
  ''
389
424
  end
390
425
 
391
- def inline_fn(_id)
426
+ def inline_fn(id)
427
+ @crossref[:footnote][id] = @crossref[:footnote][id] ? @crossref[:footnote][id] + 1 : 1
428
+ ''
429
+ end
430
+
431
+ def inline_endnote(id)
432
+ @crossref[:endnote][id] = @crossref[:endnote][id] ? @crossref[:endnote][id] + 1 : 1
392
433
  ''
393
434
  end
394
435
 
@@ -464,16 +505,30 @@ module ReVIEW
464
505
  ''
465
506
  end
466
507
 
467
- def bibpaper(_lines, id, caption)
508
+ def bibpaper(lines, id, caption)
468
509
  check_id(id)
469
510
  item = ReVIEW::Book::Index::Item.new(id, @bibpaper_index.size + 1, caption)
470
511
  @bibpaper_index.add_item(item)
512
+ compile_inline(caption)
513
+ lines.each { |line| compile_inline(line) }
471
514
  end
472
515
 
473
516
  def inline_hd(_id)
474
517
  ''
475
518
  end
476
519
 
520
+ def inline_secref(_id)
521
+ ''
522
+ end
523
+
524
+ def inline_sec(_id)
525
+ ''
526
+ end
527
+
528
+ def inline_sectitle(_id)
529
+ ''
530
+ end
531
+
477
532
  def inline_bib(_id)
478
533
  ''
479
534
  end
@@ -602,12 +657,13 @@ module ReVIEW
602
657
  # ignore in indexing
603
658
  end
604
659
 
605
- def texequation(_lines, id = nil, _caption = '')
660
+ def texequation(_lines, id = nil, caption = '')
606
661
  check_id(id)
607
662
  if id
608
663
  item = ReVIEW::Book::Index::Item.new(id, @equation_index.size + 1)
609
664
  @equation_index.add_item(item)
610
665
  end
666
+ compile_inline(caption)
611
667
  end
612
668
 
613
669
  def get_chap(_chapter = nil)
@@ -618,10 +674,16 @@ module ReVIEW
618
674
  ''
619
675
  end
620
676
 
621
- def captionblock(_type, _lines, _caption, _specialstyle = nil)
677
+ def captionblock(_type, lines, caption, _specialstyle = nil)
678
+ compile_inline(caption)
679
+ lines.each { |line| compile_inline(line) }
622
680
  ''
623
681
  end
624
682
 
683
+ def graph(lines, id, _command, caption = '')
684
+ image(lines, id, caption)
685
+ end
686
+
625
687
  def tsize(_str)
626
688
  ''
627
689
  end
data/lib/review/init.rb CHANGED
@@ -179,12 +179,12 @@ EOS
179
179
  content = content.split("\n").delete_if { |l| l.strip.start_with?('#') || l.strip.empty? }.join("\n")
180
180
  end
181
181
 
182
- File.open(File.join(dir, 'config.yml'), 'w') { |f| f.write content }
182
+ File.write(File.join(dir, 'config.yml'), content)
183
183
  if @webui && !@web_result[2].empty?
184
184
  File.open(File.join(dir, 'config-ebook.yml'), 'w') do |f|
185
185
  f.puts <<EOT
186
186
  # for ebook PDF
187
- # REVIEW_CONFIG_FILE=config.yml rake pdf
187
+ # REVIEW_CONFIG_FILE=config-ebook.yml rake pdf
188
188
  inherit: ["config.yml"]
189
189
  # bookname: book-ebook
190
190
  texdocumentclass: ["#{@web_result[0]}", "#{@web_result[2]}"]
@@ -257,7 +257,7 @@ EOS
257
257
  exit 1
258
258
  end
259
259
 
260
- if filename =~ %r{\Ahttps?://}
260
+ if %r{\Ahttps?://}.match?(filename)
261
261
  begin
262
262
  @logger.info "Downloading from #{filename}"
263
263
  zipdata = Net::HTTP.get(URI.parse(filename))
@@ -334,7 +334,7 @@ EOS
334
334
  # validation
335
335
  if @web_result
336
336
  @web_result.each do |s|
337
- if s !~ /\A[a-z0-9=_,.-]*\Z/i
337
+ unless /\A[a-z0-9=_,.-]*\Z/i.match?(s)
338
338
  @web_result = nil
339
339
  break
340
340
  end
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2002-2007 Minero Aoki
2
2
  # 2008-2009 Minero Aoki, Kenshi Muto
3
- # 2010-2021 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi
3
+ # 2010-2022 Minero Aoki, Kenshi Muto, TAKAHASHI Masayoshi
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -98,6 +98,8 @@ module ReVIEW
98
98
  private :puts
99
99
 
100
100
  def result
101
+ check_printendnotes
102
+
101
103
  if @chapter.is_a?(ReVIEW::Book::Part) && !@book.config.check_version('2', exception: false)
102
104
  puts '\end{reviewpart}'
103
105
  end
@@ -155,7 +157,7 @@ module ReVIEW
155
157
  puts macro('label', sec_label(anchor))
156
158
  puts macro('label', label) if label
157
159
  end
158
- rescue
160
+ rescue StandardError
159
161
  app_error "unknown level: #{level}"
160
162
  end
161
163
 
@@ -197,12 +199,11 @@ module ReVIEW
197
199
  blank
198
200
  @doc_status[:column] = true
199
201
 
200
- target = nil
201
- if label
202
- target = "\\hypertarget{#{column_label(label)}}{}"
203
- else
204
- target = "\\hypertarget{#{column_label(caption)}}{}"
205
- end
202
+ target = if label
203
+ "\\hypertarget{#{column_label(label)}}{}"
204
+ else
205
+ "\\hypertarget{#{column_label(caption)}}{}"
206
+ end
206
207
 
207
208
  @doc_status[:caption] = true
208
209
  if @book.config.check_version('2', exception: false)
@@ -474,11 +475,11 @@ module ReVIEW
474
475
  captionstr = macro(command + 'caption', compile_inline(caption))
475
476
  else
476
477
  begin
477
- if get_chap.nil?
478
- captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
479
- else
480
- captionstr = macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
481
- end
478
+ captionstr = if get_chap.nil?
479
+ macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
480
+ else
481
+ macro('reviewlistcaption', "#{I18n.t('list')}#{I18n.t('format_number_header', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
482
+ end
482
483
  rescue KeyError
483
484
  app_error "no such list: #{id}"
484
485
  end
@@ -576,13 +577,12 @@ module ReVIEW
576
577
  end
577
578
 
578
579
  def image_image(id, caption = '', metric = nil)
579
- captionstr = nil
580
580
  @doc_status[:caption] = true
581
- if @book.config.check_version('2', exception: false)
582
- captionstr = macro('caption', compile_inline(caption)) + "\n"
583
- else
584
- captionstr = macro('reviewimagecaption', compile_inline(caption)) + "\n"
585
- end
581
+ captionstr = if @book.config.check_version('2', exception: false)
582
+ macro('caption', compile_inline(caption)) + "\n"
583
+ else
584
+ macro('reviewimagecaption', compile_inline(caption)) + "\n"
585
+ end
586
586
  captionstr << macro('label', image_label(id))
587
587
  @doc_status[:caption] = nil
588
588
 
@@ -803,7 +803,7 @@ module ReVIEW
803
803
  end
804
804
 
805
805
  if @tsize
806
- if @tsize =~ /\A[\d., ]+\Z/
806
+ if /\A[\d., ]+\Z/.match?(@tsize)
807
807
  @cellwidth = @tsize.split(/\s*,\s*/)
808
808
  @cellwidth.collect! { |i| "p{#{i}mm}" }
809
809
  puts macro('begin', 'reviewtable', '|' + @cellwidth.join('|') + '|')
@@ -856,7 +856,7 @@ module ReVIEW
856
856
  end
857
857
 
858
858
  def th(s, cellwidth = 'l')
859
- if /\\\\/ =~ s
859
+ if /\\\\/.match?(s)
860
860
  if !@book.config.check_version('2', exception: false) && cellwidth =~ /\{/
861
861
  macro('reviewth', s.gsub("\\\\\n", '\\newline{}'))
862
862
  else
@@ -869,7 +869,7 @@ module ReVIEW
869
869
  end
870
870
 
871
871
  def td(s, cellwidth = 'l')
872
- if /\\\\/ =~ s
872
+ if /\\\\/.match?(s)
873
873
  if !@book.config.check_version('2', exception: false) && cellwidth =~ /\{/
874
874
  s.gsub("\\\\\n", '\\newline{}')
875
875
  else
@@ -968,11 +968,11 @@ module ReVIEW
968
968
 
969
969
  if id
970
970
  puts macro('begin', 'reviewequationblock')
971
- if get_chap.nil?
972
- captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
973
- else
974
- captionstr = macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
975
- end
971
+ captionstr = if get_chap.nil?
972
+ macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
973
+ else
974
+ macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}")
975
+ end
976
976
  end
977
977
 
978
978
  if caption_top?('equation') && captionstr
@@ -1151,6 +1151,19 @@ module ReVIEW
1151
1151
  app_error "unknown footnote: #{id}"
1152
1152
  end
1153
1153
 
1154
+ def inline_endnote(id)
1155
+ macro('endnote', compile_inline(@chapter.endnote(id).content.strip))
1156
+ rescue KeyError
1157
+ app_error "unknown footnote: #{id}"
1158
+ end
1159
+
1160
+ def printendnotes
1161
+ @shown_endnotes = true
1162
+ blank
1163
+ puts '\theendnotes'
1164
+ blank
1165
+ end
1166
+
1154
1167
  BOUTEN = '・'.freeze
1155
1168
 
1156
1169
  def inline_bou(str)
@@ -1264,11 +1277,11 @@ module ReVIEW
1264
1277
 
1265
1278
  def inline_hd_chap(chap, id)
1266
1279
  n = chap.headline_index.number(id)
1267
- if n.present? && chap.number && over_secnolevel?(n)
1268
- str = I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)])
1269
- else
1270
- str = I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
1271
- end
1280
+ str = if n.present? && chap.number && over_secnolevel?(n)
1281
+ I18n.t('hd_quote', [chap.headline_index.number(id), compile_inline(chap.headline(id).caption)])
1282
+ else
1283
+ I18n.t('hd_quote_without_number', compile_inline(chap.headline(id).caption))
1284
+ end
1272
1285
  if @book.config['chapterlink']
1273
1286
  anchor = n.tr('.', '-')
1274
1287
  macro('reviewsecref', str, sec_label(anchor))
@@ -1277,6 +1290,28 @@ module ReVIEW
1277
1290
  end
1278
1291
  end
1279
1292
 
1293
+ def inline_sec(id)
1294
+ if @book.config['chapterlink']
1295
+ n = super(id)
1296
+ anchor = n.tr('.', '-')
1297
+ macro('reviewsecref', n, sec_label(anchor))
1298
+ else
1299
+ super(id)
1300
+ end
1301
+ rescue KeyError
1302
+ app_error "unknown headline: #{id}"
1303
+ end
1304
+
1305
+ def inline_sectitle(id)
1306
+ if @book.config['chapterlink']
1307
+ chap, id2 = extract_chapter_id(id)
1308
+ anchor = chap.headline_index.number(id2).tr('.', '-')
1309
+ macro('reviewsecref', super(id), sec_label(anchor))
1310
+ else
1311
+ super(id)
1312
+ end
1313
+ end
1314
+
1280
1315
  def inline_column_chap(chapter, id)
1281
1316
  macro('reviewcolumnref',
1282
1317
  I18n.t('column', compile_inline(chapter.column(id).caption)),
@@ -1345,7 +1380,7 @@ module ReVIEW
1345
1380
  end
1346
1381
 
1347
1382
  def inline_tcy(str)
1348
- macro('rensuji', escape(str))
1383
+ macro('reviewtcy', escape(str))
1349
1384
  end
1350
1385
 
1351
1386
  def inline_balloon(str)
@@ -1399,7 +1434,7 @@ module ReVIEW
1399
1434
  end
1400
1435
 
1401
1436
  def compile_href(url, label)
1402
- if /\A[a-z]+:/ =~ url
1437
+ if /\A[a-z]+:/.match?(url)
1403
1438
  if label
1404
1439
  macro('href', escape_url(url), escape(label))
1405
1440
  else
@@ -31,7 +31,7 @@ module ReVIEW
31
31
  def skip_comment_lines
32
32
  n = 0
33
33
  while line = gets
34
- unless line.strip =~ /\A\#@/
34
+ unless /\A\#@/.match?(line.strip)
35
35
  ungets(line)
36
36
  return n
37
37
  end
@@ -88,7 +88,7 @@ module ReVIEW
88
88
 
89
89
  def while_match(re)
90
90
  while line = gets
91
- unless re =~ line
91
+ unless re&.match?(line)
92
92
  ungets(line)
93
93
  return
94
94
  end
@@ -99,7 +99,7 @@ module ReVIEW
99
99
 
100
100
  def until_match(re)
101
101
  while line = gets
102
- if re =~ line
102
+ if re&.match?(line)
103
103
  ungets(line)
104
104
  return
105
105
  end
@@ -22,7 +22,7 @@ module ReVIEW
22
22
  def string
23
23
  begin
24
24
  "#{@filename}:#{@f.lineno}"
25
- rescue
25
+ rescue StandardError
26
26
  "#{@filename}:nil"
27
27
  end
28
28
  end