review 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +20 -5
  3. data/.travis.yml +2 -1
  4. data/NEWS.ja.md +93 -0
  5. data/NEWS.md +77 -0
  6. data/README.md +1 -1
  7. data/bin/review +38 -12
  8. data/bin/review-compile +106 -88
  9. data/bin/review-epubmaker +6 -1
  10. data/bin/review-init +21 -1
  11. data/bin/review-textmaker +16 -0
  12. data/doc/config.yml.sample +6 -1
  13. data/doc/format.ja.md +23 -0
  14. data/doc/format.md +20 -2
  15. data/doc/quickstart.ja.md +8 -4
  16. data/doc/quickstart.md +11 -8
  17. data/lib/review/book/base.rb +29 -18
  18. data/lib/review/book/index.rb +10 -5
  19. data/lib/review/builder.rb +58 -33
  20. data/lib/review/catalog.rb +30 -0
  21. data/lib/review/compiler.rb +53 -19
  22. data/lib/review/configure.rb +15 -14
  23. data/lib/review/epubmaker.rb +15 -4
  24. data/lib/review/htmlbuilder.rb +56 -24
  25. data/lib/review/idgxmlbuilder.rb +17 -7
  26. data/lib/review/latexbuilder.rb +113 -38
  27. data/lib/review/markdownbuilder.rb +12 -5
  28. data/lib/review/md2inaobuilder.rb +3 -1
  29. data/lib/review/pdfmaker.rb +23 -9
  30. data/lib/review/plaintextbuilder.rb +683 -0
  31. data/lib/review/rstbuilder.rb +30 -10
  32. data/lib/review/textmaker.rb +158 -0
  33. data/lib/review/textutils.rb +10 -1
  34. data/lib/review/topbuilder.rb +32 -417
  35. data/lib/review/version.rb +1 -1
  36. data/lib/review/webmaker.rb +29 -8
  37. data/review.gemspec +3 -4
  38. data/templates/html/layout-xhtml1.html.erb +0 -2
  39. data/templates/latex/layout.tex.erb +6 -4
  40. data/templates/web/html/layout-xhtml1.html.erb +0 -2
  41. data/test/book_test_helper.rb +1 -0
  42. data/test/run_test.rb +1 -1
  43. data/test/sample-book/src/Rakefile +19 -3
  44. data/test/syntax-book/Rakefile +19 -3
  45. data/test/test_catalog.rb +45 -0
  46. data/test/test_compiler.rb +8 -2
  47. data/test/test_htmlbuilder.rb +22 -0
  48. data/test/test_idgxmlbuilder.rb +22 -0
  49. data/test/test_index.rb +31 -0
  50. data/test/test_latexbuilder.rb +48 -16
  51. data/test/test_plaintextbuilder.rb +390 -0
  52. data/test/test_textutils.rb +2 -0
  53. data/test/test_topbuilder.rb +23 -1
  54. metadata +13 -7
@@ -20,7 +20,9 @@ module ReVIEW
20
20
  class RSTBuilder < Builder
21
21
  include TextUtils
22
22
 
23
- %i[ttbold hint maru keytop labelref ref balloon strong].each { |e| Compiler.definline(e) }
23
+ %i[ttbold hint maru keytop labelref ref balloon strong].each do |e|
24
+ Compiler.definline(e)
25
+ end
24
26
  Compiler.defsingle(:dtp, 1)
25
27
 
26
28
  Compiler.defblock(:insn, 1)
@@ -152,7 +154,9 @@ module ReVIEW
152
154
  end
153
155
 
154
156
  def dd(lines)
155
- split_paragraph(lines).each { |paragraph| puts " #{paragraph.gsub(/\n/, '')}" }
157
+ split_paragraph(lines).each do |paragraph|
158
+ puts " #{paragraph.gsub(/\n/, '')}"
159
+ end
156
160
  end
157
161
 
158
162
  def dl_end
@@ -160,7 +164,9 @@ module ReVIEW
160
164
 
161
165
  def paragraph(lines)
162
166
  pre = ''
