summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-tex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-tex.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-tex.lua39
1 files changed, 24 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-tex.lua b/Master/texmf-dist/tex/context/base/data-tex.lua
index 14148b20ea8..6cb361699fa 100644
--- a/Master/texmf-dist/tex/context/base/data-tex.lua
+++ b/Master/texmf-dist/tex/context/base/data-tex.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['data-tex'] = {
license = "see context related readme files"
}
+local char = string.char
+
local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local report_tex = logs.reporter("resolvers","tex")
@@ -17,17 +19,17 @@ local methodhandler = resolvers.methodhandler
local splitlines = string.splitlines
local utffiletype = unicode.filetype
-local fileprocessor = nil
-local lineprocessor = nil
+-- local fileprocessor = nil
+-- local lineprocessor = nil
-local textfileactions = sequencers.reset {
- arguments = "str,filename",
+local textfileactions = sequencers.new {
+ arguments = "str,filename,coding",
returnvalues = "str",
results = "str",
}
-local textlineactions = sequencers.reset {
- arguments = "str,filename,linenumber,noflines",
+local textlineactions = sequencers.new {
+ arguments = "str,filename,linenumber,noflines,coding",
returnvalues = "str",
results = "str",
}
@@ -46,7 +48,10 @@ appendgroup(textlineactions,"before") -- user
appendgroup(textlineactions,"system") -- private
appendgroup(textlineactions,"after" ) -- user
-function helpers.textopener(tag,filename,filehandle)
+local ctrl_d = char( 4) -- unix
+local ctrl_z = char(26) -- windows
+
+function helpers.textopener(tag,filename,filehandle,coding)
local lines
local t_filehandle = type(filehandle)
if not filehandle then
@@ -60,7 +65,7 @@ function helpers.textopener(tag,filename,filehandle)
filehandle:close()
end
if type(lines) == "string" then
- local coding = utffiletype(lines)
+ local coding = coding or utffiletype(lines) -- so we can signal no regime
if trace_locating then
report_tex("%s opener, '%s' opened using method '%s'",tag,filename,coding)
end
@@ -72,11 +77,11 @@ function helpers.textopener(tag,filename,filehandle)
lines = unicode.utf32_to_utf8_be(lines)
elseif coding == "utf-32-le" then
lines = unicode.utf32_to_utf8_le(lines)
- else -- utf8 or unknown
- if textfileactions.dirty then -- maybe use autocompile
- fileprocessor = sequencers.compile(textfileactions)
+ else -- utf8 or unknown (could be a mkvi file)
+ local runner = textfileactions.runner
+ if runner then
+ lines = runner(lines,filename,coding) or lines
end
- lines = fileprocessor(lines,filename) or lines
lines = splitlines(lines)
end
elseif trace_locating then
@@ -111,11 +116,15 @@ function helpers.textopener(tag,filename,filehandle)
return nil
elseif content == "" then
return ""
+ -- elseif content == ctrl_d or ctrl_z then
+ -- return nil -- we need this as \endinput does not work in prints
else
- if textlineactions.dirty then
- lineprocessor = sequencers.compile(textlineactions) -- maybe use autocompile
+ local runner = textlineactions.runner
+ if runner then
+ return runner(content,filename,currentline,noflines,coding) or content
+ else
+ return content
end
- return lineprocessor(content,filename,currentline,noflines) or content
end
end
end