class ReVIEW::INAOBuilder

Public Instance Methods

base_parablock(type, lines, caption=nil) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 80
def base_parablock(type, lines, caption=nil)
  puts "◆#{@titles[type]}/◆"
  puts "■■■■■#{compile_inline(caption)}" unless caption.nil?
  puts split_paragraph(lines).join("\n")
  puts "◆/#{@titles[type]}◆"
  blank
end
cmd(lines, caption=nil) click to toggle source

whiteリスト代用

# File ../../../../../lib/review/inaobuilder.rb, line 229
def cmd(lines, caption=nil)
  puts "◆list-white/◆"
  puts %Q[●#{compile_inline(caption)}] unless caption.nil?
  lines.each do |line|
    puts detab(line)
  end
  puts "◆/list-white◆"
end
column_begin(level, label, caption) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 145
def column_begin(level, label, caption)
  puts "◆column/◆"
  puts "■■■■#{compile_inline(caption)}"

end
column_end(level) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 151
def column_end(level)
  puts "◆/column◆"
end
compile_ruby(base, ruby) click to toggle source

「赤文字」はなし

# File ../../../../../lib/review/inaobuilder.rb, line 137
def compile_ruby(base, ruby)
  "◆ルビ/◆#{base}◆#{ruby}◆/ルビ◆"
end
emlist(lines, caption=nil) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 209
def emlist(lines, caption=nil)
  puts "◆list/◆"
  puts %Q[●#{compile_inline(caption)}] unless caption.nil?
  lines.each do |line|
    puts detab(line)
  end
  puts "◆/list◆"
end
error(msg) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 72
def error(msg)
  $stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}"
end
extname() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 27
def extname
  '.txt'
end
footnote(id, str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 119
def footnote(id, str)
  #
end
headline(level, label, caption) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 88
def headline(level, label, caption)
  prefix = "■" * level
  puts "#{prefix}#{compile_inline(caption)}"
end
image(lines, id, caption, metric=nil) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 247
def image(lines, id, caption, metric=nil)
  if get_chap.nil?
    puts "●図#{@chapter.image(id).number} #{compile_inline(caption)}"
  else
    puts "●図#{get_chap}.#{@chapter.image(id).number} #{compile_inline(caption)}"
  end
  if @chapter.image(id).bound?
    puts @chapter.image(id).path
  else
    lines.each do |line|
      puts line
    end
  end
end
inline_b(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 103
def inline_b(str)
  "◆b/◆#{str}◆/b◆"
end
inline_balloon(str) click to toggle source

o1,o2のようなことはできない

# File ../../../../../lib/review/inaobuilder.rb, line 220
def inline_balloon(str)
  "◆comment/◆#{str}◆/comment◆"
end
inline_cmd(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 115
def inline_cmd(str)
  inline_tt(str)
end
inline_comment(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 224
def inline_comment(str)
  inline_balloon(str)
end
inline_fn(id) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 123
def inline_fn(id)
  "◆注/◆#{compile_inline(@chapter.footnote(id).content.strip)}◆/注◆"
end
inline_i(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 107
def inline_i(str)
  "◆i/◆#{str}◆/i◆"
end
inline_img(id) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 238
def inline_img(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    "図#{chapter.image(id).number}"
  else
    "図#{get_chap(chapter)}.#{chapter.image(id).number}"
  end
end
inline_kbd(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 131
def inline_kbd(str)
  inline_keytop(str)
end
inline_keytop(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 127
def inline_keytop(str)
  "#{str}▲"
end
inline_list(id) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 177
def inline_list(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    %Q[リスト#{@chapter.list(id).number}]
  else
    %Q[リスト#{get_chap(chapter)}.#{@chapter.list(id).number}]
  end
end
inline_raw(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 337
def inline_raw(str)
  %Q[#{super(str).gsub("\\n", "\n")}]
end
inline_table(id) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 262
def inline_table(id)
  chapter, id = extract_chapter_id(id)
  if get_chap(chapter).nil?
    "表#{chapter.table(id).number}"
  else
    "表#{get_chap(chapter)}.#{chapter.table(id).number}"
  end
end
inline_tt(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 111
def inline_tt(str)
  "◆cmd/◆#{str}◆/cmd◆"
end
inline_uchar(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 341
def inline_uchar(str)
  [str.to_i(16)].pack("U")
end
list_body(id, lines, lang) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 195
def list_body(id, lines, lang)
  lines.each do |line|
    puts detab(line)
  end
  puts "◆/list◆"
end
list_header(id, caption, lang) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 186
def list_header(id, caption, lang)
  puts "◆list/◆"
  if get_chap.nil?
    puts %Q[●リスト#{@chapter.list(id).number} #{compile_inline(caption)}]
  else
    puts %Q[●リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}]
  end
end
listnum_body(lines, lang) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 202
def listnum_body(lines, lang)
  lines.each_with_index do |line, i|
    puts detab((i+1).to_s.rjust(2) + " " +line)
  end
  puts "◆/list◆"
end
messages() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 76
def messages
  error_messages() + warning_messages()
end
nofunc_text(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 349
def nofunc_text(str)
  str
end
noindent() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 99
def noindent
  @noindent = true
end
ol_begin() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 165
def ol_begin
  @olitem = 0
end
ol_end() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 173
def ol_end
  @olitem = nil
end
ol_item(lines, num) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 169
def ol_item(lines, num)
  puts "(#{num})#{lines.join}"
end
paragraph(lines) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 93
def paragraph(lines)
  print " " if @noindent.nil?
  @noindent = nil
  puts lines.join
end
post_paragraph() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 23
def post_paragraph
  ''
end
pre_paragraph() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 19
def pre_paragraph
  ''
end
quote(lines) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 141
def quote(lines)
  base_parablock "quote", lines, nil
end
result() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 64
def result
  @output.string
end
table(lines, id = nil, caption = nil) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 271
def table(lines, id = nil, caption = nil)
  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)

  puts "◆table/◆"
  begin
    table_header id, caption unless caption.nil?
  rescue KeyError
    error "no such table: #{id}"
  end
  return if rows.empty?
  table_begin rows.first.size
  if sepidx
    sepidx.times do
      print "◆table-title◆"
      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_begin(ncols) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 318
def table_begin(ncols)
end
table_end() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 333
def table_end
  puts "◆/table◆"
end
table_header(id, caption) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 310
def table_header(id, caption)
  if get_chap.nil?
    puts "●表#{@chapter.table(id).number} #{compile_inline(caption)}"
  else
    puts "●表#{get_chap}.#{@chapter.table(id).number} #{compile_inline(caption)}"
  end
end
td(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 329
def td(str)
  str
end
text(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 345
def text(str)
  str
end
th(str) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 325
def th(str)
  str
end
tr(rows) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 321
def tr(rows)
  puts rows.join("\t")
end
ul_begin() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 155
def ul_begin
end
ul_end() click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 162
def ul_end
end
ul_item(lines) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 158
def ul_item(lines)
  puts "・#{lines.join}"
end
warn(msg) click to toggle source
# File ../../../../../lib/review/inaobuilder.rb, line 68
def warn(msg)
  $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}"
end