summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/base/tex.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/base/tex.rb')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/base/tex.rb200
1 files changed, 44 insertions, 156 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/tex.rb b/Master/texmf-dist/scripts/context/ruby/base/tex.rb
index 84025693b01..2184447ce84 100644
--- a/Master/texmf-dist/scripts/context/ruby/base/tex.rb
+++ b/Master/texmf-dist/scripts/context/ruby/base/tex.rb
@@ -87,8 +87,6 @@ class TEX
@@texmethods = Hash.new
@@mpsmethods = Hash.new
@@pdftex = 'pdftex' # new default, pdfetex is gone
- @@luafiles = "luafiles.tmp"
- @@luatarget = "lua/context"
@@platformslash = if System.unix? then "\\\\" else "\\" end
@@ -96,7 +94,6 @@ class TEX
['aleph','omega'] .each do |e| @@texengines[e] = 'aleph' end
['xetex'] .each do |e| @@texengines[e] = 'xetex' end
['petex'] .each do |e| @@texengines[e] = 'petex' end
- ['luatex'] .each do |e| @@texengines[e] = 'luatex' end
['metapost','mpost', 'standard'] .each do |e| @@mpsengines[e] = 'mpost' end
@@ -118,18 +115,16 @@ class TEX
# todo norwegian (no)
- ['plain'] .each do |f| @@texformats[f] = 'plain' end
- ['cont-en','en','english','context','standard'].each do |f| @@texformats[f] = 'cont-en' end
- ['cont-nl','nl','dutch'] .each do |f| @@texformats[f] = 'cont-nl' end
- ['cont-de','de','german'] .each do |f| @@texformats[f] = 'cont-de' end
- ['cont-it','it','italian'] .each do |f| @@texformats[f] = 'cont-it' end
- ['cont-fr','fr','french'] .each do |f| @@texformats[f] = 'cont-fr' end
- ['cont-cs','cs','cont-cz','cz','czech'] .each do |f| @@texformats[f] = 'cont-cs' end
- ['cont-ro','ro','romanian'] .each do |f| @@texformats[f] = 'cont-ro' end
- ['cont-gb','gb','cont-uk','uk','british'] .each do |f| @@texformats[f] = 'cont-gb' end
- ['cont-pe','pe','persian'] .each do |f| @@texformats[f] = 'cont-pe' end
- ['cont-xp','xp','experimental'] .each do |f| @@texformats[f] = 'cont-xp' end
- ['mptopdf'] .each do |f| @@texformats[f] = 'mptopdf' end
+ ['plain'] .each do |f| @@texformats[f] = 'plain' end
+ ['cont-en','en','english','context','standard'].each do |f| @@texformats[f] = 'cont-en.mkii' end
+ ['cont-nl','nl','dutch'] .each do |f| @@texformats[f] = 'cont-nl.mkii' end
+ ['cont-de','de','german'] .each do |f| @@texformats[f] = 'cont-de.mkii' end
+ ['cont-it','it','italian'] .each do |f| @@texformats[f] = 'cont-it.mkii' end
+ ['cont-fr','fr','french'] .each do |f| @@texformats[f] = 'cont-fr.mkii' end
+ ['cont-cs','cs','cont-cz','cz','czech'] .each do |f| @@texformats[f] = 'cont-cs.mkii' end
+ ['cont-ro','ro','romanian'] .each do |f| @@texformats[f] = 'cont-ro.mkii' end
+ ['cont-gb','gb','cont-uk','uk','british'] .each do |f| @@texformats[f] = 'cont-gb.mkii' end
+ ['mptopdf'] .each do |f| @@texformats[f] = 'mptopdf' end
['latex'] .each do |f| @@texformats[f] = 'latex.ltx' end
@@ -137,15 +132,20 @@ class TEX
['metafun','context','standard'] .each do |f| @@mpsformats[f] = 'metafun' end
['pdftex','pdfetex','aleph','omega','petex',
- 'xetex','luatex'] .each do |p| @@prognames[p] = 'context' end
+ 'xetex'] .each do |p| @@prognames[p] = 'context' end
['mpost'] .each do |p| @@prognames[p] = 'metafun' end
['latex','pdflatex'] .each do |p| @@prognames[p] = 'latex' end
['plain','default','standard','mptopdf'] .each do |f| @@texmethods[f] = 'plain' end
- ['cont-en','cont-nl','cont-de','cont-it',
- 'cont-fr','cont-cs','cont-ro','cont-gb',
- 'cont-pe','cont-xp'] .each do |f| @@texmethods[f] = 'context' end
- ['latex','pdflatex'] .each do |f| @@texmethods[f] = 'latex' end
+ ['cont-en','cont-en.mkii',
+ 'cont-nl','cont-nl.mkii',
+ 'cont-de','cont-de.mkii',
+ 'cont-it','cont-it.mkii',
+ 'cont-fr','cont-fr.mkii',
+ 'cont-cs','cont-cs.mkii',
+ 'cont-ro','cont-ro.mkii',
+ 'cont-gb','cont-gb.mkii'] .each do |f| @@texmethods[f] = 'context' end
+ ['latex','latex.ltx','pdflatex'] .each do |f| @@texmethods[f] = 'latex' end # untested
['plain','default','standard'] .each do |f| @@mpsmethods[f] = 'plain' end
['metafun'] .each do |f| @@mpsmethods[f] = 'metafun' end
@@ -158,7 +158,6 @@ class TEX
'cont-pe','cont-xp'] .each do |f| @@texprocstr[f] = @@platformslash + "emergencyend" end
@@runoptions['aleph'] = ['--8bit']
- @@runoptions['luatex'] = ['--file-line-error']
@@runoptions['mpost'] = ['--8bit']
@@runoptions['pdfetex'] = ['--8bit'] # obsolete
@@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex
@@ -166,11 +165,9 @@ class TEX
@@runoptions['xetex'] = ['--8bit','-output-driver="xdvipdfmx -E -d 4 -V 5"']
@@draftoptions['pdftex'] = ['--draftmode']
@@synctexcoptions['pdftex'] = ['--synctex=1']
- @@synctexcoptions['luatex'] = ['--synctex=1']
@@synctexcoptions['xetex'] = ['--synctex=1']
@@tcxflag['aleph'] = true
- @@tcxflag['luatex'] = false
@@tcxflag['mpost'] = false
@@tcxflag['pdfetex'] = true
@@tcxflag['pdftex'] = true
@@ -184,7 +181,7 @@ class TEX
'nomapfiles', 'local',
'arrange', 'noarrange',
'forcexml', 'foxet',
- 'alpha', 'beta', 'luatex',
+ 'alpha', 'beta',
'mpyforce', 'forcempy',
'forcetexutil', 'texutil',
'globalfile', 'autopath',
@@ -198,7 +195,7 @@ class TEX
'filters', 'usemodules', 'environments', 'separation', 'setuppath',
'arguments', 'input', 'output', 'randomseed', 'modes', 'mode', 'filename',
'ctxfile', 'printformat', 'paperformat', 'paperoffset',
- 'timeout', 'passon'
+ 'timeout', 'passon', 'pdftitle'
]
@@mainstandardvars = [
'mainlanguage', 'bodyfont', 'language'
@@ -362,9 +359,9 @@ class TEX
end
rescue
end
- ['mpgraph.mp'].each do |file|
- (File.delete(file) if (FileTest.size?(file) rescue 10) < 10) rescue false
- end
+ # ['mpgraph.mp'].each do |file|
+ # (File.delete(file) if (FileTest.size?(file) rescue 10) < 10) rescue false
+ # end
end
def backends() @@backends.keys.sort end
@@ -426,7 +423,7 @@ class TEX
def prefixed(format,engine)
# format
case engine
- when /etex|pdftex|pdfetex|aleph|xetex|luatex/io then
+ when /etex|pdftex|pdfetex|aleph|xetex/io then
"*#{format}"
else
format
@@ -442,14 +439,6 @@ class TEX
if str.class == String then str.split(',') else str.flatten end
end
- def validtexformat(str) validsomething(str,@@texformats,'tex') end
- def validmpsformat(str) validsomething(str,@@mpsformats,'mp' ) end
- def validtexengine(str) validsomething(str,@@texengines,'pdftex') end
- def validmpsengine(str) validsomething(str,@@mpsengines,'mpost' ) end
-
- def validtexmethod(str) [validsomething(str,@@texmethods)].flatten.first end
- def validmpsmethod(str) [validsomething(str,@@mpsmethods)].flatten.first end
-
def validsomething(str,something,type=nil)
if str then
list = [str].flatten.collect do |s|
@@ -471,6 +460,15 @@ class TEX
end
end
+ def validtexformat(str) validsomething(str,@@texformats,'tex') ||
+ validsomething(str,@@texformats,'mkii') end
+ def validmpsformat(str) validsomething(str,@@mpsformats,'mp' ) end
+ def validtexengine(str) validsomething(str,@@texengines,'pdftex') end
+ def validmpsengine(str) validsomething(str,@@mpsengines,'mpost' ) end
+
+ def validtexmethod(str) [validsomething(str,@@texmethods)].flatten.first end
+ def validmpsmethod(str) [validsomething(str,@@mpsmethods)].flatten.first end
+
def validbackend(str)
if str && @@backends.key?(str) then
@@backends[str]
@@ -562,7 +560,7 @@ class TEX
# will go to context/process context/listing etc
def contextversion # ook elders gebruiken
- filename = Kpse.found('context.tex')
+ filename = Kpse.found('context.mkii')
version = 'unknown'
begin
if FileTest.file?(filename) && IO.read(filename).match(/\\contextversion\{(\d+\.\d+\.\d+.*?)\}/) then
@@ -573,39 +571,6 @@ class TEX
return version
end
- def cleanupluafiles
- File.delete(@@luafiles) rescue false
- end
-
- def compileluafiles
- begin
- Dir.glob("lua/context/*.luc").each do |luc|
- File.delete(luc) rescue false
- end
- rescue
- end
- if data = (IO.readlines(@@luafiles) rescue nil) then
- report("compiling lua files (using #{File.expand_path(@@luafiles)})")
- begin
- FileUtils.makedirs(@@luatarget) rescue false
- data.each do |line|
- luafile = line.chomp
- lucfile = File.basename(luafile).gsub(/\..*?$/,'') + ".luc"
- if runcommand(["luac","-s","-o",quoted(File.join(Dir.getwd,@@luatarget,lucfile)),quoted(luafile)]) then
- report("#{File.basename(luafile)} converted to #{File.basename(lucfile)}")
- else
- report("#{File.basename(luafile)} not converted to #{File.basename(lucfile)}")
- end
- end
- rescue
- report("fatal error in compilation")
- end
- else
- report("no lua compilations needed")
- end
- File.delete(@@luafiles) rescue false
- end
-
# we need engine methods
def makeformats
@@ -618,14 +583,6 @@ class TEX
else
report('updating file database')
Kpse.update # obsolete here
- if getvariable('luatex') then
- begin
- runcommand(["luatools","--generate","--verbose"])
- rescue
- report("run 'luatools --generate' manualy")
- exit
- end
- end
end
# goody
if getvariable('texformats') == 'standard' then
@@ -658,22 +615,10 @@ class TEX
# makeuserfile
# makeresponsefile
# end
- if texengine == 'luatex' then
- cleanupluafiles
- texformats.each do |texformat|
- report("generating tex format #{texformat}")
- flags = ['--ini','--compile']
- flags << '--verbose' if getvariable('verbose')
- flags << '--mkii' if getvariable('mkii')
- run_luatools("#{flags.join(" ")} #{texformat}")
- end
- compileluafiles
- else
- texformats.each do |texformat|
- report("generating tex format #{texformat}")
- progname = validprogname([getvariable('progname'),texformat,texengine])
- runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)])
- end
+ texformats.each do |texformat|
+ report("generating tex format #{texformat}")
+ progname = validprogname([getvariable('progname'),texformat,texengine])
+ runcommand([quoted(texengine),prognameflag(progname),iniflag,tcxflag(texengine),prefixed(texformat,texengine),texmakeextras(texformat)])
end
else
report("unable to make format due to lack of permissions")
@@ -728,15 +673,6 @@ class TEX
end
end
end
- begin
- lucdir = File.join(texformatpath,@@luatarget)
- Dir.chdir(lucdir)
- rescue
- else
- Dir.glob("*.luc").each do |file|
- report("luc: #{filestate(file)} > #{File.expand_path(file)} (#{File.size(file)})")
- end
- end
# to be sure, go back to current path
begin
Dir.chdir(savedpath)
@@ -781,7 +717,7 @@ class TEX
f.close
if FileTest.file?(tempfilename('tex')) then
format = File.basename(name)
- engine = if name =~ /(pdftex|pdfetex|aleph|xetex|luatex)[\/\\]#{format}/ then $1 else '' end
+ engine = if name =~ /(pdftex|pdfetex|aleph|xetex)[\/\\]#{format}/ then $1 else '' end
if engine.empty? then
engineflag = ""
else
@@ -831,7 +767,7 @@ class TEX
private
- def makeuserfile # not used in luatex (yet)
+ def makeuserfile
language = getvariable('language')
mainlanguage = getvariable('mainlanguage')
bodyfont = getvariable('bodyfont')
@@ -1179,24 +1115,6 @@ class TEX
public
- # def run_luatools(args)
- # dirty trick: we know that the lua path is relative to the ruby path; of course this
- # will not work well when stubs are used
- # [(ENV["_CTX_K_S_texexec_"] or ENV["_CTX_K_S_THREAD_"] or ENV["TEXMFSTART.THREAD"]), File.dirname($0)].each do |path|
- # if path then
- # script = "#{path}/../lua/luatools.lua"
- # if FileTest.file?(script) then
- # return runcommand("luatex --luaonly #{script} #{args}")
- # end
- # end
- # end
- # return runcommand("texmfstart luatools #{args}")
- # end
-
- def run_luatools(args)
- return runcommand("luatools #{args}")
- end
-
def processmpgraphic
getarrayvariable('files').each do |filename|
setvariable('filename',filename)
@@ -1584,17 +1502,8 @@ end
report("tex format: #{texformat}")
if texengine && texformat then
fixbackendvars(@@mappaths[texengine])
- if texengine == "luatex" then
- # currently we use luatools to start luatex but some day we should
- # find a clever way to directly call luatex (problem is that we need
- # to feed the explicit location of the format and lua initialization
- # file)
- run_luatools("--fmt=#{texformat} #{filename}")
- else
- progname = validprogname([getvariable('progname'),texformat,texengine])
- runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)])
- end
- # true
+ progname = validprogname([getvariable('progname'),texformat,texengine])
+ runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag(texengine),runoptions(texengine),filename,texprocextras(texformat)])
else
false
end
@@ -1673,24 +1582,6 @@ end
end
end
- def runluacheck(jobname)
- if false then
- # test-pos.tex / 6 meg tua file: 18.6 runtime
- old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc')
- if FileTest.file?(old) then
- report("converting #{old} into #{new}")
- system("luac -s -o #{new} #{old}")
- end
- else
- # test-pos.tex / 6 meg tua file: 17.5 runtime
- old, new = File.suffixed(jobname,'tua'), File.suffixed(jobname,'tuc')
- if FileTest.file?(old) then
- report("renaming #{old} into #{new}")
- File.rename(old,new) rescue false
- end
- end
- end
-
# 1=tex 2=mptex 3=mpxtex 4=mpgraphic 5=mpstatic
def runtexexec(filename=[], options=[], mode=nil)
@@ -1928,7 +1819,6 @@ end
ok = runtex(if dummyfile || forcexml then rawbase else rawname end)
if ok then
ok = runtexutil(rawbase) if getvariable('texutil') || getvariable('forcetexutil')
- runluacheck(rawbase)
runbackend(rawbase)
popresult(rawbase,result)
end
@@ -1979,7 +1869,6 @@ end
mprundone = runtexmpjob(rawbase, "mprun")
end
ok = runtexutil(rawbase)
- runluacheck(rawbase)
state.update
stoprunning = state.stable?
end
@@ -1989,7 +1878,6 @@ end
end
if (nofruns == 1) && getvariable('texutil') then
ok = runtexutil(rawbase)
- runluacheck(rawbase)
end
if ok && finalrun && (nofruns > 1) then
makeoptionfile(rawbase,jobname,orisuffix,true,finalrun,4,texruns) unless getvariable('nooptionfile')