class Stepmod::Utils::Converters::Table

Public Instance Methods

convert(node, state = {}) click to toggle source
# File lib/stepmod/utils/converters/table.rb, line 7
def convert(node, state = {})
  id = node["id"]
  anchor = id ? "[[#{id}]]\n" : ""
  title = node["caption"].to_s
  title = ".#{title}\n" unless title.empty?
  attrs = style(node)
  "\n\n#{anchor}#{attrs}#{title}|===\n#{treat_children(node,
                                                       state)}\n|===\n"
end
frame(node) click to toggle source
# File lib/stepmod/utils/converters/table.rb, line 17
def frame(node)
  case node["frame"]
  when "void"
    "frame=none"
  when "hsides"
    "frame=topbot"
  when "vsides"
    "frame=sides"
  when "box", "border"
    "frame=all"
  end
end
rules(node) click to toggle source
# File lib/stepmod/utils/converters/table.rb, line 30
def rules(node)
  case node["rules"]
  when "all"
    "rules=all"
  when "rows"
    "rules=rows"
  when "cols"
    "rules=cols"
  when "none"
    "rules=none"
  end
end
style(node) click to toggle source
# File lib/stepmod/utils/converters/table.rb, line 43
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