summaryrefslogtreecommitdiff
path: root/tex/context/base/type-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/type-ini.lua')
-rw-r--r--tex/context/base/type-ini.lua121
1 files changed, 81 insertions, 40 deletions
diff --git a/tex/context/base/type-ini.lua b/tex/context/base/type-ini.lua
index 9ee97acae..cd5b32d3e 100644
--- a/tex/context/base/type-ini.lua
+++ b/tex/context/base/type-ini.lua
@@ -6,15 +6,23 @@ if not modules then modules = { } end modules ['type-ini'] = {
license = "see context related readme files"
}
+local gsub = string.gsub
+local lpegmatch, P, Cs = lpeg.match, lpeg.P, lpeg.Cs
+
-- more code will move here
-local commands, context = commands, context
+local commands = commands
+local context = context
+local implement = interfaces.implement
-local gsub = string.gsub
+local uselibrary = resolvers.uselibrary
-local report_typescripts = logs.reporter("fonts","typescripts")
+local name_one = nil
+local name_two = nil
-local patterns = { "type-imp-%s.mkiv", "type-imp-%s.tex", "type-%s.mkiv", "type-%s.tex" } -- this will be imp only
+local p_strip = Cs((P("type-") * (P("imp-")^0))^0/"" * P(1)^0)
+
+local report = logs.reporter("fonts","typescripts")
local function action(name,foundname)
-- context.startreadingfile()
@@ -27,50 +35,83 @@ local function action(name,foundname)
context.loadfoundtypescriptfile(foundname)
end
-local name_one, name_two
+local patterns = {
+ "type-imp-%s.mkiv",
+ "type-imp-%s.tex"
+}
-local function failure_two(name)
- report_typescripts("unknown library %a or %a",name_one,name_two)
+local function failure(name)
+ if name == "loc" then
+ -- ignore
+ else
+ report("unknown library %a",name)
+ end
end
-local function failure_one(name)
- name_two = gsub(name,"%-.*$","")
- if name_two == name then
- report_typescripts("unknown library %a",name_one)
- else
- commands.uselibrary {
- name = name_two,
+implement {
+ name = "loadtypescriptfile",
+ arguments = "string",
+ actions = function(name) -- a more specific name
+ uselibrary {
+ name = lpegmatch(p_strip,name) or name,
patterns = patterns,
action = action,
- failure = failure_two,
+ failure = failure,
onlyonce = false, -- will become true
}
end
-end
-
-function commands.doprocesstypescriptfile(name)
- name_one = gsub(name,"^type%-","")
- commands.uselibrary {
- name = name_one,
- patterns = patterns,
- action = action,
- failure = failure_one,
- onlyonce = false, -- will become true
- }
-end
+}
-local patterns = { "type-imp-%s.mkiv", "type-imp-%s.tex" }
+local patterns = {
+ "type-imp-%s.mkiv",
+ "type-imp-%s.tex",
+ -- obsolete
+ "type-%s.mkiv",
+ "type-%s.tex"
+}
-local function failure(name)
- report_typescripts("unknown library %a",name)
-end
+-- local function failure_two(name)
+-- report("unknown library %a or %a",name_one,name_two)
+-- end
+--
+-- local function failure_one(name)
+-- name_two = gsub(name,"%-.*$","")
+-- if name == "loc" then
+-- -- ignore
+-- elseif name_two == name then
+-- report("unknown library %a",name_one)
+-- else
+-- commands.uselibrary {
+-- name = name_two,
+-- patterns = patterns,
+-- action = action,
+-- failure = failure_two,
+-- onlyonce = false, -- will become true
+-- }
+-- end
+-- end
+--
+-- function commands.doprocesstypescriptfile(name)
+-- name_one = lpegmatch(p_strip,name) or name
+-- uselibrary {
+-- name = name_one,
+-- patterns = patterns,
+-- action = action,
+-- failure = failure_one,
+-- onlyonce = false, -- will become true
+-- }
+-- end
-function commands.loadtypescriptfile(name) -- a more specific name
- commands.uselibrary {
- name = gsub(name,"^type%-",""),
- patterns = patterns,
- action = action,
- failure = failure,
- onlyonce = false, -- will become true
- }
-end
+implement {
+ name = "doprocesstypescriptfile",
+ arguments = "string",
+ actions = function(name)
+ uselibrary {
+ name = lpegmatch(p_strip,name) or name,
+ patterns = patterns,
+ action = action,
+ failure = failure,
+ onlyonce = false, -- will become true
+ }
+ end
+}