#!/usr/local/bin/perl # # David MacKay 4 June 94 # # delatex3.p - program to strip out tex stuff from bbl file # $killem = 1 ; # if this is 0, \em gets turned into $EM$ while( <>){ if ( /\\end\{document\}/ ) { last ; } # if there is a % character (not \% ) then delete what follows. s/\\\%/ /g; s/\%.*$//; # replace accents by themselves s/\\(["'`])/$1/g; if ( /\\harvarditem/ || /\\newcommand/ || /\\begin/ || /\\bibitem/ || /\}\]\{/ || /\\end/ ) { next ; } # NB if these strings appear in a line, the whole line is # skipped. # the string }]{ indicates a bibitem continued on # a 2nd line. The best solution would have been to find the matching # braces. s/\\newblock//g; s/\{(\w+)\}/$1/g; # changes {B}ayes to Bayes s/\~/ /g; s/\\rm//g; if ( $killem ) { s/\\it//g; s/\\em//g; s/\\bf//g; s/\\sc//g; } else { s/\\it/\$EM\$/g; s/\\em/\$EM\$/g; s/\\bf/\$BF\$/g; s/\\sc/\$SC\$/g; } s/\\lsaand/and/g ; s/lsadashify//g ; s#\\/##g; s/\{|\}|\\//g; print ; }