diff options
author | Hans Hagen <pragma@wxs.nl> | 2004-08-15 00:00:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2004-08-15 00:00:00 +0200 |
commit | 57f1545214ebba9625b9be722d4e4f9357dab87a (patch) | |
tree | 29dd99fb0b08de5fca50a557e8af043ea082478a /scripts/context | |
parent | 599c5089a184d1967ec8dc66307de52378e911d4 (diff) | |
download | context-57f1545214ebba9625b9be722d4e4f9357dab87a.tar.gz |
stable 2004.08.15
Diffstat (limited to 'scripts/context')
-rw-r--r-- | scripts/context/perl/texexec.pl | 124 | ||||
-rw-r--r-- | scripts/context/perl/texexec.rme | 2 | ||||
-rw-r--r-- | scripts/context/perl/texfont.pl | 13 | ||||
-rw-r--r-- | scripts/context/ruby/xmltools.rb | 11 |
4 files changed, 117 insertions, 33 deletions
diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl index eb1664357..00e336ea5 100644 --- a/scripts/context/perl/texexec.pl +++ b/scripts/context/perl/texexec.pl @@ -184,6 +184,7 @@ my $Random = 0; my $Filters = ''; my $NoMapFiles = 0 ; my $Foxet = 0 ; +my $UseEnginePath = 0 ; my $StartLine = 0 ; my $StartColumn = 0 ; @@ -285,6 +286,7 @@ my $MakeMpy = ''; "globalfile" => \$GlobalFile, "nomapfiles" => \$NoMapFiles, "foxet" => \$Foxet, + "engine" => \$UseEnginePath, #### exxperiment "startline=s" => \$StartLine, "startcolumn=s" => \$StartColumn, @@ -347,7 +349,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) { *STDERR = *LOGFILE; } -my $Program = " TeXExec 4.3 - ConTeXt / PRAGMA ADE 1997-2004"; +my $Program = " TeXExec 4.4 - ConTeXt / PRAGMA ADE 1997-2004"; print "\n$Program\n\n"; @@ -645,6 +647,11 @@ if ( open( INI, $IniPath ) ) { sub IniValue { my ( $Key, $Default ) = @_; if ( defined( $Done{$Key} ) ) { $Default = $Done{$Key} } + if ($Default =~ /^(true|yes|on)$/io) { + $Default = 1 ; + } elsif ($Default =~ /^(false|no|off)$/io) { + $Default = 0 ; + } if ($Verbose) { print " used setting : $Key = $Default\n" } return $Default; } @@ -676,11 +683,14 @@ my $MpPassString = IniValue( 'MpPassString', '' ); my $MpFormat = IniValue( 'MpFormat', $MetaFun ); my $MpFormatPath = IniValue( 'MpFormatPath', $TeXFormatPath ); +my $UseEnginePath = IniValue( 'UseEnginePath', $UseEnginePath); + my $FmtLanguage = IniValue( 'FmtLanguage', '' ); my $FmtBodyFont = IniValue( 'FmtBodyFont', '' ); my $FmtResponse = IniValue( 'FmtResponse', '' ); my $TcXPath = IniValue( 'TcXPath', '' ); + $SetFile = IniValue( 'SetFile', $SetFile ); if ( ($Verbose) && ( $kpsewhich ne '' ) ) { @@ -718,6 +728,11 @@ if ( $MpFormatFlag eq "" ) { $MpFormatFlag = "-mem=" ; } +if ($UseEnginePath && (! $MakeFormats)) { + $MpFormatFlag .= $MpExecutable . '/' ; + $TeXFormatFlag .= $TeXExecutable . '/' ; +} + #~ if ( $TeXFormatFlag eq "" ) { $TeXFormatFlag = "&" } #~ if ( $MpFormatFlag eq "" ) { $MpFormatFlag = "&" } @@ -730,8 +745,12 @@ if ($TeXProgram) { $TeXExecutable = $TeXProgram } my $fmtutil = ''; +# for the moment forget about fmtutil, since it does not support $engine subpaths + +$Alone = 1 ; + if ( $MakeFormats || $Verbose ) { - if ($Alone) { + if ($Alone || $UseEnginePath) { if ($Verbose) { print " generating format : not using fmtutil\n" } } elsif ( $TeXShell =~ /tetex|fptex/i ) { foreach (@paths) { @@ -739,7 +758,7 @@ if ( $MakeFormats || $Verbose ) { if ( -e $p ) { $fmtutil = $p; last } elsif ( -e $p . '.exe' ) { $fmtutil = $p . '.exe'; last } } - $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ; + $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ; if ($Verbose) { if ( $fmtutil eq '' ) { print " locating fmtutil : not found in path\n"; @@ -921,11 +940,14 @@ sub print_opt { sub show_help_options { print # "\n" . - " --help overview of all options and their values\n" + " --help overview of all options and their values\n" . " --help all all about all options\n" . " --help short just the main options\n" . " --help mode ... pdf all about a few options\n" - . " --help '*.pdf' all about options containing 'pdf'\n"; + . " --help '*.pdf' all about options containing 'pdf'\n" + . "\n" + . " more info http://www.pragma-ade.com/general/manuals/mtexexec.pdf\n" + . " http://www.ntg.nl/mailman/listinfo/ntg-context\n"; } # determine what user wants to see @@ -1238,7 +1260,7 @@ sub CheckPositions { } my $ConTeXtVersion = "unknown"; my $ConTeXtModes = ''; -sub ScanPreamble { +sub ScanTeXPreamble { my ($FileName) = @_; open( TEX, $FileName ); while (<TEX>) { @@ -1266,6 +1288,12 @@ sub ScanPreamble { } } close(TEX); + + # handy later on + + $ProducePdfT = ($OutputFormat eq "pdftex") ; + $ProducePdfM = ($OutputFormat eq "dvipdfm") ; + $ProducePdfX = ($OutputFormat eq "dvipdfmx") ; } sub ScanContent { @@ -1570,6 +1598,23 @@ sub RunConTeXtFile { if ($DummyFile) { open( TMP, ">$JobName.run" ); if ( ( $JobSuffix =~ /(xml|fo|fox)/io ) || $ForceXML ) { + # scan xml preamble + open(XML,"<$JobName.$JobSuffix") ; + while (<XML>) { + if (/\<[a-z]+/io) { + last ; + } elsif (/\<\?context\-directive\s+(.+?)\s+(.+?)\s+(.+?)\s*\?\>/o) { + my ($class, $key, $value) = ($1, $2, $3) ; + if ($class eq 'job') { + if ($key eq 'stylefile') { + print TMP "\\environment $value\n" ; + } elsif ($key eq 'interface') { + $ConTeXtInterface = $value ; + } + } + } + } + close(XML) ; if ( $Filters ne "" ) { print " using xml filters : $Filters\n"; } @@ -1585,9 +1630,8 @@ sub RunConTeXtFile { $JobSuffix = "run"; } if ( ( -e "$JobName.$JobSuffix" ) || ($GlobalFile) ) { - unless ($DummyFile) # we don't need this for xml - { - ScanPreamble("$JobName.$JobSuffix"); + unless ($DummyFile) { # we don't need this for xml + ScanTeXPreamble("$JobName.$JobSuffix"); if ( $ConTeXtInterface eq "unknown" ) { ScanContent("$JobName.$JobSuffix"); } @@ -1692,6 +1736,11 @@ sub RunConTeXtFile { CopyFile( "$JobName.top", "$JobName.tmp" ); unlink "$JobName.tup"; # previous tuo file unlink "$JobName.top"; # runtime option file + if ($ProducePdfX) { + system("dvipdfmx -f dvipdfmx.map -d 4 $JobName") ; + } elsif ($ProducePdfM) { + system("dvipdfm $JobName") ; + } PopResult($JobName); } if ($Purge) { PurgeFiles($JobName) } @@ -2033,6 +2082,7 @@ sub RunCombine { sub LocatedFormatPath { my $FormatPath = shift; + my $EnginePath = shift; if ( ( $FormatPath eq '' ) && ( $kpsewhich ne '' ) ) { $FormatPath = `$kpsewhich --show-path=fmt`; chomp $FormatPath; @@ -2048,6 +2098,14 @@ sub LocatedFormatPath { print " located formatpath : $FormatPath\n"; } } + + if ($UseEnginePath && ($FormatPath ne '' && ($FormatPath !~ /$EnginePath\/$/))) { + $FormatPath .= $EnginePath . '/' ; + unless (-d $FormatPath) { + mkdir $FormatPath ; + } + } + return $FormatPath; } @@ -2056,6 +2114,7 @@ sub RunOneFormat { my @TeXFormatPath; my $TeXPrefix = ""; if ( ( $fmtutil ne "" ) && ( $FormatName !~ /metafun|mptopdf/io ) ) { +# could not happen, not supported any more my $cmd = "$fmtutil --byfmt $FormatName"; if ($Verbose) { print "\n$cmd\n\n" } MakeUserFile; # this works only when the path is kept @@ -2072,11 +2131,11 @@ sub RunOneFormat { $TeXPrefix = "*"; } my $CurrentPath = cwd(); - $TeXFormatPath = LocatedFormatPath($TeXFormatPath); - if ( $TeXFormatPath ne '' ) { chdir $TeXFormatPath } + my $TheTeXFormatPath = LocatedFormatPath($TeXFormatPath, $TeXExecutable); + if ( $TheTeXFormatPath ne '' ) { chdir $TheTeXFormatPath } MakeUserFile; MakeResponseFile; - $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ; + $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ; my $cmd = "$own_quote$TeXProgramPath$TeXExecutable$own_quote $TeXVirginFlag " . "$TeXPassString $PassOn ${TeXPrefix}$FormatName"; @@ -2085,7 +2144,7 @@ sub RunOneFormat { RemoveResponseFile; RestoreUserFile; - if ( ( $TeXFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { + if ( ( $TheTeXFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { chdir $CurrentPath; } } @@ -2130,15 +2189,15 @@ sub RunMpFormat { my $MpFormat = shift; return if ( $MpFormat eq '' ); my $CurrentPath = cwd(); - $MpFormatPath = LocatedFormatPath($MpFormatPath); - if ( $MpFormatPath ne '' ) { chdir "$MpFormatPath" } + my $TheMpFormatPath = LocatedFormatPath($MpFormatPath, $MpExecutable); + if ( $TheMpFormatPath ne '' ) { chdir $TheMpFormatPath } $own_quote = ($MpExecutable =~ m/^[^\"].* / ? "\"" : "") ; my $cmd = "$own_quote$MpExecutable$own_quote $MpVirginFlag $MpPassString $MpFormat"; if ($Verbose) { print "\n$cmd\n\n" } system($cmd ) ; - if ( ( $MpFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { + if ( ( $TheMpFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { chdir $CurrentPath; } } @@ -2298,14 +2357,37 @@ sub checkMPlabels { return 0 unless ( -s "$MpName.mpt" > 10 ); return 0 unless open( MP, "$MpName.mpt" ); my $n = 0; + my $t = "" ; while (<MP>) { - if (/% figure (\d+) : (.*)/o) { $mpbetex{$1} .= "$2\n"; ++$n } + if (/% setup : (.*)/o) { + $t = $1 ; + } else { + $t = "" ; + } + if (/% figure (\d+) : (.*)/o) { + if ($t ne "") { + $mpbetex{$1} .= "$t\n" ; + $t = "" ; + } + $mpbetex{$1} .= "$2\n"; + ++$n ; + } } close(MP); print " second MP run needed : $n tex labels found\n" if $n; return $n; } +sub doMergeMP { + # make sure that the verbatimtex ends up before btex etc + my ($n,$str) = @_ ; + if ($str =~ /(.*?)(verbatimtex.*?etex)\s*\;(.*)/mois) { + return "beginfig($n)\;\n$1$2\;\n$mpbetex{$n}\n$3\;endfig\;\n" ; + } else { + return "beginfig($n)\;\n$mpbetex{$n}\n$str\;endfig\;\n" ; + } +} + sub doRunMP { ########### my ( $MpName, $MergeBE ) = @_; my $TexFound = 0; @@ -2337,9 +2419,9 @@ sub doRunMP { ########### s/(\".*?)\@\@\@(.*?\")/$1\;$2/gmois; # added # merge labels if ($MergeBE) { - s/beginfig\s*\((\d+)\)\s*\;/beginfig($1)\;\n$mpbetex{$1}\n/goims; + # i hate this indirect (sub regexp) mess + s/beginfig\s*\((\d+)\)\s*\;(.*?)endfig\s*\;/doMergeMP($1,$2)/gems ; } - # flush unless (/beginfig\s*\(\s*0\s*\)/gmois) { print MP $mpbetex{0} } print MP $_; print MP "\n" . "end" . "\n"; @@ -2347,7 +2429,7 @@ sub doRunMP { ########### } if ($TexFound) { print " metapost to tex : $MpName\n"; - $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; + $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; $Problems = system("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex"); if ( -e $MpTex && !$Problems ) { @@ -2411,7 +2493,7 @@ sub RunMPX { local $/ = "\0777"; $_ = <MP>; close(MP); - if (/(btex|etex|verbatimtex)/o) { + if (/(btex|etex|verbatimtex)/mos) { print " generating mpx file : $MpName\n"; $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; $Problems = diff --git a/scripts/context/perl/texexec.rme b/scripts/context/perl/texexec.rme index 5ccf1f645..419d1faec 100644 --- a/scripts/context/perl/texexec.rme +++ b/scripts/context/perl/texexec.rme @@ -51,6 +51,8 @@ set TeXShell to tetex % % Here are some general defaults. They can be overruled later. +set UseEnginePath to false + set UsedInterfaces to en nl metafun mptopdf set UserInterface to en diff --git a/scripts/context/perl/texfont.pl b/scripts/context/perl/texfont.pl index bf93ccaf1..bebb636f5 100644 --- a/scripts/context/perl/texfont.pl +++ b/scripts/context/perl/texfont.pl @@ -155,9 +155,6 @@ my $variant = "" ; # atl: encoding variant my $extension = "pfb" ; # atl: default font extension my $lcdf = "" ; # atl: trigger for lcdf otftotfm -my $mappath = 'fonts/map/pdftex/context' ; # will be set later -my $encpath = 'fonts/enc/dvips/context' ; # will be set later - my @cleanup = () ; # atl: build list of generated files to delete # todo: parse name for style, take face from command line @@ -495,7 +492,7 @@ if ($sourcepath eq "auto") # todo uppercase root else { $path = `kpsewhich -expand-path=\\\$$root` } chomp $path ; - $path = $ENV{$root} if (($path == '') && defined($ENV{$root})) ; + $path = $ENV{$root} if (($path eq '') && defined($ENV{$root})) ; report ("checking root : $root") ; if ($preproc) { $sourcepath = "$path/fonts/truetype/$vendor/$collection" } @@ -566,7 +563,7 @@ if ($sourcepath eq "auto") # todo uppercase root error ("unknown subpath ../fonts/afm/$vendor/$collection") unless -d $sourcepath } error ("unknown source path $sourcepath") unless -d $sourcepath ; -error ("unknown option $ARGV[0]") if ($ARGV[0] =~ /\-\-/) ; +error ("unknown option $ARGV[0]") if (($ARGV[0]||'') =~ /\-\-/) ; my $afmpath = "$fontroot/fonts/afm/$vendor/$collection" ; my $tfmpath = "$fontroot/fonts/tfm/$vendor/$collection" ; @@ -694,7 +691,7 @@ sub globafmfiles } return @files } -if ($ARGV[0] ne "") +if ($ARGV[0]) { $pattern = $ARGV[0] ; report ("processing files : all in pattern $ARGV[0]") ; @files = globafmfiles($runpath,$pattern) } @@ -760,7 +757,7 @@ if ($map) print MAP "%\n" ; print MAP "% Alternatively in your TeX source you can say:\n" ; print MAP "%\n" ; - print MAP "% \\pdfmapfile\{+$mapfile\}\n" ; + print MAP "% \\pdf \{+$mapfile\}\n" ; print MAP "%\n" ; print MAP "% In ConTeXt you can best use:\n" ; print MAP "%\n" ; @@ -906,7 +903,7 @@ foreach my $file (@files) if ($afmpl) { report " generating pl : $cleanname$fontsuffix (from $cleanname)" ; $encstr = " -p $encfil" ; - my $command = "afm2pl $shape $passon $encstr $file $cleanname$fontsuffix.vpl" ; + my $command = "afm2pl -f afm2tfm $shape $passon $encstr $file $cleanname$fontsuffix.vpl" ; print "$command\n" if $trace ; my $ok = `$command` ; if (open (TMP,"$cleanname$fontsuffix.map")) diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb index b4a983c9c..c4fcc5937 100644 --- a/scripts/context/ruby/xmltools.rb +++ b/scripts/context/ruby/xmltools.rb @@ -35,7 +35,7 @@ class Commands class << output def xputs(str,n=0) - puts("#{' '*n} #{str}") + puts("#{' '*n}#{str}") end end @@ -170,7 +170,7 @@ class Commands end f.close else - report("missing data log file #{filename}") + report("missing data log file #{file}") end end if png then @@ -182,11 +182,11 @@ class Commands system("imagemagick #{long}.pdf #{long}-%d.jpg") end else - report("error in processing file #{filename}") + report("error in processing file #{file}") end system("texmfstart texutil --purge") else - report("error in processing file #{filename}") + report("error in processing file #{file}") end end @@ -199,6 +199,9 @@ commandline = CommandLine.new commandline.registeraction('dir', 'generate directory listing') commandline.registeraction('mmlpages','generate graphic from mathml') +# commandline.registeraction('dir', 'filename --pattern= --output= [--recurse --stripname --url --root]') +# commandline.registeraction('mmlpages','filename [--eps --jpg --png --style= --mode=]') + commandline.registeraction('ls') commandline.registeraction('help') |