module Export::TeX

Constants

Questions

Public Class Methods

export(io, nb_col, lines, headers, opts = {}) click to toggle source
# File lib/cless/export.rb, line 64
def self.export(io, nb_col, lines, headers, opts = {})
  io << "\\begin{tabular}{|" << (["c"] * nb_col).join("|") << "|}\\hline\n"
  if headers
    io << headers.join(" & ") 
    io << "\\tabularnewline\\hline\\hline\n"
  end
  lines.each { |a|
    a.map! { |t| t && t.gsub(/\&/, '\&').gsub(/\\/, "\\textbackslash{}") }
    io << a.join(" & ") << "\\tabularnewline\\hline\n"
  }
  io << "\\end{tabular}\n"
end