Class: Asciidoctor::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/latex/node_processors.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) tex_process



628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File 'lib/asciidoctor/latex/node_processors.rb', line 628

def tex_process
    # # warn "This is Asciidoctor::Table, tex_process.  I don't know how to do that".yellow +  " (#{self.node_name})".magenta if $VERBOSE
    # table = Table.new self.parent, self.attributes
    n_rows = self.rows.body.count
    n_columns = self.columns.count
    alignment = (['c']*n_columns).join('|')
    output = "\\begin\{center\}\n"
    output << "\\begin\{tabular\}\{|#{alignment}|\}\n"
    output << "\\hline\n"
    self.rows.body.each_with_index do |row, index|
      row_array = []
      row.each do |cell|
        row_array << cell.content[0]
      end
      output << row_array.join(' & ')
      output << " \\\\ \n"
    end
    output << "\\hline\n"
    output << "\\end{tabular}\n"
    output << "\\end{center}\n"
    "#{output}"
end