class ReVIEW::INAOBuilder
Public Instance Methods
base_parablock(type, lines, caption=nil)
click to toggle source
# File lib/review/inaobuilder.rb, line 59 def base_parablock(type, lines, caption=nil) buf = "" buf << "◆#{@titles[type]}/◆\n" buf << "■■■■■#{caption}\n" unless caption.nil? buf << lines.join("") buf << "◆/#{@titles[type]}◆\n" buf << "\n" buf end
cmd(lines, caption = nil)
click to toggle source
whiteリスト代用
# File lib/review/inaobuilder.rb, line 226 def cmd(lines, caption = nil) buf = "◆list-white/◆\n" buf << %Q[●#{caption}\n] unless caption.nil? lines.each do |line| buf << detab(line) << "\n" end buf << "◆/list-white◆\n" buf end
column_begin(level, label, caption)
click to toggle source
# File lib/review/inaobuilder.rb, line 130 def column_begin(level, label, caption) buf = "" buf << "◆column/◆\n" buf << "■■■■#{caption}\n" buf end
column_end(level)
click to toggle source
# File lib/review/inaobuilder.rb, line 137 def column_end(level) "◆/column◆\n" end
compile_ruby(base, ruby)
click to toggle source
「赤文字」はなし
# File lib/review/inaobuilder.rb, line 121 def compile_ruby(base, ruby) "◆ルビ/◆#{base}◆#{ruby}◆/ルビ◆" end
emlist(lines, caption = nil)
click to toggle source
# File lib/review/inaobuilder.rb, line 204 def emlist(lines, caption = nil) buf = "" buf << "◆list/◆\n" buf << %Q[●#{caption}\n] unless caption.nil? lines.each do |line| buf << detab(line) << "\n" end buf << "◆/list◆\n" buf end
error(msg)
click to toggle source
# File lib/review/inaobuilder.rb, line 51 def error(msg) $stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}" end
extname()
click to toggle source
# File lib/review/inaobuilder.rb, line 28 def extname '.txt' end
footnote(id, str)
click to toggle source
# File lib/review/inaobuilder.rb, line 102 def footnote(id, str) # "" end
headline(level, label, caption)
click to toggle source
# File lib/review/inaobuilder.rb, line 69 def headline(level, label, caption) prefix = "■" * level "#{prefix}#{caption}\n" end
image(lines, id, caption, metric=nil)
click to toggle source
# File lib/review/inaobuilder.rb, line 245 def image(lines, id, caption, metric=nil) buf = "" if get_chap.nil? buf << "●図#{@chapter.image(id).number} #{caption}\n" else buf << "●図#{get_chap}.#{@chapter.image(id).number} #{caption}\n" end if @chapter.image(id).bound? buf << @chapter.image(id).path << "\n" else lines.each do |line| buf << line + "\n" end end buf end
inline_b(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 86 def inline_b(str) "◆b/◆#{str}◆/b◆" end
inline_balloon(str)
click to toggle source
o1,o2のようなことはできない
# File lib/review/inaobuilder.rb, line 217 def inline_balloon(str) "◆comment/◆#{str}◆/comment◆" end
inline_cmd(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 98 def inline_cmd(str) inline_tt(str) end
inline_comment(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 221 def inline_comment(str) inline_balloon(str) end
inline_fn(id)
click to toggle source
# File lib/review/inaobuilder.rb, line 107 def inline_fn(id) "◆注/◆#{@chapter.footnote(id).content.strip}◆/注◆" end
inline_i(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 90 def inline_i(str) "◆i/◆#{str}◆/i◆" end
inline_img(id)
click to toggle source
# File lib/review/inaobuilder.rb, line 236 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 115 def inline_kbd(str) inline_keytop(str) end
inline_keytop(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 111 def inline_keytop(str) "#{str}▲" end
inline_list(id)
click to toggle source
# File lib/review/inaobuilder.rb, line 167 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 340 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 94 def inline_tt(str) "◆cmd/◆#{str}◆/cmd◆" end
inline_uchar(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 344 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 186 def list_body(id, lines, lang) buf = "" lines.each do |line| buf << detab(line) << "\n" end buf << "◆/list◆\n" buf end
list_header(id, caption, lang)
click to toggle source
# File lib/review/inaobuilder.rb, line 176 def list_header(id, caption, lang) buf = "◆list/◆\n" if get_chap.nil? buf << %Q[●リスト#{@chapter.list(id).number} #{caption}\n] else buf << %Q[●リスト#{get_chap}.#{@chapter.list(id).number} #{caption}\n] end buf end
listnum_body(lines, lang)
click to toggle source
# File lib/review/inaobuilder.rb, line 195 def listnum_body(lines, lang) buf = "" lines.each_with_index do |line, i| buf << detab((i+1).to_s.rjust(2) + " " + line) << "\n" end buf << "◆/list◆\n" buf end
messages()
click to toggle source
# File lib/review/inaobuilder.rb, line 55 def messages error_messages() + warning_messages() end
nofunc_text(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 352 def nofunc_text(str) str end
noindent()
click to toggle source
# File lib/review/inaobuilder.rb, line 82 def noindent @noindent = true end
ol_begin()
click to toggle source
# File lib/review/inaobuilder.rb, line 153 def ol_begin @olitem = 0 "" end
ol_end()
click to toggle source
# File lib/review/inaobuilder.rb, line 162 def ol_end @olitem = nil "" end
ol_item(lines, num)
click to toggle source
# File lib/review/inaobuilder.rb, line 158 def ol_item(lines, num) "(#{num})#{lines.join}\n" end
paragraph(lines)
click to toggle source
# File lib/review/inaobuilder.rb, line 74 def paragraph(lines) buf = "" buf << " " if @noindent.nil? @noindent = nil buf << lines.join + "\n" buf end
post_paragraph()
click to toggle source
# File lib/review/inaobuilder.rb, line 24 def post_paragraph '' end
pre_paragraph()
click to toggle source
# File lib/review/inaobuilder.rb, line 20 def pre_paragraph '' end
quote(lines)
click to toggle source
# File lib/review/inaobuilder.rb, line 125 def quote(lines) lines_fixed = lines.map{|line| line.sub(/^ /,"")} ## インデントを消す base_parablock "quote", lines_fixed, nil 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) buf = "" 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) buf << "◆table/◆\n" begin buf << table_header(id, caption) unless caption.nil? rescue KeyError error "no such table: #{id}" end return buf if rows.empty? buf << table_begin(rows.first.size) if sepidx sepidx.times do buf << "◆table-title◆" buf << tr(rows.shift.map {|s| th(s) }) end rows.each do |cols| buf << tr(cols.map {|s| td(s) }) end else rows.each do |cols| h, *cs = *cols buf << tr([th(h)] + cs.map {|s| td(s) }) end end buf << table_end buf end
table_begin(ncols)
click to toggle source
# File lib/review/inaobuilder.rb, line 320 def table_begin(ncols) "" end
table_end()
click to toggle source
# File lib/review/inaobuilder.rb, line 336 def table_end "◆/table◆\n" end
table_header(id, caption)
click to toggle source
# File lib/review/inaobuilder.rb, line 312 def table_header(id, caption) if get_chap.nil? "●表#{@chapter.table(id).number} #{caption}\n" else "●表#{get_chap}.#{@chapter.table(id).number} #{caption}\n" end end
td(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 332 def td(str) str end
text(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 348 def text(str) str end
th(str)
click to toggle source
# File lib/review/inaobuilder.rb, line 328 def th(str) str end
tr(rows)
click to toggle source
# File lib/review/inaobuilder.rb, line 324 def tr(rows) rows.join("\t") + "\n" end
ul_begin()
click to toggle source
# File lib/review/inaobuilder.rb, line 141 def ul_begin "" end
ul_end()
click to toggle source
# File lib/review/inaobuilder.rb, line 149 def ul_end "" end
ul_item(lines)
click to toggle source
# File lib/review/inaobuilder.rb, line 145 def ul_item(lines) "・#{lines.join}\n" end
warn(msg)
click to toggle source
# File lib/review/inaobuilder.rb, line 47 def warn(msg) $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}" end
Private Instance Methods
builder_init_file()
click to toggle source
# File lib/review/inaobuilder.rb, line 32 def builder_init_file @noindent = nil @titles = { "emlist" => "list", "list" => "list", "cmd" => "list", "source" => "list", "quote" => "quote", "column" => "column", } end