163
- pre = ' ' if @in_role == true
167
+ if @in_role
168
+ pre = ' '
169
+ end
164
170
  puts pre + lines.join
165
171
  puts "\n"
166
172
  end
@@ -186,7 +192,9 @@ module ReVIEW
186
192
  end
187
193
 
188
194
  def list_body(_id, lines, _lang)
189
- lines.each { |line| puts '-' + detab(line) }
195
+ lines.each do |line|
196
+ puts '-' + detab(line)
197
+ end
190
198
  end
191
199
 
192
200
  def base_block(_type, lines, caption = nil)
@@ -213,7 +221,9 @@ module ReVIEW
213
221
  lang ||= 'none'
214
222
  puts ".. code-block:: #{lang}"
215
223
  blank
216
- lines.each { |line| puts ' ' + detab(line) }
224
+ lines.each do |line|
225
+ puts ' ' + detab(line)
226
+ end
217
227
  blank
218
228
  end
219
229
 
@@ -227,18 +237,24 @@ module ReVIEW
227
237
  puts ".. code-block:: #{lang}"
228
238
  puts ' :linenos:'
229
239
  blank
230
- lines.each { |line| puts ' ' + detab(line) }
240
+ lines.each do |line|
241
+ puts ' ' + detab(line)
242
+ end
231
243
  blank
232
244
  end
233
245
 
234
246
  def listnum_body(lines, _lang)
235
- lines.each_with_index { |line, i| puts(i + 1).to_s.rjust(2) + ": #{line}" }
247
+ lines.each_with_index do |line, i|
248
+ puts(i + 1).to_s.rjust(2) + ": #{line}"
249
+ end
236
250
  blank
237
251
  end
238
252
 
239
253
  def cmd(lines, _caption = nil)
240
254
  puts '.. code-block:: bash'
241
- lines.each { |line| puts ' ' + detab(line) }
255
+ lines.each do |line|
256
+ puts ' ' + detab(line)
257
+ end
242
258
  end
243
259
 
244
260
  def quote(lines)
@@ -257,7 +273,9 @@ module ReVIEW
257
273
 
258
274
  def image_image(id, caption, metric)
259
275
  chapter, id = extract_chapter_id(id)
260
- scale = metric.split('=')[1].to_f * 100 if metric
276
+ if metric
277
+ scale = metric.split('=')[1].to_f * 100
278
+ end
261
279
 
262
280
  puts ".. _#{id}:"
263
281
  blank
@@ -353,7 +371,9 @@ module ReVIEW
353
371
  end
354
372
 
355
373
  def compile_href(url, label)
356
- label = url if label.blank?
374
+ if label.blank?
375
+ label = url
376
+ end
357
377
  " `#{label} <#{url}>`_ "
358
378
  end
359
379
 
