summaryrefslogtreecommitdiff
path: root/tabella.pl
blob: 93c1123946ca3bf9f84e1c2b155b165043260ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl 
use strict;
use warnings;
 
my @lineterm=qw(& & \\\\);
my $state=0;my $mline=0;
while (my $line=<>) {
    if ($state==0) {
        if ($line=~/matrix/) {$state=1};
    }
    if ($state==1) {
        if ($line=~/{/) {$state=2};
    }
    if ($line=~/\\end/) {$state=3}
    if ($state==2) {
        $line=~s[}\s*(&|\\\\|)\s*(%.*)?$][$lineterm[$mline%3] $2\n] 
            and ++$mline;
    }
    print $line;
    if ($mline==18) {
        $mline=0;
        print <<'EOM';
};
\end{tikzpicture}
 
\begin{tikzpicture}
\matrix
{
EOM
    }
}