summaryrefslogtreecommitdiff
path: root/tex/context/base/type-ini.lua
blob: 9ee97acaed3a7abc1a2e995331cc79b0873db593 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
if not modules then modules = { } end modules ['type-ini'] = {
    version   = 1.001,
    comment   = "companion to type-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- more code will move here

local commands, context = commands, context

local gsub = string.gsub

local report_typescripts = logs.reporter("fonts","typescripts")

local patterns = { "type-imp-%s.mkiv", "type-imp-%s.tex", "type-%s.mkiv", "type-%s.tex" } -- this will be imp only

local function action(name,foundname)
 -- context.startreadingfile()
 -- context.unprotect()
 -- context.pushendofline()
 -- context.input(foundname)
 -- context.popendofline()
 -- context.protect()
 -- context.stopreadingfile()
    context.loadfoundtypescriptfile(foundname)
end

local name_one, name_two

local function failure_two(name)
    report_typescripts("unknown library %a or %a",name_one,name_two)
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,
            patterns = patterns,
            action   = action,
            failure  = failure_two,
            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 function failure(name)
    report_typescripts("unknown library %a",name)
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