#!/usr/bin/perl
# This is html2ps version 1.0 beta3, an HTML-to-PostScript converter.
# Copyright (C) 1995-2000 Jan Karrman.
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Jan Karrman, Dept. of Scientific Computing, Uppsala University,
# Sweden, e-mail: jan@tdb.uu.se.
# Set the name of the global configuration file. See the installation notes
# and manual page for more details on configuration files.
$globrc='/etc/html2psrc';
$ug='/usr/share/doc/html2ps/html2ps.html';
$conf=<<'EOR';
@html2ps {
package {
PerlMagick: 0;
ImageMagick: 0;
pbmplus: 0;
netpbm: 0;
djpeg: 0;
Ghostscript: 0;
TeX: 0;
dvips: 0;
libwww-perl: 0;
jfriedl: 0;
geturl: "";
check: "";
path: "";
}
paper {
type: A4;
height: "";
width: "";
}
option {
twoup: 0;
base: "";
check: 0;
toc: "";
debug: 0;
DSC: 0;
encoding: "ISO-8859-1";
rcfile: "";
frame: 0;
grayscale: 0;
help: 0;
hyphenate: 0;
scaleimage: 1;
cookie: "";
language: "";
landscape: 0;
scalemath: 1;
number: 0;
startno: "";
output: "";
original: 0;
rootdir: "";
xref: 0;
scaledoc: 1;
style: "";
titlepage: 0;
text: 0;
underline: 0;
colour: 0;
version: 0;
web: "";
duplex: "";
}
margin {
middle: 2cm;
}
xref {
text: "[p $N]";
passes: 1;
}
quote {
en {
open: "“";
close: "”";
open2: "`";
close2: "'";
}
sv {
open: "”";
close: "”";
open2: "'";
close2: "'";
}
da {
open: "»";
close: "«";
}
no {
open: "«";
close: "»";
}
fr {
open: "« ";
close: " »";
}
de {
open: "„";
close: "“";
open2: "‚";
close2: "`";
}
fi: sv;
es: en;
it: no;
nn: no;
nb: no;
}
toc {
heading: "
Table of Contents ";
level: 6;
indent: 1em;
}
titlepage {
content: "
$T
$[author] ";
margin-top: 1cm;
}
font {
times {
names: "Times-Roman
Times-Italic
Times-Bold
Times-BoldItalic";
}
new-century-schoolbook {
names: "NewCenturySchlbk-Roman
NewCenturySchlbk-Italic
NewCenturySchlbk-Bold
NewCenturySchlbk-BoldItalic";
}
helvetica {
names: "Helvetica
Helvetica-Oblique
Helvetica-Bold
Helvetica-BoldOblique";
}
helvetica-narrow {
names: "Helvetica-Narrow
Helvetica-Narrow-Oblique
Helvetica-Narrow-Bold
Helvetica-Narrow-BoldOblique";
}
palatino {
names: "Palatino-Roman
Palatino-Italic
Palatino-Bold
Palatino-BoldItalic";
}
avantgarde {
names: "AvantGarde-Book
AvantGarde-BookOblique
AvantGarde-Demi
AvantGarde-DemiOblique";
}
bookman {
names: "Bookman-Light
Bookman-LightItalic
Bookman-Demi
Bookman-DemiItalic";
}
courier {
names: "Courier
Courier-Oblique
Courier-Bold
Courier-BoldOblique";
}
}
hyphenation {
min: 8;
start: 4;
end: 3;
en {
file: "";
extfile: "";
}
}
header {
left: "";
center: "";
right: "";
odd-left: "";
odd-center: "";
odd-right: "";
even-left: "";
even-center: "";
even-right: "";
font-family: Helvetica;
font-size: 8pt;
font-style: normal;
font-weight: normal;
color: black;
alternate: 1;
}
footer {
left: "";
center: "";
right: "";
odd-left: "";
odd-center: "";
odd-right: "";
even-left: "";
even-center: "";
even-right: "";
font-family: Helvetica;
font-size: 8pt;
font-style: normal;
font-weight: normal;
color: black;
alternate: 1;
}
frame {
width: 0.6pt;
margin: 0.5cm;
color: black;
}
justify {
word: 15pt;
letter: 0pt;
}
draft {
text: DRAFT;
print: "";
dir: 0;
font-family: Helvetica;
font-style: normal;
font-weight: bold;
color: F0F0F0;
}
colour {
black: 000000;
green: 008000;
silver: C0C0C0;
lime: 00FF00;
gray: 808080;
olive: 808000;
white: FFFFFF;
yellow: FFFF00;
maroon: 800000;
navy: 000080;
red: FF0000;
blue: 0000FF;
purple: 800080;
teal: 008080;
fuchsia: FF00FF;
aqua: 00FFFF;
}
html2psrc: "$HOME/.html2psrc";
imgalt: "[IMAGE]";
datefmt: "%e %b %Y %R";
locale: "";
doc-sep: "";
ball-radius: 0.25em;
numbstyle: 0;
showurl: 0;
seq-number: 0;
extrapage: 1;
break-table: 0;
forms: 1;
textarea-data: 0;
page-break: 1;
expand-acronyms: 0;
spoof: "";
ssi: 1;
prefilled: 0;
}
BODY {
font-family: Times;
font-size: 11pt;
text-align: left;
background: white;
}
H1, H2, H3, H4, H5, H6 {
font-weight: bold;
margin-top: 0.8em;
margin-bottom: 0.5em;
}
H1 { font-size: 19pt }
H2 { font-size: 17pt }
H3 { font-size: 15pt }
H4 { font-size: 13pt }
H5 { font-size: 12pt }
H6 { font-size: 11pt }
P, OL, UL, DL, BLOCKQUOTE, PRE {
margin-top: 1em;
margin-bottom: 1em;
}
P {
line-height: 1.2em;
text-indent: 0;
}
OL, UL, DD { margin-left: 2em }
TT, KBD, PRE { font-family: Courier }
PRE { font-size: 11pt }
BLOCKQUOTE {
margin-left: 1em;
margin-right: 1em;
}
ADDRESS {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
TABLE {
margin-top: 1.3em;
margin-bottom: 1em;
}
DIV.noprint { display: none }
DEL { text-decoration: line-through }
A:link, HR { color: black }
@page {
margin-left: 1cm;
margin-right: 1cm;
margin-top: 0cm;
margin-bottom: 0.5cm;
}
EOR
eval "require POSIX";
$posix = !$@;
%extend=('quote',1, 'font',1, 'colour',1, 'hyphenation',1);
%fal=("serif","times", "sans_serif","helvetica", "monospace","courier");
@fo=("p","pre","h1","h2","h3","h4","h5","h6","i","b","tt","kbd","cite","samp",
"address","blockquote","ol","ul","dl","dt","dd","table","header","footer");
%quote=('','en');
%valid=('font',1, 'font_files',1, 'margin,left',1, 'margin,right',1,
'margin,top',1, 'margin,bottom',1);
%cm=('cm',1, 'mm',0.1, 'in',2.54, 'pt',2.54/72, 'pc',2.54/6);
%pt=('cm',72/2.54, 'mm',72/25.4, 'in',72, 'pt',1, 'pc',12);
%space=('thinsp',6, '#8201',6, 'ensp',2, '#8194',2, 'emsp',1, '#8195',1);
$space=join('|',keys %space);
%vars=("T","Ti", "N","Pn", "U","UR", "H","h", "A","Au");
%height=("letter",27.9, "legal",35.6, "arche",121.9, "archd",91.4, "archc",61,
"archb",45.7, "archa",30.5, "flsa",33, "flse",33, "halfletter",21.6,
"11x17",43.2, "ledger",27.9);
%width=("letter",21.6, "legal",21.6, "arche",91.4, "archd",61, "archc",45.7,
"archb",30.5, "archa",22.9, "flsa",21.6, "flse",21.6, "halfletter",14,
"11x17",27.9, "ledger",43.2);
$version="html2ps version 1.0 beta3";
$opts="2|b:|c|C:|d|D|e:|f:|F|g|h|H|i:|k:|l:|L|m:|n|N:|o:|O|r:|R|s:|S:|t|T|u|"
."U|v|W:|x:";
%optalias=( 'twoup','2', 'base','b', 'check','c', 'toc','C', 'debug','d',
'DSC','D', 'encoding','e', 'rcfile','f', 'frame','F', 'grayscale','g',
'help','h', 'hyphenate','H', 'scaleimage','i', 'cookie','k', 'language','l',
'landscape','L', 'scalemath','m', 'number','n', 'startno','N', 'output','o',
'original','O', 'rootdir','r', 'xref','R', 'scaledoc','s', 'style','S',
'titlepage','t', 'text','T', 'underline','u', 'colour','U', 'version','v',
'web','W', 'duplex','x');
%type=( 'paper,height',2, 'paper,width',2, 'option,i',3, 'option,m',3,
'option,N',4, 'option,s',3, 'option,x',4, 'xref,passes',4, 'draft,print',5);
$usage=<html2ps.dbg") || die "Error opening debug file: html2ps.dbg\n";
print STDERR "***** Writing debug info to html2ps.dbg\n";
print DBG "***** $version\n***** Command: $0 $args\n***** Perl: $]\n";
print DBG "***** HTML2PSPATH=$ENV{'HTML2PSPATH'}\n";
}
undef $/;
$user=0;
$V='(-?\d+\.?\d*|-?\d*\.?\d+)';
&getconf($conf);
&pagedef;
undef %AT_page;
for(@fo,"draft") {
eval "\$deffnt{'$_'}=defined \$$_\{'font-family'\}?"
."\$$_\{'font-family'\}:\$body{'font-family'}";
}
$user=1;
if(open(RC,$globrc)) {
$conf=;
print DBG "***** Global file $globrc:\n$conf" if($opt_d);
&getconf($conf);
close RC;
} else {
&dbg("Warning: cannot open the global resource file: $globrc\n") if($globrc);
}
$html2psrc=~s/^(~|\$HOME)/$ENV{"HOME"}/;
$prc=$html2psrc;
if($opt_f) {
($prc=$opt_f)=~s/^:/$html2psrc:/;
$prc=~s/:$/:$html2psrc/;
$prc=~s/::/:$html2psrc:/;
}
$cwd=$posix?POSIX::getcwd():"";
opendir(DIR,$cwd);
@local=readdir DIR;
closedir DIR;
$globrc=~/html2psrc/;
$gdir=$`;
$hpath=$ENV{"HTML2PSPATH"}?$ENV{"HTML2PSPATH"}:".:";
$hpath=~s/^:/$gdir:/;
$hpath=~s/:$/:$gdir/;
$hpath=~s/::/:$gdir:/;
$cur=$hpath=~s/(^|:)\.($|:)/$1$cwd$2/;
@hpath=split(/:/,$hpath);
for(@hpath) {
if(opendir(DIR,$_)) {
@files=readdir DIR;
$files{$_}=" @files ";
closedir DIR;
}
}
@rc=split(/:/,$prc);
for $rc (@rc) {
$found=0;
S:for $dir (@hpath) {
if(-r $rc && !grep(/^$rc$/,@local) || $files{$dir}=~/ $rc /) {
chdir $dir if($files{$dir}=~/ $rc / && $cwd);
if(open(RC,$rc)) {
$conf=;
print DBG "***** Personal file $rc:\n$conf" if($opt_d);
&getconf($conf);
close RC;
$found=1;
}
last S;
}
}
&dbg("Error opening resource file: $rc\n") if($opt_f && !$found);
}
chdir $cwd if($cwd);
$user=2;
&getconf($opt_S) if($opt_S);
print DBG "*****\n" if($opt_d);
&pagedef;
($pagew,$pageh)=split /\s+/, $AT_page{'size'} if(defined $AT_page{'size'});
require Image::Magick if($package{'PerlMagick'});
$geturl=$package{'geturl'};
$ulanch="f";
$f=72/2.54;
$giftopm="giftopnm" if($package{'netpbm'});
$giftopm="giftoppm" if($package{'pbmplus'});
for(keys %option){eval "\$opt_$_='$option{$_}' if(!defined \$opt_$_)"};
die $usage if $opt_h;
die "$version\n" if $opt_v;
&dbg("$version\n") if ($opt_v||$opt_d);
die "Ghostscript is required to generate DSC PostScript\n"
if($opt_D && !$package{'Ghostscript'});
die "Ghostscript is required to generate cross references\n"
if($opt_R && !$package{'Ghostscript'});
$tmpname=$posix?POSIX::tmpnam():"h2p_$$";
($scr=$tmpname)=~/\w+$/;
$tempdir=$`;
if($opt_u) {$ulanch="t"};
if(defined $opt_x && $opt_x!~/^[0-2]$/) {
die "Illegal duplex value: $opt_x\n";
}
$V='(-?\d+\.?\d*|-?\d*\.?\d+)';
for $o ($opt_s,$opt_i,$opt_m,$opt_N) {
die "Non numeric: $o\n" if(defined($o) && $o!~/^$V$/);
}
$twoup=$opt_2?"t":"f";
$xp=$extrapage?"t":"f";
die "Invalid option: -W $opt_W\n" if($opt_W!~/^[abflprsL\d]*$/);
$tocdoc=$opt_C=~/[ft]/;
if($tocdoc && !defined $opt_W) {$opt_W=4};
$mult=$#ARGV>0 || $opt_W;
$maxlev=$opt_W=~/(\d+)/?$1:4;
$link=$opt_W=~/l/;
$local=$opt_W=~/s/;
$rel=$opt_W=~/r/;
$below=$opt_W=~/b/;
$layer=$opt_W=~/L/;
$prompt=$opt_W=~/p/;
if($opt_C && $opt_C!~/^(b?[ft]|[ft]b?|b?h|hb?)$/)
{die "Invalid option: -C $opt_C\n"};
$tc=$opt_C?"t":"f";
$rev=$opt_C=~/t/;
$first=$opt_C=~/b/ || $opt_R;
$th=$tocdoc?"f":"t";
$oeh=0;
$oef=0;
@now=localtime;
@gmnow=gmtime;
POSIX::setlocale(&POSIX::LC_TIME,$locale) if($posix);
$R='(\s*>|[^a-zA-Z0-9>][^>]*>)';
$S='([\w.:/%-]+)|"([^"]*)"|\'([^\']*)\'';
$X='[\da-fA-F]';
$IM='(gif|jpeg|jpg|png|xbm|xpm|ps|eps)';
for('odd-left','odd-center','odd-right','even-left','even-center','even-right')
{
$oeh=1 if defined $header{$_};
$oef=1 if defined $footer{$_};
}
%metarc=();
for $a ('left','center','right') {
if(defined $header{"odd-$a"} || defined $header{"even-$a"}) {
$oeh=1;
}
if(defined $footer{"odd-$a"} || defined $footer{"even-$a"}) {
$oef=1;
}
for('','odd-','even-') {
$apa=$header{$_.$a};
$numb=1 if($apa=~/(^|[^\$])\$N/);
&spec($header{$_.$a});
&spec($footer{$_.$a});
$header{$_.$a}="($apa)";
$apa=$footer{$_.$a};
$numb=1 if($apa=~/(^|[^\$])\$N/);
$footer{$_.$a}="($apa)";
&varsub($header{$_.$a},$footer{$_.$a});
}
}
if($oeh) {
$yz="/YY [[{$header{'odd-left'}}{$header{'even-left'}}]"
."[{$header{'odd-right'}}{$header{'even-right'}}]"
."[{$header{'odd-center'}}{$header{'even-center'}}]] D\n";
} else {
$ind=$header{'alternate'};
$yz="/YY [[{$header{'left'}}$ind][{$header{'right'}}".(1-$ind)
."][{$header{'center'}}2]] D\n";
}
if($oef) {
$yz.="/ZZ [[{$footer{'odd-left'}}{$footer{'even-left'}}]"
."[{$footer{'odd-right'}}{$footer{'even-right'}}]"
."[{$footer{'odd-center'}}{$footer{'even-center'}}]] D";
} else {
$ind=$footer{'alternate'};
$yz.="/ZZ [[{$footer{'left'}}$ind][{$footer{'right'}}".(1-$ind)
."][{$footer{'center'}}2]] D";
}
$number=$opt_n || !$numb && ($opt_C || $opt_N || $opt_R)?"t":"f";
$tih=$titlepage{'content'};
$toch=$toc{'heading'};
for ($imgalt,$xref{'text'},$tih,$toch,$inh,$draft{'text'}) {
&spec($_);
}
for ($paper{'height'},$paper{'width'},$margin{'middle'},$frame{'margin'},
$mlr,$mrl,$mtl,$mbl,$mll,$mrr,$mtr,$mbr,$pagew,$pageh) {
&getval($_,1);
}
$opt_s*=0.65 if($opt_2 && $opt_L);
$opt_N=1 if(!defined $opt_N);
$opt_N=int($opt_N-1);
$mm=int($margin{'middle'}*$f);
$is=0.8*$opt_i;
$msc=1/$opt_s;
$mag=1200*$opt_m*$opt_s;
$xref=$opt_R?"t":"f";
$xref{'text'}=~s/\$N/) WB pN WB (/g;
$d=int($f*$frame{'margin'});
for (0..10) {
$temp=2**(-$_/2);
$width{"a$_"}=int($temp*2**(-1/4)*1000+.5)/10;
$height{"a$_"}=int($temp*2**(1/4)*1000+.5)/10;
$width{"b$_"}=int($temp*1000+.5)/10;
$height{"b$_"}=int($temp*2**(1/2)*1000+.5)/10;
}
if(!$pagew || !$pageh) {
if($width{"\L$paper{'type'}"}) {
$paper{'width'}=$width{"\L$paper{'type'}"} if(!defined $paper{'width'});
$paper{'height'}=$height{"\L$paper{'type'}"} if(!defined $paper{'height'});
($pagew,$pageh)=($paper{'width'},$paper{'height'});
} elsif($paper{'type'}) {
&dbg("Unknown paper type: $paper{'type'}\n");
}
}
if($opt_L) {
$wl=$pageh-$mll-$mrl;
$wr=$pageh-$mlr-$mrr;
$hl=int(($pagew-$mtl-$mbl)*$f+.5);
$hr=int(($pagew-$mtr-$mbr)*$f+.5);
$xl=int($mtl*$f+.5);
$xr=int($mtr*$f+.5);
$yl=int($mll*$f+.5);
$yr=int($mlr*$f+.5);
$rot=" 90 rotate";
} else {
$wl=$pagew-$mll-$mrl;
$wr=$pagew-$mlr-$mrr;
$hl=int(($pageh-$mtl-$mbl)*$f+.5);
$hr=int(($pageh-$mtr-$mbr)*$f+.5);
$xl=int($mll*$f+.5);
$xr=int($mlr*$f+.5);
$yl=int(($pageh-$mtl)*$f+.5);
$yr=int(($pageh-$mtr)*$f+.5);
$rot="";
}
if($opt_2) {
$wl=($wl-$margin{'middle'})/2;
$wr=($wr-$margin{'middle'})/2;
}
$wl=int($wl*$f+.5);
$wr=int($wr*$f+.5);
$pag=int($pageh*$f+.5);
$fe=$opt_F?"t":"f";
$cf=$opt_U?"t":"f";
$tp=$opt_t?"t":"f";
$rm=$numbstyle?"t":"f";
$pa=$showurl?"t":"f";
$nh=$seq_number?"t":"f";
$bt=$break_table?"t":"f";
$ea=$expand_acronyms?"t":"f";
$fi=$prefilled?"t":"f";
$latin1=$opt_e=~/ISO-8859-1/i;
$lt=$del{'text-decoration'}=~/^line-through$/i?"SE":"WB";
if(!$opt_x && defined $opt_x) {
$dupl="[{false statusdict/setduplexmode get exec} stopped cleartomark";
}
if($opt_x) {
$dupl="[{true statusdict/setduplexmode get exec} stopped cleartomark";
}
if($opt_x==2) {
$dupl.="\n[{true statusdict/settumble get exec} stopped cleartomark";
}
%head=("html",1, "head",1, "title",1, "base",1, "meta",1, "link",1, "style",1,
"script",1, "isindex",1);
%algn=("left",1, "center",2, "right",3, "justify",4, "char",5);
%f=("void",1, "above",2, "below",3, "hsides",4, "lhs",5, "rhs",6, "vsides",7,
"box",8, "border",9);
%r=("none",1, "groups",2, "rows",3, "cols",4, "all",5);
%v=("top",1, "middle",2, "bottom",3, "baseline",4);
%it=("radio",0, "checkbox",1, "text",2, "password",2, "image",3);
%ssy=(200,"\\", 201, "(", 202, ")");
%lity=("I",0, "i",1, "A",2, "a",3, "1",4, "disc",5, "square",6, "circle",7);
$ltr=join('|',keys %lity);
%tex=('`a',"\340", '\^a',"\342", '`e',"\350", '`e',"\350", 'c\{c\}',"\347",
"'e","\351", '\^e',"\352", '"e',"\353", '\^i',"\356", '"i',"\357",
'\^o',"\364", '`u',"\371", '\^u',"\373", '"u',"\374", '"y',"\377",
'aa',"\345", '"a',"\344", '"o',"\366", 'ae',"\346", 'oe',"\225");
@hind=(0,0,0,0,0,0);
$ltrs='A-Za-z\222-\226\300-\377';
%ent=(
"lsquo|#8216",96,
"rsquo|#8217",39,
"circ|#710",141,
"tilde|#732",142,
"permil|#8240",143,
"dagger|#8224",144,
"Dagger|#8225",145,
"Yuml|#376",146,
"scaron|#353",147,
"Scaron|#352",148,
"oelig|#339",149,
"OElig|#338",150,
"lsaquo|#8249",151,
"rsaquo|#8250",152,
"sbquo|#8218",153,
"bdquo|#8222",154,
"ldquo|#8220",155,
"rdquo|#8221",156,
"ndash|#8211",157,
"mdash|#8212",158,
"trade|#8482",159,
"nbsp",160,
"iexcl",161,
"cent",162,
"pound",163,
"curren",164,
"yen",165,
"brvbar",166,
"sect",167,
"uml",168,
"copy",169,
"ordf",170,
"laquo",171,
"not",172,
"reg",174,
"macr",175,
"deg",176,
"plusmn",177,
"sup2",178,
"sup3",179,
"acute",180,
"micro",181,
"para",182,
"middot",183,
"cedil",184,
"sup1",185,
"ordm",186,
"raquo",187,
"frac14",188,
"frac12",189,
"frac34",190,
"iquest",191,
"Agrave",192,
"Aacute",193,
"Acirc",194,
"Atilde",195,
"Auml",196,
"Aring",197,
"AElig",198,
"Ccedil",199,
"Egrave",200,
"Eacute",201,
"Ecirc",202,
"Euml",203,
"Igrave",204,
"Iacute",205,
"Icirc",206,
"Iuml",207,
"ETH",208,
"Ntilde",209,
"Ograve",210,
"Oacute",211,
"Ocirc",212,
"Otilde",213,
"Ouml",214,
"times",215,
"Oslash",216,
"Ugrave",217,
"Uacute",218,
"Ucirc",219,
"Uuml",220,
"Yacute",221,
"THORN",222,
"szlig",223,
"agrave",224,
"aacute",225,
"acirc",226,
"atilde",227,
"auml",228,
"aring",229,
"aelig",230,
"ccedil",231,
"egrave",232,
"eacute",233,
"ecirc",234,
"euml",235,
"igrave",236,
"iacute",237,
"icirc",238,
"iuml",239,
"eth",240,
"ntilde",241,
"ograve",242,
"oacute",243,
"ocirc",244,
"otilde",245,
"ouml",246,
"divide",247,
"oslash",248,
"ugrave",249,
"uacute",250,
"ucirc",251,
"uuml",252,
"yacute",253,
"thorn",254,
"yuml",255);
%symb=(
"alpha|#945",141,
"beta|#946",142,
"gamma|#947",147,
"delta|#948",144,
"epsilon|#949",145,
"zeta|#950",172,
"eta|#951",150,
"theta|#952",161,
"thetasym|#977",112,
"iota|#953",151,
"kappa|#954",153,
"lambda|#955",154,
"mu|#956",155,
"nu|#957",156,
"xi|#958",170,
"pi|#960",160,
"piv|#982",166,
"omicron|#959",157,
"rho|#961",162,
"sigma|#963",163,
"sigmaf|#962",126,
"tau|#964",164,
"upsilon|#965",165,
"upsih|#978",241,
"phi|#966",146,
"phiv",152,
"chi|#967",143,
"psi|#968",171,
"omega|#969",167,
"Alpha|#913",101,
"Beta|#914",102,
"Gamma|#915",107,
"Delta|#916",104,
"Epsilon|#917",105,
"Zeta|#918",132,
"Eta|#919",110,
"Theta|#920",121,
"Iota|#921",111,
"Kappa|#922",113,
"Lambda|#923",114,
"Mu|#924",115,
"Nu|#925",116,
"Xi|#926",130,
"Omicron|#927",117,
"Pi|#928",120,
"Rho|#929",122,
"Sigma|#931",123,
"Tau|#932",124,
"Upsilon|#933",125,
"Phi|#934",106,
"Chi|#935",103,
"Psi|#936",131,
"Omega|#937",127,
"fnof|#402",246,
"perp|#8869",136,
"plusmn|#177",261,
"cdot|#183",327,
"or|#8744",332,
"and|#8743",331,
"le|#8804",243,
"ge|#8805",263,
"equiv|#8801",272,
"cong|#8773",100,
"asymp|#8776",273,
"ne|#8800",271,
"sub|#8834",314,
"sube|#8838",315,
"sup|#8835",311,
"supe|#8839",312,
"isin|#8712",316,
"larr|#8592",254,
"rarr|#8594",256,
"uarr|#8593",255,
"darr|#8595",257,
"harr|#8596",253,
"lArr|#8656",334,
"rArr|#8658",336,
"uArr|#8657",335,
"dArr|#8659",337,
"hArr|#8660",333,
"forall|#8704","042",
"exist|#8707","044",
"infin|#8734",245,
"nabla|#8711",321,
"part|#8706",266,
"hellip|#8230",274,
"int|#8747",362,
"sum|#8721",345,
"prod|#8719",325,
"real|#8476",302,
"image|#8465",301,
"bull|#8226",267,
"prime|#8242",242,
"Prime|#8243",262,
"oline|#8254",140,
"frasl|#8260",244,
"weierp|#8472",303,
"alefsym|#8501",300,
"crarr|#8629",277,
"empty|#8709",306,
"notin|#8713",317,
"ni|#8715","047",
"minus|#8722","055",
"lowast|#8727","052",
"radic|#8730",326,
"prop|#8733",265,
"ang|#8736",320,
"cap|#8745",307,
"cup|#8746",310,
"sim|#8764",176,
"nsub|#8836",313,
"oplus|#8853",305,
"otimes|#8855",304,
"sdot|#8901",327,
"lceil|#8968",351,
"rceil|#8969",371,
"lfloor|#8970",353,
"rfloor|#8971",373,
"lang|#9001",341,
"rang|#9002",361,
"spades|#9824",252,
"clubs|#9827",247,
"hearts|#9829",251,
"diams|#9830",250,
"loz|#9674",340);
$pc=')WB NL NP(';
$nimg=-1;
$nm=-1;
@font=();
@size=();
@styl=();
@alig=();
@colr=();
@topm=();
@botm=();
@lftm=();
@rgtm=();
@z1=();
@z2=();
@z3=();
&Subst($doc_sep);
($toct=$toch)=~s|<[\w/!?][^>]*>||g;
$dh="/h0 [()($toct)] D\n";
&Subst($toch);
$toch=~s/ H\(/ -1 H(/g;
$toch="($toch)";
&varsub($toch);
&Subst($tih);
$tih=~s/ H\(/ -1 H(/g;
$tih="($tih)";
&varsub($tih);
$mn=0;
$nfont=0;
$mi=0;
for (@fo) {&setel($_)};
%arr=%draft;
&fs("draft");
if(!$latin1 && !defined $fontid{"times"}) {
$fontid{"times"}=$nfont++;
@docfonts=(@docfonts,split(/\s+/,$font_names{"times"}));
}
$wind=0;
$wf="t";
if(!$latin1) {
$wind=$fontid{"times"};
$wf="f";
}
for $k (keys %font_files){
@ff=split(/\s+/,$font_files{$k});
@fn=split(/\s+/,$font_names{$k});
for (0..3) {
if($ff[$_]) {
$ff{$fn[$_]}=$ff[$_];
} elsif(!$ff{$fn[$_]}) {
$ff{$fn[$_]}=$ff[0];
}
$fr{$fn[$_]}=$k;
}
}
$pta=defined $p{"text-align"}?$p{"text-align"}:$body{"text-align"};
$pal=0;
$pal=1 if($pta=~/^c/i);
$pal=2 if($pta=~/^r/i);
$pal=3 if($pta=~/^j/i);
$bgcol=&col2rgb($body{"background"});
if(!$bgcol) {$bgcol="[16#FF 16#FF 16#FF]"};
if(!$p{"color"}) {$p{"color"}="black"};
$tcol=&col2rgb($p{"color"});
$lcol=&col2rgb($a__link{"color"});
if($lcol) {
$Lc="/Lc t D\n/Dl $lcol D\n";
$Lc.=$tcol ne $lcol?"/LX t D":"/LX f D";
} else {
$Lc="/Lc f D\n/LX f D";
}
$pcol=&col2rgb($pre{"color"});
if(!$pcol) {$pcol="[0 0 0]"};
$deftbg=&col2rgb($table{"background"});
$hc=&col2rgb($hr{"color"});
if(!$hc) {$hc="[0 0 0]"};
$fcol=&col2rgb($frame{"color"});
if(!$fcol) {$fcol="[0 0 0]"};
for ($p{"font-size"},$pre{"font-size"},$header{"font-size"},$frame{'width'},
$footer{"font-size"},$justify{'letter'},$justify{'word'},
$titlepage{'margin-top'}) {
&getval($_,2);
}
for ($p{"line-height"},$p{"text-indent"},$p{"margin-top"},$toc{'indent'},
$ball_radius) {
&getval($_,0);
}
$fl="/FL [/".join("\n/",@docfonts)."] D";
for $k (keys %ff) {
$f=$ff{$k};
if(defined $fontid{$fr{$k}} && !defined($cont{$f})) {
open(FONT,$f) || &dbg("Error opening fontfile $f\n");
($cont{$f}=)=~s/(^|\r?\n|\r)%.*//g;
close FONT;
}
}
$fontdef="";
for (keys %cont) {
$fontdef.=$cont{$_};
}
&ent($yz);
&ent($xref{'text'});
&ent($draft{'text'});
$lnum=0;
for (keys %quote_open) {
$lid{$_}=$lnum++;
if(!defined $quote_close{$_}) {$quote_close{$_}=$quote_open{$_}};
if(!defined $quote_open2{$_}) {$quote_open2{$_}=$quote_open{$_}};
if(!defined $quote_close2{$_}) {$quote_close2{$_}=$quote_close{$_}};
&ent($quote_open{$_});
&ent($quote_close{$_});
&ent($quote_open2{$_});
&ent($quote_close2{$_});
push(@qo,$quote_open{$_});
push(@qc,$quote_close{$_});
push(@qo2,$quote_open2{$_});
push(@qc2,$quote_close2{$_});
}
$qo=join(')(',@qo);
$qc=join(')(',@qc);
$qo2=join(')(',@qo2);
$qc2=join(')(',@qc2);
$hyphenation_file{''}=$hyphenation_file{'en'};
$br=$collapse_br?"f":"t";
$gd=0;
$ddr=defined $draft{'print'};
if($ddr) {
if($draft{'print'}==0) {
$draft="f";
} else {
$gd=1;
$draft="t";
}
}
if(-e '/dev/null' || !-e 'nul') {
$pathsep=':';
$gs='gs';
} else {
$pathsep=';';
$gs='gswin32c';
}
$gb=$gs_bug?"t":"f";
for (keys %quote) {$lid{$_}=$lid{$quote{$_}}};
$ENV{'PATH'}.="$pathsep$package{'path'}" if($package{'path'});
$delim="%-- End of variable part --";
$cd="/Cd {aload length 2 idiv dup dict begin {D} repeat currentdict end} D";
$mysymb=<1?"s":"")." remaining\n");
}
if($banner) {
$_="/Ba t D /BA {($banner)BN} D\nBs f Pb CP /BO E D pop\n";
&Subst($_);
s/ H\(/ -1 H(/g;
} else {
$_="/Ba f D /BO 0 D Bs";
}
if($tocdoc && $first && $ndoc==1) {
$TC=" TC\n";
$et=" NP Ep ET /Tc f D";
} else {
$TC="";
$et="";
}
$_.="\n/UR ($html) D\n/Ti ($ti) D\n/Au ($au) D\n/Df $draft D\n/ME [";
for $i (sort {$metarc{$a} <=> $metarc{$b}} keys %metarc){
$_.="($meta{$i})";
}
$_.="] D\n$TC";
if($ndoc==1) {$top=$_};
if(!$tocdoc) {
$toc.="ND 1 gt{Ts 3 mul Np $refs{$html}()0 C()BD($ti)ES()$refs{$html}"
." 1 TN()EA()BN}if\n";
}
$hv=0;
while($P2=~s/(\d) (\d) H\(([^\s<)]*)/$1 $2 $nhd H($3)WB $nref Sn(/) {
$nhd++;
if($hv+1<$2) {
for($hv+1..$2-1) {
push(@z1,-$nref);
push(@z2,$_);
}
}
$hv=$2;
$hind[$hv-1]++;
for $i ($hv..5) {$hind[$i]=0};
$hind=join('.',@hind[0..$hv-1]);
$hst=$3;
$'=~/\)EH/;
($htxt=$hst.$`)=~s/\)EA\(//g;
if(!$tocdoc) {
$toc.="$hv NH le{$nref($hind\\240\\240)$hv C($htxt)$nref 1 TN()EA()BN}if\n";
}
push(@z1,$nref);
push(@z2,$hv);
$nref++;
$htxt=~s/(\s+|\)BR\()/ /g;
$htxt=~s/(^\s+|\)[^(]*\(|\s+$)//g;
$htxt="" if(!$latin1);
$dh.="/h$nhd [($hind\\240\\240)($htxt)] D\n";
}
if($tocdoc) {
if($ndoc==1 && !$first) {
$toc="TC RC ZF $_ $P2 WB () BN\n";
$P2="";
$P3="";
$np="";
$_="";
}
}
$P3.="$fl1\n/Cb $bg D /Ct $tcol D /Cl $lcol D /CL -1 D Ct Sc\n";
if($ndoc==1 && !$first) {$P3.="Pt\n"};
$P3.="$fl2\n$_\n$np\n$P2";
if($tocdoc && $ndoc==1 && !$first) {
$np="/Cb $bg D NP RC ZF";
} else {
$fl1="WB NL$et";
$fl2="DS";
$np="0 BO R";
}
}
}
$P3.=($P3!~/\)\s*$/?"()":"")."WB NL";
if(!$tocdoc && $first && $nhd){$P3="$toc/OU t D /Cb $bg D NP Ep ET $P3"};
if(!$first && ($tocdoc || !$tocdoc && $nhd)){$P3.=" $toc"};
if($ntab>=0) {
$_="$tables] D";
&ack($_);
y/\t\f/ /;
s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
s/\)XX/)9 9 PR/g;
s/ H\(/ -1 H(/g;
$tables=$_;
}
$_="%!PS\n%%Title: $title\n$P0$P1";
if($nimg>=0) {
$_.="/AX [".join(' ',@XS)."] D\n/AY [".join(' ',@YS)."] D\n"
."/IX [".join(' ',@IX)."] D\n/IT [".join(' ',@IT)."] D\n";
if($nm>=0) {
$_.="/AZ [".join(' ',@DP)."] D\n/WS [".join(' ',@WS)."] D\n"
."/FC [".join(' ',@FC)."] D\n/NI $nm D\n/BM ".($nm+1)." array D\nSB\n";
for $i (0..$nm) {$_.="$BM[$i]\n\n"}
}
$_.="\n$pv%Endpv\n" if($nps);
}
@kw=split(/[, ]+/,$kw);
@Kw=();
for $i (@kw){push(@Kw,$i) if(!grep(/^$i$/,@Kw))};
$kw=join(', ',@Kw);
for $i (0..$#z2) {
$n=0;
$j=$i;
while($j++<=$#z2 && $z2[$j]>$z2[$i]) {$n++ if($z2[$j]==$z2[$i]+1)};
push(@z3,$n);
}
$tdef=$ntab>=0?"$tbl$tables\n0 1 $ntab\{TS}for RC ZF\n":"";
$hd="/Hr [@z1]D\n/HV [@z2]D\n/Cn [@z3]D";
&cut($hd);
if($gd) {
$sd="/Df t D /DG IW IW mul IL IL mul add sqrt D IW IL IW IL lt{E}if"
." /WM E D /WX E D /DZ 180 D gsave SD /DZ DZ DF mul D SD grestore\n";
} else {
$sd="/Df f D\n";
}
$_.=<}ie SW pop D
ET RC ZF
$sd$rfs$tdef$top$P3
/TE t D NP TU PM 0 eq and{/Pn () D showpage}if end restore
EOD
if(($first || $opt_R) && $xref{'passes'}) {
&dbg("Inserting cross references\n") if($opt_d);
for $i (1..$xref{'passes'}) {&ref};
}
&fin;
sub h2p {
if($html eq '-') {
$_=<>;
} elsif($html=~m|://|) {
if(($prompt || $nrem>50) && $level>1) {
&prompt("Retrieve document $html (y/n/q)? ",$ans);
if($ans=~/q/i) {undef @docs};
return 0 unless($ans=~/y/i);
}
&geturl($html,$_) || return;
$nrem++;
if($contyp!~m|text/html|i) {$_=" \n$_"};
unless(($ba2)=$html=~m|(.*://.*/)|) {$ba2=$html."/"};
} else {
if(open(FILE,$html)) {
&dbg("Reading $html\n") if($opt_W || $opt_d);
$_=;
if(!/1)) {
$_=" \n$_";
}
close FILE;
$var{DOCUMENT_NAME}=$html;
if($posix) {
$var{LAST_MODIFIED}=POSIX::strftime("%c",localtime((stat $html)[9]));
$var{DATE_LOCAL}=POSIX::strftime("%c",@now);
$var{DATE_GMT}=POSIX::strftime("%c",@gmnow);
}
$mod=(stat $html)[9];
} else {
&dbg("*** Error opening $html\n");
return 0;
}
}
if(/^%!/ && /$delim/) {
$psin=1;
&openps if($opt_o);
$_=$P0.$';
for $s ("b","c","cw","g","t") {
&dbg("Option -$s ignored\n") if(eval "\$opt_$s");
}
&fin;
}
&hb($_,$head);
$head=~/" if(!$ti);
$title=$ti if(!$title);
$draft="f" if(!$ddr);
%meta=();
$au="";
while($head=~/ ]*(name|http-equiv)\s*=\s*["']?\s*(\w+)$R/gi) {
$k=lc $2;
($v)=$&=~/content\s*=\s*["']\s*([^"']+)/i;
$v=~s/\s+/ /g;
$v=~s/\s*$//g;
&spec($v);
&ent($v);
$meta{$k}=$v;
if($k=~/author/) {$au=$au?"$au, $v":$v};
if($k=~/keywords/) {$kw=$kw?"$kw, $v":$v};
if($k=~/subject/ && !$su) {$su=$v};
if(!$ddr && $k=~/status/ && $v=~/draft/i) {$draft="t";$gd=1};
}
$Au.=($Au?" + ":"").$au if($au);
$b2=$opt_b;
unless($b2) {
($b2)=$head=~/ ]*rel\s*=\s*["']?next$R/gi) {
if(($lnk)=$&=~/href\s*=\s*["']?\s*([^"' >]*)/gi) {
if($lnk=~m|.+//[^/]+$|) {$lnk=$&."/"}
if($lnk=~m|://|) {
$rlnk=0;
} else {
$rlnk=1;
if($lnk=~m|^/|) {$lnk=$b1.$lnk} else {$lnk=$b2.$lnk}
}
while($lnk!~m|^\.\./| && $lnk=~m|[^/]*/\.\./|) {$lnk=$`.$'};
$lnk=~s|/\./|/|g;
if(&follow && !$levl{$lnk}) {
$levl{$lnk}=$level+1;
push(@links,$lnk);
}
}
}
($battr)=/ ]+lang\s*=\s*['"]?([a-zA-Z-]+)/i if(!$lang);
$lang=$opt_l if($opt_l);
$lang='en' if(!$lang);
$lang=lc $lang;
if($battr=~/\stext\s*=\s*['"]?\s*#?(\w+)/i) {$tcol=&col2rgb($1)};
if(!$tcol) {$tcol="Dt"};
if($battr=~/\slink\s*=\s*['"]?\s*#?(\w+)/i) {$lcol=&col2rgb($1)};
if(!$lcol) {$lcol="Dl"};
&inihyph if($opt_H);
($bg)=$battr=~/BGCOLOR\s*=\s*["']?\s*#?(\w+)/i;
$bg=&col2rgb($bg);
if($bg) {
($red,$grn,$blu)=@cvec;
} else {
($red,$grn,$blu)=$bgcol=~/#(\w+).*#(\w+).*#(\w+)/;
$bg="Db";
}
$temp="";
while(/$idoc";
} else {
&hb($idoc,$dum);
}
$_=$idoc;
$_.=$' if($end=~/<\/object>/i);
} else {
&dbg("\n*** Error opening $uaddr\n");
$_=$end;
}
} else {
$temp.=$tag;
$_=$end;
}
}
$_=$temp.$_;
if($opt_c && defined $package{'check'}) {
$file=$html;
if($html=~m|://|) {
open(SCRATCH,">$scr");
print SCRATCH $head;
print SCRATCH;
close SCRATCH;
$file="$scr";
}
&dbg(`$package{'check'} $file`);
}
if(!$latin1) {
if($opt_e=~/EUC-/i) {
s/([\216\217\241-\376].)+/\000$&\000/g;
&spec($_);
s/\000(.+?)\000/)F1($1)F2(/g;
} elsif($opt_e=~/SHIFT-JIS/i) {
s/[\201-\237\340-\374][@-~\200-\374]/$&\000/g;
s/[\241-\337]+(?!\000)/$&\000/g;
s/[ -~\t\n\r\240]+(?!\000)/\002$&\001/g;
&spec($_);
s/\000//g;
} else {
while(/\e\$B([^\e]*)/) {
$beg=$`;
$end=$';
$mat=$1;
$mat=~s/\s//g;
$_="$beg\001$mat$end";
}
s/\e\([BJ]/\002/g;
&spec($_);
}
s/\001/)F1(/g;
s/\002/)F2(/g;
$_=")F2($_";
y/\000-\010\013\016-\037\177//d;
} else {
&spec($_);
y/\000-\010\013\016-\037\177-\237//d;
}
s/(\r\n|\r)/\n/g;
$refs{$html}=$nref++ if(!defined $refs{$html});
$_="\004$lang\004)WB $refs{$html} Sn($_";
# Yes, I know Perl has case-insensitive pattern matching. But on my system
# it takes about 10 times longer to run!
$pt="";
if(/<[pP][lL][aA][iI][nN][tT][eE][xX][tT]$R/) {$_=$`;$pt=$'};
while($_){
if(/(<[lL][iI][sS][tT][iI][nN][gG]$R)/) {$_=$`; $tag=$1; $rest=$';
if(/<[xX][mM][pP]$R/){$_=$`; &Subst($_); $P2.="$_)XX("; $_=$'.$tag.$rest;
if(m|[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
else {$P2.=$'; $_=""}}
else {&Subst($_); $P2.="$_)XX("; $_=$rest;
if(m|[lL][iI][sS][tT][iI][nN][gG]$R|) {$P2.="$`)RP("; $_=$'}
else {$P2.=$'; $_=""}}}
elsif(/<[xX][mM][pP]$R/) {$_=$`; &Subst($_); $P2.="$_)XX("; $_=$';
if(m|[xX][mM][pP]$R|) {$P2.="$`)RP("; $_=$'}
else {$P2.=$'; $_=""}}
else {&Subst($_);$P2.=$_; $_=""}
}
$pt=~s/\f/$pc/g;
if($pt) {$P2.=")XX($pt"};
$P2.=")";
if($plain) {$P2.="RP ()"};
while($P2=~/XX\(/) {
$beg=$`;
$'=~/\)(RP|$)/;
$mat=$`;
$end=$&.$';
$mat=~s/(.*\n){30}.*/$&)WR(/g;
($temp=$mat)=~s/\)[^(]+\(//g;
@prel=split(' *\n',$temp);
$maxl=0;
for $line (@prel) {
$line=~s/\\.../x/g;
while($line=~/\t+/) {
$sp=' ' x (length($&)*8-length($`)%8);
$line=~s/\t+/$sp/;
$mat=~s/\t+/$sp/;
}
$ll=length($line);
$maxl=$ll if($ll > $maxl);
}
$P2="$beg ".($#prel+1)." $maxl PR($mat$end";
}
$P1=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
$P2=~s/[\200-\377]/sprintf("\\%3.3o",ord($&))/eg;
$P2=~y/\t\f/ /;
1;
}
sub Subst{
local($_)=@_;
if($page_break) {
s//$pc/g;
s/<(\?|hr\s+class\s*=\s*["']?)\s*page-break$R/$pc/gi;
}
s//)WB NL OP(/g;
if($ssi && $html!~m|://|) {
while(//) {
$inc="";
$file=$3;
if($1 eq "include" && (substr($file,0,1) ne "/" || $opt_r)) {
if(substr($file,0,1) ne "/") {
$file=$B2.$file;
} elsif($2 eq "virtual") {
$file=$opt_r.$file;
}
if(open INC,$file) {
$inc=;
&spec($inc);
close INC;
}
} elsif ($1 eq "config" && $2 eq "timefmt") {
if($posix) {
$var{LAST_MODIFIED}=POSIX::strftime($3,localtime((stat $html)[9]));
$var{DATE_LOCAL}=POSIX::strftime($3,@now);
$var{DATE_GMT}=POSIX::strftime($3,@gmnow);
}
} elsif ($1 eq "echo") {
$inc=$var{$3};
}
$_=$`.$inc.$';
}
}
s/(?|?|)/)HY(/g;
while(/