Class: ReVIEW::TOPBuilder

Inherits:
PLAINTEXTBuilder show all
Defined in:
lib/review/topbuilder.rb

Direct Known Subclasses

TEXTBuilder

Constant Summary

Constants inherited from Builder

Builder::CAPTION_TITLES

Instance Attribute Summary

Attributes inherited from Builder

#doc_status

Instance Method Summary collapse

Methods inherited from PLAINTEXTBuilder

#best, #bibpaper, #bibpaper_bibpaper, #bpo, #caution, #centering, #circle_end, #cmd, #column_begin, #column_end, #dl_begin, #dl_end, #dtp, #edition_begin, #edition_end, #emlist, #expert, #extname, #flushright, #hood_begin, #hood_end, #imgtable, #important, #info, #inline_br, #inline_chap, #inline_chapref, #inline_del, #inline_dtp, #inline_hd_chap, #inline_raw, #inline_uchar, #insideout_begin, #insideout_end, #insn, #label, #link, #memo, #nodisp_begin, #nodisp_end, #nofunc_text, #nonum_end, #note, #notice, #notoc_end, #ol_begin, #ol_end, #olnum, #paragraph, #planning, #point, #post_paragraph, #practice, #pre_paragraph, #quote, #ref_begin, #ref_end, #reference, #result, #security, #shoot, #source, #sup_begin, #sup_end, #table_begin, #table_header, #term, #text, #tip, #tr, #ul_begin, #ul_end, #warning, #world_begin, #world_end, #xcolumn_begin, #xcolumn_end

Methods included from TextUtils

#detab, #split_paragraph

Methods inherited from Builder

#bibpaper, #bind, #blankline, #captionblock, #compile_inline, #detab, #embed, #emtable, #error, #escape, #extract_chapter_id, #firstlinenum, #get_chap, #graph, #graph_aafigure, #graph_blockdiag, #graph_gnuplot, #graph_graphviz, #graph_plantuml, #handle_metric, #image_ext, #initialize, #inline_chap, #inline_chapref, #inline_column, #inline_column_chap, #inline_embed, #inline_eq, #inline_hd, #inline_href, #inline_img, #inline_imgref, #inline_include, #inline_kw, #inline_list, #inline_raw, #inline_ruby, #inline_table, #inline_tcy, #inline_title, #inline_w, #inline_wb, #line_num, #list, #listnum, #load_words, #parse_metric, #post_paragraph, #pre_paragraph, #print, #puts, #raw, #result, #result_metric, #source, #system_graph, #target_name, #text, #tsize, #ul_item_begin, #ul_item_end, #unescape, #warn

Constructor Details

This class inherits a constructor from ReVIEW::Builder

Instance Method Details

#base_block(type, lines, caption = nil) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/review/topbuilder.rb', line 113

