#
# fix_print_html.lib
#
#   Dan Scott  / 
#   Ferg       / 
#
#   Used to prepare single-file HTML variant for PDF/Postscript creation
#   thru htmldoc.
#
# log:
#     16Oct2000 - 0.1   - initial entry 
#     03Apr2001 - 0.2   - fix for 
#     05Jul2001 - 0.3   - fix for  and -f
#     12Oct2001 - 0.4   - fix for sections; loop thru both files (body/title)
#     27Nov2001 - 0.5   - fixed bug in determining where doc-index lies
#     18Jan2002 - 0.5.1 - entity fix (822*)
#     02Apr2002 - 0.6   - misc fixes (bibliography/appendix, etc).
#     04Apr2002 - 0.7   - fix for newer DSSSL
#
sub fix_print_html {
   my($in,$out,$ttl) = @_;
   open(IN_FILE, "< $in") || do {
        print "fix_print_html: cannot open $in: $!\n";
        return 0;
   };
   my($buf, $ttl_buf) = '';
   my($indx) = -1;
   my($is_article) = 1;
   while() {
         if( $indx == 1 ) {
             # ignore everything until we see the chapter or sect
             #
             if( $_ =~ /CLASS="CHAP/i || $_ =~ /CLASS="PREF/i
                 ||
                 $_ =~ /CLASS="SECT/i )  {
                 $buf .= $_;
                 $indx++;
             } else {
                 next;
             }
         } elsif( $indx == 0 ) {
             # write out the title page file
             #
             if( $_ =~ /CLASS="TOC"/ ) {
                 $ttl_buf .= ">\n