summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua')
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua99
1 files changed, 45 insertions, 54 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua b/Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua
index 4243625adb9..342ff1c284a 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-mptopdf.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['mtx-mptopdf'] = {
version = 1.303,
- comment = "companion to mtxrun.lua",
+ comment = "companion to mtxrun.lua, patched by HH so errors are his",
author = "Taco Hoekwater, Elvenkind BV, Dordrecht NL",
copyright = "Elvenkind BV / ConTeXt Development Team",
license = "see context related readme files"
@@ -10,40 +10,30 @@ scripts = scripts or { }
scripts.mptopdf = scripts.mptopdf or { }
scripts.mptopdf.aux = scripts.mptopdf.aux or { }
-do
- -- setup functions and variables here
+local dosish = os.type == 'windows'
+local miktex = dosish and environment.TEXSYSTEM and environment.TEXSYSTEM:find("miktex")
+local escapeshell = environment.SHELL and environment.SHELL:find("sh") and true
- local dosish, miktex, escapeshell = false, false, false
+function scripts.mptopdf.aux.find_latex(fname)
+ local d = io.loaddata(fname) or ""
+ return d:find("\\documentstyle") or d:find("\\documentclass") or d:find("\\begin{document}")
+end
- if os.platform == 'windows' then
- dosish = true
- if environment.TEXSYSTEM and environment.TEXSYSTEM:find("miktex") then
- miktex = true
+function scripts.mptopdf.aux.do_convert (fname)
+ local command, done, pdfdest = "", 0, ""
+ if fname:find(".%d+$") or fname:find("%.mps$") then
+ if miktex then
+ command = "pdftex -undump=mptopdf"
+ else
+ command = "pdftex -fmt=mptopdf -progname=context"
end
- end
- if environment.SHELL and environment.SHELL:find("sh") then
- escapeshell = true
- end
-
- function scripts.mptopdf.aux.find_latex(fname)
- local d = io.loaddata(fname) or ""
- return d:find("\\documentstyle") or d:find("\\documentclass") or d:find("\\begin{document}")
- end
-
- function scripts.mptopdf.aux.do_convert (fname)
- local command, done, pdfdest = "", 0, ""
- if fname:find(".%d+$") or fname:find("%.mps$") then
- if miktex then
- command = "pdftex -undump=mptopdf"
- else
- command = "pdftex -fmt=mptopdf -progname=context"
- end
- if dosish then
- command = string.format('%s \\relax "%s"',command,fname)
- else
- command = string.format('%s \\\\relax "%s"',command,fname)
- end
- os.execute(command)
+ if dosish then
+ command = string.format('%s \\relax "%s"',command,fname)
+ else
+ command = string.format('%s \\\\relax "%s"',command,fname)
+ end
+ local result = os.execute(command)
+ if result == 0 then
local name, suffix = file.nameonly(fname), file.extname(fname)
local pdfsrc = name .. ".pdf"
if lfs.isfile(pdfsrc) then
@@ -55,29 +45,28 @@ do
done = 1
end
end
- return done, pdfdest
end
+ return done, pdfdest
+end
- function scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun)
- local rest, mpbin = latex and " --tex=latex " or " ", ""
- if rawmp then
- if metafun then
- mpbin = "mpost --progname=mpost --mem=metafun"
- else
- mpbin = "mpost --mem=mpost"
- end
+function scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun)
+ local rest, mpbin = latex and " --tex=latex " or " ", ""
+ if rawmp then
+ if metafun then
+ mpbin = "mpost --progname=mpost --mem=metafun"
else
- if latex then
- mpbin = "mpost --mem=mpost"
- else
- mpbin = "texexec --mptex"
- end
+ mpbin = "mpost --mem=mpost"
end
- local runner = mpbin .. rest .. fn
- logs.simple("running: %s\n", runner)
- return (os.execute(runner))
- end
-
+ else
+ if latex then
+ mpbin = "mpost --mem=mpost"
+ else
+ mpbin = "texexec --mptex"
+ end
+ end
+ local runner = mpbin .. rest .. fn
+ logs.simple("running: %s\n", runner)
+ return (os.execute(runner))
end
function scripts.mptopdf.convertall()
@@ -97,7 +86,8 @@ function scripts.mptopdf.convertall()
exit(1)
end
local report = { }
- for _,fn in ipairs(files) do
+ for i=1,#files do
+ local fn = files[i]
local success, name = scripts.mptopdf.aux.do_convert(fn)
if success > 0 then
report[#report+1] = { fn, name }
@@ -106,11 +96,12 @@ function scripts.mptopdf.convertall()
if #report > 0 then
logs.simple("number of converted files: %i", #report)
logs.simple("")
- for _, r in ipairs(report) do
+ for i=1,#report do
+ local r = report[i]
logs.simple("%s => %s", r[1], r[2])
end
else
- logs.simple("no input files match %s", table.concat(files,' '))
+ logs.simple("no files are converted")
end
else
logs.simple("no files match %s", table.concat(environment.files,' '))