# PROGRAM TO PROCESS THE MARSH SLIDE SHOW TXT FILE INTO ConTeXt # entry types # p1 title page # p2 section title page -- horizontal slide # p3 normal page -- horizontal slide # p4 side-by-side page -- text and vertical slide # p5 biblio page # p6 the-end page #the following six subroutines are here rather than just # having an if statement at L5 because this was the # way the code worked for slides to HTML in the previous # version of the program sub dumpp1 { # an entry of type p1 $slidepattern="pone"; dumptex(); } # end sub dumpp1 sub dumpp2 { # an entry of type p2 $slidepattern="ptwo"; dumptex(); } # end sub dumpp2 sub dumpp3 { # dump an html file of type p3 $slidepattern="pthree"; dumptex(); } # end sub dumpp3 sub dumpp4 { # dump an html file of type p4 $slidepattern="pfour"; dumptex(); } # end sub dumpp4 sub dumpp5 { # dump an html file of type p5 $slidepattern="pfive"; dumptex(); } # end sub dumpp5 sub dumpp6 { # dump an html file of type p6 $slidepattern="psix"; dumptex(); } # end sub dumpp6 sub dumptex { #dump some lines of tex print(rOUT "\n"); print(rOUT '\\'.$slidepattern.'{'.$slidenumber.'}{'.$slidecaption.'}{'); $i = 0; while ($i <= $linecnt) { print(rOUT $slidetext[$i]); $i=$i+1; }; print(rOUT '}'); print(rOUT "\n"); } # end of dumping some lines of tex Start: open(IN,"scorton-marsh-script.txt") or die "can't open given input file : $!\n"; $tempoutfile=">"."scorton-marsh-script.txt".'.tex'; open(rOUT,$tempoutfile) or die "can't open tex output file: $!\n"; L1: print "\nFinding ..."; L10: if (eof(IN)) {goto EXIT;}; $inputline = ; $inputline2 = $inputline; L2: if ( $inputline !~ m/\\SLIDE/ ) {goto L10;}; # parse line into three fields, and then find fourth field if ( $inputline =~ m/\{(.+)}\{(.+)}\{(.+)}\{/ ) {$slidenumber = $1; $slidecaption = $2; $slidepattern = $3; }; #extend slidenumbers to three characters $slidenumberP1 = $slidenumber + 1; if ($slidenumberP1 < 100) {$slidenumberP1="0".$slidenumberP1}; if ($slidenumberP1 < 10) {$slidenumberP1="0".$slidenumberP1}; $slidenumberM1 = $slidenumber - 1; if ($slidenumberM1 < 100) {$slidenumberM1="0".$slidenumberM1}; if ($slidenumberM1 < 10) {$slidenumberM1="0".$slidenumberM1}; print "slide",$slidenumber," ",$slidepattern; $linecnt=0; if ( $inputline =~ m/\{(.+)}\{(.+)}\{(.+)}\{(.+)}/ ) { $slidetext[$linecnt]=$4."\n"; goto L5;}; # all slide text is on same line if ($inputline =~ m/\{(.+)}\{(.+)}\{(.+)}\{(.+)$/ ) { $slidetext[$linecnt]=$4."\n"; goto L6; }; # slide text only begins on this line print "\nProblem ?? around slide number ",$slidenumber," Shutting down"; goto L6; L6: $linecnt = $linecnt +1; # get next line of text $inputline = ; if ($inputline =~ m/^(.+)}/ ) { $slidetext[$linecnt]=$1."\n"; goto L5;}; # last line of text if ($inputline =~ m/^$/ ) {$slidetext[$linecnt]="\n"; goto L6;}; # blank line of text $slidetext[$linecnt]=$inputline; goto L6; #another line of text L5: if ( $slidepattern eq "p1") {dumpp1{}; goto L1;}; if ( $slidepattern eq "p2") {dumpp2{}; goto L1;}; if ( $slidepattern eq "p3") {dumpp3{}; goto L1;}; if ( $slidepattern eq "p4") {dumpp4{}; goto L1;}; if ( $slidepattern eq "p5") {dumpp5{}; goto L1;}; if ( $slidepattern eq "p6") {dumpp6{}; goto L1;}; print "\nFound undefined pattern type around slide ",$slidenumber; #fall into EXIT EXIT: close(rOUT); close(IN); print "\nDone converting input file to output file\n"; # END OF PROGRAM