#! /usr/bin/perl
-# $Cambridge: exim/doc/doc-docbook/TidyHTML-filter,v 1.1 2005/06/16 10:32:31 ph10 Exp $
+# $Cambridge: exim/doc/doc-docbook/TidyHTML-filter,v 1.2 2005/11/10 12:30:13 ph10 Exp $
# Script to tidy up the filter HTML file that is generated by xmlto. The
# following changes are made:
#
# 1. Split very long lines.
# 2. Create reverse links from chapter and section titles back to the TOC.
+# 3. Turn <div class="literallayout"><p> into <div class="literallayout"> and
+# a matching </p></div> into </div> to get rid of unwanted vertical white
+# space.
$tocref = 1;
+$thisdiv = 0;
# Read in the filter.html file.
for (; $i < scalar(@text); $i++)
{
- if ($text[$i] =~ /^<h[23] /)
+ if ($text[$i] eq "<div class=\"literallayout\">\n" && $text[$i+1] eq "<p>\n")
+ {
+ $text[++$i] = "";
+ $thisdiv = 1;
+ }
+ elsif ($thisdiv && $text[$i] eq "</p>\n" && $text[$i+1] eq "</div>\n")
+ {
+ $text[$i] = "";
+ $thisdiv = 0;
+ }
+ elsif ($text[$i] =~ /^<h[23] /)
{
$i++;
if ($text[$i] =~ /^<a( xmlns="[^"]+")? id="([^"]+)">$/)