@@ -0,0 +1,158 @@
1
+ # Copyright (c) 2018 Kenshi Muto
2
+ #
3
+ # This program is free software.
4
+ # You can distribute or modify this program under the terms of
5
+ # the GNU LGPL, Lesser General Public License version 2.1.
6
+ # For details of the GNU LGPL, see the file "COPYING".
7
+ #
8
+ require 'optparse'
9
+ require 'yaml'
10
+ require 'fileutils'
11
+
12
+ require 'review/converter'
13
+ require 'review/configure'
14
+ require 'review/book'
15
+ require 'review/yamlloader'
16
+ require 'review/topbuilder'
17
+ require 'review/version'
18
+
19
+ module ReVIEW
20
+ class TEXTMaker
21
+ attr_accessor :config, :basedir
22
+
23
+ def initialize
24
+ @basedir = nil
25
+ @logger = ReVIEW.logger
26
+ @plaintext = nil
27
+ end
28
+
29
+ def error(msg)
30
+ @logger.error "#{File.basename($PROGRAM_NAME, '.*')}: #{msg}"
31
+ exit 1
32
+ end
33
+
34
+ def warn(msg)
35
+ @logger.warn "#{File.basename($PROGRAM_NAME, '.*')}: #{msg}"
36
+ end
37
+
38
+ def self.execute(*args)
39
+ self.new.execute(*args)
40
+ end
41
+
42
+ def parse_opts(args)
43
+ cmd_config = {}
44
+ opts = OptionParser.new
45
+
46
+ opts.banner = 'Usage: review-textmaker [-n] configfile'
47
+ opts.version = ReVIEW::VERSION
48
+ opts.on('-n', 'No decoration.') { @plaintext = true }
49
+ opts.on('--help', 'Prints this message and quit.') do
50
+ puts opts.help
51
+ exit 0
52
+ end
53
+
54
+ opts.parse!(args)
55
+ if args.size != 1
56
+ puts opts.help
57
+ exit 0
58
+ end
59
+
60
+ [cmd_config, args[0]]
61
+ end
62
+
63
+ def build_path
64
+ "#{@config['bookname']}-text"
65
+ end
66
+
67
+ def remove_old_files(path)
68
+ FileUtils.rm_rf(path)
69
+ end
70
+
71
+ def execute(*args)
72
+ @config = ReVIEW::Configure.values
73
+ @config.maker = 'textmaker'
74
+ cmd_config, yamlfile = parse_opts(args)
75
+ error "#{yamlfile} not found." unless File.exist?(yamlfile)
76
+
77
+ begin
78
+ loader = ReVIEW::YAMLLoader.new
79
+ @config.deep_merge!(loader.load_file(yamlfile))
80
+ rescue => e
81
+ error "yaml error #{e.message}"
82
+ end
83
+ # YAML configs will be overridden by command line options.
84
+ @config.deep_merge!(cmd_config)
85
+ I18n.setup(@config['language'])
86
+ begin
87
+ generate_text_files(yamlfile)
88
+ rescue ApplicationError => e
89
+ raise if @config['debug']
90
+ error(e.message)
91
+ end
92
+ end
93
+
94
+ def generate_text_files(yamlfile)
95
+ @basedir = File.dirname(yamlfile)
96
+ @path = build_path
97
+ remove_old_files(@path)
98
+ Dir.mkdir(@path)
99
+
100
+ @book = ReVIEW::Book.load(@basedir)
101
+ @book.config = @config
102
+
103
+ build_body(@path, yamlfile)
104
+ end
105
+
106
+ def build_body(basetmpdir, _yamlfile)
107
+ base_path = Pathname.new(@basedir)
108
+ builder = nil
109
+ if @plaintext
110
+ builder = ReVIEW::PLAINTEXTBuilder.new
111
+ else
112
+ builder = ReVIEW::TOPBuilder.new
113
+ end
114
+ @converter = ReVIEW::Converter.new(@book, builder)
115
+ @book.parts.each do |part|
116
+ if part.name.present?
117
+ if part.file?
118
+ build_chap(part, base_path, basetmpdir, true)
119
+ else
120
+ textfile = "part_#{part.number}.txt"
121
+ build_part(part, basetmpdir, textfile)
122
+ end
123
+ end
124
+
125
+ part.chapters.each { |chap| build_chap(chap, base_path, basetmpdir, false) }
126
+ end
127
+ end
128
+
129
+ def build_part(part, basetmpdir, textfile)
130
+ File.open("#{basetmpdir}/#{textfile}", 'w') do |f|
131
+ f.print '■H1■' unless @plaintext
132
+ f.print ReVIEW::I18n.t('part', part.number)
133
+ f.print " #{part.name.strip}" if part.name.strip.present?
134
+ f.puts
135
+ end
136
+ end
137
+
138
+ def build_chap(chap, base_path, basetmpdir, ispart)
139
+ filename = ''
140
+
141
+ if ispart.present?
142
+ filename = chap.path
143
+ else
144
+ filename = Pathname.new(chap.path).relative_path_from(base_path).to_s
145
+ end
146
+ id = filename.sub(/\.re\Z/, '')
147
+
148
+ textfile = "#{id}.txt"
149
+
150
+ begin
151
+ @converter.convert(filename, File.join(basetmpdir, textfile))
152
+ rescue => e
153
+ warn "compile error in #{filename} (#{e.class})"
154
+ warn e.message
155
+ end
156
+ end
157
+ end
158
+ end
@@ -15,9 +15,10 @@ module ReVIEW
15
15
  def split_paragraph(lines)
