class ReVIEW::IndexBuilder

Attributes

bibpaper_index[R]
column_index[R]
endnote_index[R]
equation_index[R]
footnote_index[R]
headline_index[R]
icon_index[R]
image_index[R]
indepimage_index[R]
list_index[R]
numberless_image_index[R]
table_index[R]

Public Class Methods

new(strict = false, *args) click to toggle source
Calls superclass method ReVIEW::Builder::new
# File lib/review/index_builder.rb, line 21
def initialize(strict = false, *args)
  super
end

Public Instance Methods

bibpaper(lines, id, caption) click to toggle source
# File lib/review/index_builder.rb, line 508
def bibpaper(lines, id, caption)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @bibpaper_index.size + 1, caption)
  @bibpaper_index.add_item(item)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
bind(compiler, chapter, location) click to toggle source
# File lib/review/index_builder.rb, line 43
def bind(compiler, chapter, location)
  @compiler = compiler
  @chapter = chapter
  @location = location
  @output = StringIO.new
  if @chapter.present?
    @book = @chapter.book
  end
  builder_init_file
end
blankline() click to toggle source
# File lib/review/index_builder.rb, line 363
def blankline
end
bpo(lines) click to toggle source
# File lib/review/index_builder.rb, line 380
def bpo(lines)
  lines.each { |line| compile_inline(line) }
end
captionblock(_type, lines, caption, _specialstyle = nil) click to toggle source
# File lib/review/index_builder.rb, line 677
def captionblock(_type, lines, caption, _specialstyle = nil)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
  ''
end
centering(lines) click to toggle source
# File lib/review/index_builder.rb, line 370
def centering(lines)
  lines.each { |line| compile_inline(line) }
