#!/usr/bin/perl
# Rude script to convert a html-file to a sgml-file in a format
# suitabel for linuxdoc-sgml
# (c) Peter Antman, 1997.
#
# 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 program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

$THISPROG = "mkbook 0.1";


$usage = "usage: mkbook fil.sgml";

#print "hej";

die $usage if @ARGV < 1;
$sgmlfile = shift (@ARGV);

$sgmlfile =~ /([\S]*?)\.sgml/;
$filename = $1;
$bookfile = "$filename-book.sgml";
print "$bookfile";
open (sgml, $sgmlfile);
open (book, ">$bookfile");

while (<sgml>) {
	s/<article>/<book>/gi;
	s/<\/article>/<\/book>/gi;
	
	s/<sect>/<chapt>/gi;
	s/<sect1>/<sect>/gi;
	s/<sect2>/<sect1>/gi;
	s/<sect3>/<sect2>/gi;
	s/<sect4>/<sect3>/gi;
	s/<sect5>/<sect4>/gi;

#	s/<abstract>|<\/abstract>//gi;
#	print;
	print book;
}

close book;
