: # Use perl
eval 'exec perl -S $0 "$@"'
  if $running_under_some_shell;

# This is html2ps 0.1 beta, an HTML-to-PostScript converter.
# Author: Jan Krrman, Dept. of Scientific Computing, Uppsala University,
#         Sweden, e-mail: jan@tdb.uu.se.
#
# The part of this Perl script that does the actual conversion into PostScript
# is converted from a sed script with s2p. It probably can be improved, but I
# have yet to learn Perl properly.

$usage=<<EOU;
Usage:
 html2ps [-aCcFLnUuv] [-cw program] [-f font] [-hn scalefactor] [-im text]
  [-l length] [-LM size] [-o file] [-p scalefactor] [-PS size] [-s scalefactor]
  [-tn style] [-TM size] [-w width] [file...]
EOU
$version="html2ps 0.1 beta";
$styles="Possible choices are: n, i, b, bi, f, fb, fi and fbi";
$opts="a|c|C|F|L|n|u|U|v|s:|w:|l:|p:|f:|o:|cw:|im:|LM:|TM:|PS:|h1:|h2:|h3:|h4:|h5:|h6:|t1:|t2:|t3:|t4:|t5:|t6:";
$ulanch=true;
$number=false;
$mask=7;
$opt_PS=27.9;
$opt_LM=2.5;
$opt_TM=3;
$opt_s=1;
$opt_p=1;
$opt_f=n;
$ff="Courier";
$fb="Courier-Bold";
$fi="Courier-Oblique";
$ft="Courier-BoldOblique";
$opt_h1=1;
$opt_h2=1;
$opt_h3=1;
$opt_h4=1;
$opt_h5=1;
$opt_h6=1;
$opt_t1=b;
$opt_t2=b;
$opt_t3=b;
$opt_t4=b;
$opt_t5=b;
$opt_t6=b;
$opt_im="[IMAGE]";
$d=9;
$f=72/2.54;
&Getopts($opts) || die "$usage";
die "$usage" if $opt_U;
die "$version\n" if $opt_v;
if ($opt_a) {$mask=0};
if ($opt_n) {$number=true};
if ($opt_u) {$ulanch=false};
if ($opt_PS=~/^[aA]4$/) {$opt_PS=29.7};
if ($opt_PS=~/^[uU][sS]$/) {$opt_PS=27.9};

for $o
 ($opt_s,$opt_w,$opt_l,$opt_p,$opt_LM,$opt_TM,$opt_PS,
  $opt_h1,$opt_h2,$opt_h3,$opt_h4,$opt_h5,$opt_h6)
  {die "Non numeric: $o\n" if($o!~/^\d*\.?\d*$/)}

$h1=19*$opt_h1;
$h2=17*$opt_h2;
$h3=15*$opt_h3;
$h4=13*$opt_h4;
$h5=12*$opt_h5;
$h6=11*$opt_h6;

if ($opt_L) {
  $opt_w=24.5 unless $opt_w;
  $opt_l=15 unless $opt_l;
  $xc=int($opt_TM*$f);
  $yc=int($opt_LM*$f);
  $w=int($opt_w*$f);
  $l=int($opt_l*$f);
  $rot=" 90 rotate"
}
else {
  $opt_w=16 unless $opt_w;
  $opt_l=23 unless $opt_l;
  $xc=int($opt_LM*$f);
  $yc=int(($opt_PS-$opt_TM)*$f);
  $w=int($opt_w*$f);
  $l=int($opt_l*$f)
}
if($opt_F) {
  $xr=$w+$d;
  $yb=-$l-$d;
  $fr="\n gsave -$d $d M $xr $d L $xr $yb L -$d $yb L -$d $d L stroke grestore"
}
$opt_im=~s|\\|\\\\|g;
$opt_im=~s|\(|\\(|g;
$opt_im=~s|\)|\\)|g;

@n=(
 "NewCenturySchlbk-Roman",
 "NewCenturySchlbk-Bold",
 "NewCenturySchlbk-Italic",
 "NewCenturySchlbk-BoldItalic");
@t=(
 "Times-Roman",
 "Times-Bold",
 "Times-Italic",
 "Times-BoldItalic");
@h=(
 "Helvetica",
 "Helvetica-Bold",
 "Helvetica-Oblique",
 "Helvetica-BoldOblique");
