class ReverseAdoc::Converters::Table
Public Instance Methods
convert(node, state = {})
click to toggle source
# File lib/reverse_adoc/converters/table.rb, line 4 def convert(node, state = {}) id = node['id'] anchor = id ? "[[#{id}]]\n" : "" title = extract_title(node) title = ".#{title}\n" unless title.empty? attrs = style(node) "\n\n#{anchor}#{attrs}#{title}|===\n" << treat_children(node, state) << "\n|===\n" end
extract_title(node)
click to toggle source
# File lib/reverse_adoc/converters/table.rb, line 13 def extract_title(node) title = node.at("./caption") return "" if title.nil? treat_children(title, {}) end
frame(node)
click to toggle source
# File lib/reverse_adoc/converters/table.rb, line 19 def frame(node) case node["frame"] when "void" "frame=none" when "hsides" "frame=topbot" when "vsides" "frame=sides" when "box", "border" "frame=all" else nil end end
rules(node)
click to toggle source
# File lib/reverse_adoc/converters/table.rb, line 34 def rules(node) case node["rules"] when "all" "rules=all" when "rows" "rules=rows" when "cols" "rules=cols" when "none" "rules=none" else nil end end
style(node)
click to toggle source
# File lib/reverse_adoc/converters/table.rb, line 49 def style(node) width = "width=#{node['width']}" if node['width'] attrs = [] frame_attr = frame(node) rules_attr = rules(node) attrs << width if width attrs << frame_attr if frame_attr attrs << rules_attr if rules_attr return "" if attrs.empty? "[#{attrs.join(',')}]\n" end