diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/perl/texexec.pl | 44 | ||||
-rw-r--r-- | scripts/context/perl/texutil.pl | 4 | ||||
-rw-r--r-- | scripts/context/ruby/ctxtools.rb | 116 | ||||
-rw-r--r-- | scripts/context/ruby/exa/logger.rb | 6 | ||||
-rw-r--r-- | scripts/context/ruby/texmfstart.rb | 20 |
5 files changed, 170 insertions, 20 deletions
diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl index 523c2b1be..277e2f810 100644 --- a/scripts/context/perl/texexec.pl +++ b/scripts/context/perl/texexec.pl @@ -148,6 +148,7 @@ my $PrintFormat = 'standard'; my $ProducePdfT = 0; my $ProducePdfM = 0; my $ProducePdfX = 0; +my $ProducePdfXTX = 0; my $Input = ""; my $Result = ''; my $Suffix = ''; @@ -189,6 +190,7 @@ my $NoMapFiles = 0 ; my $Foxet = 0 ; my $TheEnginePath = 0 ; my $Paranoid = 0 ; +my $NotParanoid = 0 ; my $StartLine = 0 ; my $StartColumn = 0 ; @@ -245,6 +247,7 @@ my $MakeMpy = ''; "pdf" => \$ProducePdfT, "pdm" => \$ProducePdfM, "pdx" => \$ProducePdfX, + "xtx" => \$ProducePdfXTX, "pdfarrange" => \$PdfArrange, "pdfselect" => \$PdfSelect, "pdfcombine" => \$PdfCombine, @@ -294,6 +297,7 @@ my $MakeMpy = ''; "foxet" => \$Foxet, "engine" => \$TheEnginePath, "paranoid" => \$Paranoid, + "notparanoid" => \$NotParanoid, #### experiment "startline=s" => \$StartLine, "startcolumn=s" => \$StartColumn, @@ -328,9 +332,13 @@ if ($Paranoid) { $ENV{shell_escape} = 'f' ; $ENV{openout_any} = 'p' ; $ENV{openin_any} = 'p' ; +} elsif ($NotParanoid) { + $ENV{shell_escape} = 't' ; + $ENV{openout_any} = 'p' ; + $ENV{openin_any} = 'a' ; } -if (($ENV{openout_any} eq 'p') || ($ENV{openin_any} eq 'p')) { +if ($ENV{openin_any} eq 'p') { $Paranoid = 1 ; # extra test in order to set readlevel } @@ -346,10 +354,11 @@ if ($ScreenSaver) { } if ( $DoMPTeX || $DoMPXTeX ) { - $RunOnce = 1; - $ProducePdfT = 0; - $ProducePdfX = 0; - $ProducePdfM = 0; + $RunOnce = 1; + $ProducePdfT = 0; + $ProducePdfX = 0; + $ProducePdfM = 0; + $ProducePdfXTX = 0; } if ( $PdfArrange || $PdfSelect || $PdfCopy || $PdfCombine ) { @@ -357,9 +366,15 @@ if ( $PdfArrange || $PdfSelect || $PdfCopy || $PdfCombine ) { $RunOnce = 1; } -if ($ProducePdfT) { $OutputFormat = "pdftex" } -elsif ($ProducePdfM) { $OutputFormat = "dvipdfm" } -elsif ($ProducePdfX) { $OutputFormat = "dvipdfmx" } +if ($ProducePdfT) { $OutputFormat = "pdftex" } +elsif ($ProducePdfM) { $OutputFormat = "dvipdfm" } +elsif ($ProducePdfX) { $OutputFormat = "dvipdfmx" } +elsif ($ProducePdfXTX) { $OutputFormat = "xetex" } + +if ( $ProducePdfXTX ) { + $TeXProgram = 'xetex' ; # ignore the default pdfetex engine + $PassOn .= ' -no-pdf ' ; # Adam Lindsay's preference +} if ($AutoPdf) { $PdfOpen = $PdfClose = 1 ; @@ -388,7 +403,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) { *STDERR = *LOGFILE; } -my $Program = " TeXExec 5.2.2 - ConTeXt / PRAGMA ADE 1997-2004"; +my $Program = " TeXExec 5.2.3 - ConTeXt / PRAGMA ADE 1997-2004"; print "\n$Program\n\n"; @@ -849,6 +864,7 @@ $OutputFormats{dviwindo} = "dviwindo"; $OutputFormats{dviview} = "dviview"; $OutputFormats{dvipdfm} = "dvipdfm"; $OutputFormats{dvipdfmx} = "dvipdfmx"; +$OutputFormats{xetex} = "xetex"; my @ConTeXtFormats = ( "nl", "en", "de", "cz", "uk", "it", "ro", "xx" ); @@ -1335,9 +1351,10 @@ sub ScanTeXPreamble { # handy later on - $ProducePdfT = ($OutputFormat eq "pdftex") ; - $ProducePdfM = ($OutputFormat eq "dvipdfm") ; - $ProducePdfX = ($OutputFormat eq "dvipdfmx") ; + $ProducePdfT = ($OutputFormat eq "pdftex") ; + $ProducePdfM = ($OutputFormat eq "dvipdfm") ; + $ProducePdfX = ($OutputFormat eq "dvipdfmx") ; + $ProducePdfXTX = ($OutputFormat eq "xetex") ; } sub ScanContent { @@ -1865,6 +1882,8 @@ if ($JobSuffix =~ /\_fo$/i) { system("dvipdfmx -f dvipdfmx.map -d 4 $JobName") ; } elsif ($ProducePdfM) { system("dvipdfm $JobName") ; + } elsif ($ProducePdfXTX) { + system("xdv2pdf $JobName.xdv") ; } PopResult($JobName); } @@ -2387,6 +2406,7 @@ sub RunFiles { } else { my $JobSuffix = "tex"; foreach my $JobName (@ARGV) { + next if ($JobName =~ /^\-/io) ; # start experiment - full name spec including suffix is prerequisite if (($StartLine>0) && ($EndLine>=$StartLine) && (-e $JobName)) { if (open(INP,$JobName) && open(OUT,'>texexec.tex')) { diff --git a/scripts/context/perl/texutil.pl b/scripts/context/perl/texutil.pl index bcee7dbdb..fa3f78919 100644 --- a/scripts/context/perl/texutil.pl +++ b/scripts/context/perl/texutil.pl @@ -2752,7 +2752,7 @@ sub PurgeFiles # no my in foreach foreach $suffix (@texnonesuffixes) { foreach (@files) { if (/(.*)\.$suffix$/i) - { if ((-e "$1.tex")||(-e "$1.xml")) + { if ((-e "$1.tex")||(-e "$1.xml")||(-e "$1.fo")) { KeepContextFile($_) } else { $strippedname = $1 ; @@ -2815,7 +2815,7 @@ sub FilterPages # temp feature / no reporting close(PDF) ; close(TUO) } } -sub GenerateSciteApi # ugly, not generic, but fast +sub GenerateSciteApi # ugly, not generic, but fast, will become xsltproc based { my $filename = $ARGV[0] ; my $commands = 0 ; my $environments = 0 ; diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb index 36b34f30e..59243aee0 100644 --- a/scripts/context/ruby/ctxtools.rb +++ b/scripts/context/ruby/ctxtools.rb @@ -19,6 +19,26 @@ require 'ftools' require 'xmpl/switch' require 'exa/logger' +class String + + def i_translate(element, attribute, category) + self.gsub!(/(<#{element}.*?#{attribute}=)([\"\'])(.*?)\2/) do + if category.key?($3) then + "#{$1}#{$2}#{category[$3]}#{$2}" + else + "#{$1}#{$2}#{$3}#{$2}" # unchanged + end + end + end + + def i_load(element, category) + self.scan(/<#{element}.*?name=([\"\'])(.*?)\1.*?value=\1(.*?)\1/) do + category[$2] = $3 + end + end + +end + class Commands include CommandBase @@ -78,12 +98,108 @@ class Commands end + def translateinterface + + # since we know what kind of file we're dealign with, + # we do it quick and dirty instead of using rexml or + # xslt + + interfaces = @commandline.arguments + + if interfaces.empty? then + interfaces = ['cz','de','it','nl','ro'] + else + interfaces.delete('en') + end + + interfaces.flatten.each do |interface| + + variables, constants, strings, list, data = Hash.new, Hash.new, Hash.new, '', '' + + keyfile, intfile, outfile = "keys-#{interface}.xml", "cont-en.xml", "cont-#{interface}.xml" + + report("generating #{keyfile}") + + begin + one = "texexec --make --alone --all #{interface}" + two = "texexec --batch --silent --interface=#{interface} x-set-01" + if @commandline.option("force") then + system(one) + system(two) + elsif not system(two) then + system(one) + system(two) + end + rescue + end + + unless File.file?(keyfile) then + report("no #{keyfile} generated") + next + end + + report("loading #{keyfile}") + + begin + list = IO.read(keyfile) + rescue + list = empty + end + + if list.empty? then + report("error in loading #{keyfile}") + next + end + + list.i_load('cd:variable', variables) + list.i_load('cd:constant', constants) + list.i_load('cd:command' , strings) + list.i_load('cd:element' , strings) + + report("loading #{intfile}") + + begin + data = IO.read(intfile) + rescue + data = empty + end + + if data.empty? then + report("error in loading #{intfile}") + next + end + + report("translating interface en to #{interface}") + + data.i_translate('cd:string' , 'value', strings) + data.i_translate('cd:variable' , 'value', variables) + data.i_translate('cd:parameter', 'name' , constants) + data.i_translate('cd:constant' , 'type' , variables) + data.i_translate('cd:variable' , 'type' , variables) + data.i_translate('cd:inherit' , 'name' , strings) + data.i_translate('cd:command' , 'name' , strings) + + report("saving #{outfile}") + + begin + if f = File.open(outfile, 'w') then + f.write(data) + f.close + end + rescue + end + + end + + end + end logger = EXA::ExaLogger.new(banner.shift) commandline = CommandLine.new commandline.registeraction('touchcontextfile', '') +commandline.registeraction('translateinterface', '') commandline.registeraction('help') commandline.registeraction('version') diff --git a/scripts/context/ruby/exa/logger.rb b/scripts/context/ruby/exa/logger.rb index fc5212fc0..0bbd67f24 100644 --- a/scripts/context/ruby/exa/logger.rb +++ b/scripts/context/ruby/exa/logger.rb @@ -88,6 +88,10 @@ module EXA @@verbose = true end + def silent + @@verbose = false + end + def verbose? @@verbose end @@ -101,4 +105,4 @@ module EXA end -end
\ No newline at end of file +end diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb index 67aba9dbe..47e8ff25d 100644 --- a/scripts/context/ruby/texmfstart.rb +++ b/scripts/context/ruby/texmfstart.rb @@ -162,6 +162,15 @@ def expanded(arg) end end +def runcommand(command) + if $execute then + report("using 'exec' instead of 'system' call") if $verbose + exec(command) + else + system(command) + end +end + def runoneof(application,fullname,browserpermitted) if browserpermitted && launch(fullname) then return true @@ -175,7 +184,7 @@ def runoneof(application,fullname,browserpermitted) return true else applications.each do |a| - if system([a,fullname,expanded($arguments)].join(' ')) then + if runcommand([a,fullname,expanded($arguments)].join(' ')) then return true end end @@ -185,14 +194,14 @@ def runoneof(application,fullname,browserpermitted) print [fullname,expanded($arguments)].join(' ') return true else - return system([fullname,expanded($arguments)].join(' ')) + return runcommand([fullname,expanded($arguments)].join(' ')) end else if $report then print [applications,fullname,expanded($arguments)].join(' ') return true else - return system([applications,fullname,expanded($arguments)].join(' ')) + return runcommand([applications,fullname,expanded($arguments)].join(' ')) end end return false @@ -208,7 +217,7 @@ def usage print("\n") print("usage : texmfstart [switches] filename [optional arguments]\n") print("\n") - print("switches : --verbose --report --browser --direct\n") + print("switches : --verbose --report --browser --direct --execute\n") print(" --program --file --page --arguments\n") print(" --make --lmake --wmake\n") print("\n") @@ -431,7 +440,7 @@ end def direct(fullname) begin - return system([fullname.sub(/^bin\:/, ''),expanded($arguments)].join(' ')) + return runcommand([fullname.sub(/^bin\:/, ''),expanded($arguments)].join(' ')) rescue return false end @@ -486,6 +495,7 @@ $browser = $directives['browser'] || false $report = $directives['report'] || false $verbose = $directives['verbose'] || false $arguments = $directives['arguments'] || '' +$execute = $directives['execute'] || $directives['exec'] || false $make = $directives['make'] || false $unix = $directives['unix'] || false |