16
16
  pre = pre_paragraph
17
17
  post = post_paragraph
18
+ trimmed_lines = trim_lines(lines)
18
19
 
19
20
  blocked_lines = [[]]
20
- lines.each do |element|
21
+ trimmed_lines.each do |element|
21
22
  if element.empty?
22
23
  blocked_lines << [] if blocked_lines.last != []
23
24
  else
@@ -28,5 +29,13 @@ module ReVIEW
28
29
  blocked_lines.map! { |i| [pre] + i + [post] } if pre && post
29
30
  blocked_lines.map(&:join)
30
31
  end
32
+
33
+ private
34
+
35
+ def trim_lines(lines)
36
+ new_lines = lines.dup
37
+ new_lines.pop while new_lines[-1] && new_lines[-1].strip.empty?
38
+ new_lines
39
+ end
31
40
  end
32
41
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008-2017 Minero Aoki, Kenshi Muto
1
+ # Copyright (c) 2008-2018 Minero Aoki, Kenshi Muto
2
2
  # 2002-2006 Minero Aoki
3
3
  #
4
4
  # This program is free software.
@@ -6,47 +6,12 @@
6
6
  # the GNU LGPL, Lesser General Public License version 2.1.
7
7
  #
8
8
 
9
- require 'review/builder'
10
- require 'review/textutils'
9
+ require 'review/plaintextbuilder'
11
10
 
12
11
  module ReVIEW
13
- class TOPBuilder < Builder
14
- include TextUtils
15
-
16
- %i[ttbold hint maru keytop labelref ref balloon strong].each { |e| Compiler.definline(e) }
17
- Compiler.defsingle(:dtp, 1)
18
-
19
- Compiler.defblock(:insn, 1)
20
- Compiler.defblock(:planning, 0..1)
21
- Compiler.defblock(:best, 0..1)
22
- Compiler.defblock(:securty, 0..1)
23
- Compiler.defblock(:point, 0..1)
24
- Compiler.defblock(:reference, 0)
25
- Compiler.defblock(:term, 0)
26
- Compiler.defblock(:practice, 0)
27
- Compiler.defblock(:expert, 0)
28
- Compiler.defblock(:link, 0..1)
29
- Compiler.defblock(:shoot, 0..1)
30
-
31
- def pre_paragraph
32
- ''
33
- end
34
-
35
- def post_paragraph
36
- ''
37
- end
38
-
39
- def extname
40
- '.txt'
41
- end
42
-
12
+ class TOPBuilder < PLAINTEXTBuilder
43
13
  def builder_init_file
44
- @section = 0
45
- @subsection = 0
46
- @subsubsection = 0
47
- @subsubsubsection = 0
48
- @blank_seen = true
49
- @sec_counter = SecCounter.new(5, @chapter)
14
+ super
50
15
 
