Class: Slaw::Grammars::Tables::Table
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Slaw::Grammars::Tables::Table
- Defined in:
- lib/slaw/grammars/tables_nodes.rb
Instance Method Summary collapse
Instance Method Details
#to_xml(b, idprefix, i = 0) ⇒ Object
5 6 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 |
# File 'lib/slaw/grammars/tables_nodes.rb', line 5 def to_xml(b, idprefix, i=0) b.table(id: "#{idprefix}table#{i}") { |b| # we'll gather cells into this row list rows = [] cells = [] for child in table_body.elements if child.is_a? TableCell # cell cells << child else # new row marker rows << cells unless cells.empty? cells = [] end end rows << cells unless cells.empty? for row in rows b.tr { |tr| for cell in row cell.to_xml(tr, "") end } end } end |