end
check_id(id) click to toggle source
# File lib/review/index_builder.rb, line 25
def check_id(id)
  if id
    if id =~ %r![#%\\{}\[\]~/$'"|*?&<>`\s]!
      warn "deprecated ID: `#{$&}` in `#{id}`", location: location
    elsif id.start_with?('.')
      warn "deprecated ID: `#{id}` begins from `.`", location: location
    end
  end
end
cmd(lines, caption = nil) click to toggle source
# File lib/review/index_builder.rb, line 280
def cmd(lines, caption = nil)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
column_begin(_level, label, caption) click to toggle source
# File lib/review/index_builder.rb, line 176
def column_begin(_level, label, caption)
  check_id(label)
  item_id = label || caption
  item = ReVIEW::Book::Index::Item.new(item_id, @column_index.size + 1, caption)
  @column_index.add_item(item)
end
column_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 183
def column_end(_level)
end
comment(lines, comment = nil) click to toggle source
# File lib/review/index_builder.rb, line 312
def comment(lines, comment = nil)
end
compile_inline(s) click to toggle source
# File lib/review/index_builder.rb, line 390
def compile_inline(s)
  @compiler.text(s)
end
dd(lines) click to toggle source
# File lib/review/index_builder.rb, line 227
def dd(lines)
end
dl_begin() click to toggle source
# File lib/review/index_builder.rb, line 221
def dl_begin
end
dl_end() click to toggle source
# File lib/review/index_builder.rb, line 230
def dl_end
end
dt(line) click to toggle source
# File lib/review/index_builder.rb, line 224
def dt(line)
end
embed(_lines, _arg = nil) click to toggle source
# File lib/review/index_builder.rb, line 651
def embed(_lines, _arg = nil)
  ''
end
emlist(lines, caption = nil, _lang = nil) click to toggle source
# File lib/review/index_builder.rb, line 270
def emlist(lines, caption = nil, _lang = nil)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
emlistnum(lines, caption = nil, _lang = nil) click to toggle source
# File lib/review/index_builder.rb, line 275
def emlistnum(lines, caption = nil, _lang = nil)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
emtable(_lines, caption = nil) click to toggle source
# File lib/review/index_builder.rb, line 306
def emtable(_lines, caption = nil)
  # item = ReVIEW::Book::TableIndex::Item.new(id, @table_index.size + 1)
  # @table_index << item
  compile_inline(caption)
end
endnote(id, str) click to toggle source
# File lib/review/index_builder.rb, line 334
def endnote(id, str)
  check_id(id)
  @crossref[:endnote][id] ||= 0
  item = ReVIEW::Book::Index::Item.new(id, @endnote_index.size + 1, str)
  @endnote_index.add_item(item)
  compile_inline(str)
end
error(msg = nil) click to toggle source

override

# File lib/review/index_builder.rb, line 656
def error(msg = nil)
  # ignore in indexing
end
extract_chapter_id(_chap_ref) click to toggle source
# File lib/review/index_builder.rb, line 673
def extract_chapter_id(_chap_ref)
  ''
end
firstlinenum(_num) click to toggle source
# File lib/review/index_builder.rb, line 484
def firstlinenum(_num)
  ''
end
flushright(lines) click to toggle source
# File lib/review/index_builder.rb, line 366
def flushright(lines)
  lines.each { |line| compile_inline(line) }
end
footnote(id, str) click to toggle source
# File lib/review/index_builder.rb, line 326
def footnote(id, str)
  check_id(id)
  @crossref[:footnote][id] ||= 0
  item = ReVIEW::Book::Index::Item.new(id, @footnote_index.size + 1, str)
  @footnote_index.add_item(item)
  compile_inline(str)
end
get_chap(_chapter = nil) click to toggle source
# File lib/review/index_builder.rb, line 669
def get_chap(_chapter = nil)
  ''
end
graph(lines, id, _command, caption = '') click to toggle source
# File lib/review/index_builder.rb, line 683
def graph(lines, id, _command, caption = '')
  image(lines, id, caption)
end
headline(level, label, caption) click to toggle source
# File lib/review/index_builder.rb, line 97
def headline(level, label, caption)
  check_id(label)
  @sec_counter.inc(level)
  return if level < 2

  cursor = level - 2

  @headline_stack[cursor] = (label || caption)
  if @headline_stack.size > cursor + 1
    @headline_stack = @headline_stack.take(cursor + 1)
  end

  item_id = @headline_stack.join('|')

  item = ReVIEW::Book::Index::Item.new(item_id, @sec_counter.number_list, caption)
  @headline_index.add_item(item)
  compile_inline(caption)
end
highlight?() click to toggle source
# File lib/review/index_builder.rb, line 699
def highlight?
  false
end
hr() click to toggle source
# File lib/review/index_builder.rb, line 356
def hr
end
image(_lines, id, caption, _metric = nil) click to toggle source
# File lib/review/index_builder.rb, line 289
def image(_lines, id, caption, _metric = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @image_index.size + 1, caption)
  @image_index.add_item(item)
  compile_inline(caption)
end
imgtable(_lines, id, caption = nil, _metric = nil) click to toggle source
# File lib/review/index_builder.rb, line 315
def imgtable(_lines, id, caption = nil, _metric = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @table_index.size + 1)
  @table_index.add_item(item)

  ## to find image path
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
  @indepimage_index.add_item(item)
  compile_inline(caption)
end
indepimage(_lines, id, caption = '', _metric = nil) click to toggle source
# File lib/review/index_builder.rb, line 342
def indepimage(_lines, id, caption = '', _metric = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
  @indepimage_index.add_item(item)
  compile_inline(caption)
end
inline_abbr(_str) click to toggle source
# File lib/review/index_builder.rb, line 564
def inline_abbr(_str)
  ''
end
inline_acronym(_str) click to toggle source
# File lib/review/index_builder.rb, line 568
def inline_acronym(_str)
  ''
end
inline_ami(_str) click to toggle source
# File lib/review/index_builder.rb, line 444
def inline_ami(_str)
  ''
end
inline_b(_str) click to toggle source
# File lib/review/index_builder.rb, line 440
def inline_b(_str)
  ''
end
inline_balloon(_arg) click to toggle source
# File lib/review/index_builder.rb, line 552
def inline_balloon(_arg)
  ''
end
inline_bib(_id) click to toggle source
# File lib/review/index_builder.rb, line 532
def inline_bib(_id)
  ''
end
inline_big(_str) click to toggle source
# File lib/review/index_builder.rb, line 600
def inline_big(_str)
  ''
end
inline_bou(str) click to toggle source
# File lib/review/index_builder.rb, line 448
def inline_bou(str)
  str
end
inline_br(_str) click to toggle source
# File lib/review/index_builder.rb, line 476
def inline_br(_str)
  ''
end
inline_chap(_id) click to toggle source
# File lib/review/index_builder.rb, line 398
def inline_chap(_id)
  ''
end
inline_chapref(_id) click to toggle source
# File lib/review/index_builder.rb, line 394
def inline_chapref(_id)
  ''
end
inline_cite(_str) click to toggle source
# File lib/review/index_builder.rb, line 572
def inline_cite(_str)
  ''
end
inline_code(_str) click to toggle source
# File lib/review/index_builder.rb, line 464
def inline_code(_str)
  ''
end
inline_column(_id) click to toggle source
# File lib/review/index_builder.rb, line 536
def inline_column(_id)
  ''
end
inline_column_chap(_chapter, _id) click to toggle source
# File lib/review/index_builder.rb, line 540
def inline_column_chap(_chapter, _id)
  ''
end
inline_del(_str) click to toggle source
# File lib/review/index_builder.rb, line 620
def inline_del(_str)
  ''
end
inline_dfn(_str) click to toggle source
# File lib/review/index_builder.rb, line 576
def inline_dfn(_str)
  ''
end
inline_dtp(_str) click to toggle source
# File lib/review/index_builder.rb, line 460
def inline_dtp(_str)
  ''
end
inline_em(_str) click to toggle source
# File lib/review/index_builder.rb, line 580
def inline_em(_str)
  ''
end
inline_embed(_args) click to toggle source
# File lib/review/index_builder.rb, line 695
def inline_embed(_args)
  ''
end
inline_endnote(id) click to toggle source
# File lib/review/index_builder.rb, line 431
def inline_endnote(id)
  @crossref[:endnote][id] = @crossref[:endnote][id] ? @crossref[:endnote][id] + 1 : 1
  ''
end
inline_eq(_id) click to toggle source
# File lib/review/index_builder.rb, line 422
def inline_eq(_id)
  ''
end
inline_fn(id) click to toggle source
# File lib/review/index_builder.rb, line 426
def inline_fn(id)
  @crossref[:footnote][id] = @crossref[:footnote][id] ? @crossref[:footnote][id] + 1 : 1
  ''
end
inline_hd(_id) click to toggle source
# File lib/review/index_builder.rb, line 516
def inline_hd(_id)
  ''
end
inline_hidx(_str) click to toggle source
# File lib/review/index_builder.rb, line 472
def inline_hidx(_str)
  ''
end
inline_hr(_arg) click to toggle source
# File lib/review/index_builder.rb, line 500
def inline_hr(_arg)
  ''
end
inline_href(_arg) click to toggle source
# File lib/review/index_builder.rb, line 496
def inline_href(_arg)
  ''
end
inline_i(_str) click to toggle source
# File lib/review/index_builder.rb, line 436
def inline_i(_str)
  ''
end
inline_icon(id) click to toggle source
# File lib/review/index_builder.rb, line 636
def inline_icon(id)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @icon_index.size + 1)
  @icon_index.add_item(item)
  ''
end
inline_idx(_str) click to toggle source
# File lib/review/index_builder.rb, line 468
def inline_idx(_str)
  ''
end
inline_img(_id) click to toggle source
# File lib/review/index_builder.rb, line 410
def inline_img(_id)
  ''
end
inline_imgref(_id) click to toggle source
# File lib/review/index_builder.rb, line 414
def inline_imgref(_id)
  ''
end
inline_ins(_str) click to toggle source
# File lib/review/index_builder.rb, line 624
def inline_ins(_str)
  ''
end
inline_kbd(_str) click to toggle source
# File lib/review/index_builder.rb, line 584
def inline_kbd(_str)
  ''
end
inline_kw(_arg) click to toggle source
# File lib/review/index_builder.rb, line 492
def inline_kw(_arg)
  ''
end
inline_list(_id) click to toggle source
# File lib/review/index_builder.rb, line 406
def inline_list(_id)
  ''
end
inline_m(_str) click to toggle source
# File lib/review/index_builder.rb, line 480
def inline_m(_str)
  ''
end
inline_pageref(_id) click to toggle source
# File lib/review/index_builder.rb, line 544
def inline_pageref(_id)
  ''
end
inline_raw(_args) click to toggle source
# File lib/review/index_builder.rb, line 691
def inline_raw(_args)
  ''
end
inline_recipe(_str) click to toggle source
# File lib/review/index_builder.rb, line 632
def inline_recipe(_str)
  ''
end
inline_ruby(_arg) click to toggle source
# File lib/review/index_builder.rb, line 488
def inline_ruby(_arg)
  ''
end
inline_samp(_str) click to toggle source
# File lib/review/index_builder.rb, line 588
def inline_samp(_str)
  ''
end
inline_sec(_id) click to toggle source
# File lib/review/index_builder.rb, line 524
def inline_sec(_id)
  ''
end
inline_secref(_id) click to toggle source
# File lib/review/index_builder.rb, line 520
def inline_secref(_id)
  ''
end
inline_sectitle(_id) click to toggle source
# File lib/review/index_builder.rb, line 528
def inline_sectitle(_id)
  ''
end
inline_small(_str) click to toggle source
# File lib/review/index_builder.rb, line 604
def inline_small(_str)
  ''
end
inline_strong(_str) click to toggle source
# File lib/review/index_builder.rb, line 592
def inline_strong(_str)
  ''
end
inline_sub(_str) click to toggle source
# File lib/review/index_builder.rb, line 608
def inline_sub(_str)
  ''
end
inline_sup(_str) click to toggle source
# File lib/review/index_builder.rb, line 612
def inline_sup(_str)
  ''
end
inline_table(_id) click to toggle source
# File lib/review/index_builder.rb, line 418
def inline_table(_id)
  ''
end
inline_tcy(_arg) click to toggle source
# File lib/review/index_builder.rb, line 548
def inline_tcy(_arg)
  ''
end
inline_title(_id) click to toggle source
# File lib/review/index_builder.rb, line 402
def inline_title(_id)
  ''
end
inline_tt(_str) click to toggle source
# File lib/review/index_builder.rb, line 616
def inline_tt(_str)
  ''
end
inline_ttb(_str) click to toggle source
# File lib/review/index_builder.rb, line 456
def inline_ttb(_str)
  ''
end
inline_tti(_str) click to toggle source
# File lib/review/index_builder.rb, line 452
def inline_tti(_str)
  ''
end
inline_u(_str) click to toggle source
# File lib/review/index_builder.rb, line 628
def inline_u(_str)
  ''
end
inline_uchar(_str) click to toggle source
# File lib/review/index_builder.rb, line 643
def inline_uchar(_str)
  ''
end
inline_var(_str) click to toggle source
# File lib/review/index_builder.rb, line 596
def inline_var(_str)
  ''
end
inline_w(_s) click to toggle source
# File lib/review/index_builder.rb, line 556
def inline_w(_s)
  ''
end
inline_wb(_s) click to toggle source
# File lib/review/index_builder.rb, line 560
def inline_wb(_s)
  ''
end
label(id) click to toggle source
# File lib/review/index_builder.rb, line 359
def label(id)
  check_id(id)
end
lead(_lines)
Alias for: read
list(lines, id, caption, _lang = nil) click to toggle source
# File lib/review/index_builder.rb, line 249
def list(lines, id, caption, _lang = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @list_index.size + 1)
  @list_index.add_item(item)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
listnum(lines, id, caption, _lang = nil) click to toggle source
# File lib/review/index_builder.rb, line 262
def listnum(lines, id, caption, _lang = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @list_index.size + 1)
  @list_index.add_item(item)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
nodisp_begin(level, label, caption) click to toggle source
# File lib/review/index_builder.rb, line 156
def nodisp_begin(level, label, caption)
  check_id(label)
  return if level < 2

  cursor = level - 2

  @headline_stack[cursor] = (label || caption)
  if @headline_stack.size > cursor + 1
    @headline_stack = @headline_stack.take(cursor + 1)
  end

  item_id = @headline_stack.join('|')

  item = ReVIEW::Book::Index::Item.new(item_id, nil, caption)
  @headline_index.add_item(item)
end
nodisp_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 173
def nodisp_end(_level)
end
nofunc_text(_str) click to toggle source
# File lib/review/index_builder.rb, line 240
def nofunc_text(_str)
  ''
end
noindent() click to toggle source
# File lib/review/index_builder.rb, line 384
def noindent
end
nonum_begin(level, label, caption) click to toggle source
# File lib/review/index_builder.rb, line 116
def nonum_begin(level, label, caption)
  check_id(label)
  return if level < 2

  cursor = level - 2

  @headline_stack[cursor] = (label || caption)
  if @headline_stack.size > cursor + 1
    @headline_stack = @headline_stack.take(cursor + 1)
  end

  item_id = @headline_stack.join('|')

  item = ReVIEW::Book::Index::Item.new(item_id, nil, caption)
  @headline_index.add_item(item)
end
nonum_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 133
def nonum_end(_level)
end
notoc_begin(level, label, caption) click to toggle source
# File lib/review/index_builder.rb, line 136
def notoc_begin(level, label, caption)
  check_id(label)
  return if level < 2

  cursor = level - 2

  @headline_stack[cursor] = (label || caption)
  if @headline_stack.size > cursor + 1
    @headline_stack = @headline_stack.take(cursor + 1)
  end

  item_id = @headline_stack.join('|')

  item = ReVIEW::Book::Index::Item.new(item_id, nil, caption)
  @headline_index.add_item(item)
end
notoc_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 153
def notoc_end(_level)
end
numberlessimage(_lines, id, caption = '', _metric = nil) click to toggle source
# File lib/review/index_builder.rb, line 349
def numberlessimage(_lines, id, caption = '', _metric = nil)
  check_id(id)
  item = ReVIEW::Book::Index::Item.new(id, @indepimage_index.size + 1)
  @indepimage_index.add_item(item)
  compile_inline(caption)
end
ol_begin() click to toggle source
# File lib/review/index_builder.rb, line 212
def ol_begin
end
ol_end() click to toggle source
# File lib/review/index_builder.rb, line 218
def ol_end
end
ol_item(lines, _num) click to toggle source
# File lib/review/index_builder.rb, line 215
def ol_item(lines, _num)
end
olnum(_num) click to toggle source
# File lib/review/index_builder.rb, line 374
def olnum(_num)
end
pagebreak() click to toggle source
# File lib/review/index_builder.rb, line 377
def pagebreak
end
paragraph(lines) click to toggle source
# File lib/review/index_builder.rb, line 233
def paragraph(lines)
end
parasep() click to toggle source
# File lib/review/index_builder.rb, line 236
def parasep
  ''
end
post_paragraph() click to toggle source
# File lib/review/index_builder.rb, line 39
def post_paragraph
  ''
end
pre_paragraph() click to toggle source
# File lib/review/index_builder.rb, line 35
def pre_paragraph
  ''
end
printendnotes() click to toggle source
# File lib/review/index_builder.rb, line 387
def printendnotes
end
quote(lines) click to toggle source
# File lib/review/index_builder.rb, line 285
def quote(lines)
  lines.each { |line| compile_inline(line) }
end
raw(_str) click to toggle source
# File lib/review/index_builder.rb, line 647
def raw(_str)
  ''
end
read(_lines) click to toggle source
# File lib/review/index_builder.rb, line 244
def read(_lines)
end
Also aliased as: lead
result() click to toggle source
# File lib/review/index_builder.rb, line 81
def result
  %i[footnote endnote].each do |name|
    @crossref[name].each_pair do |k, v|
      if v == 0
        warn "#{@chapter.basename}: #{name} ID #{k} is not referred."
      end
    end
  end

  nil
end
source(lines, caption = nil, _lang = nil) click to toggle source
# File lib/review/index_builder.rb, line 257
def source(lines, caption = nil, _lang = nil)
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
sup_begin(_level, label, _caption) click to toggle source
# File lib/review/index_builder.rb, line 193
def sup_begin(_level, label, _caption)
  check_id(label)
end
sup_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 197
def sup_end(_level)
end
table(lines, id = nil, caption = nil) click to toggle source
# File lib/review/index_builder.rb, line 296
def table(lines, id = nil, caption = nil)
  check_id(id)
  if id
    item = ReVIEW::Book::Index::Item.new(id, @table_index.size + 1, caption)
    @table_index.add_item(item)
  end
  compile_inline(caption)
  lines.each { |line| compile_inline(line) }
end
target_name() click to toggle source
# File lib/review/index_builder.rb, line 93
def target_name
  'index'
end
texequation(_lines, id = nil, caption = '') click to toggle source
# File lib/review/index_builder.rb, line 660
def texequation(_lines, id = nil, caption = '')
  check_id(id)
  if id
    item = ReVIEW::Book::Index::Item.new(id, @equation_index.size + 1)
    @equation_index.add_item(item)
  end
  compile_inline(caption)
end
text(_str) click to toggle source
# File lib/review/index_builder.rb, line 504
def text(_str)
  ''
end
tsize(_str) click to toggle source
# File lib/review/index_builder.rb, line 687
def tsize(_str)
  ''
end
ul_begin() click to toggle source
# File lib/review/index_builder.rb, line 200
def ul_begin
end
ul_end() click to toggle source
# File lib/review/index_builder.rb, line 209
def ul_end
end
ul_item_begin(lines) click to toggle source
# File lib/review/index_builder.rb, line 203
def ul_item_begin(lines)
end
ul_item_end() click to toggle source
# File lib/review/index_builder.rb, line 206
def ul_item_end
end
unknown_command(*_args) click to toggle source
# File lib/review/index_builder.rb, line 703
def unknown_command(*_args)
  # ignore
end
xcolumn_begin(_level, label, _caption) click to toggle source
# File lib/review/index_builder.rb, line 186
def xcolumn_begin(_level, label, _caption)
  check_id(label)
end
xcolumn_end(_level) click to toggle source
# File lib/review/index_builder.rb, line 190
def xcolumn_end(_level)
end

Private Instance Methods

builder_init_file() click to toggle source
Calls superclass method ReVIEW::Builder#builder_init_file
# File lib/review/index_builder.rb, line 54
def builder_init_file
  super
  @headline_stack = []
  @crossref = {
    footnote: {},
    endnote: {}
  }

  @list_index = ReVIEW::Book::ListIndex.new
  @table_index = ReVIEW::Book::TableIndex.new
  @equation_index = ReVIEW::Book::EquationIndex.new
  @footnote_index = ReVIEW::Book::FootnoteIndex.new
  @endnote_index = ReVIEW::Book::EndnoteIndex.new
  @headline_index = ReVIEW::Book::HeadlineIndex.new(@chapter)
  @column_index = ReVIEW::Book::ColumnIndex.new
  @chapter_index = ReVIEW::Book::ChapterIndex.new
  @bibpaper_index = ReVIEW::Book::BibpaperIndex.new

  if @book
    @image_index = ReVIEW::Book::ImageIndex.new(@chapter)
    @icon_index = ReVIEW::Book::IconIndex.new(@chapter)
    @numberless_image_index = ReVIEW::Book::NumberlessImageIndex.new(@chapter)
    @indepimage_index = ReVIEW::Book::IndepImageIndex.new(@chapter)
  end
end