summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/core-two.lua
blob: 45f1d0f46d178a6c8e1df47e19f531ca643d0232 (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
77
78
79
80
81
82
83
if not modules then modules = { } end modules ['core-two'] = {
    version   = 1.001,
    comment   = "companion to core-two.tex",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

--[[ldx--
<p>We save multi-pass information in the main utility table.</p>
--ldx]]--

if not jobs        then jobs         = { } end
if not job         then jobs['main'] = { } end job = jobs['main']
if not job.twopass then job.twopass  = { } end

function job.definetwopassdata(id)
    job.twopass[id] = job.twopass[id] or { }
end

function job.gettwopassdata(id)
    local jti = job.twopass[id]
    if jti and #jti > 0 then
        tex.print(jti[1])
        table.remove(jti,1)
    end
end

function job.checktwopassdata(id)
    local jti = job.twopass[id]
    if jti and #jti > 0 then
        tex.print(jti[1])
    end
end

function job.getfromtwopassdata(id,n)
    local jti = job.twopass[id]
    if jti and jti[n] then
        tex.print(jti[n])
    end
end

job.findtwopassdata  = job.getfromtwopassdata
job.getfirstpassdata = job.checktwopassdata

function job.getlasttwopassdata(id)
    local jti = job.twopass[id]
    if jti and #jti > 0 then
        tex.print(jti[#jti])
    end
end

function job.noftwopassitems(id)
    local jti = job.twopass[id]
    if jti then
        tex.print(#jti)
    else
        tex.print('0')
    end
end

function job.twopassdatalist(id)
    local jti = job.twopass[id]
    if jti then
        tex.print(table.concat(jti,','))
    end
end

function job.doifelseintwopassdata(id,str)
    local jti = job.twopass[id]
    if jti then
        local found = false
        for _, v in pairs(jti) do
            if v == str then
                found = true
                break
            end
        end
        cs.testcase(found)
    else
        cs.testcase(false)
    end
end