require 'cgi' def title h1 end def section h3 end def code _puts "
"
  _body {|line| _puts "   #{::CGI.escape_html(line)}" }   # indentation
  _puts "
" end def rx(str) ::Regexp.compile(::Regexp.escape(str)) end def inout src, out = _args t1 = ::File.readlines(src) rescue (abort "t1 = #{src}") t2 = ::File.readlines(out) rescue (abort "t2 = #{out}") # To pacify markdown for README (FIXME later) t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join puts <<-HTML
Input Output
#{t1}
#{t2}
HTML end def put_table(src, exp) t1 = ::File.readlines(src) rescue (abort "t1 = #{src}") t2 = ::File.readlines(exp) rescue (abort "t2 = #{out}") t1 = t1.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join t2 = t2.map {|x| " " + x.sub(/ +$/,"").gsub(/_/, "\\_") }.join puts <<-HTML
Input Output
#{t1}
#{t2}
HTML end def testcase name = _args.first _puts "\nTest: #{name}
" src, exp = "#{Data}/#{name}/source.lt3", "{Data}/#{name}/expected-output.txt" @_args = [src, exp] # Better way to do this?? put_table(src, exp) _puts "
" end