<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -i 

undef $/;
$file = &lt;&gt;;

$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/\|\|/&amp;/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
</pre></body></html>