$1
\n\n"); }; $html2html->{rules}->{'^<@@head>(.*)$'} = sub { $skipnewline = 1; $headbuf = $1; }; $html2html->{rules}->{'^<@@part>.*$'} = sub { $current = "PART"; }; $html2html->{rules}->{'^<@@endhead>.*$'} = sub { SWITCH: { $outfh->print("$headbuf
\n\n"), last SWITCH if ($current eq "PART"); $outfh->print("$headbuf
\n\n"), last SWITCH if ($current eq "CHAPTER"); $outfh->print("$headbuf
\n\n"), last SWITCH if ($current eq "SECTION"); $outfh->print("$headbuf
\n\n"), last SWITCH if ($current eq "SUBSECT"); $outfh->print("$headbuf
\n\n"), last SWITCH; } $current = ""; $headbuf = ""; $skipnewline = 0; }; $html2html->{rules}->{'^<@@chapt>(.*)$'} = sub { $chapter_mode = 1; $skipnewline = 1; $sectname = $1; &start_chapter($sectname); }; $html2html->{rules}->{'^<@@sect>(.*)$'} = sub { $skipnewline = 1; $ssectname = $1; if ($chapter_mode) { &start_section($ssectname); } else { $sectname = $ssectname; &start_chapter($ssectname); } }; $html2html->{rules}->{'^<@@ssect>(.*)$'} = sub { $skipnewline = 1; $ssectname = $1; if (!$chapter_mode) { &start_section($ssectname); } else { $current = ""; $headbuf = $ssectname; } }; $html2html->{rules}->{'^<@@endchapt>.*$'} = sub { STDOUT->print("\n") if ($in_section_list); if ($outfh->fileno != STDOUT->fileno) { &footing($outfh) if (!$super_page_mode); $outfh->close; $outfh = STDOUT; } }; $html2html->{rules}->{'^<@@endsect>.*$'} = sub { STDOUT->print("\n") if (!$chapter_mode && $in_section_list); if (($outfh->fileno != STDOUT->fileno) && ((!$chapter_mode) || (!$big_page_mode))) { &footing($outfh) if (!$super_page_mode); $outfh->close; $outfh = STDOUT; } }; $html2html->{rules}->{'^<@@endssect>.*$'} = sub { if (($outfh->fileno != STDOUT->fileno) && (!$chapter_mode) && (!$big_page_mode) && (!$super_page_mode)) { &footing($outfh); $outfh->close; $outfh = STDOUT; } }; $html2html->{rules}->{'^<@@enddoc>.*$'} = sub { }; $html2html->{rules}->{'^<@@label>(.*)$'} = sub { if (!defined($lprec->{$1})) { STDERR->print(qq(html2html: Problem with label "$1"\n)); next; } if ($skipnewline) { $headbuf = sprintf(qq( %s), $1, $headbuf); } else { $outfh->print(qq( )); } }; $html2html->{rules}->{'^<@@ref>(.*)$'} = sub { my $tmp; $refname = $1; if (!defined($lprec->{$1})) { STDERR->print(qq(html2html: Problem with ref "$1"\n)); $skipnewline++; next; } SWITCH: { $tmp = qq(), last SWITCH if ($lprec->{$1} == $filenum - 1); $tmp = qq(), last SWITCH if ($lprec->{$1} == 0); $tmp = qq(), last SWITCH; } if ($skipnewline) { $headbuf = "$headbuf$tmp"; } else { $headbuf = $tmp; } $skipnewline++; }; $html2html->{rules}->{'^<@@refnam>.*$'} = sub { $headbuf = "$headbuf$refname\n"; }; $html2html->{rules}->{'^<@@endref>.*$'} = sub { if ($skipnewline == 1) { $outfh->print($headbuf); $skipnewline = -1; } elsif ($skipnewline == 2) { $skipnewline--; } else { STDERR->print("html2html: Problem with endref\n"); $skipnewline--; } }; # Default parsing rule $html2html->{defaultrule} = sub { $skipnewline++ if ($skipnewline < 0); if ($skipnewline) { chop; $headbuf = "$headbuf$_"; } else { $outfh->print($_); } }; # Finalize parsing process $html2html->{finish} = sub { # Finish footers if ($outfh->fileno != STDOUT->fileno) { if (!$super_page_mode) { &footing($outfh); $outfh->close; } } # if ($super_page_mode) { if ($toclevel > 0) { STDOUT->print("\n\n"); } $outfh->close if ($outfh->fileno != STDOUT->fileno); if ( -r $content_file ) { open CONTENT, "<$content_file" or die "Can't open content file\n"; while (