51
16
  @titles = {
52
17
  'emlist' => 'インラインリスト',
@@ -94,77 +59,27 @@ module ReVIEW
94
59
  end
95
60
  private :builder_init_file
96
61
 
97
- def print(s)
98
- @blank_seen = false
99
- super
100
- end
101
- private :print
102
-
103
- def puts(s)
104
- @blank_seen = false
105
- super
106
- end
107
- private :puts
108
-
109
- def blank
110
- @output.puts unless @blank_seen
111
- @blank_seen = true
112
- end
113
- private :blank
114
-
115
- def result
116
- @output.string
117
- end
118
-
119
62
  def headline(level, _label, caption)
120
63
  prefix, _anchor = headline_prefix(level)
121
64
  puts %Q(■H#{level}■#{prefix}#{compile_inline(caption)})
122
65
  end
123
66
 
124
- def ul_begin
125
- blank
126
- end
127
-
128
67
  def ul_item(lines)
129
68
  puts "●\t#{lines.join}"
130
69
  end
131
70
 
132
- def ul_end
133
- blank
134
- end
135
-
136
- def ol_begin
137
- blank
138
- @olitem = 0
139
- end
140
-
141
71
  def ol_item(lines, num)
142
72
  puts "#{num}\t#{lines.join}"
143
73
  end
144
74
 
145
- def ol_end
146
- blank
147
- @olitem = nil
148
- end
149
-
150
- def dl_begin
151
- blank
152
- end
153
-
154
75
  def dt(line)
155
76
  puts "★#{line}☆"
156
77
  end
157
78
 
158
79
  def dd(lines)
159
- split_paragraph(lines).each { |paragraph| puts "\t#{paragraph.gsub(/\n/, '')}" }
160
- end
161
-
162
- def dl_end
163
- blank
164
- end
165
-
166
- def paragraph(lines)
167
- puts lines.join
80
+ split_paragraph(lines).each do |paragraph|
81
+ puts "\t#{paragraph.gsub(/\n/, '')}"
82
+ end
168
83
  end
169
84
 
170
85
  def read(lines)
@@ -176,15 +91,6 @@ module ReVIEW
176
91
 
177
92
  alias_method :lead, :read
178
93
 
179
- def inline_list(id)
180
- chapter, id = extract_chapter_id(id)
181
- if get_chap(chapter)
182
- %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap(chapter), chapter.list(id).number])})
183
- else
184
- %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [chapter.list(id).number])})
185
- end
186
- end
187
-
188
94
  def list_header(id, caption, _lang)
189
95
  blank
190
96
  puts "◆→開始:#{@titles['list']}←◆"
@@ -197,7 +103,9 @@ module ReVIEW
197
103
  end
198
104
 
199
105
  def list_body(_id, lines, _lang)
200
- lines.each { |line| puts detab(line) }
106
+ lines.each do |line|
107
+ puts detab(line)
108
+ end
201
109
  puts "◆→終了:#{@titles['list']}←◆"
202
110
  blank
203
111
  end
@@ -220,59 +128,25 @@ module ReVIEW
220
128
  blank
221
129
  end
222
130
 
223
- def emlist(lines, caption = nil, _lang = nil)
224
- base_block 'emlist', lines, caption
225
- end
226
-
227
131
  def emlistnum(lines, caption = nil, _lang = nil)
228
132
  blank
229
133
  puts "◆→開始:#{@titles['emlist']}←◆"
230
134
  puts "■#{compile_inline(caption)}" if caption.present?
231
- lines.each_with_index { |line, i| puts((i + 1).to_s.rjust(2) + ": #{line}") }
135
+ lines.each_with_index do |line, i|
136
+ puts((i + 1).to_s.rjust(2) + ": #{line}")
137
+ end
232
138
  puts "◆→終了:#{@titles['emlist']}←◆"
233
139
  blank
234
140
  end
235
141
 
236
142
  def listnum_body(lines, _lang)
237
- lines.each_with_index { |line, i| puts((i + 1).to_s.rjust(2) + ": #{line}") }
143
+ lines.each_with_index do |line, i|
144
+ puts((i + 1).to_s.rjust(2) + ": #{line}")
145
+ end
238
146
  puts "◆→終了:#{@titles['list']}←◆"
239
147
  blank
240
148
  end
241
149
 
242
- def cmd(lines, caption = nil)
243
- base_block 'cmd', lines, caption
244
- end
245
-
246
- def quote(lines)
247
- base_parablock 'quote', lines, nil
248
- end
249
-
250
- def inline_table(id)
251
- chapter, id = extract_chapter_id(id)
252
- if get_chap(chapter)
253
- "#{I18n.t('table')}#{I18n.t('format_number', [get_chap(chapter), chapter.table(id).number])}"
254
- else
255
- "#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [chapter.table(id).number])}"
256
- end
257
- end
258
-
259
- def inline_img(id)
260
- chapter, id = extract_chapter_id(id)
261
- if get_chap(chapter)
262
- "#{I18n.t('image')}#{I18n.t('format_number', [get_chap(chapter), chapter.image(id).number])}"
263
- else
264
- "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [chapter.image(id).number])}"
265
- end
266
- end
267
-
268
- def handle_metric(str)
269
- str
270
- end
271
-
272
- def result_metric(array)
273
- array.join(',')
274
- end
275
-
276
150
  def image(lines, id, caption, metric = nil)