@hn=(
 "Helvetica-Narrow",
 "Helvetica-Narrow-Bold",
 "Helvetica-Narrow-Oblique",
 "Helvetica-Narrow-BoldOblique");
@p=(
 "Palatino-Roman",
 "Palatino-Bold",
 "Palatino-Italic",
 "Palatino-BoldItalic");
@a=(
 "AvantGarde-Book",
 "AvantGarde-Demi",
 "AvantGarde-BookOblique",
 "AvantGarde-DemiOblique");
@b=(
 "Bookman-Light",
 "Bookman-Demi",
 "Bookman-LightItalic",
 "Bookman-DemiItalic");

# Below is an example how to add a new font, specified on the command line
# with "-f myf". Remove the "#" characters and change the names into the
# appropriate for your font. Be sure that you get the names of the different
# styles right. You should also add the name ("myf" in this example) to the
# list of fonts on the line "$pfonts="Possible choices..." below the example.

#@myf=(
# "MyFont",
# "MyFont-Bold",
# "MyFont-Italic",
# "MyFont-BoldItalic");

$pfonts="Possible choices are: n, t, h, hn, p, a and b";
$nf=eval "\@$opt_f\[0]" || die "Unknown font: $opt_f\n$pfonts\n";
$bf=eval "\@$opt_f\[1]";
$if=eval "\@$opt_f\[2]";
$bi=eval "\@$opt_f\[3]";

%style=(n,1, f,2, b,3, fb,4, i,5, fi,6, bi,7, fbi,8);
for $i (1..6) {
  $temp=eval "\$opt_t$i";
  die "Unknown font style: $temp\n$styles\n" if !$style{$temp};
  eval "\$t$i=$style{$temp}-1"
}

if ($opt_c || $opt_C || $opt_cw) {
  $opt_cw="weblint" unless $opt_cw;
  for (@ARGV) {
    $co=`$opt_cw $_`;
    die "Error opening $opt_cw\n" if $?;
    print STDERR $co
  }
}
exit if $opt_C;
if ($opt_o) {open(STDOUT,">$opt_o") || die "Error opening $opt_o for output\n"}

print <<EOT; 
%!
%%Title: @ARGV
%%DocumentFonts: $nf $bf $if $bi $ff $fb $fi $ft
%%Creator: $version, written by Jan Karrman, jan\@tdb.uu.se
%%EndComments
save
/D {def} def /E {exch} D
/M {moveto} D
/S {show} D
/R {rmoveto} D
/L {lineto} D
/RL {rlineto} D
/SW {stringwidth} D
/GI {getinterval} D
/PI {putinterval} D
/U {gsave CP currentfont /FontInfo get /UnderlinePosition get
 0 E currentfont /FontMatrix get dtransform E pop add newpath M
 dup SW RL stroke grestore S } D
/B {/r E D gsave -10 0 R CP 
  newpath r 0 360 arc closepath fill grestore } D
/OB {/r E D gsave -10 0 R CP 
  newpath r 0 360 arc closepath stroke grestore } D
/NP {PN 0 ne {showpage} if 0.6 setlinewidth $xc $yc translate$rot$fr
 F dup scale /BP true D /PN PN 1 add D NO {/OF currentfont D RF findfont
 10 scalefont setfont W 2 div LE neg 40 sub M PN ST cvs S OF setfont} if
 XO SZ SL get neg M} D
/SF {dup SZ SL 3 2 roll put dup -1.2 mul /YI E D E findfont E scalefont
 setfont} D
/FS {CF MK PF {1 or} if and or /CF E D FR SL CF put FL CF get E SF} D
/RF {/$nf} D
/BF {/$bf} D
/IF {/$if} D
/IB {/$bi} D
/FF {/$ff} D
/FB {/$fb} D
/FI {/$fi} D
/FT {/$ft} D
/FL [RF FF BF FB IF FI IB FT] D
/reencodeISO {
dup dup findfont dup length dict begin
{ 1 index /FID ne { def }{ pop pop } ifelse } forall
/Encoding ISOLatin1Encoding D
currentdict end definefont
} D
/ISOLatin1Encoding [
/space/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
/parenleft/parenright/asterisk/plus/comma/minus/period/slash
/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve
/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut
/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar
/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
/guillemotright/onequarter/onehalf/threequarters/questiondown
/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
/yacute/thorn/ydieresis
] D
[RF BF IF IB FF FB FI FT] {reencodeISO D} forall

