#!/usr/bin/ruby BEGIN{ $stdout.puts "=begin"} END{ $stdout.puts "=end"} ARGF.each_line{ |line| if /^=/=~line then if /^=((begin)|(end))/!~ line then # out = line.reverse.sub(/(=)(=*)$/){ '*'+ ' '*($2.size) }.reverse.sub(/\*(.*)$/){ '*'+ '((<"'+ $1+ '">))'} headings = %r{^(=+)(.*)}.match(line) out = ' '*(headings[1].size- 1)+ '*' out+= '((<"'+ headings[2]+ '">))' $stdout.puts out end # if /^(begin)|(end)/=~ line then end # if /^=/=~line then }