#!/usr/bin/perl -i undef $/; $file = <>; $tableLineRE = '\|\|([^\|\n]*?)(\|\|[^\|\n]*?)*?\|\|'."\n"; $file =~ s/($tableLineRE($tableLineRE)+)/processTable($1)/eg; #$file =~ s/(.*|\n)*/'I found a table!'/gsm; print $file; sub processTable { my ($table) = @_; $table =~ /(.*)/; $tableLine1 = $1; $dividerCount = 0; while ($tableLine1 =~ /\|\|/g) { $dividerCount = $dividerCount + 1;} $colCount = $dividerCount - 1; $colSpec = '|l'.('|l' x ($colCount - 1)).'|'; $table =~ s/^\|\|(.*)\|\|$/$1/gm; $table =~ s/\|\|/&/g; $table =~ s/\n/\\\\\n/g; $table = "\\begin{tabular}{$colSpec}\n".'\hline'."\n".$table.'\hline'."\n".'\end{tabular}'; return $table; } #todo: add this to easylatex