s-math-parameters.lua /size: 4438 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['s-math-coverage'] = {
2    version   = 1.001,
3    comment   = "companion to s-math-coverage.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.parameters = moduledata.math.parameters or { }
11
12local tables = utilities.tables.definedtable("math","tracing","spacing","tables")
13
14tables.styleaxis = {
15    "ord", "op", "bin", "rel", "open", "close", "punct", "inner",
16}
17
18tables.parameters = {
19    "quad", "axis", "operatorsize",
20    "overbarkern", "overbarrule", "overbarvgap",
21    "underbarkern", "underbarrule", "underbarvgap",
22    "radicalkern", "radicalrule", "radicalvgap",
23    "radicaldegreebefore", "radicaldegreeafter", "radicaldegreeraise",
24    "stackvgap", "stacknumup", "stackdenomdown",
25    "fractionrule", "fractionnumvgap", "fractionnumup",
26    "fractiondenomvgap", "fractiondenomdown", "fractiondelsize",
27    "limitabovevgap", "limitabovebgap", "limitabovekern",
28    "limitbelowvgap", "limitbelowbgap", "limitbelowkern",
29    "underdelimitervgap", "underdelimiterbgap",
30    "overdelimitervgap", "overdelimiterbgap",
31    "subshiftdrop", "supshiftdrop", "subshiftdown",
32    "subsupshiftdown", "subtopmax", "supshiftup",
33    "supbottommin", "supsubbottommax", "subsupvgap",
34    "spaceafterscript", "connectoroverlapmin",
35}
36
37tables.styles = {
38    "display",
39    "text",
40    "script",
41    "scriptscript",
42}
43
44function tables.stripmu(str)
45    str = string.gsub(str,"mu","")
46    str = string.gsub(str," ","")
47    str = string.gsub(str,"plus","+")
48    str = string.gsub(str,"minus","-")
49    return str
50end
51
52function tables.strippt(old)
53    local new = string.gsub(old,"pt","")
54    if new ~= old then
55        new = string.format("%0.4f",tonumber(new))
56    end
57    return new
58end
59
60function moduledata.math.parameters.showspacing()
61
62    local styles    = tables.styles
63    local styleaxis = tables.styleaxis
64
65    context.starttabulate { "|Tl|Tl|" .. string.rep("Tc|",(#styles*2)) }
66        context.HL()
67        context.NC()
68        context.NC()
69        context.NC()
70        for i=1,#styles do
71            context.bold(styles[i])
72            context.NC()
73            context.bold("(cramped)")
74            context.NC()
75        end
76        context.NR()
77        context.HL()
78        for i=1,#styleaxis do
79         -- print(key,tex.getmath(key,"text"))
80            local one = styleaxis[i]
81            for j=1,#styleaxis do
82                local two = styleaxis[j]
83                context.NC()
84                if j == 1 then
85                    context.bold(one)
86                end
87                context.NC()
88                context.bold(two)
89                context.NC()
90                for i=1,#styles do
91                    context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\%sstyle'))}",one,two,styles[i])
92                    context.NC()
93                    context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\cramped%sstyle'))}",one,two,styles[i])
94                    context.NC()
95                end
96                context.NR()
97            end
98        end
99    context.stoptabulate()
100end
101
102function moduledata.math.parameters.showparameters()
103
104    local styles     = tables.styles
105    local parameters = tables.parameters
106
107    context.starttabulate { "|l|" .. string.rep("Tc|",(#styles*2)) }
108        context.HL()
109        context.NC()
110        context.NC()
111        for i=1,#styles do
112            context.bold(styles[i])
113            context.NC()
114            context.bold("(cramped)")
115            context.NC()
116        end
117        context.NR()
118        context.HL()
119        for i=1,#parameters do
120            local parameter = parameters[i]
121         -- print(parameter,tex.getmath(parameter,"text"))
122            context.NC()
123            context.type(parameter)
124            context.NC()
125            for i=1,#styles do
126                context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\%sstyle'))}",parameter,styles[i])
127                context.NC()
128                context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\cramped%sstyle'))}",parameter,styles[i])
129                context.NC()
130            end
131            context.NR()
132        end
133    context.stoptabulate()
134
135end
136