Sha256: 932018775f67a5424875245ca043dfc31e5cc23a449dfc0ebc25cec3dd1f89e5
Contents?: true
Size: 1.89 KB
Versions: 22
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true module Stepmod module Utils module Converters class Table < ReverseAdoc::Converters::Base def self.pattern(state, id) if state[:schema_and_entity].nil? raise StandardError.new("[table]: no state given, #{id}") end schema = state[:schema_and_entity].split(".").first "table-#{schema}-#{id}" end def convert(node, state = {}) # If we want to skip this node return "" if state[:no_notes_examples] id = node["id"] anchor = id ? "[[table-#{self.class.pattern(state, 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 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 def rules(node) case node["rules"] when "all" "rules=all" when "rows" "rules=rows" when "cols" "rules=cols" when "none" "rules=none" end end 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 end ReverseAdoc::Converters.register :table, Table.new end end end
Version data entries
22 entries across 22 versions & 1 rubygems