1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
if not modules then modules = { } end modules ['data-met'] = {
version = 1.100,
comment = "companion to luat-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
local find = string.find
local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local report_resolvers = logs.new("resolvers")
local allocate = utilities.storage.allocate
local resolvers = resolvers
resolvers.concatinators = allocate ()
resolvers.locators = allocate { notfound = { nil } } -- locate databases
resolvers.hashers = allocate { notfound = { nil } } -- load databases
resolvers.generators = allocate { notfound = { nil } } -- generate databases
function resolvers.splitmethod(filename)
if not filename then
return { } -- safeguard
elseif type(filename) == "table" then
return filename -- already split
elseif not find(filename,"://") then
return { scheme="file", path = filename, original = filename } -- quick hack
else
return url.hashed(filename)
end
end
function resolvers.methodhandler(what, filename, filetype) -- ...
filename = file.collapse_path(filename)
local specification = (type(filename) == "string" and resolvers.splitmethod(filename)) or filename -- no or { }, let it bomb
local scheme = specification.scheme
local resolver = resolvers[what]
if resolver[scheme] then
if trace_locating then
report_resolvers("handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolver[scheme](filename,filetype)
else
return resolver.tex(filename,filetype) -- todo: specification
end
end
|