Class: Docbook::Mirror::Handlers::Table
- Inherits:
-
Object
- Object
- Docbook::Mirror::Handlers::Table
- Defined in:
- lib/docbook/mirror/handlers/table.rb
Class Method Summary collapse
Class Method Details
.build_table_rows(rows) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/docbook/mirror/handlers/table.rb', line 38 def self.build_table_rows(rows) rows.map do |row| cells = row.entry.map do |entry| cell_content = [] text = entry.content.join.strip cell_content << Node::Text.new(text: text) unless text.empty? cell_attrs = {} cell_attrs[:align] = entry.align if entry.align cell_attrs[:valign] = entry.valign if entry.valign cell_attrs[:namest] = entry.namest if entry.namest cell_attrs[:nameend] = entry.nameend if entry.nameend cell_attrs[:morerows] = entry.morerows if entry.morerows Node::TableCell.new(attrs: cell_attrs.compact, content: cell_content) end Node::TableRow.new(content: cells) end end |
.call(element, context:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/docbook/mirror/handlers/table.rb', line 7 def self.call(element, context:) attrs = {} attrs[:xml_id] = element.xml_id if element.xml_id if element.title attrs[:title] = element.title.content.join end attrs[:frame] = element.frame if element.frame attrs[:colsep] = element.colsep if element.colsep attrs[:rowsep] = element.rowsep if element.rowsep table_content = [] tgroups = element.tgroup tgroups.each do |tg| attrs[:cols] = tg.cols if tg.cols if tg.thead head_rows = build_table_rows(tg.thead.row) table_content << Node::TableHead.new(content: head_rows) unless head_rows.empty? end next unless tg.tbody body_rows = build_table_rows(tg.tbody.row) table_content << Node::TableBody.new(content: body_rows) unless body_rows.empty? end Node::Table.new(attrs: attrs.compact, content: table_content) end |