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

moduledata.math           = moduledata.math           or { }
moduledata.math.ligatures = moduledata.math.ligatures or { }

local context = context

local utfchar = utf.char
local uformat = string.formatters["%U"]

function moduledata.math.ligatures.showlist(specification)
 -- specification = interfaces.checkedspecification(specification)

    local function setlist(unicode,list,start,v,how)
        if list[start] ~= 0x20 then
            local t, u = { }, { }
            for i=start,#list do
                local li = list[i]
                t[#t+1] = utfchar(li)
                u[#u+1] = uformat(li)
            end
            context.NC() context(how)
            context.NC() context("%U",unicode)
            context.NC() context("%c",unicode)
            context.NC() context("% t",u)
            context.NC() context("%t",t)
            context.NC() context("%t",t)
            context.NC()
            context.nohyphens()
            context.veryraggedright()
            local n = v.mathname
            if n then
                context.tex(n)
            else
                local c = v.mathspec
                if c then
                    for i=1,#c do
                        local n = c[i].name
                        if n then
                            context.tex(n)
                            context.quad()
                        end
                    end
                end
            end
            context.NC()
            context.NR()
        end
    end

    context.starttabulate { "|T|T|m|T|T|m|pl|" }
    for unicode, v in table.sortedhash(characters.data) do
        local vs = v.specials
        if vs and #vs > 2 then
            local kind = vs[1]
            if (v.mathclass or v.mathspec) and (kind == "char" or kind == "compat") then
                setlist(unicode,vs,2,v,"sp")
            end
        end
        local ml = v.mathlist
        if ml then
            setlist(unicode,ml,1,v,"ml")
        end
    end
    context.stoptabulate()
end