7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/asciidoctor/html/table.rb', line 7
def self.display_row(tsec, row)
result = ["<tr>"]
row.each do |cell|
cell_content = if tsec == :head
cell.text
elsif cell.style == :literal
"<pre>#{cell.text}</pre>"
else
cell.content.join "\n"
end
cell_tag_name = (tsec == :head || cell.style == :header ? "th" : "td")
cell_attrs = []
cell_attrs << %(halign-#{cell.attr "halign"}) unless cell.attr?("halign", "left")
cell_attrs << %(align-#{cell.attr "valign"}) unless cell.attr?("valign", "top")
cell_class_attribute = %( class="#{cell_attrs.join " "}") unless cell_attrs.empty?
cell_colspan_attribute = cell.colspan ? %( colspan="#{cell.colspan}") : ""
cell_rowspan_attribute = cell.rowspan ? %( rowspan="#{cell.rowspan}") : ""
cell_attributes = "#{cell_class_attribute}#{cell_colspan_attribute}#{cell_rowspan_attribute}"
result << %(<#{cell_tag_name}#{cell_attributes}>#{cell_content}</#{cell_tag_name}>)
end
result << "</tr>"
result.join "\n"
end
|