#!perl # qx2html.pl # by Jon C. Jensen # created 1998 August # updated 1999 February 9 # HTML preferences $allow_nbsp = 1; $allow_wbr = 1; # debugging output option $debug_info = 0; die "No files to process" unless @ARGV; $OUT = "from-quark.html"; open OUT, ">$OUT" or die "Can't open output file $OUT\n"; foreach $path (sort @ARGV) { $path =~ /:([^:]+)$/; push @xtags_files,$1; } print OUT <
/ig; # <\c> <\b> new column, box
s/<\#(\d+)>/chr($1)/ge; # <\#???> ASCII code
# convert tabs to spaces and collapse extraneous whitespace to single space
s/\s+/ /g; # multiple spaces
# convert bold, italic, and underline attributes
s{<([BbIiUu])>([^<]+)<[\$P]>}{<\@$1>$2<\@/$1>}g;
# <\d> discretionary return
s/<\\d>/if ($allow_wbr) {"<\@wbr>"} else {""}/eig;
# <\-> regular (breaking) hyphen
s/<\\->/if ($allow_wbr) {"-<\@wbr>"} else {"-"}/eig;
# <\!s> <\!f> <\!p> <\!q> various nonbreaking spaces
s/<\\![sfpq]>/if ($allow_nbsp) {" "} else {" "}/eig;
# remove all remaining tags
s/<[^\@][^>]*>//g; # don't take out <@...> tags, as these are new HTML tags
# correct HTML tags
s/<\@([^>]*>)/<$1/g;
# convert right angle brackets
unless (/) {s/>/>/g} else {
while (/>/) {last unless (s/(<[^>]*>[^<>]*)>/$1>/g)}
}
# catch odd characters
$change=0;
@chars=split(//,$_);
foreach $c (@chars) {
$v = unpack("C",$c);
if ($v > 126) {
if ($v == 213 || $v == 212) {$c="'"; $change=1;} # convert real apostrophes
elsif ($v == 208) {$c="-"; $change=1;} # convert en dash
elsif ($v == 209) {$c="-- \n$_\n