Sha256: a5e60ee8ffb4a5a59cd4a4902abbd1ee0e58ddb4b3854d0bb07ce4232963eea0

Contents?: true

Size: 1.94 KB

Versions: 19

Compression:

Stored size: 1.94 KB

Contents

require 'cgi'

def title
  puts "<center><h2>#{_data}</h2></center>"
end

def section
  puts "<br>" * 2 + "<b><font size=+1>#{_data}</font></b>" + "<br>"
end

def code
  _puts "<pre>"
  _body {|line| _puts "   #{::CGI.escape_html(line)}" }   # indentation
  _puts "</pre>"
end

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 = OLD_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 p
# puts "<p>"
  _passthru(_data)
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>
      <td width=50%><b>Input</b></td>
      <td width=50%><b>Output</b></td>
    </tr>
    <tr>
      <td width=50% bgcolor=#fec0fe valign=top>
        <pre>#{t1}</pre>
      </td>
      <td width=50% bgcolor=lightgray valign=top>
        <pre>#{t2}</pre>
      </td>
    </tr>
    </table>
    </center>
  HTML
end

def testcase
  name = _args.first
  _puts "\n<b>Test: <tt>#{name.gsub(/_/, "\\_")}</tt></b><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.
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
livetext-0.7.3 ./dsl/tutorial.rb
livetext-0.7.2 ./dsl/tutorial.rb
livetext-0.7.1 ./dsl/tutorial.rb
livetext-0.7.0 ./dsl/tutorial.rb
livetext-0.6.9 ./dsl/tutorial.rb
livetext-0.6.8 ./dsl/tutorial.rb
livetext-0.6.7 ./dsl/tutorial.rb
livetext-0.6.5 ./dsl/tutorial.rb
livetext-0.6.4 ./dsl/tutorial.rb
livetext-0.6.3 ./dsl/tutorial.rb
livetext-0.6.2 ./dsl/tutorial.rb
livetext-0.6.1 ./dsl/tutorial.rb
livetext-0.6.0 ./dsl/tutorial.rb
livetext-0.5.9 ./dsl/tutorial.rb
livetext-0.5.8 ./dsl/tutorial.rb
livetext-0.5.7 ./dsl/tutorial.rb
livetext-0.5.6 ./lib/tutorial.rb
livetext-0.5.4 ./lib/tutorial.rb
livetext-0.5.3 ./lib/tutorial.rb