277
151
  metrics = parse_metric('top', metric)
278
152
  metrics = " #{metrics}" if metrics.present?
@@ -288,7 +162,9 @@ module ReVIEW
288
162
  puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
289
163
  else
290
164
  warn "image not bound: #{id}"
291
- lines.each { |line| puts line }
165
+ lines.each do |line|
166
+ puts line
167
+ end
292
168
  end
293
169
  puts "◆→終了:#{@titles['image']}←◆"
294
170
  blank
@@ -326,8 +202,12 @@ module ReVIEW
326
202
  return if rows.empty?
327
203
  table_begin rows.first.size
328
204
  if sepidx
329
- sepidx.times { tr(rows.shift.map { |s| th(s) }) }
330
- rows.each { |cols| tr(cols.map { |s| td(s) }) }
205
+ sepidx.times do
206
+ tr(rows.shift.map { |s| th(s) })
207
+ end
208
+ rows.each do |cols|
209
+ tr(cols.map { |s| td(s) })
210
+ end
331
211
  else
332
212
  rows.each do |cols|
333
213
  h, *cs = *cols
@@ -337,32 +217,10 @@ module ReVIEW
337
217
  table_end
338
218
  end
339
219
 
340
- def table_header(id, caption)
341
- if id.nil?
342
- puts compile_inline(caption)
343
- elsif get_chap
344
- puts "#{I18n.t('table')}#{I18n.t('format_number', [get_chap, @chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
345
- else
346
- puts "#{I18n.t('table')}#{I18n.t('format_number_without_chapter', [@chapter.table(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
347
- end
348
- blank
349
- end
350
-
351
- def table_begin(ncols)
352
- end
353
-
354
- def tr(rows)
355
- puts rows.join("\t")
356
- end
357
-
358
220
  def th(str)
359
221
  "★#{str}☆"
360
222
  end
361
223
 
362
- def td(str)
363
- str
364
- end
365
-
366
224
  def table_end
367
225
  puts "◆→終了:#{@titles['table']}←◆"
368
226
  blank
@@ -371,7 +229,9 @@ module ReVIEW
371
229
  def comment(lines, comment = nil)
372
230
  return unless @book.config['draft']
373
231
  lines ||= []
374
- lines.unshift comment unless comment.blank?
232
+ unless comment.blank?
233
+ lines.unshift comment
234
+ end
375
235
  str = lines.join
376
236
  puts "◆→#{str}←◆"
377
237
  end
@@ -382,6 +242,8 @@ module ReVIEW
382
242
 
383
243
  def inline_fn(id)
384
244
  "【注#{@chapter.footnote(id).number}】"
245
+ rescue KeyError
246
+ error "unknown footnote: #{id}"
385
247
  end
386
248
 
387
249
  def compile_ruby(base, ruby)
@@ -411,10 +273,6 @@ module ReVIEW
411
273
  "#{str}◆→DTP連絡:「#{str}」は下付き←◆"
412
274
  end
413
275
 
414
- def inline_raw(str)
415
- super(str).gsub('\\n', "\n")
416
- end
417
-
418
276
  def inline_hint(str)
419
277
  "◆→ヒントスタイルここから←◆#{str}◆→ヒントスタイルここまで←◆"
420
278
  end