/WK ( ) D
/BS {/PC E D /TX E D /fin false D /BW WK SW pop D /CW 0 D /LK 0 D /SC 0 D
 /RT TX D {RT WK search {/NW E D pop /RT E D /WH NW SW pop D CW WH add LL gt
 {TX SC LK SC sub GI PC /SC LK D /CW WH BW add D}
 {/CW CW WH add BW add D} ifelse
 /LK LK NW length add 1 add D} {pop exit} ifelse} loop
 /fin true D /LC TX length D /WH RT SW pop D CW WH add LL gt
 {TX SC LK SC sub GI PC NL RT dup () ne {PC} {pop} ifelse}
 {TX SC LC SC sub GI PC} ifelse} D

/W {$w F div} D
/LE {$l F div} D
/BL {HM not {CP E pop XO E M} if} D
/NL {CP /YC E D pop XO YC M YC LE neg gt
 {YI CI sub dup 0 lt BP not and {dup 0 E R CI add /CI E D} {pop} ifelse}
 {NP} ifelse} D
/RS {/TM E D /CN 0 D TM
 {dup 9 eq E 10 eq or {TM CN ( ) PI} if
  /CN CN 1 add D} forall /CN 0 D /BK HM EN and {0} {1} ifelse D TM
 {dup 32 ne {TM CN 3 2 roll put /CN CN 1 add D /BK 0 D}
 {pop BK 0 eq {TM CN 32 put /CN CN 1 add D} if /BK 1 D} ifelse}
  forall TM 0 CN GI dup () ne 
  {dup CN 1 sub get 32 eq {/EN false D} {/EN true D} ifelse} if} D
/join {2 copy length E length add string dup 4 2 roll 2 index 0 3 index
 PI E length E PI} bind D

/CP {currentpoint} D
/WR {dup () eq {pop} {IG {DE search {pop pop} if /IG false D} if
 PB {dup 0 get 10 ne {(\\n) E join} if /PB false D} if
 PP {dup 0 get 10 ne {(\\n) E join} if /PP false D} if
 (\\n) search {TR /CI 0 D /NC 0 D NL pop WR} {TR} ifelse} ifelse} D
/TR {(\\t) search {dup length /NC E NC add D SH MS 0 8 NC 8 mod sub dup
 /NC E NC add D GI SH pop TR} {dup length /NC E NC add D SH} ifelse
 /BP false D} D
/SH {CP E pop LE neg lt {NP} if AU AF and UF or {U} {S} ifelse} D
/ON {AR AI NN get 1 add dup AR AI 3 -1 roll put ST cvs length dup ST E (. ) PI
 ST 0 3 -1 roll 2 add GI dup SW pop neg 0 R SH} D
/SP {YI E /YI E D NL /YI E D} D
/BR {BN} D
/BN {PF {WR} {BT NL} ifelse /HM false D} D
/AB {CH E 0 E put CH join WB} D
/NN {dup 0 lt {pop 0} if} D
/HD {IG {DE search {pop pop} if /IG false D} if} D
/DH {pop BT} D
/TL {} D
/LT {pop BT} D
/H  {1 sub /HL E D BN CP E pop LE neg WW add lt {NP} if
 BH SP /SL SL 1 add D HS HL get HT HL get FS} D
/EH {BN AH SP /SL SL 1 sub NN D /CF 0 D SZ SL get FR SL get FS} D
/BT {IG {DE search {pop pop} if /IG false D} if RS dup dup () ne E ( ) ne and
 {/LS LL D /LL W CP pop sub D {/CI 0 D SH /BP false D fin not {NL} if
  /HM true D /LL LS D} BS} {S} ifelse} D
/P  {PF {WR /PP true D} {BN AE not {AH SP} if} ifelse} D
/HR {BN 0 CP E pop M gsave W 0 RL stroke grestore
 /CI 0 D BP {/BP false D} if NL} D
/AD {BN /AE true D AH SP IF 11 SF} D
/DA {BN /AE false D AH SP RF 11 SF} D
/PR {BN /CF 0 D 9 PS mul 1 FS /PF true D /PB true D /NC 0 D} D
/PW {pop PR} D
/RP {dup () ne {dup dup length 1 sub get 10 ne {(\\n) join} if} if
 WR AH SP /CF 0 D 11 0 FS /PF false D} D
