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.



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

def initialize
  super
end

Instance Method Details

#setupObject



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

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

#teardownObject



32
33
34
35
36
# File 'lib/rt/rt2html-lib.rb', line 32

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

#visit_Body(ary = @body) ⇒ Object



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

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 << cell.value
        ret << '</td>'
      end
      ret << "</tr>\n"
    end
    ret << "</tbody>\n"
  end
end

#visit_Header(ary = @header) ⇒ Object



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

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 << cell.value
          ret << '</th>'
        end
        ret << "</tr>\n"
      end
      ret << "</thead>\n"
    end
  end
end