class Slaw::Grammars::Tables::TableCell

Public Instance Methods

to_xml(b, idprefix) click to toggle source
# File lib/slaw/grammars/tables_nodes.rb, line 37
def to_xml(b, idprefix)
  tag = table_cell_start.th? ? 'th' : 'td'

  attrs = {}
  if not attribs.empty?
    for item in attribs.attribs.elements
      # key=value (strip quotes around value)
      attrs[item.name.text_value.strip] = item.value.text_value[1..-2]
    end
  end

  b.send(tag.to_sym, attrs) { |b|
    b.p { |b|
      # first line, and the rest
      lines = [content.line] + content.elements.last.elements.map(&:line)

      lines.each_with_index do |line, i|
        line.to_xml(b, i, i == lines.length-1)
      end
    }
  }
end