/SI {/XO AI LG add NN IN mul BC NN BI mul add D /LL W XO sub D} D
/DT {BN /LG LG 1 sub D SI /LG LG 1 add D BL} D
/DD {BN SI BL} D
/DL {BN XO 0 eq {AH SP} if /LG LG 1 add D BL} D
/LD {BN LG 0 gt {/LG LG 1 sub D} if SI XO 0 eq {AH SP} if BL} D
/UL {BT XO 0 eq {AH SP} {NL} ifelse NR AI NN 0 put /UI UI 1 add D
 /AI AI 1 add D SI BL} D
/LU {BT /UI UI 1 sub D /AI AI 1 sub D SI XO 0 eq {AH SP} {NL} ifelse BL} D
/OL {BT XO 0 eq {AH SP} {NL} ifelse NR AI NN 1 put /AI AI 1 add D SI BL} D
/LO {BT AR AI NN 0 put /AI AI 1 sub D SI XO 0 eq {AH SP} {NL} ifelse BL} D
/LI {BN /BP false D /CI 0 D CP E pop LE neg lt {NP} if NR AI 1 sub NN get 1 eq
 {ON} {0 3 R 2.5 UI 2 mod 0 eq {OB} {B} ifelse 0 -3 R} ifelse BL} D
/BQ {BN AH SP /BC BC 1 add D SI BL} D
/QB {BN AH SP /BC BC 1 sub D SI BL} D
/WB {PF {WR} {BT} ifelse} D
/A  {WB /AF true D} D
/EA {WB /AF false D} D
/CM {WB /IG true D /DE (-->) D} D
/SK {PF {(<) join WR} {BT /IG true D /DE (>) D} ifelse} D
/SS {SZ SL get /SL SL 1 add D} D
/I  {WB SS 4 FS} D
/BD {WB SS 2 FS} D
/TT {WB SS 1 FS} D
/KB {WB SS /CF 0 D 3 FS} D
/CT {WB SS /CF 0 D 4 FS} D
/SM {WB SS /CF 0 D 1 FS} D
/ES {WB /SL SL 1 sub NN D /CF 0 D SZ SL get FR SL get FS} D
/UN {WB /UF true D} D
/NU {WB /UF false D} D

