dsl/tutorial.rb in livetext-0.8.1 vs dsl/tutorial.rb in livetext-0.8.2
- old
+ new
@@ -1,13 +1,13 @@
require 'cgi'
def title
- puts "<center><h2>#{@_data}</h2></center>"
+ h1
end
def section
- puts "<br>" * 2 + "<b><font size=+1>#{@_data}</font></b>" + "<br>"
+ h3
end
def code
_puts "<pre>"
_body {|line| _puts " #{::CGI.escape_html(line)}" } # indentation
@@ -16,46 +16,17 @@
def rx(str)
::Regexp.compile(::Regexp.escape(str))
end
-def list
- puts "<ul>"
- _body {|line| puts "<li>#{_formatting(line)}</li>" }
- _puts "</ul>"
-end
-
-def nlist
- puts "<ol>"
- _body {|line| puts "<li>#{_formatting(line)}</li>" }
- _puts "</ol>"
-end
-
-def dlist
- delim = "~~"
- _puts "<table>"
- _body do |line|
-# @tty.puts "Line = #{line}"
- line = _formatting(line)
-# @tty.puts "Line = #{line}\n "
- term, defn = line.split(delim)
- _puts "<tr>"
- _puts "<td width=3%><td width=10%>#{term}</td><td>#{defn}</td>"
- _puts "</tr>"
- end
- _puts "</table>"
-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
-# t1 = ::CGI.escape_html(t1)
-# t2 = ::CGI.escape_html(t2)
puts <<-HTML
<center>
<table width=80% cellpadding=4>
<tr>
@@ -101,13 +72,11 @@
HTML
end
def testcase
name = _args.first
-# _puts "\n<b>Test: <tt>#{name.gsub(/_/, "\\_")}</tt></b><br>"
_puts "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
src, exp = "test/testfiles/#{name}/source.ltx", "test/testfiles/#{name}/expected-output.txt"
@_args = [src, exp] # Better way to do this??
-# inout # Weird - only place I've done this yet.
put_table(src, exp)
_puts "<br>"
end