| 1 |
#!/usr/bin/env perl |
| 2 |
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
# mk4ht Version 1.1 % |
| 4 |
# Copyright (C) 2003--2009 Eitan M. Gurari % |
| 5 |
# Copyright 2009 TeX Users Group % |
| 6 |
# % |
| 7 |
# This work may be distributed and/or modified under the % |
| 8 |
# conditions of the LaTeX Project Public License, either % |
| 9 |
# version 1.3 of this license or (at your option) any % |
| 10 |
# later version. The latest version of this license is % |
| 11 |
# in % |
| 12 |
# http://www.latex-project.org/lppl.txt % |
| 13 |
# and version 1.3 or later is part of all distributions % |
| 14 |
# of LaTeX version 2003/12/01 or later. % |
| 15 |
# % |
| 16 |
# This work has the LPPL maintenance status "maintained".% |
| 17 |
# % |
| 18 |
# The Current Maintainer of this work % |
| 19 |
# is the TeX4ht Project. % |
| 20 |
# % |
| 21 |
# [email protected] % |
| 22 |
# http://www.tug.org/tex4ht % |
| 23 |
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 24 |
|
| 25 |
use strict; |
| 26 |
$^W=1; # turn warning on |
| 27 |
my $texFile = ''; |
| 28 |
if( @ARGV ){ |
| 29 |
my(@array) = split('\.',@ARGV[1]); |
| 30 |
$texFile = @array[0]; |
| 31 |
} |
| 32 |
my @options = ( |
| 33 |
"", "ht", "", "", "", "-cvalidatehtml", |
| 34 |
"ht", "htlatex", "latex", "", "", "-cvalidatehtml", |
| 35 |
"ht", "httex", "tex", "", "", "-cvalidatehtml", |
| 36 |
"ht", "httexi", "texi", "", "", "-cvalidatehtml", |
| 37 |
"ht", "htcontext", "context", "", "", "-cvalidatehtml", |
| 38 |
"ht", "htxetex", "xetex", "", "", "-cvalidatehtml", |
| 39 |
"ht", "htxelatex", "xelatex", "", "", "-cvalidatehtml", |
| 40 |
"xh", "xhlatex", "latex", "xhtml", "", "-cvalidate", |
| 41 |
"xh", "xhtex", "tex", "xhtml", "", "-cvalidate", |
| 42 |
"xh", "xhtexi", "texi", "xhtml", "", "-cvalidate", |
| 43 |
"xh", "xhcontext","context", "xhtml", "", "-cvalidat", |
| 44 |
"xh", "xhxelatex", "xelatex", "xhtml", "", "-cvalidate", |
| 45 |
"xh", "xhxetex", "xetex", "xhtml", "", "-cvalidate", |
| 46 |
"uxh", "uxhlatex", "latex", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 47 |
"uxh", "uxhtex", "tex", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 48 |
"uxh", "uxhtexi", "texi", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 49 |
"uxh", "uxhcontext","context", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 50 |
"uxh", "uxhxelatex", "xelatex", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 51 |
"uxh", "uxhxetex", "xetex", "xhtml,uni-html4", " -cunihtf", "-cvalidate", |
| 52 |
"xhm", "xhmlatex", "latex", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 53 |
"xhm", "xhmtex", "tex", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 54 |
"xhm", "xhmtexi", "texi", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 55 |
"xhm", "xhmcontext","context", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 56 |
"xhm", "xhmxelatex", "xelatex", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 57 |
"xhm", "xhmxetex", "xetex", "xhtml,mathml", " -cunihtf", "-cvalidate", |
| 58 |
"mz", "mzlatex", "latex", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 59 |
"mz", "mztex", "tex", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 60 |
"mz", "mztexi", "texi", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 61 |
"mz", "mzcontext", "context", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 62 |
"mz", "mzxelatex", "xelatex", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 63 |
"mz", "mzxetex", "xetex", "xhtml,mozilla", " -cmozhtf", "-cvalidate", |
| 64 |
"oo", "oolatex", "latex", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 65 |
"oo", "ootex", "tex", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 66 |
"oo", "ootexi", "texi", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 67 |
"oo", "oocontext", "context", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 68 |
"oo", "ooxelatex", "xelatex", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 69 |
"oo", "ooxetex", "xetex", "xhtml,ooffice", "ooffice/\! -cmozhtf", "-cooxtpipes -coo", |
| 70 |
"es", "eslatex", "latex", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 71 |
"es", "estex", "tex", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 72 |
"es", "estexi", "texi", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 73 |
"es", "escontext", "context", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 74 |
"es", "esxelatex", "xelatex", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 75 |
"es", "esxetex", "xetex", "xhtml,emspk", " -cemspkhtf -s4es", "-cemspk", |
| 76 |
"js", "jslatex", "latex", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 77 |
"js", "jstex", "tex", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 78 |
"js", "jstexi", "texi", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 79 |
"js", "jscontext", "context", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 80 |
"js", "jsxelatex", "xelatex", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 81 |
"js", "jsxetex", "xetex", "xhtml,jsml", " -cjsmlhtf", "-cjsml", |
| 82 |
"jm", "jmlatex", "latex", "xhtml,jsmath", " -cmozhtf", "", |
| 83 |
"jm", "jmtex", "tex", "xhtml,jsmath", " -cmozhtf", "", |
| 84 |
"jm", "jmtexi", "texi", "xhtml,jsmath", " -cmozhtf", "", |
| 85 |
"jm", "jmcontext", "context", "xhtml,jsmath", " -cmozhtf", "", |
| 86 |
"jm", "jmxelatex", "xelatex", "xhtml,jsmath", " -cmozhtf", "", |
| 87 |
"jm", "jmxetex", "xetex", "xhtml,jsmath", " -cmozhtf", "", |
| 88 |
"tei", "teilatex", "latex", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 89 |
"tei", "teitex", "tex", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 90 |
"tei", "teitexi", "texi", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 91 |
"tei", "teicontext","context", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 92 |
"teim", "teimlatex", "latex", "xhtml,tei-mml"," -cunihtf", "-cvalidate", |
| 93 |
"teim", "teimtex", "tex", "xhtml,tei-mml"," -cunihtf", "-cvalidate", |
| 94 |
"teim", "teimtexi", "texi", "xhtml,tei-mml"," -cunihtf", "-cvalidate", |
| 95 |
"teim", "teimcontext","context","xhtml,tei-mml"," -cunihtf", "-cvalidate", |
| 96 |
"tei", "teixelatex", "xelatex", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 97 |
"tei", "teixetex", "xetex", "xhtml,tei", " -cunihtf", "-cvalidate", |
| 98 |
"db", "dblatex", "latex", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 99 |
"db", "dbtex", "tex", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 100 |
"db", "dbtexi", "texi", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 101 |
"db", "dbcontext", "context", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 102 |
"dbm", "dbmlatex", "latex", "xhtml,docbook-mml", " -cunihtf", "-cdocbk", |
| 103 |
"dbm", "dbmtex", "tex", "xhtml,docbook-mml", " -cunihtf", "-cdocbk", |
| 104 |
"dbm", "dbmtexi", "texi", "xhtml,docbook-mml", " -cunihtf", "-cdocbk", |
| 105 |
"dbm", "dbmcontext","context", "xhtml,docbook-mml", " -cunihtf", "-cdocbk", |
| 106 |
"db", "dbxelatex", "xelatex", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 107 |
"db", "dbxetex", "xetex", "xhtml,docbook", " -cunihtf", "-cvalidate -cdocbk", |
| 108 |
"w", "wlatex", "latex", "xhtml,word", " -csymhtf", "", |
| 109 |
"w", "wtex", "tex", "xhtml,word", " -csymhtf", "", |
| 110 |
"w", "wtexi", "texi", "xhtml,word", " -csymhtf", "", |
| 111 |
"w", "wcontext", "context", "xhtml,word", " -csymhtf", "", |
| 112 |
"w", "wxelatex", "xelatex", "xhtml,word", " -csymhtf", "", |
| 113 |
"w", "wxetex", "xetex", "xhtml,word", " -csymhtf", "", |
| 114 |
"jh", "jhlatex", "latex", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 115 |
"jh", "jhtex", "tex", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 116 |
"jh", "jhtexi", "texi", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 117 |
"jh", "jhcontext","context", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 118 |
"jh", "jhxelatex", "xelatex", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 119 |
"jh", "jhxetex", "xetex", "html,javahelp,xml,3.2,unicode", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp -cvalidatehtml", |
| 120 |
"jh1", "jh1latex", "latex", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 121 |
"jh1", "jh1tex", "tex", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 122 |
"jh1", "jh1texi", "texi", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 123 |
"jh1", "jh1context","context", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 124 |
"jh1", "jh1xelatex", "xelatex", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 125 |
"jh1", "jh1xetex", "xetex", "html,javahelp,xml,3.2,unicode,jh1.0", " -cmozhtf -u10", " -d$texFile-doc/ -cjavahelp", |
| 126 |
|
| 127 |
); |
| 128 |
|
| 129 |
sub showInstrucions(){ |
| 130 |
print " option1: mk4ht #1 \"#2\" \"#3\" \"#4\" \"#5\"\n"; |
| 131 |
print " \n"; |
| 132 |
print " #1: htlatex, xhlatex, mzlatex, oolatex, dblatex, dbmlatex,\n"; |
| 133 |
print " jhlatex, eslatex, teilatex, teimlatex, uxhlatex, \n"; |
| 134 |
print " wlatex, xhmlatex\n"; |
| 135 |
print " \n"; |
| 136 |
print " also 'tex', 'texi', 'context', 'xetex', and 'xelatex'\n"; |
| 137 |
print " instead of 'latex'\n"; |
| 138 |
print " \n"; |
| 139 |
print " #2: file name\n"; |
| 140 |
print " #3: optional arguments for latex/tex/... \n"; |
| 141 |
print " #4: optional arguments for tex4ht.c\n"; |
| 142 |
print " #5: optional arguments for t4ht.c\n"; |
| 143 |
print " \n"; |
| 144 |
print " option2: mk4ht ht #2 #3 \"#4\" \"#5\"\n"; |
| 145 |
print " \n"; |
| 146 |
print " #1: ht\n"; |
| 147 |
print " #2: latex, tex\n"; |
| 148 |
print " #3: file name\n"; |
| 149 |
print " #4: optional arguments for tex4ht.c\n"; |
| 150 |
print " #5: optional arguments for t4ht.c\n"; |
| 151 |
print " \n"; |
| 152 |
print " Within the program, in column three of the options\n"; |
| 153 |
print " variable, the requests for the commands \"latex\",\n"; |
| 154 |
print " \"tex\", etc. can be replaced with other equivalent\n"; |
| 155 |
print " commands (e.g., \"tex -fmt=latex\").\n"; |
| 156 |
|
| 157 |
print "--------------------------------------------------------------------------\n"; |
| 158 |
print " Private configuration file: mk4ht.cfg\n"; |
| 159 |
print "--------------------------------------------------------------------------\n"; |
| 160 |
print "\n"; |
| 161 |
print "A private configuration file mk4ht.cfg or .mk4ht may be placed at the\n"; |
| 162 |
print "work or home directory, to update existing commands and introduce new\n"; |
| 163 |
print "ones. The configuration file may contain records of the following\n"; |
| 164 |
print "kinds.\n"; |
| 165 |
print "\n"; |
| 166 |
print " # Comment\n"; |
| 167 |
print " \n"; |
| 168 |
print " name = type\n"; |
| 169 |
print " Defines a ht*tex like command, and assocites to it the \n"; |
| 170 |
print " TeX compiler of the specified type. Examples of TeX \n"; |
| 171 |
print " types: latex, tex, texi, context, xetex, and xelatex.\n"; |
| 172 |
print " \n"; |
| 173 |
print " name.tex = options\n"; |
| 174 |
print " Command line options for the compilation under\n"; |
| 175 |
print " the (la)tex compiler\n"; |
| 176 |
print " \n"; |
| 177 |
print " name.tex4ht = options\n"; |
| 178 |
print " Command line options for tex4ht.c \n"; |
| 179 |
print " \n"; |
| 180 |
print " name.t4ht = options\n"; |
| 181 |
print " Command line options for t4ht.c\n"; |
| 182 |
print " \n"; |
| 183 |
print "Each record should appear in a different line. Variants\n"; |
| 184 |
print "`name.tex += options', `name.tex4ht += options',\n"; |
| 185 |
print "`name.t4ht += options' of the above records are also allowed.\n"; |
| 186 |
print "They append the listed options to the base values.\n"; |
| 187 |
print "\n"; |
| 188 |
print "Example:\n"; |
| 189 |
print "\n"; |
| 190 |
print " foohlatex = latex\n"; |
| 191 |
print " foohlatex.tex = xhtml,uni-html4\n"; |
| 192 |
print " foohlatex.tex4ht += -cunihtf\n"; |
| 193 |
print " foohlatex.t4ht = -cvalidate\n"; |
| 194 |
print " htlatex.t4ht += -d./\n"; |
| 195 |
|
| 196 |
|
| 197 |
print "--------------------------------------------------------------------------\n"; |
| 198 |
print " Deleting files\n"; |
| 199 |
print "--------------------------------------------------------------------------\n"; |
| 200 |
print "\n"; |
| 201 |
print "The configuration file mk4ht.cfg may also contain requests for\n"; |
| 202 |
print "removing files created in the work directory during the compilation.\n"; |
| 203 |
print "The requests are to be made through records of the following forms.\n"; |
| 204 |
print "\n"; |
| 205 |
print " clean ext1 ext2 ...\n"; |
| 206 |
print " The extensions of the file name to be removed.\n"; |
| 207 |
print " \n"; |
| 208 |
print " clean.name ext1 ext2 ...\n"; |
| 209 |
print " Conditional request. The `name' refers to the ht*tex \n"; |
| 210 |
print " like command in use.\n"; |
| 211 |
print "\n"; |
| 212 |
print "Example:\n"; |
| 213 |
print " clean dvi idv\n"; |
| 214 |
print " clean.foohlatex lg \n"; |
| 215 |
print " clean.htlatex lg tmp\n"; |
| 216 |
|
| 217 |
} |
| 218 |
|
| 219 |
print "mk4ht (Version 1.1)\n"; |
| 220 |
if( !@ARGV ){ |
| 221 |
print "improper command\n"; |
| 222 |
showInstrucions(); exit(1); |
| 223 |
} |
| 224 |
my @command=("","","","",""); |
| 225 |
my $i=0; |
| 226 |
my $j=0; |
| 227 |
my $param; |
| 228 |
my $name; |
| 229 |
my $compiler; |
| 230 |
my $tex; |
| 231 |
my $tex4ht; |
| 232 |
my $t4ht; |
| 233 |
my $texp; |
| 234 |
my $tex4htp = ""; |
| 235 |
my $t4htp = ""; |
| 236 |
my @ext; |
| 237 |
|
| 238 |
foreach $param (@ARGV) { |
| 239 |
if( $i == 0 ){ |
| 240 |
my $inf; |
| 241 |
open $inf, "<mk4ht.cfg" |
| 242 |
or |
| 243 |
( open $inf, "<.mk4ht" |
| 244 |
or |
| 245 |
( |
| 246 |
open $inf, "<" . $ENV{HOME} . "/mk4ht.cfg" |
| 247 |
or |
| 248 |
( |
| 249 |
open $inf, "<" . $ENV{HOME} . "/.mk4ht" |
| 250 |
or $inf = "" |
| 251 |
) ) ) |
| 252 |
; |
| 253 |
|
| 254 |
if( $inf ){ |
| 255 |
print "(mk4ht cfg)\n"; |
| 256 |
while(<$inf>) { |
| 257 |
my($line) = $_; |
| 258 |
chomp($line); # remove eoln char |
| 259 |
if ($line =~ m|\s*#.*|) {} |
| 260 |
elsif($line =~ m|^\s*(\S*)\.(\S*)\s*\+=\s*(.*\S)\s*$|) { |
| 261 |
if( ($param."tex4ht") eq ($1.$2) ){ |
| 262 |
$tex4htp = $tex4htp . " " . $3; |
| 263 |
} |
| 264 |
elsif( ($param."t4ht") eq ($1.$2) ){ |
| 265 |
$t4htp = $t4htp . " " . $3; |
| 266 |
} |
| 267 |
elsif( ($param."tex") eq ($1.$2) ){ |
| 268 |
$texp = $texp . "," . $3; |
| 269 |
} |
| 270 |
} |
| 271 |
elsif($line =~ m|^\s*(\S*)\.(\S*)\s*=\s*(.*\S)\s*$|) { |
| 272 |
if( ($param."tex4ht") eq ($1.$2) ){ |
| 273 |
$tex4ht = $3 . " "; |
| 274 |
$tex4htp = ""; |
| 275 |
} |
| 276 |
elsif( ($param."t4ht") eq ($1.$2) ){ |
| 277 |
$t4ht = $3 . " "; |
| 278 |
$t4htp = ""; |
| 279 |
} |
| 280 |
elsif( ($param."tex") eq ($1.$2) ){ |
| 281 |
$tex = $3 . ","; |
| 282 |
$texp = ""; |
| 283 |
} |
| 284 |
} |
| 285 |
elsif($line =~ m|^\s*(\S*)\s*=\s*(.*\S)\s*$|) { |
| 286 |
if( $param eq $1 ){ |
| 287 |
$name = $1; |
| 288 |
$compiler = $2; |
| 289 |
} |
| 290 |
} |
| 291 |
elsif($line =~ m|^\s*clean\s+(.+)|){ |
| 292 |
my(@array) = split(' ',$1); |
| 293 |
push(@ext,@array); |
| 294 |
} elsif($line =~ m|^\s*clean\.(\S+)\s+(.+)|){ |
| 295 |
if( $1 eq @ARGV[0] ){ |
| 296 |
my(@array) = split(' ',$2); |
| 297 |
push(@ext,@array); |
| 298 |
} } |
| 299 |
|
| 300 |
elsif ($line) { print "--- Error --- " . $line . "\n"; } |
| 301 |
} |
| 302 |
close $inf; |
| 303 |
} |
| 304 |
|
| 305 |
for( $j=1; $j<$#options; $j+=6 ){ |
| 306 |
if( $param eq $options[$j] ){ |
| 307 |
if( $name ){ |
| 308 |
$command[0] = "ht".$compiler; |
| 309 |
if( $tex ){ $command[2] = $tex; } else { $command[2] = ""; } |
| 310 |
if( $tex4ht ){ $command[3] = $tex4ht; } else { $command[3] = ""; } |
| 311 |
if( $t4ht ){ $command[4] = $t4ht; } else { $command[4] = ""; } |
| 312 |
|
| 313 |
} else { |
| 314 |
if( $options[$j-1] eq "" ){ |
| 315 |
$command[0] = $options[$j]; |
| 316 |
} else { |
| 317 |
$command[0] = "ht".$options[$j+1]; |
| 318 |
} |
| 319 |
if( $tex ){ $command[2] = $tex; } else { $command[2] = $options[$j+2]; } |
| 320 |
if( $tex4ht ){ $command[3] = $tex4ht; } else { $command[3] = $options[$j+3]; } |
| 321 |
if( $t4ht ){ $command[4] = $t4ht; } else { $command[4] = $options[$j+4]; } |
| 322 |
|
| 323 |
} |
| 324 |
if( $texp ){ $command[2] = $command[2] . "," . $texp; } |
| 325 |
if( $tex4htp){ $command[3] = $command[3] . " " . $tex4htp; } |
| 326 |
if( $t4htp ){ $command[4] = $command[4] . " " . $t4htp; } |
| 327 |
|
| 328 |
last; |
| 329 |
} } |
| 330 |
if( $j>$#options ){ |
| 331 |
if( $name ){ $command[0] = "ht".$compiler; |
| 332 |
if( $tex ){ $command[2] = $tex; } else { $command[2] = ""; } |
| 333 |
if( $tex4ht ){ $command[3] = $tex4ht; } else { $command[3] = ""; } |
| 334 |
if( $t4ht ){ $command[4] = $t4ht; } else { $command[4] = ""; } |
| 335 |
} |
| 336 |
else { |
| 337 |
print "improper command: $param \n"; |
| 338 |
showInstrucions(); exit(1); |
| 339 |
} } |
| 340 |
} elsif ( $i== 1 ) { |
| 341 |
$command[1] = $param; |
| 342 |
} elsif ( $i== 2 ) { |
| 343 |
if( $command[2] eq "" ){ |
| 344 |
$command[2] = $param; |
| 345 |
} else { |
| 346 |
$command[2] = $param. "," . $command[2]; |
| 347 |
} |
| 348 |
} elsif ( $i== 3 ) { |
| 349 |
$command[3] = $param . $command[3]; |
| 350 |
} else { |
| 351 |
$command[4] = $param. " " .$command[4]; |
| 352 |
} |
| 353 |
$i++; |
| 354 |
} |
| 355 |
my $cmd; |
| 356 |
open (KPSEA, "kpsewhich " . $command[0] . " |"); |
| 357 |
if ($cmd = <KPSEA>){ |
| 358 |
$cmd =~ s/\s+$//; |
| 359 |
} else { |
| 360 |
$cmd = $command[0]; |
| 361 |
} |
| 362 |
close KPSEA; |
| 363 |
|
| 364 |
my $commando = $cmd . " " . $command[1] . " \"". |
| 365 |
$command[2] . "\" \"". $command[3] . "\" \"" . |
| 366 |
$command[4] . "\""; |
| 367 |
print "$commando\n"; |
| 368 |
my $rtrn; |
| 369 |
if( $rtrn = system($commando) ){ |
| 370 |
print "--- error --- failed to execute command\n"; |
| 371 |
} else { |
| 372 |
my $file; |
| 373 |
my $ext; |
| 374 |
opendir(DIR,".") ; |
| 375 |
while ($file = readdir(DIR) ){ |
| 376 |
if(index($file,$texFile) == 0 ){ |
| 377 |
foreach $ext(@ext){ |
| 378 |
if (index($file,$ext,length($file)-length($ext)) != -1){ |
| 379 |
if( stat($file)){ |
| 380 |
unlink($file); |
| 381 |
print "Deleted: ". $file . "\n"; |
| 382 |
} } } } } |
| 383 |
closedir(DIR); |
| 384 |
|
| 385 |
} |
| 386 |
exit( $rtrn ); |
| 387 |
|