Method: MaRuKu::Out::HTML#to_html_table

Defined in:
lib/maruku/output/to_html.rb

#to_html_tableObject



798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
# File 'lib/maruku/output/to_html.rb', line 798

def to_html_table
  num_columns = self.align.size

  head, *rows = @children.each_slice(num_columns).to_a

  table = html_element('table')
  thead = xelem('thead')
  tr = xelem('tr')
  array_to_html(head).inject(tr, &:<<)
  thead << tr
  table << thead

  tbody = xelem('tbody')
  rows.each do |row|
    tr = xelem('tr')
    array_to_html(row).each_with_index do |x, i|
      x['style'] ="text-align: #{self.align[i].to_s};"
      tr << x
    end

    tbody << tr << xml_newline
  end

  table << tbody
end