summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2005-07-13 00:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2005-07-13 00:00:00 +0200
commitc7f924443bf5e21f5cd9210fc76c633a3a77e20e (patch)
tree43b35cb107e3c369f19d7b0147a6476a0dcda0cc /scripts
parent606ac7d65f5f5974ae7926e84dfb34849ce96db8 (diff)
downloadcontext-c7f924443bf5e21f5cd9210fc76c633a3a77e20e.tar.gz
stable 2005.07.13
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/mptopdf.pl34
-rw-r--r--scripts/context/ruby/base/tex.rb10
-rw-r--r--scripts/context/ruby/base/texutil.rb8
-rw-r--r--scripts/context/ruby/mpstools.rb5
-rw-r--r--scripts/context/ruby/newtexutil.rb104
-rw-r--r--scripts/context/ruby/texmfstart.rb21
6 files changed, 142 insertions, 40 deletions
diff --git a/scripts/context/perl/mptopdf.pl b/scripts/context/perl/mptopdf.pl
index 0528a4010..5b00d4679 100644
--- a/scripts/context/perl/mptopdf.pl
+++ b/scripts/context/perl/mptopdf.pl
@@ -26,14 +26,15 @@ use strict ;
$Getopt::Long::passthrough = 1 ; # no error message
$Getopt::Long::autoabbrev = 1 ; # partial switch accepted
-my $Help = my $Latex = my $RawMP = 0 ;
+my $Help = my $Latex = my $RawMP = my $MetaFun = 0 ;
my $PassOn = '' ;
&GetOptions
- ( "help" => \$Help ,
- "rawmp" => \$RawMP,
- "passon" => \$PassOn,
- "latex" => \$Latex ) ;
+ ( "help" => \$Help ,
+ "rawmp" => \$RawMP,
+ "metafun" => \$MetaFun,
+ "passon" => \$PassOn,
+ "latex" => \$Latex ) ;
my $program = "MPtoPDF 1.3" ;
my $pattern = $ARGV[0] ;
@@ -70,7 +71,12 @@ elsif ($pattern =~ /\.mp$/io)
if ($RawMP)
{ if ($Latex)
{ $rest .= " $mplatexswitch" }
- $mpbin = 'mpost' }
+ if ($MetaFun) {
+ $mpbin = 'mpost --mem=mpost' ;
+ } else {
+ $mpbin = 'mpost --mem=metafun' ;
+ }
+ }
else
{ if ($Latex)
{ $rest .= " $texlatexswitch" }
@@ -93,19 +99,15 @@ foreach my $file (@files)
{ $_ = $file ;
if (s/\.(\d+|mps)$// && -e $file)
{ if ($miktex)
- { if ($dosish)
- { $command = "pdfetex &mptopdf" }
- else
- { $command = "pdfetex \\&mptopdf" } }
+ { $command = "pdfetex -fmt=mptopdf" }
else
- { if ($dosish)
- { $command = "pdfetex -progname=context &mptopdf" }
- else
- { $command = "pdfetex -progname=context \\&mptopdf" } }
+ { $command = "pdfetex -progname=context -fmt=mptopdf" }
if ($dosish)
- { system ("$command \\relax $file") }
+ { $command = "$command \\relax $file" }
else
- { system ("$command \\\\relax $file") }
+ { $command = "$command \\\\relax $file" }
+ #~ print $command ;
+ system($command) ;
rename ("$_.pdf", "$_-$1.pdf") ;
if (-e "$_.pdf") { CopyFile ("$_.pdf", "$_-$1.pdf") }
if ($done) { $report .= " +" }
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 1ec2a6ea1..baa70d749 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -126,7 +126,7 @@ class TEX
'mpyforce', 'forcempy',
'forcetexutil', 'texutil',
'globalfile', 'autopath',
- 'purge', 'pdfopen', 'simplerun', 'verbose',
+ 'purge', 'autopdf', 'simplerun', 'verbose',
]
@@stringvars = [
'modefile', 'result', 'suffix', 'response', 'path',
@@ -1151,9 +1151,9 @@ class TEX
setvariable('nomprun',true) if orisuffix == 'mpx' # else cylic run
- PDFview.closeall if getvariable('pdfopen')
+ PDFview.closeall if getvariable('autopdf')
- forcexml = jobsuffix === /(xml|fo|fox|rlg|exa|)/io # === returns true|false, =~ returns position
+ forcexml = jobsuffix.match(/^(xml|fo|fox|rlg|exa)$/io) # nil or match
dummyfile = false
@@ -1261,8 +1261,8 @@ class TEX
report("unable to delete stub file")
end
- if ! problems && getvariable('pdfopen') then
- PDFview.open(if resultname.empty? then jobname else resultname end)
+ if ! problems && getvariable('autopdf') then
+ PDFview.open(File.suffixed(if result.empty? then jobname else result end,'pdf'))
end
end
diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb
index 2e5fbaaad..8a40627d3 100644
--- a/scripts/context/ruby/base/texutil.rb
+++ b/scripts/context/ruby/base/texutil.rb
@@ -306,13 +306,13 @@ class TeXUtil
def MyExtras::writer(logger,handle)
handle << logger.banner("programs: #{@@programs.size}")
@@programs.each do |p|
- handle << "% #{p} (#{@@programs[p]})\n"
+ handle << "% #{p} (#{@@programs[p.to_i]})\n"
end
end
def MyExtras::processor(logger)
@@programs.each do |p|
- cmd = "texmfstart #{@@programs[p]}"
+ cmd = "texmfstart #{@@programs[p.to_i]}"
logger.report("running #{cmd}")
system(cmd)
end
@@ -741,7 +741,7 @@ class TeXUtil
File.open(File.suffixed(filename,'tui')).each do |line|
case line.chomp
when /^f (.*)$/o then @plugins.reader('MyFiles', $1.splitdata)
- when /^c (.*)$/o then @plugins.reader('MyCommands', $1.splitdata)
+ when /^c (.*)$/o then @plugins.reader('MyCommands', [$1])
when /^e (.*)$/o then @plugins.reader('MyExtras', $1.splitdata)
when /^s (.*)$/o then @plugins.reader('MySynonyms', $1.splitdata)
when /^r (.*)$/o then @plugins.reader('MyRegisters',$1.splitdata)
@@ -751,7 +751,7 @@ class TeXUtil
end
end
rescue
- report("fatal error in parsing file (#{$!})")
+ report("fatal error in parsing #{filename}")
@filename = 'texutil'
else
@filename = filename
diff --git a/scripts/context/ruby/mpstools.rb b/scripts/context/ruby/mpstools.rb
new file mode 100644
index 000000000..6dc0c35ad
--- /dev/null
+++ b/scripts/context/ruby/mpstools.rb
@@ -0,0 +1,5 @@
+# todo
+
+puts("This program is yet unfinished, for the moment it just calls 'mptopdf'.\n\n")
+
+system("texmfstart mptopdf #{ARGV.join(' ')}")
diff --git a/scripts/context/ruby/newtexutil.rb b/scripts/context/ruby/newtexutil.rb
index b8cc99ccf..af003a8e7 100644
--- a/scripts/context/ruby/newtexutil.rb
+++ b/scripts/context/ruby/newtexutil.rb
@@ -1,22 +1,96 @@
+banner = ['TeXUtil ', 'version 9.1.0', '1997-2005', 'PRAGMA ADE/POD']
+
+unless defined? ownpath
+ ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
+ $: << ownpath
+end
+
+require 'base/switch'
require 'base/logger'
+require 'base/file'
require 'base/texutil'
-logger = Logger.new('TeXUtil')
+class Commands
+
+ include CommandBase
+
+ def references
+ filename = @commandline.argument('first')
+ if not filename.empty? and FileTest.file?(File.suffixed(filename,'tuo')) then
+ if tu = TeXUtil::Converter.new(logger) and tu.loaded(filename) then
+ tu.saved if tu.processed
+ end
+ end
+ end
+
+ def main
+ if @commandline.arguments.length>0 then
+ references
+ else
+ help
+ end
+ end
+
+ def purgefiles
+ system("texmfstart ctxtools --purge #{@commandline.argument.join(' ')}")
+ end
-filename = ARGV[0] || 'tuitest'
+ def purgeallfiles
+ system("texmfstart ctxtools --purgeall #{@commandline.argument.join(' ')}")
+ end
+
+ def documentation
+ system("texmfstart ctxtools --document #{@commandline.argument.join(' ')}")
+ end
+
+ def analyzefile
+ system("texmfstart pdftools --analyze #{@commandline.argument.join(' ')}")
+ end
+
+ def filterpages # obsolete
+ system("texmfstart ctxtools --purge #{@commandline.argument.join(' ')}")
+ end
+
+ def figures
+ report("this code is not yet converted from perl to ruby")
+ end
+
+ def logfile
+ report("this code is not yet converted from perl to ruby")
+ end
-if tu = TeXUtil::Converter.new(logger) and tu.loaded(filename) then
- tu.saved if tu.processed
end
-# if ($UnknownOptions ) { ShowHelpInfo } # not yet done
-# elsif ($ProcessReferences) { HandleReferences }
-# elsif ($ProcessFigures ) { HandleFigures }
-# elsif ($ProcessLogFile ) { HandleLogFile }
-# elsif ($PurgeFiles ) { my $args = @ARGV.join(' ') ; system("texmfstart ctxtools --purge $args") }
-# elsif ($PurgeAllFiles ) { my $args = @ARGV.join(' ') ; system("texmfstart ctxtools --purgeall $args") }
-# elsif ($ProcessDocuments ) { my $args = @ARGV.join(' ') ; system("texmfstart ctxtools --document $args") }
-# elsif ($AnalyzeFile ) { my $args = @ARGV.join(' ') ; system("texmfstart pdftools --analyze $args") }
-# elsif ($FilterPages ) { my $args = @ARGV.join(' ') ; system("texmfstart ctxtools --filter $args") }
-# elsif ($ProcessHelp ) { ShowHelpInfo } # redundant
-# else { ShowHelpInfo }
+logger = Logger.new(banner.shift)
+commandline = CommandLine.new
+
+# main feature
+
+commandline.registeraction('references', 'convert tui file into tuo file')
+
+# todo features
+
+commandline.registeraction('figures', 'generate figure dimensions file')
+commandline.registeraction('logfile', 'filter essential log messages')
+
+# backward compatibility features
+
+commandline.registeraction('purgefiles', 'remove most temporary files')
+commandline.registeraction('purgeallfiles', 'remove all temporary files')
+commandline.registeraction('documentation', 'generate documentation file from source')
+commandline.registeraction('analyzefile', 'analyze pdf file')
+
+# old feature, not needed any longer due to extension of pdftex
+
+commandline.registeraction('filterpages')
+
+# generic features
+
+commandline.registeraction('help')
+commandline.registeraction('version')
+
+commandline.registerflag('verbose')
+
+commandline.expand
+
+Commands.new(commandline,logger,banner).send(commandline.action || 'main')
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index d791ee1a4..fabcee2f9 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -63,19 +63,28 @@ $suffixinputs['pdf'] = 'PDFINPUTS'
$predefined['texexec'] = 'texexec.pl'
$predefined['texutil'] = 'texutil.pl'
$predefined['texfont'] = 'texfont.pl'
+$predefined['mptopdf'] = 'mptopdf.pl'
$predefined['examplex'] = 'examplex.rb'
$predefined['concheck'] = 'concheck.rb'
$predefined['textools'] = 'textools.rb'
$predefined['ctxtools'] = 'ctxtools.rb'
$predefined['rlxtools'] = 'rlxtools.rb'
$predefined['pdftools'] = 'pdftools.rb'
+$predefined['mpstools'] = 'mpstools.rb'
$predefined['exatools'] = 'exatools.rb'
$predefined['xmltools'] = 'xmltools.rb'
$predefined['pstopdf'] = 'pstopdf.rb'
+if ENV['TEXMFSTART_MODE'] = 'experimental' then
+ $predefined['texexec'] = 'newtexexec.rb'
+ $predefined['pstopdf'] = 'newpstopdf.rb'
+end
+
$scriptlist = 'rb|pl|py|jar'
$documentlist = 'pdf|ps|eps|htm|html'
+$editor = ENV['EDITOR'] || ENV['editor'] || 'scite'
+
$crossover = true # to other tex tools, else only local
$applications['unknown'] = ''
@@ -381,6 +390,7 @@ def usage
print(" texmfstart --iftouched=normal,lowres downsample.rb normal lowres\n")
print(" texmfstart texmfstart bin:scite kpse:texmf.cnf\n")
print(" texmfstart texmfstart --exec bin:scite *.tex\n")
+ print(" texmfstart texmfstart --edit texmf.cnf\n")
end
# somehow registration does not work out (at least not under windows)
@@ -621,6 +631,14 @@ def direct(fullname)
end
end
+def edit(filename)
+ begin
+ return runcommand([$editor,expanded(filename),expanded($arguments)].join(' '))
+ rescue
+ return false
+ end
+end
+
def make(filename,windows=false,linux=false)
basename = filename.dup
basename.sub!(/\.[^.]+?$/, '')
@@ -689,6 +707,7 @@ def execute(arguments)
$filename = $directives['file'] || ''
$program = $directives['program'] || 'context'
$direct = $directives['direct'] || false
+ $edit = $directives['edit'] || false
$page = $directives['page'] || 0
$browser = $directives['browser'] || false
$report = $directives['report'] || false
@@ -755,6 +774,8 @@ def execute(arguments)
process do
if $direct || $filename =~ /^bin\:/ then
direct($filename)
+ elsif $edit && ! $editor.empty? then
+ edit($filename)
else # script: or no prefix
command = find(shortpathname($filename),$program)
register("THREAD",File.dirname(File.expand_path(command)))