summaryrefslogtreecommitdiff
path: root/tex/context/base/core-obj.lua
blob: b94719993f24c233adb990171e41c33464c33b24 (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
if not modules then modules = { } end modules ['core-obj'] = {
    version   = 1.001,
    comment   = "companion to core-obj.tex",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

--[[ldx--
<p>We save object references in the main utility table. Objects are
reusable components.</p>
--ldx]]--

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

function job.getobjectreference(tag,default)
    if job.objects[tag] then
        tex.sprint(job.objects[tag][1] or default)
    else
        tex.sprint(default)
    end
end

function job.getobjectreferencepage(tag,default)
    if job.objects[tag] then
        tex.sprint(job.objects[tag][2] or default)
    else
        tex.sprint(default)
    end
end

function job.doifobjectreference(tag)
    cs.testcase(job.objects[tag])
end