def base_block(type, lines, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "#{compile_inline(caption)}" if caption.present?
  puts lines.join("\n")
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end

#base_parablock(type, lines, caption = nil) ⇒ Object



122
123
124
125
126
127
128
129
# File 'lib/review/topbuilder.rb', line 122

def base_parablock(type, lines, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "#{compile_inline(caption)}" if caption.present?
  puts split_paragraph(lines).join("\n")
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end

#bibpaper_header(id, caption) ⇒ Object



365
366
367
368
# File 'lib/review/topbuilder.rb', line 365

def bibpaper_header(id, caption)
  print "[#{@chapter.bibpaper(id).number}]"
  puts " #{compile_inline(caption)}"
end

#circle_begin(_level, _label, caption) ⇒ Object



433
434
435
# File 'lib/review/topbuilder.rb', line 433

def circle_begin(_level, _label, caption)
  puts "・\t#{caption}"
end

#comment(lines, comment = nil) ⇒ Object



237
238
239
240
241
242
243
244
245
# File 'lib/review/topbuilder.rb', line 237

def comment(lines, comment = nil)
  return unless @book.config['draft']
  lines ||= []
  unless comment.blank?
    lines.unshift comment
  end
  str = lines.join("\n")
  puts "◆→#{str}←◆"
end

#common_column_begin(type, caption) ⇒ Object



388
389
390
391
392
# File 'lib/review/topbuilder.rb', line 388

def common_column_begin(type, caption)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "#{compile_inline(caption)}"
end

#common_column_end(type) ⇒ Object



394
395
396
397
# File 'lib/review/topbuilder.rb', line 394

def common_column_end(type)
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end

#compile_href(url, label) ⇒ Object



268
269
270
271
272
273
274
# File 'lib/review/topbuilder.rb', line 268

def compile_href(url, label)
  if label
    "#{label}(△#{url}☆)"
  else
    "#{url}"
  end
end

#compile_kw(word, alt) ⇒ Object



261
262
263
264
265
266
# File 'lib/review/topbuilder.rb', line 261

def compile_kw(word, alt)
  if alt
  then "#{word}☆(#{alt.strip}"
  else "#{word}"
  end
end

#compile_ruby(base, ruby) ⇒ Object



257
258
259
# File 'lib/review/topbuilder.rb', line 257

def compile_ruby(base, ruby)
  "#{base}◆→DTP連絡:「#{base}」に「#{ruby}」とルビ←◆"
end

#dd(lines) ⇒ Object



79
80
81
82
83
# File 'lib/review/topbuilder.rb', line 79

def dd(lines)
  split_paragraph(lines).each do |paragraph|
    puts "\t#{paragraph.gsub(/\n/, '')}"
  end
end

#dt(line) ⇒ Object



75
76
77
# File 'lib/review/topbuilder.rb', line 75

def dt(line)
  puts "#{line}"
end

#emlistnum(lines, caption = nil, _lang = nil) ⇒ Object



131
132
133
134
135
136
137
138
139
140
# File 'lib/review/topbuilder.rb', line 131

def emlistnum(lines, caption = nil, _lang = nil)
  blank
  puts "◆→開始:#{@titles['emlist']}←◆"
  puts "#{compile_inline(caption)}" if caption.present?
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
  puts "◆→終了:#{@titles['emlist']}←◆"
  blank
end

#footnote(id, str) ⇒ Object



247
248
249
# File 'lib/review/topbuilder.rb', line 247

def footnote(id, str)
  puts "【注#{@chapter.footnote(id).number}#{compile_inline(str)}"
end

#headline(level, _label, caption) ⇒ Object



62
63
64
65
# File 'lib/review/topbuilder.rb', line 62

def headline(level, _label, caption)
  prefix, _anchor = headline_prefix(level)
  puts %Q(■H#{level}#{prefix}#{compile_inline(caption)})
end

#image(lines, id, caption, metric = nil) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/review/topbuilder.rb', line 150

def image(lines, id, caption, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  puts "◆→開始:#{@titles['image']}←◆"
  if get_chap
    puts "#{I18n.t('image')}#{I18n.t('format_number', [get_chap, @chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
  else
    puts "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
  end
  blank
  if @chapter.image(id).bound?
    puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
  else
    warn "image not bound: #{id}"
    lines.each do |line|
      puts line
    end
  end
  puts "◆→終了:#{@titles['image']}←◆"
  blank
end

#indepimage(_lines, id, caption = nil, metric = nil) ⇒ Object Also known as: numberlessimage



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/review/topbuilder.rb', line 399

def indepimage(_lines, id, caption = nil, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  begin
    puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
  rescue
    warn "image not bound: #{id}"
    puts "◆→画像 #{id}←◆"
  end
  puts "図 #{compile_inline(caption)}" if caption.present?
  blank
end

#inline_ami(str) ⇒ Object



300
301
302
# File 'lib/review/topbuilder.rb', line 300

def inline_ami(str)
  "#{str}◆→DTP連絡:「#{str}」に網カケ←◆"
end

#inline_b(str) ⇒ Object Also known as: inline_strong



308
309
310
# File 'lib/review/topbuilder.rb', line 308

def inline_b(str)
  "#{str}"
end

#inline_balloon(str) ⇒ Object



349
350
351
# File 'lib/review/topbuilder.rb', line 349

def inline_balloon(str)
  %Q(\t←#{str.gsub(/@maru\[(\d+)\]/, inline_maru('\1'))})
end

#inline_bib(id) ⇒ Object



370
371
372
373
374
# File 'lib/review/topbuilder.rb', line 370

def inline_bib(id)
  %Q([#{@chapter.bibpaper(id).number}])
rescue KeyError
  error "unknown bib: #{id}"
end

#inline_bou(str) ⇒ Object



341
342
343
# File 'lib/review/topbuilder.rb', line 341

def inline_bou(str)
  "#{str}◆→DTP連絡:「#{str}」に傍点←◆"
end

#inline_code(str) ⇒ Object



415
416
417
# File 'lib/review/topbuilder.rb', line 415

def inline_code(str)
  "#{str}"
end

#inline_comment(str) ⇒ Object



353
354
355
356
357
358
359
# File 'lib/review/topbuilder.rb', line 353

def inline_comment(str)
  if @book.config['draft']
    "◆→#{str}←◆"
  else
    ''
  end
end

#inline_fn(id) ⇒ Object



251
252
253
254
255
# File 'lib/review/topbuilder.rb', line 251

def inline_fn(id)
  "【注#{@chapter.footnote(id).number}"
rescue KeyError
  error "unknown footnote: #{id}"
end

#inline_hidx(str) ⇒ Object



296
297
298
# File 'lib/review/topbuilder.rb', line 296

def inline_hidx(str)
  "◆→索引項目:#{str}←◆"
end

#inline_hint(str) ⇒ Object



284
285
286
# File 'lib/review/topbuilder.rb', line 284

def inline_hint(str)
  "◆→ヒントスタイルここから←◆#{str}◆→ヒントスタイルここまで←◆"
end

#inline_i(str) ⇒ Object



304
305
306
# File 'lib/review/topbuilder.rb', line 304

def inline_i(str)
  "#{str}"
end

#inline_icon(id) ⇒ Object



332
333
334
335
336
337
338
339
# File 'lib/review/topbuilder.rb', line 332

def inline_icon(id)
  begin
    "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
  rescue
    warn "image not bound: #{id}"
    "◆→画像 #{id}←◆"
  end
end

#inline_idx(str) ⇒ Object



292
293
294
# File 'lib/review/topbuilder.rb', line 292

def inline_idx(str)
  "#{str}◆→索引項目:#{str}←◆"
end

#inline_keytop(str) ⇒ Object



345
346
347
# File 'lib/review/topbuilder.rb', line 345

def inline_keytop(str)
  "#{str}◆→キートップ#{str}←◆"
end

#inline_labelref(idref) ⇒ Object Also known as: inline_ref



423
424
425
# File 'lib/review/topbuilder.rb', line 423

def inline_labelref(idref)
  "「◆→#{idref}←◆」" # 節、項を参照
end

#inline_m(str) ⇒ Object



361
362
363
# File 'lib/review/topbuilder.rb', line 361

def inline_m(str)
  %Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
end

#inline_maru(str) ⇒ Object



288
289
290
# File 'lib/review/topbuilder.rb', line 288

def inline_maru(str)
  "#{str}◆→丸数字#{str}←◆"
end

#inline_pageref(idref) ⇒ Object



429
430
431
# File 'lib/review/topbuilder.rb', line 429

def inline_pageref(idref)
  "●ページ◆→#{idref}←◆" # ページ番号を参照
end

#inline_sub(str) ⇒ Object



280
281
282
# File 'lib/review/topbuilder.rb', line 280

def inline_sub(str)
  "#{str}◆→DTP連絡:「#{str}」は下付き←◆"
end

#inline_sup(str) ⇒ Object



276
277
278
# File 'lib/review/topbuilder.rb', line 276

def inline_sup(str)
  "#{str}◆→DTP連絡:「#{str}」は上付き←◆"
end

#inline_tt(str) ⇒ Object



314
315
316
# File 'lib/review/topbuilder.rb', line 314

def inline_tt(str)
  "#{str}"
end

#inline_ttb(str) ⇒ Object Also known as: inline_ttbold



318
319
320
# File 'lib/review/topbuilder.rb', line 318

def inline_ttb(str)
  "#{str}☆◆→等幅フォント太字←◆"
end

#inline_tti(str) ⇒ Object



324
325
326
# File 'lib/review/topbuilder.rb', line 324

def inline_tti(str)
  "#{str}☆◆→等幅フォントイタ←◆"
end

#inline_ttibold(str) ⇒ Object



419
420
421
# File 'lib/review/topbuilder.rb', line 419

def inline_ttibold(str)
  "#{str}☆◆→等幅フォント太字イタ←◆"
end

#inline_u(str) ⇒ Object



328
329
330
# File 'lib/review/topbuilder.rb', line 328

def inline_u(str)
  "#{str}@◆→@〜@部分に下線←◆"
end

#list_body(_id, lines, _lang) ⇒ Object



105
106
107
108
109
110
111
# File 'lib/review/topbuilder.rb', line 105

def list_body(_id, lines, _lang)
  lines.each do |line|
    puts detab(line)
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end

#list_header(id, caption, _lang) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/review/topbuilder.rb', line 94

def list_header(id, caption, _lang)
  blank
  puts "◆→開始:#{@titles['list']}←◆"
  if get_chap
    puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
  else
    puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
  end
  blank
end

#listnum_body(lines, _lang) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/review/topbuilder.rb', line 142

def listnum_body(lines, _lang)
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end

#noindentObject



376
377
378
# File 'lib/review/topbuilder.rb', line 376

def noindent
  puts '◆→DTP連絡:次の1行インデントなし←◆'
end

#nonum_begin(level, _label, caption) ⇒ Object



380
381
382
# File 'lib/review/topbuilder.rb', line 380

def nonum_begin(level, _label, caption)
  puts "■H#{level}#{compile_inline(caption)}"
end

#notoc_begin(level, _label, caption) ⇒ Object



384
385
386
# File 'lib/review/topbuilder.rb', line 384

def notoc_begin(level, _label, caption)
  puts "■H#{level}#{compile_inline(caption)}◆→DTP連絡:目次に掲載しない←◆"
end

#ol_item(lines, num) ⇒ Object



71
72
73
# File 'lib/review/topbuilder.rb', line 71

def ol_item(lines, num)
  puts "#{num}\t#{lines.join}"
end

#read(lines) ⇒ Object Also known as: lead



85
86
87
88
89
90
# File 'lib/review/topbuilder.rb', line 85

def read(lines)
  puts "◆→開始:#{@titles['lead']}←◆"
  puts split_paragraph(lines).join("\n")
  puts "◆→終了:#{@titles['lead']}←◆"
  blank
end

#table(lines, id = nil, caption = nil) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/review/topbuilder.rb', line 188

def table(lines, id = nil, caption = nil)
  blank
  puts "◆→開始:#{@titles['table']}←◆"

  rows = []
  sepidx = nil
  lines.each_with_index do |line, idx|
    if /\A[\=\-]{12}/ =~ line
      # just ignore
      # error "too many table separator" if sepidx
      sepidx ||= idx
      next
    end
    rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
  end
  rows = adjust_n_cols(rows)

  begin
    table_header id, caption if caption.present?
  rescue KeyError
    error "no such table: #{id}"
  end
  return if rows.empty?
  table_begin rows.first.size
  if sepidx
    sepidx.times do
      tr(rows.shift.map { |s| th(s) })
    end
    rows.each do |cols|
      tr(cols.map { |s| td(s) })
    end
  else
    rows.each do |cols|
      h, *cs = *cols
      tr([th(h)] + cs.map { |s| td(s) })
    end
  end
  table_end
end

#table_endObject



232
233
234
235
# File 'lib/review/topbuilder.rb', line 232

def table_end
  puts "◆→終了:#{@titles['table']}←◆"
  blank
end

#texequation(lines, id = nil, caption = '') ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/review/topbuilder.rb', line 173

def texequation(lines, id = nil, caption = '')
  blank
  puts "◆→開始:#{@titles['texequation']}←◆"
  if id
    if get_chap
      puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
    else
      puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
    end
  end
  puts lines.join("\n")
  puts "◆→終了:#{@titles['texequation']}←◆"
  blank
end

#th(str) ⇒ Object



228
229
230
# File 'lib/review/topbuilder.rb', line 228

def th(str)
  "#{str}"
end

#ul_item(lines) ⇒ Object



67
68
69
# File 'lib/review/topbuilder.rb', line 67

def ul_item(lines)
  puts "●\t#{lines.join}"
end