Module: Metanorma::Mirror::Output::HtmlRenderers::TableRenderers
- Included in:
- Metanorma::Mirror::Output::HtmlRenderer
- Defined in:
- lib/metanorma/mirror/output/html_renderers/table_renderers.rb
Constant Summary collapse
- WRAPPER_TAGS =
{ "table_head" => "thead", "table_foot" => "tfoot", "table_body" => "tbody", }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.register(registry) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/metanorma/mirror/output/html_renderers/table_renderers.rb', line 14 def self.register(registry) registry.register_node_handler("table", instance_method(:render_table)) registry.register_node_handler("table_head", instance_method(:render_table_section)) registry.register_node_handler("table_body", instance_method(:render_table_section)) registry.register_node_handler("table_foot", instance_method(:render_table_section)) end |
Instance Method Details
#render_table(node, depth: 0) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/metanorma/mirror/output/html_renderers/table_renderers.rb', line 25 def render_table(node, depth: 0) sections = node.content.grep(Model::Container) HtmlRenderers.build do |doc| attrs = { class: "mn-table" } attrs[:id] = node.attrs["id"] if node.attrs["id"] doc.div(attrs) do if node.attrs["title"] doc.div(class: "mn-table__header") do doc.text node.attrs["title"] end end doc.table do sections.each do |section| HtmlRenderers.(doc, build_table_section(section)) end end end end end |
#render_table_section(node, depth: 0) ⇒ Object
46 47 48 |
# File 'lib/metanorma/mirror/output/html_renderers/table_renderers.rb', line 46 def render_table_section(node, depth: 0) build_table_section(node) end |