/F $opt_s D
/BH -35 D
/AH -28 D
/LL W D
/XO 0 D
/YI 0 D
/CI 0 D
/LG 0 D
/AI 0 D
/UI 0 D
/IN 30 D
/BI 12 D
/WW 50 D
/PS $opt_p D
/AR [0 0 0 0 0 0 0 0 0 0] D
/NR [0 0 0 0 0 0 0 0 0 0] D
/FR [0 0 0 0 0 0 0 0 0 0] D
/SZ [0 0 0 0 0 0 0 0 0 0] D
/HS [$h1 $h2 $h3 $h4 $h5 $h6] D
/HT [$t1 $t2 $t3 $t4 $t5 $t6] D
/SL 0 D
/CF 0 D
/BC 0 D
/MK $mask D
/PN 0 D
/MS (        ) D
/CH 1 string D
/ST 6 string D
/IG false D
/HM false D
/PF false D
/EN false D
/UF false D
/PP false D
/AE false D
/AF false D
/NO $number D
/AU $ulanch D
/BP true D
%%EndProlog
save
RF 11 SF
0 LE neg 20 sub M
(
EOT

undef $/;
while (<>) {
  s|\r||g;
  s|\\|\\\\|g;
  s|\(|\\(|g;
  s|\)|\\)|g;

#  Yes, I know Perl has case-insensitive pattern matching. But on my system
#  it takes about 10 times longer to run!

  if(/<[pP][lL][aA][iI][nN][tT][eE][xX][tT] *>/) {$_=$`;$pt=$'};
  while($_){
    if(/(<[lL][iI][sS][tT][iI][nN][gG] *>)/) {$_=$`; $tag=$1; $rest=$';
      if(/<[xX][mM][pP] *>/) {$_=$`; &Subst; print ")PR("; $_=$'.$tag.$rest;
        if(m|</[xX][mM][pP] *>|) {print "$`)RP("; $_=$'}
        else {print $'; $_=""}}
      else {&Subst; print ")PR("; $_=$rest;
        if(m|</[lL][iI][sS][tT][iI][nN][gG] *>|) {print "$`)RP("; $_=$'}
        else {print $'; $_=""}}}
    elsif(/<[xX][mM][pP] *>/) {$_=$`; &Subst; print ")PR("; $_=$';
      if(m|</[xX][mM][pP] *>|) {print "$`)RP("; $_=$'}
      else {print $'; $_=""}}
    else {&Subst;$_=""}
  }
}
if($pt) {print ")PR($pt"};
print ")WB showpage restore\n";

sub Subst{
 s|<[hH][tT][mM][lL] *>||g;
 s|</[hH][tT][mM][lL]>||g;
 s|<[hH][eE][aA][dD] *>|)HD(|g;
 s|</[hH][eE][aA][dD]>|)DH(|g;
 s|<[bB][oO][dD][yY] *>||g;
 s|</[bB][oO][dD][yY]>||g;
 s|<[tT][iI][tT][lL][eE] *>|)TL(|g;
 s|</[tT][iI][tT][lL][eE]>|)LT(|g;
 s|<[hH]([1-6]{1}) *[^>]*>|)$1 H(|g;
 s|</[hH][1-6]{1}>|)EH(|g;
 s|<[bB][rR] *>|)BR(|g;
 s|<[pP]>|)P(|g;
 s|<[pP] +[^>]*>|)P(|g;
 s|</[pP] *>|)P(|g;
 s|<[hH][rR] *>|)HR(|g;
 s|<[aA][dD][dD][rR][eE][sS][sS] *>|)AD(|g;
 s|</[aA][dD][dD][rR][eE][sS][sS]>|)DA(|g;
 s|<[pP][rR][eE] *>|)PR(|g;
 s|<[pP][rR][eE] *[wW][iI][dD][tT][hH] *= *['"]* *(\d+) *['"]* *>|)$1 PW(|g;
 s|</[pP][rR][eE]>|)RP(|g;
 s|<[dD][tT] *>|)DT(|g;
 s|<[dD][dD] *>|)DD(|g;
 s|<[dD][lL] *>|)DL(|g;
 s|<[dD][lL] *[cC][oO][mM][pP][aA][cC][tT] *>|)DL(|g;
 s|</[dD][lL]>|)LD(|g;
 s|<[uU][lL] *>|)UL(|g;
 s|<[uU][lL] *[cC][oO][mM][pP][aA][cC][tT] *>|)UL(|g;
 s|</[uU][lL]>|)LU(|g;
 s|<[mM][eE][nN][uU] *>|)UL(|g;
 s|</[mM][eE][nN][uU]>|)LU(|g;
 s|<[dD][iI][rR] *>|)UL(|g;
 s|</[dD][iI][rR]>|)LU(|g;
 s|<[oO][lL] *[^>]*>|)OL(|g;
 s|</[oO][lL]>|)LO(|g;
 s|<[lL][iI] *>|)LI(|g;
 s|</[lL][iI] *>||g;
 s|<[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE] *>|)BQ(|g;
 s|</[bB][lL][oO][cC][kK][qQ][uU][oO][tT][eE]>|)QB(|g;
 s|<[sS][tT][rR][oO][nN][gG] *>|)BD(|g;
 s|</[sS][tT][rR][oO][nN][gG]>|)ES(|g;
 s|<[sS][aA][mM][pP] *>|)SM(|g;
 s|</[sS][aA][mM][pP]>|)ES(|g;
 s|<[cC][iI][tT][eE] *>|)CT(|g;
 s|</[cC][iI][tT][eE]>|)ES(|g;
 s|<[vV][aA][rR] *>|)I(|g;
 s|</[vV][aA][rR]>|)ES(|g;
 s|<[bB] *>|)BD(|g;
 s|</[bB]>|)ES(|g;
 s|<[iI] *>|)I(|g;
 s|</[iI]>|)ES(|g;
 s|<[tT][tT] *>|)TT(|g;
 s|</[tT][tT]>|)ES(|g;
 s|<[uU] *>|)UN(|g;
 s|</[uU]>|)NU(|g;
 s|<[dD][fF][nN] *>|)I(|g;
 s|</[dD][fF][nN]>|)ES(|g;
 s|<[eE][mM] *>|)I(|g;
 s|</[eE][mM]>|)ES(|g;
 s|<[cC][oO][dD][eE] *>|)SM(|g;
 s|</[cC][oO][dD][eE]>|)ES(|g;
 s|<[kK][bB][dD] *>|)KB(|g;
 s|</[kK][bB][dD]>|)ES(|g;
 s|<[aA][ \n]+[^>]*[hH][rR][eE][fF][^>]*>|)A(|g;
 s|<[aA][^>]*>||g;                               # Anchors away!  |-)
 s|</[aA]>|)EA(|g;
 s/<[iI][mM][gG] +[^>]*[aA][lL][tT] *= *"([^".]*)"[^>]*>/ $1 )WB(/g;
 s/<[iI][mM][gG] +[^>]*[aA][lL][tT] *= *([\w\.-]+)[^>]*>/ $1 )WB(/g;
 s/<[iI][mM][gG][^>]*>/ $opt_im )WB(/g;
 s|<!--NewPage-->|)WB NP(|g;
 s|<!--|)CM(|g;
 s|<|)SK(|g;
 s|&lt;|<|g;
 s|&gt;|>|g;
 s|&quot;|"|g;
 s|&AElig;||g;
 s|&Aacute;||g;
 s|&Acirc;||g;
 s|&Agrave;||g;
 s|&Aring;||g;
 s|&Atilde;||g;
 s|&Auml;||g;
 s|&Ccedil;||g;
 s|&ETH;||g;
 s|&Eacute;||g;
 s|&Ecirc;||g;
 s|&Egrave;||g;
 s|&Euml;||g;
 s|&Iacute;||g;
 s|&Icirc;||g;
 s|&Igrave;||g;
 s|&Iuml;||g;
 s|&Ntilde;||g;
 s|&Oacute;||g;
 s|&Ocirc;||g;
 s|&Ograve;||g;
 s|&Oslash;||g;
 s|&Otilde;||g;
 s|&Ouml;||g;
 s|&THORN;||g;
 s|&Uacute;||g;
 s|&Ucirc;||g;
 s|&Ugrave;||g;
 s|&Uuml;||g;
 s|&Yacute;||g;
 s|&aacute;||g;
 s|&acirc;||g;
 s|&aelig;||g;
 s|&agrave;||g;
 s|&aring;||g;
 s|&atilde;||g;
 s|&auml;||g;
 s|&ccedil;||g;
 s|&eacute;||g;
 s|&ecirc;||g;
 s|&egrave;||g;
 s|&eth;||g;
 s|&euml;||g;
 s|&iacute;||g;
 s|&icirc;||g;
 s|&igrave;||g;
 s|&iuml;||g;
 s|&ntilde;||g;
 s|&oacute;||g;
 s|&ocirc;||g;
 s|&ograve;||g;
 s|&oslash;||g;
 s|&otilde;||g;
 s|&ouml;||g;
 s|&szlig;||g;
 s|&thorn;||g;
 s|&uacute;||g;
 s|&ucirc;||g;
 s|&ugrave;||g;
 s|&uuml;||g;
 s|&yacute;||g;
 s|&yuml;||g;
 s|&nbsp;|\000|g;
 s|&#(\d*);|)$1 AB(|g;
 s|&amp;|\&|g;
 print;
}
sub Getopts {
 local($optlist)=@_;
 local(@args,$_,$opt,$opts,$rest,$olist,$plist,$found,@popts);
 local($errs)=0;
 local($[)=0;
 @args=split( /\|/, $optlist );
 for $opt (@args) {
   if(substr($opt,-1,1) ne ':') {$olist=$olist.$opt}
   else {$plist=$plist.$opt}
 }
 @popts=split(/:/,$plist);
 while(@ARGV && ($_=$ARGV[0]) =~ /^-(.*)/) {
   $opt=$1;
   if($opt =~ /^[$olist]+$/) {
     while ($char=chop $opt) {eval "\$opt_$char=1"}
     shift(@ARGV);
   }
   else {
     $found=0;
     for $opts (@popts) {
       $rest=substr($opt,length($opts));
       if(index($opt,$opts)==0) {
         $found=1;
         shift(@ARGV);
         if($rest eq '') {
           ++$errs unless @ARGV;
           $rest=shift(@ARGV);
         }
         eval "\$opt_$opts=\$rest;";
       }
     }
     if(!$found) {
       print STDERR "Unknown option: $opt\n";
       ++$errs;
       shift(@ARGV)
     }
   }
 }
 $errs==0;
}
