#!usr/local/bin/perl # Perl program that replaces paragraph tags for paragraphs that contain # textlines with changebars # Paragraphs that contain changed lines have the tag replaced with # _New # # Copyright Jesper Storm Bache, 1998 (jesper@bache.com) # For license to use see "HelpWare" clause on: # www.bache.com/sgml.html # # Version 0.8 # # ======= Subroutines ======== # This procedure reads all the lines that are associated with # a footnote or a paragraph or a table cell sub readPara { undef @a; $a[0]="not used"; $lineno=0; if ($_[0]) { $theType="Para"; } else { $theType="FNote"; } $a[++$lineno]=" <$theType"; while (<>) { chomp; $a[++$lineno]=$_; last if /^\s+\> \# end of $theType\s*$/; } } # This function scans the lines associated with a paragraph/Footnote # and returns true if one or more lines have a changebar # otherwise the function returns false sub paraHasChangeBar { $i=1; while ($i<=$lineno-3) { # If you use font overrides you might want to delete # the following two lines. I.e. the /)); return 1; } return 0; } # ======= Main loop ======== # The outher loop runs through the MIF until a textflow is # encountered. When a text flow is found the inner loop is activated # The inner loop reads the paragraphs from the text flow, and # checks if any line in the paragraph has a changebar. # If a changebar is found the paragrapg tag is changed to # _New while (<>) { # Copy until start of textflow while (!/^\; } last if /\# End of MIFFile\s*$/; print $_; # This is equal to the ; # Get tag of text flow print $_; # Don't parse the HTML textflows next if /^ \/; # Deal with the contents of the textflow while (<>) { # If the textflow ended exit the inner loop if (/\> # end of TextFlow\s*$/ || /\> # end of Tbls\s*$/) { print $_; last; } # skip to the next para/footnote $isPara = /^\s+\/)) { print " \n"; } else { print "$a[$i]\n"; } } } else { print $_; } } }