summaryrefslogtreecommitdiff
path: root/tex/context/base/s-math-parameters.lua
blob: 8e8c15a2d3735ed8716d958ea0da1b20e4faf819 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
if not modules then modules = { } end modules ['s-math-coverage'] = {
    version   = 1.001,
    comment   = "companion to s-math-coverage.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.parameters = moduledata.math.parameters or { }

local tables = utilities.tables.definedtable("math","tracing","spacing","tables")

tables.styleaxis = {
    "ord", "op", "bin", "rel", "open", "close", "punct", "inner",
}

tables.parameters = {
    "quad", "axis", "operatorsize",
    "overbarkern", "overbarrule", "overbarvgap",
    "underbarkern", "underbarrule", "underbarvgap",
    "radicalkern", "radicalrule", "radicalvgap",
    "radicaldegreebefore", "radicaldegreeafter", "radicaldegreeraise",
    "stackvgap", "stacknumup", "stackdenomdown",
    "fractionrule", "fractionnumvgap", "fractionnumup",
    "fractiondenomvgap", "fractiondenomdown", "fractiondelsize",
    "limitabovevgap", "limitabovebgap", "limitabovekern",
    "limitbelowvgap", "limitbelowbgap", "limitbelowkern",
    "underdelimitervgap", "underdelimiterbgap",
    "overdelimitervgap", "overdelimiterbgap",
    "subshiftdrop", "supshiftdrop", "subshiftdown",
    "subsupshiftdown", "subtopmax", "supshiftup",
    "supbottommin", "supsubbottommax", "subsupvgap",
    "spaceafterscript", "connectoroverlapmin",
}

tables.styles = {
    "display",
    "text",
    "script",
    "scriptscript",
}

function tables.stripmu(str)
    str = string.gsub(str,"mu","")
    str = string.gsub(str," ","")
    str = string.gsub(str,"plus","+")
    str = string.gsub(str,"minus","-")
    return str
end

function tables.strippt(old)
    local new = string.gsub(old,"pt","")
    if new ~= old then
        new = string.format("%0.4f",tonumber(new))
    end
    return new
end

function moduledata.math.parameters.showspacing()

    local styles    = tables.styles
    local styleaxis = tables.styleaxis

    context.starttabulate { "|Tl|Tl|" .. string.rep("Tc|",(#styles*2)) }
        context.HL()
        context.NC()
        context.NC()
        context.NC()
        for i=1,#styles do
            context.bold(styles[i])
            context.NC()
            context.bold("(cramped)")
            context.NC()
        end
        context.NR()
        context.HL()
        for i=1,#styleaxis do
         -- print(key,tex.getmath(key,"text"))
            local one = styleaxis[i]
            for j=1,#styleaxis do
                local two = styleaxis[j]
                context.NC()
                if j == 1 then
                    context.bold(one)
                end
                context.NC()
                context.bold(two)
                context.NC()
                for i=1,#styles do
                    context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\%sstyle'))}",one,two,styles[i])
                    context.NC()
                    context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\cramped%sstyle'))}",one,two,styles[i])
                    context.NC()
                end
                context.NR()
            end
        end
    context.stoptabulate()
end

function moduledata.math.parameters.showparameters()

    local styles     = tables.styles
    local parameters = tables.parameters

    context.starttabulate { "|l|" .. string.rep("Tc|",(#styles*2)) }
        context.HL()
        context.NC()
        context.NC()
        for i=1,#styles do
            context.bold(styles[i])
            context.NC()
            context.bold("(cramped)")
            context.NC()
        end
        context.NR()
        context.HL()
        for i=1,#parameters do
            local parameter = parameters[i]
         -- print(parameter,tex.getmath(parameter,"text"))
            context.NC()
            context.type(parameter)
            context.NC()
            for i=1,#styles do
                context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\%sstyle'))}",parameter,styles[i])
                context.NC()
                context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\cramped%sstyle'))}",parameter,styles[i])
                context.NC()
            end
            context.NR()
        end
    context.stoptabulate()

end