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



840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'lib/asciidoctor/latex/node_processors.rb', line 840

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