summaryrefslogtreecommitdiff
path: root/tex/context/base/mlib-run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mlib-run.lua')
-rw-r--r--tex/context/base/mlib-run.lua23
1 files changed, 20 insertions, 3 deletions
diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua
index fc993861c..7d670b77d 100644
--- a/tex/context/base/mlib-run.lua
+++ b/tex/context/base/mlib-run.lua
@@ -35,7 +35,7 @@ local report_mplib = logs.new("mplib")
local texerrormessage = logs.texerrormessage
-local format, gsub, match = string.format, string.gsub, string.match
+local format, gsub, match, find = string.format, string.gsub, string.match, string.find
local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
@@ -57,8 +57,8 @@ function metapost.resetlastlog()
metapost.lastlog = ""
end
-local function finder(name, mode, ftype)
- if mode=="w" then
+local function finder(name, mode, ftype) -- we can use the finder to intercept btex/etex
+ if mode == "w" then
return name
elseif file.is_qualified_path(name) then
return name
@@ -67,6 +67,23 @@ local function finder(name, mode, ftype)
end
end
+local function finder(name, mode, ftype) -- we use the finder to intercept btex/etex
+ if mode ~= "w" then
+ name = file.is_qualified_path(name) and name or resolvers.findfile(name,ftype)
+ if not (find(name,"/metapost/context/base/") or find(name,"/metapost/context/") or find(name,"/metapost/base/")) then
+ local data, found, forced = metapost.checktexts(io.loaddata(name) or "")
+ if found then
+ local temp = luatex.registertempfile(name)
+ io.savedata(temp,data)
+ name = temp
+ end
+ end
+ end
+ return name
+end
+
+-- -- --
+
metapost.finder = finder
function metapost.reporterror(result)