#!/usr/bin/perl 

my($inaxiom) = 0;

foreach my $file (<*.input.pamphlet>) {
    my @lines = `notangle $file`;
    $fname = $file;
    $fname =~ s/\.input\.pamphlet//;
    print $fname . "\n";
    open(OUT, ">$fname.stxlatex");

    for($i=0;$i<=$#lines;$i++) {
        if($lines[$i] =~ m/^\s*--(.*)/g) {
            if($inaxiom) { print OUT "\\end{axiom}\n"; }
            print OUT $1 . "\n";
            $inaxiom=0;
        }
        elsif ($lines[$i] !~ /^\s+$/) {
            if(!$inaxiom) { print OUT "\\begin{axiom}\n"; }
            print OUT $lines[$i];
            $inaxiom=1;
        } else {
            print OUT $lines[$i];
        }
    }
    if($inaxiom) { print OUT "\\end{axiom}\n"; }
    close(OUT);
    $inaxiom=0;
}


