#!/usr/bin/ruby
def contents_index(fname = $0, caption=nil)
document, index, onoff = '', '', false
begin
File.open(fname){|f| document = f.readlines}
document.each do |line|
onoff = true if line.chomp=='=begin'
onoff = false if line.chomp=='=end'
term = %r{^===([^=]*)}.match(line.chomp).to_a[1]
index += " * ((<#{term}>))\n" if term and (term.length > 0) and onoff
end # document.each do |line|
res = "* #{caption}\n" if caption
res += index
return res
rescue # File.open(fname)
$stderr.print "File not found: #{$_}\n"
end # File.open(fname)
end # def contrnts_index(fname = $0)
def rubyruby(rb, rt, *rp)
case rp.size
when 0
rp = ['(', ')']
when 1
rp[1] = rp[0]
end # case rp.size
ruby = ''
ruby+= "((::))"
ruby+= "((::))#{rb}((::))"
ruby+= "((:"
ruby+= ""
ruby+= ":))"
ruby+= "((::))"
return ruby
end # def rubyruby(rb, rt, *rp)
def color(color, string)
ret = ''
ret+= '((::))'
ret+= string
ret+= '((::))'
return ret
end # def color(color, string)