#!/usr/local/bin/ruby -s
#$sin = "----------"
=begin
txt2rd : 任意のテキストを RD 化する。
=end
puts "=begin"
indents = ARGV.length+2
ARGV.collect() do |filename|
  fn = File.basename(filename)
  str = ""
  space = nil
  open (filename) do |fd|
    indents -= 1
    space = " " * indents
#    str <<  "#{space}Code: #{fn}\n" unless $sin
    str <<  "#{space}# #{fn}\n\n" unless $sin
    str << "#{space}#$sin^ #{fn}\n" if $sin
    while fd.gets
      str << space << $_.sub(/^\t/," "*8)
    end
  end
  str << "#{space}#$sin$ #{fn}\n" if $sin
  str << "\n" if str[-1] != ?\n
  str
end.join("\n").display
puts "=end"