@@ -484,10 +342,6 @@ module ReVIEW
484
342
  %Q(\t←#{str.gsub(/@maru\[(\d+)\]/, inline_maru('\1'))})
485
343
  end
486
344
 
487
- def inline_uchar(str)
488
- [str.to_i(16)].pack('U')
489
- end
490
-
491
345
  def inline_comment(str)
492
346
  if @book.config['draft']
493
347
  "◆→#{str}←◆"
@@ -500,30 +354,15 @@ module ReVIEW
500
354
  %Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
501
355
  end
502
356
 
503
- def bibpaper(lines, id, caption)
504
- bibpaper_header id, caption
505
- bibpaper_bibpaper id, caption, lines unless lines.empty?
506
- end
507
-
508
357
  def bibpaper_header(id, caption)
509
358
  print "[#{@chapter.bibpaper(id).number}]"
510
359
  puts " #{compile_inline(caption)}"
511
360
  end
512
361
 
513
- def bibpaper_bibpaper(_id, _caption, lines)
514
- print split_paragraph(lines).join
515
- end
516
-
517
362
  def inline_bib(id)
518
363
  %Q([#{@chapter.bibpaper(id).number}])
519
- end
520
-
521
- def inline_hd_chap(chap, id)
522
- if chap.number
523
- n = chap.headline_index.number(id)
524
- return I18n.t('chapter_quote', "#{n} #{compile_inline(chap.headline(id).caption)}") if @book.config['secnolevel'] >= n.split('.').size
525
- end
526
- I18n.t('chapter_quote', compile_inline(chap.headline(id).caption))
364
+ rescue KeyError
365
+ error "unknown bib: #{id}"
527
366
  end
528
367
 
529
368
  def noindent
@@ -534,23 +373,10 @@ module ReVIEW
534
373
  puts "■H#{level}■#{compile_inline(caption)}"
535
374
  end
536
375
 
537
- def nonum_end(level)
538
- end
539
-
540
376
  def notoc_begin(level, _label, caption)
541
377
  puts "■H#{level}■#{compile_inline(caption)}◆→DTP連絡:目次に掲載しない←◆"
542
378
  end
543
379
 
544
- def notoc_end(level)
545
- end
546
-
547
- def nodisp_begin(level, label, caption)
548
- # return empty
549
- end
550
-
551
- def nodisp_end(level)
552
- end
553
-
554
380
  def common_column_begin(type, caption)
555
381
  blank
556
382
  puts "◆→開始:#{@titles[type]}←◆"
@@ -562,156 +388,6 @@ module ReVIEW
562
388
  blank
563
389
  end
564
390
 
565
- def column_begin(_level, _label, caption)
566
- common_column_begin('column', caption)
567
- end
568
-
569
- def column_end(_level)
570
- common_column_end('column')
571
- end
572
-
573
- def xcolumn_begin(_level, _label, caption)
574
- common_column_begin('xcolumn', caption)
575
- end
576
-
577
- def xcolumn_end(_level)
578
- common_column_end('xcolumn')
579
- end
580
-
581
- def world_begin(_level, _label, caption)
582
- common_column_begin('world', caption)
583
- end
584
-
585
- def world_end(_level)
586
- common_column_end('world')
587
- end
588
-
589
- def hood_begin(_level, _label, caption)
590
- common_column_begin('hood', caption)
591
- end
592
-
593
- def hood_end(_level)
594
- common_column_end('hood')
595
- end
596
-
597
- def edition_begin(_level, _label, caption)
598
- common_column_begin('edition', caption)
599
- end
600
-
601
- def edition_end(_level)
602
- common_column_end('edition')
603
- end
604
-
605
- def insideout_begin(_level, _label, caption)
606
- common_column_begin('insideout', caption)
607
- end
608
-
609
- def insideout_end(_level)
610
- common_column_end('insideout')
611
- end
612
-
613
- def ref_begin(_level, _label, caption)
614
- common_column_begin('ref', caption)
615
- end
616
-
617
- def ref_end(_level)
618
- common_column_end('ref')
619
- end
620
-
621
- def sup_begin(_level, _label, caption)
622
- common_column_begin('sup', caption)
623
- end
624
-
625
- def sup_end(_level)
626
- common_column_end('sup')
627
- end
628
-
629
- def flushright(lines)
630
- base_parablock 'flushright', lines, nil
631
- end
632
-
633
- def centering(lines)
634
- base_parablock 'centering', lines, nil
635
- end
636
-
637
- def note(lines, caption = nil)
638
- base_parablock 'note', lines, caption
639
- end
640
-
641
- def memo(lines, caption = nil)
642
- base_parablock 'memo', lines, caption
643
- end
644
-
645
- def tip(lines, caption = nil)
646
- base_parablock 'tip', lines, caption
647
- end
648
-
649
- def info(lines, caption = nil)
650
- base_parablock 'info', lines, caption
651
- end
652
-
653
- def planning(lines, caption = nil)
654
- base_parablock 'planning', lines, caption
655
- end
656
-
657
- def best(lines, caption = nil)
658
- base_parablock 'best', lines, caption
659
- end
660
-
661
- def important(lines, caption = nil)
662
- base_parablock 'important', lines, caption
663
- end
664
-
665
- def security(lines, caption = nil)
666
- base_parablock 'security', lines, caption
667
- end
668
-
669
- def caution(lines, caption = nil)
670
- base_parablock 'caution', lines, caption
671
- end
672
-
673
- def term(lines)
674
- base_parablock 'term', lines, nil
675
- end
676
-
677
- def link(lines, caption = nil)
678
- base_parablock 'link', lines, caption
679
- end
680
-
681
- def notice(lines, caption = nil)
682
- base_parablock 'notice', lines, caption
683
- end
684
-
685
- def point(lines, caption = nil)
686
- base_parablock 'point', lines, caption
687
- end
688
-
689
- def shoot(lines, caption = nil)
690
- base_parablock 'shoot', lines, caption
691
- end
692
-
693
- def reference(lines)
694
- base_parablock 'reference', lines, nil
695
- end
696
-
697
- def practice(lines)
698
- base_parablock 'practice', lines, nil
699
- end
700
-
701
- def expert(lines)
702
- base_parablock 'expert', lines, nil
703
- end
704
-
705
- def insn(lines, caption = nil)
706
- base_block 'insn', lines, caption
707
- end
708
-
709
- def warning(lines, caption = nil)
710
- base_parablock 'warning', lines, caption
711
- end
712
-
713
- alias_method :box, :insn
714
-
715
391
  def indepimage(_lines, id, caption = nil, metric = nil)
716
392
  metrics = parse_metric('top', metric)
717
393
  metrics = " #{metrics}" if metrics.present?
@@ -728,64 +404,10 @@ module ReVIEW
728
404
 
729
405
  alias_method :numberlessimage, :indepimage
730
406
 
731
- def label(_id)
732
- # FIXME
733
- ''
734
- end
735
-
736
- def dtp(str)
737
- # FIXME
738
- end
739
-
740
- def bpo(lines)
741
- base_block 'bpo', lines, nil
742
- end
743
-
744
- def inline_dtp(_str)
745
- # FIXME
746
- ''
747
- end
748
-
749
- def inline_del(_str)
750
- # FIXME
751
- ''
752
- end
753
-
754
407
  def inline_code(str)
755
408
  "△#{str}☆"
756
409
  end
757
410
 
758
- def inline_br(_str)
759
- "\n"
760
- end
761
-
762
- def text(str)
763
- str
764
- end
765
-
766
- def inline_chap(id)
767
- # "「第#{super}章 #{inline_title(id)}」"
768
- # "第#{super}章"
769
- super
770
- end
771
-
772
- def inline_chapref(id)
773
- chs = ['', '「', '」']
774
- if @book.config['chapref']
775
- chs2 = @book.config['chapref'].split(',')
776
- error '--chapsplitter must have exactly 3 parameters with comma.' if chs2.size != 3
777
- chs = chs2
778
- end
779
- "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
780
- rescue KeyError
781
- error "unknown chapter: #{id}"
782
- nofunc_text("[UnknownChapter:#{id}]")
783
- end
784
-
785
- def source(lines, caption = nil, _lang = nil)
786
- base_block 'source', lines, caption
787
- end
788
-
789
411
  def inline_ttibold(str)
790
412
  "▲#{str}☆◆→等幅フォント太字イタ←◆"
791
413
  end
@@ -803,12 +425,5 @@ module ReVIEW
803
425
  def circle_begin(_level, _label, caption)
804
426
  puts "・\t#{caption}"
805
427
  end
806
-
807
- def circle_end(level)
808
- end
809
-
810
- def nofunc_text(str)
811
- str
812
- end
813
428
  end
814
429
  end # module ReVIEW