#!/usr/local/bin/perl # # David MacKay August 94 # and TTJ # # delatex1a.p - reads in stuff in one array to do ignores right. # assumes that all { } are matched within the ignore. # $* = 1 ; @a = <>; @b = split ( /\\ign/ , join( '' , @a ) ); foreach $e (@b) { # print "String: $e\n"; if ( !($e =~ s/^ore\{// ) ) { next ; } # this preserves the initial block which # does not start with an ignore{ # $e =~ s/ore\{//; $ply = 1 ; while ( $ply > 0 && $e =~ m/(\{|\})/) { # figure out which has happened # print "ply $ply $1 "; if ( $1 eq "\}" ) { $ply -- ; $e =~ s/^[^\}]*\}//; } elsif ( $1 eq "\{" ) { $ply ++ ; $e =~ s/^[^\{]*\{//; } else { print STDERR "ERROR " , $1, "\n" ; } } # print "\n"; } print join ( '' , @b ) ;