s-math-ligatures.lua /size: 2331 b    last modification: 2021-10-28 13:51
1if not modules then modules = { } end modules['s-math-ligatures'] = {
2    version   = 1.001,
3    comment   = "companion to s-math-ligatures.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
9moduledata.math           = moduledata.math           or { }
10moduledata.math.ligatures = moduledata.math.ligatures or { }
11
12local context = context
13
14local utfchar = utf.char
15local uformat = string.formatters["%U"]
16
17function moduledata.math.ligatures.showlist(specification)
18 -- specification = interfaces.checkedspecification(specification)
19
20    local function setlist(unicode,list,start,v,how)
21        if list[start] ~= 0x20 then
22            local t, u = { }, { }
23            for i=start,#list do
24                local li = list[i]
25                t[#t+1] = utfchar(li)
26                u[#u+1] = uformat(li)
27            end
28            context.NC() context(how)
29            context.NC() context("%U",unicode)
30            context.NC() context("%c",unicode)
31            context.NC() context("% t",u)
32            context.NC() context("%t",t)
33            context.NC() context("%t",t)
34            context.NC()
35            context.nohyphens()
36            context.veryraggedright()
37            local n = v.mathname
38            if n then
39                context.tex(n)
40            else
41                local c = v.mathspec
42                if c then
43                    for i=1,#c do
44                        local n = c[i].name
45                        if n then
46                            context.tex(n)
47                            context.quad()
48                        end
49                    end
50                end
51            end
52            context.NC()
53            context.NR()
54        end
55    end
56
57    context.starttabulate { "|T|T|m|T|T|m|pl|" }
58    for unicode, v in table.sortedhash(characters.data) do
59        local vs = v.specials
60        if vs and #vs > 2 then
61            local kind = vs[1]
62            if (v.mathclass or v.mathspec) and (kind == "char" or kind == "with" or kind == "compat") then
63                setlist(unicode,vs,2,v,"sp")
64            end
65        end
66        local ml = v.mathlist
67        if ml then
68            setlist(unicode,ml,1,v,"ml")
69        end
70    end
71    context.stoptabulate()
72end
73