def to_data(force_level = :none)
      cells       = [] 
      merges      = []
      col_widths  = {}
      row_heights = {}

      css.reset(force_level)

      tb  = doc.css('table').first 

      # ignoring specified formats for anything other than table tr td/th
      tb_format = css.format_from_node(tb) 

      row = 0
      doc.css('tr').each do |tr|
        tr_format = tb_format.merge(@css.format_from_node(tr))

        increment = true
        tr.css('td, th').each_with_index do |td, col|
           
          # TODO Do we really need rowheight and colwidth now that there
          # is css parsing?
          rowheight = td.attributes["rowheight"]
          colwidth  = td.attributes["colwidth"]
          rowspan   = td.attributes["rowspan"]
          colspan   = td.attributes["colspan"]

          rowheight &&= rowheight.value.to_i
          colwidth  &&= colwidth.value.to_i
          rowspan   &&= rowspan.value.to_i
          colspan   &&= colspan.value.to_i

          add_td_to_cells(row, col, td, tr_format, cells)
          if colspan
            (1..colspan-1).each {|t| 
              add_td_to_cells(row, col+t, td, tr_format, cells)
            }
          end
          if rowspan
            (1..rowspan-2).each {|t| 
              add_td_to_cells(row+t, col, td, tr_format, cells)
            }
            increment = false
          end
          if colspan || rowspan
            merges << [
              row, col, row + (rowspan || 2)-2, col + (colspan || 1)-1
            ]
          end
        end

        row += 1 if increment
      end

      puts cells.inspect
      { cells: cells, merges: { 0 => merges } }
    end
def to_data(force_level = :none)
      cells       = [] 
      merges      = []
      col_widths  = {}
      row_heights = {}

      css.reset(force_level)

      tb  = doc.css('table').first 

      # ignoring specified formats for anything other than table tr td/th
      tb_format = css.format_from_node(tb) 

      row = 0
      doc.css('tr').each do |tr|
        tr_format = tb_format.merge(@css.format_from_node(tr))

        increment = true
        tr.css('td, th').each_with_index do |td, col|
           
          # TODO Do we really need rowheight and colwidth now that there
          # is css parsing?
          rowheight = td.attributes["rowheight"]
          colwidth  = td.attributes["colwidth"]
          rowspan   = td.attributes["rowspan"]
          colspan   = td.attributes["colspan"]

          rowheight &&= rowheight.value.to_i
          colwidth  &&= colwidth.value.to_i
          rowspan   &&= rowspan.value.to_i
          colspan   &&= colspan.value.to_i

          add_td_to_cells(row, col, td, tr_format, cells)
          if colspan
            (1..colspan-1).each {|t| 
              add_td_to_cells(row, col+t, td, tr_format, cells)
            }
          end
          if rowspan
            (1..rowspan-2).each {|t| 
              add_td_to_cells(row+t, col, td, tr_format, cells)
            }
            increment = false
          end
          if colspan || rowspan
            merges << [
              row, col, row + (rowspan || 2)-2, col + (colspan || 1)-1
            ]
          end
        end

        row += 1 if increment
      end

      puts cells.inspect
      { cells: cells, merges: { 0 => merges } }
    end
TODO clean this up