#!/usr/bin/perl -w

# docbook2html.pl
#
# 08/11/08 23:49:45 CEST Dobrica Pavlinusic <dpavlin@rot13.org>

my $full_path = shift @ARGV || die "usage: $0 file.doc";

open( my $in, "antiword -x db $full_path |" ) || die "can't convert: $!";
my $skip = 1;
while( <$in> ) {
	next if $in =~ m/^[\s\n\r]*$/;

	$skip = 0 if m{<chapter>};
	$skip = 1 if m{</chapter>};

	s/para/p/g;
	s/orderedlist/ol/g;
	s/listitem/li/g;
	s/title/h1/g;

	s{<emphasis role='bold'>(.*?)</emphasis>}{<b>$1</b>}g;

	print unless $skip;
}
while ( <$in> ) {
	print;
}


