From cb44a2aa0526c4b6ffb1b01110fac78222c315ca Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 26 Jun 2004 00:00:00 +0200 Subject: stable 2004.06.26 --- scripts/context/perl/texexec.pl | 11 +++-- scripts/context/perl/texutil.pl | 2 +- scripts/context/ruby/xmltools.rb | 80 ++++++++++++++++++++----------------- scripts/context/ruby/xmpl/switch.rb | 43 ++++++++++++++------ 4 files changed, 83 insertions(+), 53 deletions(-) (limited to 'scripts') diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl index 0e1d4c0ab..a68135ded 100644 --- a/scripts/context/perl/texexec.pl +++ b/scripts/context/perl/texexec.pl @@ -987,7 +987,10 @@ sub RunPerlScript { } else { $cmd = "$ScriptName $Options"; } - unless ( $cmd eq "" ) { system($cmd) } + unless ( $cmd eq "" ) { + print $cmd if ($Verbose) ; + system($cmd) ; + } } my $FullFormat = ''; @@ -1524,7 +1527,7 @@ my $DummyFile = 0; sub isXMLfile { my $Name = shift; - if ( ($ForceXML) || ( $Name =~ /\.xml$/io ) ) { return 1 } + if ( ($ForceXML) || ( $Name =~ /\.(xml|fo)$/io ) ) { return 1 } else { open( XML, $Name ); my $str = ; @@ -1546,7 +1549,7 @@ sub RunConTeXtFile { system("pdfclose --all") unless $ok ; } if ( -e "$JobName.$JobSuffix" ) { - $DummyFile = ( ($ForceXML) || ( $JobSuffix =~ /xml/io ) ); + $DummyFile = ( ($ForceXML) || ( $JobSuffix =~ /(xml|fo)/io ) ); } # to be considered : # { $DummyFile = isXMLfile("$JobName.$JobSuffix") } @@ -1558,7 +1561,7 @@ sub RunConTeXtFile { } if ($DummyFile) { open( TMP, ">$JobName.run" ); - if ( ( $JobSuffix =~ /xml/io ) || $ForceXML ) { + if ( ( $JobSuffix =~ /(xml|fo)/io ) || $ForceXML ) { if ( $Filters ne "" ) { print " using xml filters : $Filters\n"; } diff --git a/scripts/context/perl/texutil.pl b/scripts/context/perl/texutil.pl index 0886f0e9c..06bccb82f 100644 --- a/scripts/context/perl/texutil.pl +++ b/scripts/context/perl/texutil.pl @@ -2023,7 +2023,7 @@ sub SaveFigurePresets { ++$NOfFigures ; $Figures[$NOfFigures] = "\\presetfigure[$FNam][e=$FTyp" ; if ($FUni) - { $Figures[$NOfFigures] .= (sprintf ",w=%5.3fcm,h=%5.3fcm\n", $FWid, $FHei) } + { $Figures[$NOfFigures] .= (sprintf ",w=%5.3fcm,h=%5.3fcm", $FWid, $FHei) } else { $Figures[$NOfFigures] .= ",w=${FWid}bp,h=${FHei}bp" } if (($FXof!=0)||($FYof!=0)) diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb index 0c2367068..b4a983c9c 100644 --- a/scripts/context/ruby/xmltools.rb +++ b/scripts/context/ruby/xmltools.rb @@ -118,6 +118,7 @@ class Commands file = @commandline.argument('first') eps = @commandline.option('eps') + jpg = @commandline.option('jpg') png = @commandline.option('png') style = @commandline.option('style') modes = @commandline.option('modes') @@ -128,51 +129,57 @@ class Commands style = "--arg=\"style=#{style}\"" unless style.empty? modes = "--mode=#{modes}" unless modes.empty? if system("texmfstart texexec.pl --batch --pdf --once --result=#{long} --use=mmlpag #{style} #{modes} #{file}.xml") then - if f = open("#{file}-mmlpages.txt") then - while line = f.gets do - data = Hash.new - if fields = line.split then - fields.each do |fld| - key, value = fld.split('=') - data[key] = value if key && value - end - if data.key?('p') then - page = data['p'] - name = "#{long}-#{page}" - if eps then - report("generating eps file #{name}") - if system("pdftops -eps -f #{page} -l #{page} #{long}.pdf #{name}.eps") then - if data.key?('d') then - if epsfile = IO.read("#{name}.eps") then - epsfile.sub!(/^(\%\%BoundingBox:.*?$)/i) do - newline = $1 + "\n%%Baseline: #{data['d']}\n" - if data.key?('w') && data.key?('h') then - newline += "%%PositionWidth: #{data['w']}\n" - newline += "%%PositionHeight: #{data['h']}\n" - newline += "%%PositionDepth: #{data['d']}" + if eps then + if f = open("#{file}-mmlpages.txt") then + while line = f.gets do + data = Hash.new + if fields = line.split then + fields.each do |fld| + key, value = fld.split('=') + data[key] = value if key && value + end + if data.key?('p') then + page = data['p'] + name = "#{long}-#{page.to_i-1}" + if eps then + report("generating eps file #{name}") + if system("pdftops -eps -f #{page} -l #{page} #{long}.pdf #{name}.eps") then + if data.key?('d') then + if epsfile = IO.read("#{name}.eps") then + epsfile.sub!(/^(\%\%BoundingBox:.*?$)/i) do + newline = $1 + "\n%%Baseline: #{data['d']}\n" + if data.key?('w') && data.key?('h') then + newline += "%%PositionWidth: #{data['w']}\n" + newline += "%%PositionHeight: #{data['h']}\n" + newline += "%%PositionDepth: #{data['d']}" + end + newline + end + if g = File.open("#{name}.eps",'wb') then + g.write(epsfile) + g.close end - newline - end - if g = File.open("#{name}.eps",'wb') then - g.write(epsfile) - g.close end end + else + report("error in generating eps from #{name}") end - else - report("error in generating eps from #{name}") end end - if png then - report("generating png file #{name}") - system("imagemagick #{name}.eps #{name}.png") - end end end + f.close + else + report("missing data log file #{filename}") end - f.close - else - report("missing data log file #{filename}") + end + if png then + report("generating png file for #{long}") + system("imagemagick #{long}.pdf #{long}-%d.png") + end + if jpg then + report("generating jpg files for #{long}") + system("imagemagick #{long}.pdf #{long}-%d.jpg") end else report("error in processing file #{filename}") @@ -207,6 +214,7 @@ commandline.registervalue('root') commandline.registerflag('eps') commandline.registerflag('png') +commandline.registerflag('jpg') commandline.registervalue('style') commandline.registervalue('modes') diff --git a/scripts/context/ruby/xmpl/switch.rb b/scripts/context/ruby/xmpl/switch.rb index 69d2a8644..9c38cdbdd 100644 --- a/scripts/context/ruby/xmpl/switch.rb +++ b/scripts/context/ruby/xmpl/switch.rb @@ -32,27 +32,46 @@ module CommandBase def initialize(commandline,logger,banner) @commandline, @logger, @banner = commandline, logger, banner + @forcenewline, @versiondone = false, false version if @commandline.option('version') end - def report(*str) - @logger.report(str) - end - def reportlines(*str) @logger.reportlines(str) end - def version # just a bit of playing with defs - report(@banner.join(' - ')) - def report(*str) + # only works in 1.8 + # + # def report(*str) + # @logger.report(str) + # end + # + # def version # just a bit of playing with defs + # report(@banner.join(' - ')) + # def report(*str) + # @logger.report + # @logger.report(str) + # def report(*str) + # @logger.report(str) + # end + # end + # def version + # end + # end + + def report(*str) + if @forcenewline then @logger.report - @logger.report(str) - def report(*str) - @logger.report(str) - end + @forcenewline = false end - def version + @logger.report(str) + end + + def version # just a bit of playing with defs + unless @versiondone then + report(@banner.join(' - ')) + @forcenewline = true + @versiondone = true end end -- cgit v1.2.3