summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/pdftrimwhite.pl40
-rw-r--r--scripts/context/ruby/base/system.rb16
-rw-r--r--scripts/context/ruby/base/tex.rb229
-rw-r--r--scripts/context/ruby/base/texutil.rb58
-rw-r--r--scripts/context/ruby/ctxtools.rb258
-rw-r--r--scripts/context/ruby/graphics/gs.rb17
-rw-r--r--scripts/context/ruby/newtexexec.rb2
-rw-r--r--scripts/context/ruby/texmfstart.rb5
-rw-r--r--scripts/context/ruby/textools.rb68
9 files changed, 552 insertions, 141 deletions
diff --git a/scripts/context/perl/pdftrimwhite.pl b/scripts/context/perl/pdftrimwhite.pl
index e42a8fd49..08c1de5d7 100644
--- a/scripts/context/perl/pdftrimwhite.pl
+++ b/scripts/context/perl/pdftrimwhite.pl
@@ -180,6 +180,7 @@ my $thisisunix = $Config{'osname'} !~ /dos|mswin/i ;
my $figurefile = "" ;
my $resultfile = "" ;
+my $tempfile = "" ;
my $programname = "cropcrap" ;
@@ -224,7 +225,7 @@ my $width = my $height = my $llx = my $lly = my $urx = my $ury = 0 ;
#D help information.
sub PrintHelp
- { print "This is CropCrap\n\n" .
+ { print "This is PdfTrimWhite\n\n" .
"usage:\n\n" .
"cropcrap [switches] filename result\n\n" .
"switches:\n\n" .
@@ -246,6 +247,7 @@ sub GetItRight
{ PrintHelp() ; exit }
$figurefile = $ARGV[0] ; $figurefile =~ s/\.pdf$//oi ;
$resultfile = $ARGV[1] ; $resultfile =~ s/\.pdf$//oi ;
+ $tempfile = "pdftrimwhite-$resultfile" ;
if ($figurefile eq '')
{ PrintHelp() ; exit }
unless ($thisisunix)
@@ -257,7 +259,7 @@ sub GetItRight
exit }
if (($resultfile eq '')||($resultfile=~/(^\-|\.)/io))
{ $resultfile = $programname }
-$pipe = "2>&1" ;
+ $pipe = "2>&1" ;
if ($thisisunix)
{ $pipe = "2>&1" } }
@@ -376,7 +378,7 @@ sub PreparePlainTeX
\\figureheight=\\ht0\n" }
sub PrepareFirstPass
- { open (TEX, ">$resultfile.tex") ;
+ { open (TEX, ">$tempfile.tex") ;
if ($UsePlain)
{ print TEX
PreparePlainTeX .
@@ -406,7 +408,7 @@ sub SetupPlainTeX
{\\immediate\\pdfximage page $Page {$figurefile.pdf}\\pdfrefximage\\pdflastximage}\n" }
sub PrepareSecondPass
- { open (TEX, ">$resultfile.tex") ;
+ { open (TEX, ">$tempfile.tex") ;
if ($UsePlain)
{ print TEX
SetupPlainTeX .
@@ -438,30 +440,18 @@ sub FetchPaperSize
sub RunTeX
{ if ($UsePlain)
- { $result =
- `pdftex -prog=pdftex -fmt=plain -int=batchmode $resultfile` }
+ { $result = `pdftex -prog=pdftex -fmt=plain -int=batchmode $tempfile` }
else
- { $result =
- `texexec --batch --once --purge $resultfile` }
-# print $result if $Verbose ; $results .= "$result\n" ;
-# $result = `texutil --purge` ;
- print $result if $Verbose ; $results .= "$result\n" }
-
-sub MakePSFile
- { $result =
- `$pdfps -paperw $pwidth -paperh $pheight $resultfile.pdf $resultfile.ps` ;
+ { $result = `texexec --batch --once --purge $tempfile` }
print $result if $Verbose ; $results .= "$result\n" }
sub FindBoundingBox
- { $result =
-# `$gs -sDEVICE=bbox -dNOPAUSE -dBATCH $resultfile.ps $pipe` ;
- `$gs -sDEVICE=bbox -dNOPAUSE -dBATCH $resultfile.pdf $pipe` ;
+ { $result = `$gs -sDEVICE=bbox -dNOPAUSE -dBATCH $tempfile.pdf $pipe` ;
print $result if $Verbose ; $results .= "$result\n" }
sub IdentifyCropBox
{ RunTeX() ;
FetchPaperSize () ;
-# MakePSFile() ;
FindBoundingBox() }
#D Just to be sure, we check if there is some image data, so
@@ -495,6 +485,10 @@ sub FixCropBox
#D For error tracing we save the log information in a file.
+sub RenameResult
+ { unlink "$resultfile.pdf" ;
+ rename "$tempfile.pdf", "$resultfile.pdf" }
+
sub SaveLogInfo
{ open (LOG, ">$resultfile.log") ;
print LOG $results ;
@@ -504,10 +498,9 @@ sub SaveLogInfo
sub CleanUp
{ unless ($Verbose)
- { unlink "$resultfile.tex" ;
- unlink "$resultfile.tuo" ;
- unlink "$resultfile.tui" ;
- unlink "$resultfile.ps" ;
+ { unlink "$tempfile.tex" ;
+ unlink "$tempfile.tuo" ;
+ unlink "$tempfile.tui" ;
unlink "$figurefile.tmp" } }
#D Here it all comes together.
@@ -526,6 +519,7 @@ if (ValidatedCropBox())
{ PrepareSecondPass() ;
FixCropBox() }
+RenameResult() ;
SaveLogInfo() ;
CleanUp () ;
diff --git a/scripts/context/ruby/base/system.rb b/scripts/context/ruby/base/system.rb
index 50173a72d..4a8cba652 100644
--- a/scripts/context/ruby/base/system.rb
+++ b/scripts/context/ruby/base/system.rb
@@ -41,6 +41,18 @@ module System
end
end
+ def System.prependengine(str)
+ if str =~ /^\S+\.(pl|rb|lua|py)/io then
+ case $1
+ when 'pl' then return "perl #{str}"
+ when 'rb' then return "ruby #{str}"
+ when 'lua' then return "lua #{str}"
+ when 'py' then return "python #{str}"
+ end
+ end
+ return str
+ end
+
def System.locatedprogram(program)
if @@located.key?(program) then
return @@located[program]
@@ -49,7 +61,7 @@ module System
if binname =~ /\..*$/io then
@@binpaths.each do |path|
if FileTest.file?(str = File.join(path,binname)) then
- return @@located[program] = str
+ return @@located[program] = System.prependengine(str)
end
end
end
@@ -57,7 +69,7 @@ module System
@@binpaths.each do |path|
@@binsuffixes.each do |suffix|
if FileTest.file?(str = File.join(path,"#{binname}#{suffix}")) then
- return @@located[program] = str
+ return @@located[program] = System.prependengine(str)
end
end
end
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 1aee93fb1..700150055 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -129,7 +129,7 @@ class TEX
'forcetexutil', 'texutil',
'globalfile', 'autopath',
'purge', 'purgeall', 'keep', 'autopdf', 'xpdf', 'simplerun', 'verbose',
- 'nooptionfile', 'nobackend'
+ 'nooptionfile', 'nobackend', 'noctx'
]
@@stringvars = [
'modefile', 'result', 'suffix', 'response', 'path',
@@ -386,20 +386,20 @@ class TEX
# upward compatibility problems) but stuck to the bas/mem/fmt flags
if engine then
case validmpsengine(engine)
- when /mpost/ then "--mem"
- when /mfont/ then "--bas"
- else "--fmt"
+ when /mpost/ then "-mem"
+ when /mfont/ then "-bas"
+ else "-fmt"
end
else
- "--fmt"
+ "-fmt"
end
end
def prognameflag(progname=nil)
case getvariable('distribution')
- when 'standard' then prefix = "--progname"
- when /web2c/io then prefix = "--progname"
- when /miktex/io then prefix = "--alias"
+ when 'standard' then prefix = "-progname"
+ when /web2c/io then prefix = "-progname"
+ when /miktex/io then prefix = "-alias"
else return ""
end
if progname then
@@ -424,7 +424,7 @@ class TEX
if Kpse.miktex? then
"-tcx=#{file}"
else
- "--translate-file=#{file}"
+ "-translate-file=#{file}"
end
end
@@ -574,7 +574,7 @@ class TEX
interface = $1.sub(/cont\-/,'')
results.push('')
results.push("testing interface #{interface}")
- flags = ['--process','--batch','--once',"--interface=#{interface}",engineflag]
+ flags = ['--noctx','--process','--batch','--once',"--interface=#{interface}",engineflag]
# result = Kpse.pipescript('newtexexec',tempfilename,flags)
result = runtexexec([tempfilename], flags, 1)
if FileTest.file?("#{@@temprunfile}.log") then
@@ -842,7 +842,7 @@ class TEX
getarrayvariable('files').each do |filename|
setvariable('filename',filename)
report("processing text of graphic '#{filename}'")
- processmpx(filename,true)
+ processmpx(filename,false,true)
end
reportruntime
end
@@ -883,6 +883,7 @@ class TEX
elsif (str = getvariable('suffix')) && ! str.empty? then
opt << "\\setupsystem[file=#{jobname}.#{str}]\n"
end
+ opt << "\\setupsystem[\\c!method=2]\n" # 1=oldtexexec 2=newtexexec
opt << "\\setupsystem[\\c!type=#{Tool.ruby_platform()}]\n"
if (str = File.unixfied(getvariable('path'))) && ! str.empty? then
opt << "\\usepath[#{str}]\n" unless str.empty?
@@ -1043,9 +1044,10 @@ class TEX
report("tex format: #{texformat}")
report("progname: #{progname}")
if texengine && texformat && progname then
- command = [quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),runoptions(texengine),filename,texprocextras(texformat)].join(' ')
+ command = [quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)].join(' ')
report(command) if getvariable('verbose')
system(command)
+ true
else
false
end
@@ -1056,10 +1058,12 @@ class TEX
mpsformat = validmpsformat(getarrayvariable('mpsformats').first)
progname = validprogname(getvariable('progname'))
if mpsengine && mpsformat && progname then
- command = [quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),runoptions(mpsengine),filename,mpsprocextras(mpsformat)].join(' ')
ENV["MPXCOMMAND"] = "0" unless mpx
+ # command = [quoted(mpsengine),prognameflag(progname),formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),filename,mpsprocextras(mpsformat)].join(' ')
+ command = [quoted(mpsengine),"-progname=mpost",formatflag(mpsengine,mpsformat),tcxflag,runoptions(mpsengine),filename,mpsprocextras(mpsformat)].join(' ')
report(command) if getvariable('verbose')
system(command)
+ true
else
false
end
@@ -1070,12 +1074,14 @@ class TEX
if File.atleast?(mpfile,25) then
# first run needed
File.silentdelete(File.suffixed(mpfile,'mpt'))
- doruntexmp(mpfile,false)
+ doruntexmp(mpfile)
mpgraphics = checkmpgraphics(mpfile)
mplabels = checkmplabels(mpfile)
if mpgraphics || mplabels then
# second run needed
doruntexmp(mpfile,mplabels)
+ else
+ # no labels
end
end
end
@@ -1123,10 +1129,11 @@ class TEX
begin
if mode and job = TEX.new(@logger) then
options.each do |option|
- if option=~ /^\-*(.*?)\=(.*)$/o then
- job.setvariable($1,$2)
- else
- job.setvariable(option,true)
+ case option
+ when /^\-*(.*?)\=(.*)$/o then
+ job.setvariable($1,$2)
+ when /^\-*(.*?)$/o then
+ job.setvariable($1,true)
end
end
job.setvariable("files",filename)
@@ -1243,31 +1250,33 @@ class TEX
# preprocess files
- ctx = CtxRunner.new(rawname,@logger)
- if getvariable('ctxfile').empty? then
- ctx.manipulate(File.suffixed(rawname,'ctx'),'jobname.ctx')
- else
- ctx.manipulate(File.suffixed(getvariable('ctxfile'),'ctx'))
- end
- ctx.savelog(File.suffixed(rawname,'ctl'))
+ unless getvariable('noctx') then
+ ctx = CtxRunner.new(rawname,@logger)
+ if getvariable('ctxfile').empty? then
+ ctx.manipulate(File.suffixed(rawname,'ctx'),'jobname.ctx')
+ else
+ ctx.manipulate(File.suffixed(getvariable('ctxfile'),'ctx'))
+ end
+ ctx.savelog(File.suffixed(rawname,'ctl'))
- envs = ctx.environments
- mods = ctx.modules
+ envs = ctx.environments
+ mods = ctx.modules
- # merge environment and module specs
+ # merge environment and module specs
- envs << getvariable('environments') unless getvariable('environments').empty?
- mods << getvariable('modules') unless getvariable('modules') .empty?
+ envs << getvariable('environments') unless getvariable('environments').empty?
+ mods << getvariable('modules') unless getvariable('modules') .empty?
- envs = envs.uniq.join(',')
- mods = mods.uniq.join(',')
+ envs = envs.uniq.join(',')
+ mods = mods.uniq.join(',')
- report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose')
- report("using environments #{envs}") if envs.length > 0
- report("using modules #{mods}") if mods.length > 0
+ report("using search method '#{Kpse.searchmethod}'") if getvariable('verbose')
+ report("using environments #{envs}") if envs.length > 0
+ report("using modules #{mods}") if mods.length > 0
- setvariable('environments', envs)
- setvariable('modules', mods)
+ setvariable('environments', envs)
+ setvariable('modules', mods)
+ end
# end of preprocessing and merging
@@ -1389,11 +1398,12 @@ class TEX
end
- # mp specific
+ # The labels are collected in the mergebe hash. Here we merge the relevant labels
+ # into beginfig/endfig. We could as well do this in metafun itself. Maybe some
+ # day ... (it may cost a bit of string space but that is cheap nowadays).
- def doruntexmp(mpname,mergebe=true,context=true)
+ def doruntexmp(mpname,mergebe=nil,context=true)
texfound = false
- mpbetex = Hash.new
mpfile = File.suffixed(mpname,'mp')
mpcopy = File.suffixed(mpname,'copy','mp')
setvariable('mp.file',mpfile)
@@ -1402,38 +1412,28 @@ class TEX
if mpdata = File.silentread(mpfile) then
mpdata.gsub!(/^\#.*\n/o,'')
File.silentrename(mpfile,mpcopy)
- texfound = mergebe || mpdata =~ /btex .*? etex/mo
+ texfound = mergebe || (mpdata =~ /btex .*? etex/mo)
if mp = openedfile(mpfile) then
- mpdata.gsub!(/(btex.*?)\;(.*?etex)/o) do "#{$1}@@@#{$2}" end
- # mpdata.gsub!(/(\".*?)\;(.*?\")/o) do "#{$1}@@@#{$2}" end
- mpdata.gsub!(/(\".*?\")/o) do "#{$1.gsub(/\;/o,'@@@')}" end
- mpdata.gsub!(/\;/o, "\;\n")
- # mpdata.gsub!(/\n+/o, "\n")
- # mpdata.gsub!(/(btex.*?)\@\@\@(.*?etex)/o) do "#{$1}\;#{$2}" end
- # mpdata.gsub!(/(\".*?)\@\@\@(.*?\")/mo) do "#{$1};#{$2}" end
- mpdata.gsub!(/\@\@\@/o) do ";" end
if mergebe then
- mpdata.gsub!(/beginfig\s*\((\d+)\)\s*\;(.*?)endfig\s*\;/o) do
+ mpdata.gsub!(/beginfig\s*\((\d+)\)\s*\;(.+?)endfig\s*\;/mo) do
n, str = $1, $2
- if str =~ /(.*?)(verbatimtex.*?etex)\s*\;(.*)/o then
- "beginfig(#{n})\;\n#{$1}#{$2}\;\n#{mpbetex(n)}\n#{$3}\;endfig\;\n"
+ if str =~ /^(.*?)(verbatimtex.*?etex)\s*\;(.*)$/mo then
+ "beginfig(#{n})\;\n#{$1}#{$2}\;\n#{mergebe[n]}\n#{$3}\;endfig\;\n"
else
- "beginfig(#{n})\;\n#{mpbetex(n)}\n#{str}\;endfig\;\n"
+ "beginfig(#{n})\;\n#{mergebe[n]}\n#{str}\;endfig\;\n"
end
end
+ unless mpdata =~ /beginfig\s*\(\s*0\s*\)/o then
+ mp << mergebe['0'] if mergebe.key?('0')
+ end
end
- mpdata.gsub!(/\n+/mo, "\n")
- mpdata.gsub!(/^\s*\;\s*\n/o, "")
- unless mpdata =~ /beginfig\s*\(\s*0\s*\)/o then
- mp << mpbetex['0'] if mpbetex.key?('0')
- end
- mp << mpdata # ??
+ mp << splitmplines(mpdata)
mp << "\n"
mp << "end"
mp << "\n"
mp.close
end
- processmpx(mpname) if texfound
+ processmpx(mpname,true) if texfound
if getvariable('batchmode') then
options = ' --interaction=batch'
elsif getvariable('nonstopmode') then
@@ -1458,39 +1458,50 @@ class TEX
end
end
- def processmpx(mpname,context=true)
- mpname = File.suffixed(mpname,'mp')
- if File.atleast?(mpname,10) && (data = File.silentread(mpname)) then
+ def processmpx(mpname,force=false,context=true)
+ unless force then
+ mpname = File.suffixed(mpname,'mp')
+ if File.atleast?(mpname,10) && (data = File.silentread(mpname)) then
+ if data =~ /(btex|etex|verbatimtex|textext)/o then
+ force = true
+ end
+ end
+ end
+ if force then
begin
- if data =~ /(btex|etex|verbatimtex)/o then
- mptex = File.suffixed(mpname,'temp','tex')
- mpdvi = File.suffixed(mpname,'temp','dvi')
- mplog = File.suffixed(mpname,'temp','log')
- mpmpx = File.suffixed(mpname,'mpx')
- ok = system("mpto #{mpname} > #{mptex}")
- if ok && File.appended(mptex, "\\end\n") then
- if localjob = TEX.new(@logger) then
- localjob.setvariable('files',mptex)
- localjob.setvariable('backend','dvips')
- localjob.setvariable('engine',getvariable('engine')) unless getvariable('engine').empty?
- localjob.setvariable('once',true)
- localjob.setvariable('nobackend',true)
- if context then
- localjob.setvariable('texformats',[getvariable('interface')]) unless getvariable('interface').empty?
- elsif getvariable('interface').empty? then
- localjob.setvariable('texformats',['plain'])
- else
- localjob.setvariable('texformats',[getvariable('interface')])
- end
- localjob.processtex
- ok = true # todo
+ mptex = File.suffixed(mpname,'temp','tex')
+ mpdvi = File.suffixed(mpname,'temp','dvi')
+ mplog = File.suffixed(mpname,'temp','log')
+ mpmpx = File.suffixed(mpname,'mpx')
+ command = "mpto #{mpname} > #{mptex}"
+ report(command) if getvariable('verbose')
+ ok = system(command)
+ if ok && File.appended(mptex, "\\end\n") then
+ # to be replaced by runtexexec([filenames],options,1)
+ if localjob = TEX.new(@logger) then
+ localjob.setvariable('files',mptex)
+ localjob.setvariable('backend','dvips')
+ localjob.setvariable('engine',getvariable('engine')) unless getvariable('engine').empty?
+ localjob.setvariable('once',true)
+ localjob.setvariable('nobackend',true)
+ if context then
+ localjob.setvariable('texformats',[getvariable('interface')]) unless getvariable('interface').empty?
+ elsif getvariable('interface').empty? then
+ localjob.setvariable('texformats',['plain'])
else
- ok = false
- end
- ok = ok && FileTest.file?(mpdvi) && system("dvitomp #{mpdvi} #{mpmpx}")
- [mptex,mpdvi,mplog].each do |mpfil|
- File.silentdelete(mpfil)
+ localjob.setvariable('texformats',[getvariable('interface')])
end
+ localjob.processtex
+ ok = true # todo
+ else
+ ok = false
+ end
+ # so far
+ command = "dvitomp #{mpdvi} #{mpmpx}"
+ report(command) if getvariable('verbose')
+ ok = ok && FileTest.file?(mpdvi) && system(command)
+ [mptex,mpdvi,mplog].each do |mpfil|
+ File.silentdelete(mpfil)
end
end
rescue
@@ -1551,4 +1562,42 @@ class TEX
return nil
end
+ # mp specific (todo: mp module)
+
+ def splitmplines(str)
+ btex, verbatimtex, strings, result = Array.new, Array.new, Array.new, str.dup
+ # protect texts
+ result.gsub!(/btex\s*(.*?)\s*etex/) do
+ btex << $1
+ "btex(#{btex.length-1})"
+ end
+ result.gsub!(/verbatimtex\s*(.*?)\s*etex/) do
+ verbatimtex << $1
+ "verbatimtex(#{verbatimtex.length-1})"
+ end
+ result.gsub!(/\"(.*?)\"/) do
+ strings << $1
+ "\"#{strings.length-1}\""
+ end
+ result.gsub!(/\;/) do
+ ";\n"
+ end
+ result.gsub!(/(.{80,})(\-\-\-|\-\-|\.\.\.|\.\.)/) do
+ "#{$1}#{$2}\n"
+ end
+ result.gsub!(/\n[\s\n]+/mois) do
+ "\n"
+ end
+ result.gsub!(/btex\((\d+)\)/) do
+ "btex #{btex[$1.to_i]} etex"
+ end
+ result.gsub!(/verbatimtex\((\d+)\)/) do
+ "verbatimtex #{verbatimtex[$1.to_i]} etex"
+ end
+ result.gsub!(/\"(\d+)\"/) do
+ "\"#{strings[$1.to_i]}\""
+ end
+ result
+ end
+
end
diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb
index 12337c643..01ef11012 100644
--- a/scripts/context/ruby/base/texutil.rb
+++ b/scripts/context/ruby/base/texutil.rb
@@ -126,6 +126,8 @@ class TeXUtil
class Sorter
+ @@downcase = true
+
def initialize(max=12)
@rep, @map, @exp, @div = Hash.new, Hash.new, Hash.new, Hash.new
@max = max
@@ -149,7 +151,7 @@ class TeXUtil
# sorter.expander('ijligature', 'y')
def expander(from,to=nil)
- from, to = converted(from), converted(to)
+ to = converted(to) # not from !!!
@max = [@max,to.length+1].max if to
@exp[from] = to || from || ''
end
@@ -179,17 +181,39 @@ class TeXUtil
end
if @map.size > 0 then
# watch out, order of match matters
- @rexb = /(\\[a-zA-Z]+|#{@map.keys.join('|')}|.)\s*/ # o
+ if @@downcase then
+ @rexb = /(\\[a-zA-Z]+|#{@map.keys.join('|')}|.)\s*/i # o
+ else
+ @rexb = /(\\[a-zA-Z]+|#{@map.keys.join('|')}|.)\s*/ # o
+ end
else
- @rexb = /(\\[a-zA-Z]+|.)\s*/o
+ if @@downcase then
+ @rexb = /(\\[a-zA-Z]+|.)\s*/io
+ else
+ @rexb = /(\\[a-zA-Z]+|.)\s*/o
+ end
end
- if true then
+ if false then
@exp.keys.each do |e|
@exp[e].downcase!
end
end
end
+ def replace(str)
+ str.gsub(@rexa) do
+ @rep[$1.escaped]
+ end
+ end
+
+ def normalize(str)
+ replace(str).gsub(/ +/,' ')
+ end
+
+ def tokenize(str)
+ str.gsub(/\\strchr\{(.*?)\}/o) do "\\#{$1}" end
+ end
+
def remap(str)
s = str.dup
s.gsub!(/(\d+)/o) do
@@ -203,6 +227,9 @@ class TeXUtil
if @rexb then
s.gsub!(@rexb) do
token = $1.sub(/\\/o, '')
+if @@downcase then
+ token.downcase!
+end
if @exp.key?(token) then
@exp[token].ljust(@max,' ')
elsif @map.key?(token) then
@@ -220,7 +247,7 @@ class TeXUtil
'A'.upto('Z') do |c| expander(c) ; division(c) end
expander('1','b') ; expander('2','c') ; expander('3','e') ; expander('4','f')
expander('5','g') ; expander('6','h') ; expander('7','i') ; expander('8','i')
- expander('9','j') ; expander('0','a') ; expander('-','-') ;
+ expander('9','j') ; expander('0','a') ; expander('-',"-") ;
# end potential move
shortcuts.each do |s| shortcut(s[0],s[1]) end
expansions.each do |e| expander(e[0],e[1]) end
@@ -261,6 +288,7 @@ class TeXUtil
def converted(str)
if str then
+ # puts str
str.gsub(/([\+\-]*\d+)/o) do
n = $1.to_i
if n > 0 then
@@ -400,6 +428,7 @@ class TeXUtil
attr_writer :sortkey
def build(sorter)
+@sortkey = sorter.normalize(sorter.tokenize(@sortkey))
@sortkey = sorter.remap(sorter.simplify(@key.downcase))
if @sortkey.empty? then
@sortkey = sorter.remap(@command.downcase)
@@ -487,6 +516,8 @@ class TeXUtil
attr_writer :sortkey
def build(sorter)
+@entry, @key = sorter.normalize(@entry), sorter.normalize(sorter.tokenize{@key})
+if false then
@entry, @key = [@entry, @key].collect do |target|
# +a+b+c &a&b&c a+b+c a&b&c
case target[0,1]
@@ -501,13 +532,15 @@ class TeXUtil
target
# end
end
+else
+ @entry, @key = cleanupsplit(@entry), cleanupsplit(@key)
+end
@sortkey = sorter.simplify(@key)
@sortkey = @sortkey.split(@@split).collect do |c| sorter.remap(c) end.join(@@split)
- # if ($Key eq "") { $Key = SanitizedString($Entry) }
- # if ($ProcessHigh){ $Key = HighConverted($Key) }
@sortkey = [
@sortkey.downcase,
@sortkey,
+ @entry,
@texthowto.ljust(10,' '),
# @state, # no, messes up things
(@realpage ||'').rjust(6,' ').gsub(/0/,' '),
@@ -516,6 +549,15 @@ class TeXUtil
].join(@@split)
end
+ def cleanupsplit(target)
+ # +a+b+c &a&b&c a+b+c a&b&c
+ case target[0,1]
+ when '&' then target.sub(/^./o,'').gsub(/([^\\])\&/o) do "#{$1}#{@@split}" end
+ when '+' then target.sub(/^./o,'').gsub(/([^\\])\+/o) do "#{$1}#{@@split}" end
+ else target .gsub(/([^\\])[\&\+]/o) do "#{$1}#{@@split}" end
+ end
+ end
+
def <=> (other)
@sortkey <=> other.sortkey
end
@@ -561,7 +603,7 @@ class TeXUtil
else
testalpha = entry.sortkey[0,1].downcase
end
- if testalpha != alpha.downcase || alphaclass != entry.class then
+ if (testalpha != alpha.downcase) || (alphaclass != entry.class) then
alpha = testalpha
alphaclass = entry.class
if alpha != ' ' then
diff --git a/scripts/context/ruby/ctxtools.rb b/scripts/context/ruby/ctxtools.rb
index a768264d9..0ba1a7561 100644
--- a/scripts/context/ruby/ctxtools.rb
+++ b/scripts/context/ruby/ctxtools.rb
@@ -17,7 +17,34 @@
#
# todo: move kpse call to kpse class/module, faster and better
-banner = ['CtxTools', 'version 1.3.1', '2004/2006', 'PRAGMA ADE/POD']
+# Taco Hoekwater on patterns and lig building (see 'agr'):
+#
+# Any direct use of a ligature (as accessed by \char or through active
+# characters) is wrong and will create faulty hypenation. Normally,
+# when TeX sees "office", it has six tokens, and it knows from the
+# patterns that it can hyphenate between the "ff". It will build an
+# internal list of four nodes, like this:
+#
+# [char, o , ffi ]
+# [lig , ffi, c ,[f,f,i]]
+# [char, c , e ]
+# [char, e , NULL]
+#
+# as you can see from the ffi line, it has remembered the original
+# characters. While hyphenating, it temporarily changes back to
+# that, then re-instates the ligature afterwards.
+#
+# If you feed it the ligature directly, like so:
+#
+# [char, o , ffi ]
+# [char, ffi , c ]
+# [char, c , e ]
+# [char, e , NULL]
+#
+# it cannot do that (it tries to hyphenate as if the "ffi" was a
+# character), and the result is wrong hyphenation.
+
+banner = ['CtxTools', 'version 1.3.2', '2004/2006', 'PRAGMA ADE/POD']
unless defined? ownpath
ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
@@ -772,6 +799,7 @@ class Language
case @encoding.downcase
when 't1', 'ec', 'cork' then preload_vector('ec')
when 'y', 'texnansi' then preload_vector('texnansi')
+ when 'agr', 'agreek' then preload_vector('agr')
end
end
@@ -818,11 +846,32 @@ class Language
def convert
if @data then
n = 0
- @remapping.each do |k|
- @data.gsub!(k[0]) do
- # report("#{k[0]} => #{k[1]}")
- n += 1
- k[1]
+ if true then
+ @data.gsub!(/\\(patterns|hypenation)\{(.*?)\}/mois) do
+ command, content = $1, $2
+ @remapping.each_index do |i|
+ from, to, m = @remapping[i][0], @remapping[i][1], 0
+ content.gsub!(from) do
+ m += 1
+ "[#{i}]"
+ end
+ report("#{m.to_s.rjust(5)} entries remapped to #{to}") unless m == 0
+ n += m
+ end
+ content.gsub!(/\[(\d+)\]/) do
+ @remapping[$1.to_i][1]
+ end
+ "\\#{command}\{#{content}\}"
+ end
+ else
+ @remapping.each do |k|
+ from, to, m = k[0], k[1], 0
+ @data.gsub!(from) do
+ m += 1
+ to
+ end
+ report("#{m.to_s.rjust(5)} entries remapped to #{to}") unless m == 0
+ n += m
end
end
report("#{n} changes in patterns and exceptions")
@@ -1147,6 +1196,198 @@ class Language
remap(/\\c\{.*?\}/, "")
remap(/\\a\s*/, "[aeligature]")
remap(/\\o\s*/, "[oeligature]")
+ when 'agr' then
+ remap(/\<\'a\|/, "[greekalphaiotasubdasiatonos]")
+ # remap(/\<\'a\|/, "[greekdasiatonos][greekAlpha][greekiota]")
+ remap(/\>\'a\|/, "[greekalphaiotasubpsilitonos]")
+ remap(/\<\`a\|/, "[greekalphaiotasubdasiavaria]")
+ remap(/\>\`a\|/, "[greekalphaiotasubpsilivaria]")
+ remap(/\<\~a\|/, "[greekalphaiotasubdasiaperispomeni]")
+ remap(/\>\~a\|/, "[greekalphaiotasubpsiliperispomeni]")
+ remap(/\'a\|/, "[greekalphaiotasubtonos]")
+ remap(/\`a\|/, "[greekalphaiotasubvaria]")
+ remap(/\~a\|/, "[greekalphaiotasubperispomeni]")
+ remap(/\<a\|/, "[greekalphaiotasubdasia]")
+ remap(/\>a\|/, "[greekalphaiotasubpsili]")
+ remap(/a\|/, "[greekalphaiotasub]")
+ remap(/\<\'h\|/, "[greeketaiotasubdasiatonos]")
+ remap(/\>\'h\|/, "[greeketaiotasubpsilitonos]")
+ remap(/\<\`h\|/, "[greeketaiotasubdasiavaria]")
+ remap(/\>\`h\|/, "[greeketaiotasubpsilivaria]")
+ remap(/\<\~h\|/, "[greeketaiotasubdasiaperispomeni]")
+ remap(/\>\~h\|/, "[greeketaiotasubpsiliperispomeni]")
+ remap(/\'h\|/, "[greeketaiotasubtonos]")
+ remap(/\`h\|/, "[greeketaiotasubvaria]")
+ remap(/\~h\|/, "[greeketaiotasubperispomeni]")
+ remap(/\<h\|/, "[greeketaiotasubdasia]")
+ remap(/\>h\|/, "[greeketaiotasubpsili]")
+ remap(/h\|/, "[greeketaiotasub]")
+ remap(/\<'w\|/, "[greekomegaiotasubdasiatonos]")
+ remap(/\>'w\|/, "[greekomegaiotasubpsilitonos]")
+ remap(/\<`w\|/, "[greekomegaiotasubdasiavaria]")
+ remap(/\>`w\|/, "[greekomegaiotasubpsilivaria]")
+ remap(/\<~w\|/, "[greekomegaiotasubdasiaperispomeni]")
+ remap(/\>~w\|/, "[greekomegaiotasubpsiliperispomeni]")
+ remap(/\<w\|/, "[greekomegaiotasubdasia]")
+ remap(/\>w\|/, "[greekomegaiotasubpsili]")
+ remap(/\'w\|/, "[greekomegaiotasubtonos]")
+ remap(/\`w\|/, "[greekomegaiotasubvaria]")
+ remap(/\~w\|/, "[greekomegaiotasubperispomeni]")
+ remap(/w\|/, "[greekomegaiotasub]")
+ remap(/\<\'i/, "[greekiotadasiatonos]")
+ remap(/\>\'i/, "[greekiotapsilitonos]")
+ remap(/\<\`i/, "[greekiotadasiavaria]")
+ remap(/\>\`i/, "[greekiotapsilivaria]")
+ remap(/\<\~i/, "[greekiotadasiaperispomeni]")
+ remap(/\>\~i/, "[greekiotapsiliperispomeni]")
+ remap(/\"\'i/, "[greekiotadialytikatonos]")
+ remap(/\"\`i/, "[greekiotadialytikavaria]")
+ remap(/\"\~i/, "[greekiotadialytikaperispomeni]")
+ remap(/\<i/, "[greekiotadasia]")
+ remap(/\>i/, "[greekiotapsili]")
+ remap(/\'i/, "[greekiotaoxia]")
+ remap(/\`i/, "[greekiotavaria]")
+ remap(/\~i/, "[greekiotaperispomeni]")
+ remap(/\"i/, "[greekiotadialytika]")
+ remap(/\>\~e/, "[greekepsilonpsiliperispomeni]")
+ remap(/\<\~e/, "[greekepsilondasiaperispomeni]")
+ remap(/\<\'e/, "[greekepsilondasiatonos]")
+ remap(/\>\'e/, "[greekepsilonpsilitonos]")
+ remap(/\<\`e/, "[greekepsilondasiavaria]")
+ remap(/\>\`e/, "[greekepsilonpsilivaria]")
+ remap(/\<e/, "[greekepsilondasia]")
+ remap(/\>e/, "[greekepsilonpsili]")
+ remap(/\'e/, "[greekepsilonoxia]")
+ remap(/\`e/, "[greekepsilonvaria]")
+ remap(/\~e/, "[greekepsilonperispomeni]")
+ remap(/\<\'a/, "[greekalphadasiatonos]")
+ remap(/\>\'a/, "[greekalphapsilitonos]")
+ remap(/\<\`a/, "[greekalphadasiavaria]")
+ remap(/\>\`a/, "[greekalphapsilivaria]")
+ remap(/\<\~a/, "[greekalphadasiaperispomeni]")
+ remap(/\>\~a/, "[greekalphapsiliperispomeni]")
+ remap(/\<a/, "[greekalphadasia]")
+ remap(/\>a/, "[greekalphapsili]")
+ remap(/\'a/, "[greekalphaoxia]")
+ remap(/\`a/, "[greekalphavaria]")
+ remap(/\~a/, "[greekalphaperispomeni]")
+ remap(/\<\'h/, "[greeketadasiatonos]")
+ remap(/\>\'h/, "[greeketapsilitonos]")
+ remap(/\<\`h/, "[greeketadasiavaria]")
+ remap(/\>\`h/, "[greeketapsilivaria]")
+ remap(/\<\~h/, "[greeketadasiaperispomeni]")
+ remap(/\>\~h/, "[greeketapsiliperispomeni]")
+ remap(/\<h/, "[greeketadasia]")
+ remap(/\>h/, "[greeketapsili]")
+ remap(/\'h/, "[greeketaoxia]")
+ remap(/\`h/, "[greeketavaria]")
+ remap(/\~h/, "[greeketaperispomeni]")
+ remap(/\<\~o/, "[greekomicrondasiaperispomeni]")
+ remap(/\>\~o/, "[greekomicronpsiliperispomeni]")
+ remap(/\<\'o/, "[greekomicrondasiatonos]")
+ remap(/\>\'o/, "[greekomicronpsilitonos]")
+ remap(/\<\`o/, "[greekomicrondasiavaria]")
+ remap(/\>\`o/, "[greekomicronpsilivaria]")
+ remap(/\<o/, "[greekomicrondasia]")
+ remap(/\>o/, "[greekomicronpsili]")
+ remap(/\'o/, "[greekomicronoxia]")
+ remap(/\`o/, "[greekomicronvaria]")
+ remap(/\~o/, "[greekomicronperispomeni]")
+ remap(/\<\'u/, "[greekupsilondasiatonos]")
+ remap(/\>\'u/, "[greekupsilonpsilitonos]")
+ remap(/\<\`u/, "[greekupsilondasiavaria]")
+ remap(/\>\'u/, "[greekupsilonpsilivaria]")
+ remap(/\<\~u/, "[greekupsilondasiaperispomeni]")
+ remap(/\>\~u/, "[greekupsilonpsiliperispomeni]")
+ remap(/\"\'u/, "[greekupsilondialytikatonos]")
+ remap(/\"\`u/, "[greekupsilondialytikavaria]")
+ remap(/\"\~u/, "[greekupsilondialytikaperispomeni]")
+ remap(/\<u/, "[greekupsilondasia]")
+ remap(/\>u/, "[greekupsilonpsili]")
+ remap(/\'u/, "[greekupsilonoxia]")
+ remap(/\`u/, "[greekupsilonvaria]")
+ remap(/\~u/, "[greekupsilonperispomeni]")
+ remap(/\"u/, "[greekupsilondiaeresis]")
+ remap(/\<\'w/, "[greekomegadasiatonos]")
+ remap(/\>\'w/, "[greekomegapsilitonos]")
+ remap(/\<\`w/, "[greekomegadasiavaria]")
+ remap(/\>\`w/, "[greekomegapsilivaria]")
+ remap(/\<\~w/, "[greekomegadasiaperispomeni]")
+ remap(/\>\~w/, "[greekomegapsiliperispomeni]")
+ remap(/\<w/, "[greekomegadasia]")
+ remap(/\>w/, "[greekomegapsili]")
+ remap(/\'w/, "[greekomegaoxia]")
+ remap(/\`w/, "[greekomegavaria]")
+ remap(/\~w/, "[greekomegaperispomeni]")
+ remap(/\<r/, "[greekrhodasia]")
+ remap(/\>r/, "[greekrhopsili]")
+ remap(/\<\~/, "[greekdasiaperispomeni]")
+ remap(/\>\~/, "[greekpsiliperispomeni]")
+ remap(/\<\'/, "[greekdasiatonos]")
+ remap(/\>\'/, "[greekpsilitonos]")
+ remap(/\<\`/, "[greekdasiavaria]")
+ remap(/\>\`/, "[greekpsilivaria]")
+ remap(/\"\'/, "[greekdialytikatonos]")
+ remap(/\"\`/, "[greekdialytikavaria]")
+ remap(/\"\~/, "[greekdialytikaperispomeni]")
+ remap(/\</, "[dasia]")
+ remap(/\>/, "[psili]")
+ remap(/\'/, "[oxia]")
+ remap(/\`/, "[greekvaria]")
+ remap(/\~/, "[perispomeni]")
+ remap(/\"/, "[dialytika]")
+ # unknown
+ remap(/\|/, "[greekIotadialytika]")
+ # next
+ remap(/A/, "[greekAlpha]")
+ remap(/B/, "[greekBeta]")
+ remap(/D/, "[greekDelta]")
+ remap(/E/, "[greekEpsilon]")
+ remap(/F/, "[greekPhi]")
+ remap(/G/, "[greekGamma]")
+ remap(/H/, "[greekEta]")
+ remap(/I/, "[greekIota]")
+ remap(/J/, "[greekTheta]")
+ remap(/K/, "[greekKappa]")
+ remap(/L/, "[greekLambda]")
+ remap(/M/, "[greekMu]")
+ remap(/N/, "[greekNu]")
+ remap(/O/, "[greekOmicron]")
+ remap(/P/, "[greekPi]")
+ remap(/Q/, "[greekChi]")
+ remap(/R/, "[greekRho]")
+ remap(/S/, "[greekSigma]")
+ remap(/T/, "[greekTau]")
+ remap(/U/, "[greekUpsilon]")
+ remap(/W/, "[greekOmega]")
+ remap(/X/, "[greekXi]")
+ remap(/Y/, "[greekPsi]")
+ remap(/Z/, "[greekZeta]")
+ remap(/a/, "[greekalpha]")
+ remap(/b/, "[greekbeta]")
+ remap(/c/, "[greekfinalsigma]")
+ remap(/d/, "[greekdelta]")
+ remap(/e/, "[greekepsilon]")
+ remap(/f/, "[greekphi]")
+ remap(/g/, "[greekgamma]")
+ remap(/h/, "[greeketa]")
+ remap(/i/, "[greekiota]")
+ remap(/j/, "[greektheta]")
+ remap(/k/, "[greekkappa]")
+ remap(/l/, "[greeklambda]")
+ remap(/m/, "[greekmu]")
+ remap(/n/, "[greeknu]")
+ remap(/o/, "[greekomicron]")
+ remap(/p/, "[greekpi]")
+ remap(/q/, "[greekchi]")
+ remap(/r/, "[greekrho]")
+ remap(/s/, "[greeksigma]")
+ remap(/t/, "[greektau]")
+ remap(/u/, "[greekupsilon]")
+ remap(/w/, "[greekomega]")
+ remap(/x/, "[greekxi]")
+ remap(/y/, "[greekpsi]")
+ remap(/z/, "[greekzeta]")
else
end
@@ -1197,7 +1438,7 @@ class Commands
# todo: filter the fallback list from context
# The first entry in the array is the encoding which will be used
- # when interpreting th eraw patterns. The second entry is a list of
+ # when interpreting the raw patterns. The second entry is a list of
# filesets (string|aray), each first match of a set is taken.
@@languagedata['ba' ] = [ 'ec' , ['bahyph.tex'] ]
@@ -1224,7 +1465,7 @@ class Commands
# mnhyph
@@languagedata['nl' ] = [ 'ec' , ['nehyph96.tex'] ]
@@languagedata['no' ] = [ 'ec' , ['nohyph.tex'] ]
- # oldgrhyph.tex
+ @@languagedata['agr'] = [ 'agr' , [['grahyph4.tex','oldgrhyph.tex']] ] # new, todo
@@languagedata['pl' ] = [ 'ec' , ['plhyph.tex'] ]
@@languagedata['pt' ] = [ 'ec' , ['pthyph.tex'] ]
@@languagedata['ro' ] = [ 'ec' , ['rohyph.tex'] ]
@@ -1235,7 +1476,6 @@ class Commands
@@languagedata['sv' ] = [ 'ec' , ['svhyph.tex'] ]
@@languagedata['tr' ] = [ 'ec' , ['tkhyph.tex'] ]
@@languagedata['uk' ] = [ 'default' , [['ukhyphen.tex','ukhyph.tex']] ]
-
end
class Commands
diff --git a/scripts/context/ruby/graphics/gs.rb b/scripts/context/ruby/graphics/gs.rb
index 807cad10c..588ef2417 100644
--- a/scripts/context/ruby/graphics/gs.rb
+++ b/scripts/context/ruby/graphics/gs.rb
@@ -13,11 +13,14 @@
require 'base/variables'
require 'base/system'
+require 'ftools'
class GhostScript
include Variables
+ @@pdftrimwhite = 'pdftrimwhite.pl'
+
@@pstopdfoptions = [
'AntiAliasColorImages',
'AntiAliasGrayImages',
@@ -213,7 +216,7 @@ class GhostScript
else report("invalid conversion method #{gsmethod}")
end
rescue
- report("job aborted due to some error #{$!}")
+ report("job aborted due to some error: #{$!}")
begin
File.delete(resultfile) if test(?e,resultfile)
rescue
@@ -338,9 +341,12 @@ class GhostScript
end
- def convertbounded (inpfile, outfile)
-
+ def convertbounded(inpfile, outfile)
report("converting #{inpfile} bounded")
+ do_convertbounded(inpfile, outfile)
+ end
+
+ def do_convertbounded(inpfile, outfile)
begin
return false if FileTest.file?(outfile) && (! File.delete(outfile))
@@ -456,13 +462,14 @@ class GhostScript
report("converting #{inpfile} cropped")
- convertbounded(inpfile, @@pdftempfile)
+ do_convertbounded(inpfile, @@pdftempfile)
return unless test(?e,@@pdftempfile)
arguments = " --offset=#{@offset} #{@@pdftempfile} #{outfile}"
- unless ok = System.run('cropcrap',arguments) then
+ report("calling #{@@pdftrimwhite}")
+ unless ok = System.run(@@pdftrimwhite,arguments) then
report('cropping failed')
begin
File.delete(outfile)
diff --git a/scripts/context/ruby/newtexexec.rb b/scripts/context/ruby/newtexexec.rb
index 564205d2e..a44cf1116 100644
--- a/scripts/context/ruby/newtexexec.rb
+++ b/scripts/context/ruby/newtexexec.rb
@@ -356,7 +356,7 @@ class Commands
copyortrim(true,'trim')
end
- def copyortrim(trim=false)
+ def copyortrim(trim=false,what='unknown')
if job = TEX.new(logger) then
prepare(job)
job.cleanuptemprunfiles
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index dfc9b1a26..0320ce97a 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -85,8 +85,9 @@ $predefined['mpstools'] = 'mpstools.rb'
$predefined['exatools'] = 'exatools.rb'
$predefined['xmltools'] = 'xmltools.rb'
-$predefined['newpstopdf'] = 'newpstopdf.rb'
-$predefined['newtexexec'] = 'newtexexec.rb'
+$predefined['newpstopdf'] = 'newpstopdf.rb'
+$predefined['newtexexec'] = 'newtexexec.rb'
+$predefined['pdftrimwhite'] = 'pdftrimwhite.pl'
$makelist = [
# context
diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb
index 78982f175..3c257b7db 100644
--- a/scripts/context/ruby/textools.rb
+++ b/scripts/context/ruby/textools.rb
@@ -13,7 +13,7 @@
# This script will harbor some handy manipulations on tex
# related files.
-banner = ['TeXTools', 'version 1.2.2', '2002/2005', 'PRAGMA ADE/POD']
+banner = ['TeXTools', 'version 1.3.1', '2002/2006', 'PRAGMA ADE/POD']
unless defined? ownpath
ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
@@ -41,6 +41,70 @@ class Commands
include CommandBase
+ def tpmmake
+ if filename = @commandline.argument('first') then
+ filename = File.join('tpm',filename) unless filename =~ /^tpm[\/\\]/
+ filename += '.tpm' unless filename =~ /\.tpm$/
+ if FileTest.file?(filename) then
+ data = IO.read(filename) rescue ''
+ data, fn, n = calculate_tpm(data,"TPM:RunFiles")
+ data, fm, m = calculate_tpm(data,"TPM:DocFiles")
+ data = replace_tpm(data,"TPM:Size",n+m)
+ report("total size #{n+m}")
+ begin
+ File.open(filename, 'w') do |f|
+ f << data
+ end
+ rescue
+ report("unable to save '#{filename}'")
+ else
+ report("file '#{filename}' is updated")
+ filename = File.basename(filename).sub(/\..*$/,'')
+ zipname = sprintf("%s-%04i.%02i.%02i%s",filename,Time.now.year,Time.now.month,Time.now.day,'.zip')
+ File.delete(zipname) rescue true
+ report("zipping file '#{zipname}'")
+ system("zip -r -9 -q #{zipname} #{[fn,fm].flatten.join(' ')}")
+ end
+ else
+ report("no file '#{filename}'")
+ end
+ end
+ end
+
+ def calculate_tpm(data, tag='')
+ size, ok = 0, Array.new
+ data.gsub!(/<#{tag}.*>(.*?)<\/#{tag}>/m) do
+ content = $1
+ files = content.split(/\s+/)
+ files.each do |file|
+ unless file =~ /^\s*$/ then
+ if FileTest.file?(file) then
+ report("found file #{file}")
+ size += FileTest.size(file) rescue 0
+ ok << file
+ else
+ report("missing file #{file}")
+ end
+ end
+ end
+ "<#{tag} size=\"#{size}\">#{content}</#{tag}>"
+ end
+ [data, ok, size]
+ end
+
+ def replace_tpm(data, tag='', txt='')
+ data.gsub(/(<#{tag}.*>)(.*?)(<\/#{tag}>)/m) do
+ $1 + txt.to_s + $3
+ end
+ end
+
+
+end
+
+class Commands
+
+ include CommandBase
+
def hidemapnames
report('hiding FontNames in map files')
xidemapnames(true)
@@ -871,6 +935,8 @@ commandline.registeraction('downcasefilenames', '[--recurse] [--force]') # not y
commandline.registeraction('stripformfeeds' , '[--recurse] [--force]') # not yet documented
commandline.registeraction('showfont' , 'filename')
+commandline.registeraction('tpmmake' , 'tpm file (run in texmf root)')
+
commandline.registeraction('help')
commandline.registeraction('version')