#! /bin/sh 
# Copyright (c) 2003 Pierre Machard <pmachard@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

cp $1 $1.awk

# Remove the paragraph about RedHat CDROM
awk 'BEGIN { display=1 
	FS= "\n";
	loop=1 } 
{
    for (i = 1; i <= NF; i++) {
	    if ( $i ~ /RedHat\-CD\-HOWTO/) {
	    display = 0 ;
	    loop = 1 ;
	    }
	    
	    if(display) {
	    print $i }
	     
	    if ( $i ~ /<\/p><hr\/>/ && loop == 1 ) {
	    display=1 ;
	    loop=0 ;
	    }
    }
}' < $1.awk > $1

rm -f $1.awk
cp $1 $1.awk

# Clean the index and fix links
awk 'BEGIN {coeur=0} \
        /Coupez/ { 
       coeur++ ; 
       next 
       } 
       { 
       if (coeur==1) {
          gsub("vf/","")
	  gsub("html?.*\">","html\">")
          print }
       }' < $1.awk > $1

rm -f $1.awk


tidy -latin1 -m $1 > /dev/null 2> /dev/null

exit 0
