#! /usr/local/bin/perl # this file converts simple html text into a docbook xml variant. # The mapping of markups and links is far from perfect. But all we # want is the docbook-to-pdf converter and similar technology being # present in the world of docbook-to-anything converters. use strict; my %o; my %file; my $F; my @order; for $F (@ARGV) { if ($F =~ /^(\w+)=(.*)/) { $o{$1} = $2; }else{ open F, "<$F" or next; my $T = join ("",); close F; $file{$F}{text} = $T; $file{$F}{orig} = $F; push @order, $F; } } $o{version} = `date` if not length $o{version}; for $F (keys %file) { $_ = $file{$F}{text}; s{}{ $o{version} }gse; s{(.*)}{\n$1}mg; s{

}{}mg; s{<[Pp]([> ])}{<para$1}mg; s{</[Pp]>}{</para>}mg; s{<pre>}{<screen>}mg; s{</pre>}{</screen>}mg; s{<h3>}{<sect2><title>}mg; s{</h3>((?:.(?!<sect2>))*.?)}{$1}sg; s{]*>}{}sg; s{]*>}{}sg; s{(<\w+\b[^<>]*\swidth=)(\d+\%)}{$1\"$2\"}sg; s{(<\w+\b[^<>]*\s\w+=)(\d+)}{$1\"$2\"}sg; s{&&}{\&\;\&\;}sg; s{\$\<}{\$\<\;}sg; s{&(\w+[\),])}{\&\;$1}sg; s{(]*)?>}{$1."phrase$2>"}sge; s{(]*)?>}{$1."note$2>"}sge; s{(}{$1."emphasis>"}sge; s{(}{$1."listitem>"}sge; s{(}{$1."itemizedlist>"}sge; s{(}{$1."orderedlist>"}sge; s{(}{$1."variablelist>"}sge; s{]*)>}{""}sge; s{]*)>}{""}sge; s{]*)>}{""}sge; s{]*)>}{""}sge; s{]*)>}{""}sge; s{]*)>}{""}sge; s{(]*)?>}{$1."row$2>"}sge; s{(]*)?>}{$1."entry$2>"}sge; s{]*>\s*]*>\s* \s*]*>\s*]*>\s*\s*\s* \s*\s*\s*} {}gsx; s{(]*\swidth=\"100\%\")}{$1 pgwide=\"1\"}gs; s{(\s*]*>\s*]*\s)(width=\"50\%\")} {\n$1$2}gs; s{([\'\`]*)}{$1}sg; s{([\'\`]*)}{$2}sg; s{<(?:tt|code)>([\`\"\'])}{$1}sg; s{<(?:tt|code)>([\`\"\'])}{$1}sg; s{([\`\"\'])}{$1}sg; s{([\`\"\'])}{$1}sg; s{(}{$1."constant>"}sge; s{(}{$1."literal>"}sge; s{>([^<>]+)
}{>$1}sg; s{
}{
}sg; s{(}{$1."sect1info>"}sge; s{}{}s; s{]+)\"\s*>((?:.(?!))*.)} { "$2" }sge; s{((?:.(?!))*.)} { "$2" }sge; s{((?:.(?!))*.)} { "$2" }sge; s{((?:.(?!))*.)} { my $K = $1; chop $K; if (not exists $file{$K}) { print STDERR "bad link $1\n"; } "$2" }sge; s{((?:.(?!))*.)} { "$2" }sge; s{((?:.(?!))*.)} { "$2" }sge; # s{(}{$1."para>"}ge; $_ .= "
" if / ]/; $file{$F}{text} = $_; } my $n = "\n"; print '',$n; print 'Documentation',$n; for $F (@order) { print "" if $file{$F}{text} =~ /',$n;