math-ext.lmt /size: 1894 b    last modification: 2025-02-21 11:03
1if not modules then modules = { } end modules ['math-ext'] = {
2    version   = 1.001,
3    comment   = "companion to math-ini.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9-- This is a completely different file from the lua one but the name fits.
10
11-- We actually have a mechanism for this but it has never been used so let's go
12-- simple till we have that active again. This kind of trickery only works in
13-- controlled situations anyway.
14
15----- texnest     = tex.nest
16
17----- setproperty = nodes.setproperty
18local getproperty = nodes.getproperty
19
20local extensibles = { }
21
22function mathematics.registerextensible(specification)
23    local unicode = specification.unicode
24    if unicode then
25        extensibles[unicode] = specification
26    end
27end
28
29-- function mathematics.setextensibledata(data)
30--     local target = texnest[texnest.ptr].tail
31--     if target then -- maybe also check type
32--         setproperty(target,data)
33--     end
34-- end
35
36function mathematics.setextensibledata(data)
37    context(nodes.upcomingproperties { extensible = data })
38end
39
40function mathematics.getextensibledata(target)
41    local property = getproperty(target)
42    return property and property.extensible
43end
44
45callback.register("make_extensible",function(target,fnt,chr,size,width,height,depth,linewidth,axis,exheight,emwidth)
46    local found  = extensibles[chr]
47    if found then
48        local action = found.action
49        if action then
50            return action(target,fnt,chr,size,width,height,depth,linewidth,axis,exheight,emwidth)
51        end
52    end
53end)
54
55if not nodes.setattrlist then
56
57    local tonut       = nodes.tonut
58    local setattrlist = nodes.nuts.setattrlist
59
60    function nodes.setattrlist(target,source)
61        setattrlist(tonut(target),tonut(source))
62    end
63
64end
65