From 6b30d8eb0ad7be8b7581f54e5cbcfc3ea413a804 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 21 Jun 2004 00:00:00 +0200 Subject: stable 2004.06.21 --- scripts/context/perl/texexec.rme | 4 +- scripts/context/ruby/textools.rb | 2 +- scripts/context/ruby/xmltools.rb | 81 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/context/perl/texexec.rme b/scripts/context/perl/texexec.rme index ff3d3ae26..5ccf1f645 100644 --- a/scripts/context/perl/texexec.rme +++ b/scripts/context/perl/texexec.rme @@ -115,12 +115,12 @@ for fptex set MpPassString to -progname=mpost -translate-file=natural for miktex set TeXHashExecutable to initexmf --update-fndb for miktex set TeXExecutable to pdfetex for miktex set TeXVirginFlag to --initialize -for miktex set TeXPassString to --alias=context --8bit +for miktex set TeXPassString to --alias=context --translate-file=natural.tcx for miktex set TeXBatchFlag to --interaction=batchmode for miktex set TeXNonStopFlag to --interaction=nonstopmode for miktex set MpToTeXExecutable to mptotex for miktex set MpVirginFlag to --initialize -for miktex set MpPassString to --alias=mpost +for miktex set MpPassString to --alias=mpost --translate-file=natural.tcx for miktex set MpBatchFlag to --interaction=batchmode for miktex set MpNonStopFlag to --interaction=nonstopmode diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb index 379964dde..fec093cf3 100644 --- a/scripts/context/ruby/textools.rb +++ b/scripts/context/ruby/textools.rb @@ -11,7 +11,7 @@ banner = ['TeXTools', 'version 1.2', '2002/2004', 'PRAGMA ADE/POD'] unless defined? ownpath - ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') + ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'') $: << ownpath end diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb index e1803daf6..0c2367068 100644 --- a/scripts/context/ruby/xmltools.rb +++ b/scripts/context/ruby/xmltools.rb @@ -11,7 +11,7 @@ banner = ['XMLTools', 'version 1.0', '2002/2004', 'PRAGMA ADE/POD'] unless defined? ownpath - ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') + ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'') $: << ownpath end @@ -114,12 +114,84 @@ class Commands alias ls :dir + def mmlpages + + file = @commandline.argument('first') + eps = @commandline.option('eps') + png = @commandline.option('png') + style = @commandline.option('style') + modes = @commandline.option('modes') + + file = file.sub(/\.xml/io, '') + long = "#{file}-mmlpages" + if FileTest.file?(file+'.xml') then + 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']}" + end + newline + end + if g = File.open("#{name}.eps",'wb') then + g.write(epsfile) + g.close + end + end + 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 + end + f.close + else + report("missing data log file #{filename}") + end + else + report("error in processing file #{filename}") + end + system("texmfstart texutil --purge") + else + report("error in processing file #{filename}") + end + + end + end logger = EXA::ExaLogger.new(banner.shift) commandline = CommandLine.new -commandline.registeraction('dir','generate directory listing') +commandline.registeraction('dir', 'generate directory listing') +commandline.registeraction('mmlpages','generate graphic from mathml') + commandline.registeraction('ls') commandline.registeraction('help') @@ -133,6 +205,11 @@ commandline.registervalue('url') commandline.registervalue('output') commandline.registervalue('root') +commandline.registerflag('eps') +commandline.registerflag('png') +commandline.registervalue('style') +commandline.registervalue('modes') + commandline.expand Commands.new(commandline,logger,banner).send(commandline.action || 'help') \ No newline at end of file -- cgit v1.2.3