summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-interface.lua23
-rw-r--r--scripts/context/lua/mtxrun.lua1
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua1
-rwxr-xr-xscripts/context/stubs/unix/mtxrun1
4 files changed, 26 insertions, 0 deletions
diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua
index ed0792d32..9659dce90 100644
--- a/scripts/context/lua/mtx-interface.lua
+++ b/scripts/context/lua/mtx-interface.lua
@@ -300,6 +300,24 @@ function scripts.interface.context()
end
end
+function scripts.interface.preprocess()
+ require("luat-mac.lua")
+ local newsuffix = environment.argument("suffix") or "tex"
+ local force = environment.argument("force")
+ for i=1,#environment.files do
+ local oldname = environment.files[i]
+ local newname = file.replacesuffix(oldname,newsuffix)
+ if oldname == newname then
+ logs.simple("skipping '%s' because old and new name are the same",oldname)
+ elseif io.exists(newname) and not force then
+ logs.simple("skipping '%s' because new file exists, use --force",oldname)
+ else
+ logs.simple("processing '%s' into '%s'",oldname,newname)
+ io.savedata(newname,resolvers.macros.preprocessed(io.loaddata(oldname)))
+ end
+ end
+end
+
function scripts.interface.messages()
local filename = resolvers.findfile(environment.files[1] or "mult-mes.lua") or ""
if filename ~= "" then
@@ -338,6 +356,9 @@ messages.help = [[
--raw report commands to the console
--check generate check file
--context generate context definition files
+--preprocess preprocess mkvi files to tex files [force,suffix]
+--suffix use given suffix for output files
+--force force action even when in doubt
--messages generate context message files
]]
@@ -345,6 +366,8 @@ local ea = environment.argument
if ea("context") then
scripts.interface.context()
+elseif ea("preprocess") then
+ scripts.interface.preprocess()
elseif ea("messages") then
scripts.interface.messages()
elseif ea("scite") or ea("bbedit") or ea("jedit") or ea("textpad") or ea("text") or ea("raw") then
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index bb16aaec0..a80e4c730 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -13906,6 +13906,7 @@ function runners.execute_program(fullname)
return true
elseif state == "run" then
local before, after = environment.splitarguments(fullname)
+ for k=1,#after do after[k] = resolvers.resolve(after[k]) end
environment.initializearguments(after)
fullname = fullname:gsub("^bin:","")
local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "")
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index bb16aaec0..a80e4c730 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -13906,6 +13906,7 @@ function runners.execute_program(fullname)
return true
elseif state == "run" then
local before, after = environment.splitarguments(fullname)
+ for k=1,#after do after[k] = resolvers.resolve(after[k]) end
environment.initializearguments(after)
fullname = fullname:gsub("^bin:","")
local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "")
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index bb16aaec0..a80e4c730 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -13906,6 +13906,7 @@ function runners.execute_program(fullname)
return true
elseif state == "run" then
local before, after = environment.splitarguments(fullname)
+ for k=1,#after do after[k] = resolvers.resolve(after[k]) end
environment.initializearguments(after)
fullname = fullname:gsub("^bin:","")
local command = fullname .. " " .. (environment.reconstructcommandline(after or "",noquote) or "")