Class: RT::RT2HTMLVisitor

Inherits:
RTVisitor show all
Defined in:
lib/rt/rt2html-lib.rb

Direct Known Subclasses

RT2TXTVisitor

Constant Summary collapse

OUTPUT_SUFFIX =
"html"
INCLUDE_SUFFIX =
["html"]

Instance Attribute Summary

Attributes inherited from RTVisitor

#body, #caption, #charcode, #filename, #header, #rt

Instance Method Summary collapse

Methods inherited from RTVisitor

visit, #visit, #visit_Caption

Constructor Details

#initializeRT2HTMLVisitor

Returns a new instance of RT2HTMLVisitor.



14
# File 'lib/rt/rt2html-lib.rb', line 14

def initialize() super end

Instance Method Details

#setupObject



26
27
28
29
30
31
32
# File 'lib/rt/rt2html-lib.rb', line 26

def setup
  block('setup') do
    s = %Q[<table border="1">\n]
    s << %Q[<caption>#{esc(caption)}</caption>\n] if caption
    s
  end
end

#teardownObject



34
35
36
37
38
# File 'lib/rt/rt2html-lib.rb', line 34

def teardown
  block('teardown') do
    %Q[</table>\n]
  end
end

#visit_Body(ary = @body) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/rt/rt2html-lib.rb', line 75

def visit_Body(ary = @body)
  block('Body') do
    ret = "<tbody>\n"
    ary.each do |line|
      ret << '<tr>'
      each_cell(line) do |cell|
        ret << cell_element(cell, %Q[td align="#{cell.align.id2name}"])
        ret << esc(cell.value)
        ret << '</td>'
      end
      ret << "</tr>\n"
    end
    ret << "</tbody>\n"
  end
end

#visit_Header(ary = @header) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rt/rt2html-lib.rb', line 55

def visit_Header(ary = @header)
  block('Header') do
    if ary.empty?
      ""
    else
      ret = "<thead>\n"
      ary.each do |line|
        ret << '<tr>'
        each_cell(line) do |cell|
          ret << cell_element(cell, 'th')
          ret << esc(cell.value)
          ret << '</th>'
        end
        ret << "</tr>\n"
      end
      ret << "</thead>\n"
    end
  end
end