summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/oberdiek/magicnum.lua
blob: c96af570e702c0e11371b8b3e229098b4d851002 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
-- 
--  This is file `magicnum.lua',
--  generated with the docstrip utility.
-- 
--  The original source files were:
-- 
--  magicnum.dtx  (with options: `lua')
--  
--  This is a generated file.
--  
--  Project: magicnum
--  Version: 2011/04/10 v1.4
--  
--  Copyright (C) 2007, 2009-2011 by
--     Heiko Oberdiek <heiko.oberdiek at googlemail.com>
--  
--  This work may be distributed and/or modified under the
--  conditions of the LaTeX Project Public License, either
--  version 1.3c of this license or (at your option) any later
--  version. This version of this license is in
--     http://www.latex-project.org/lppl/lppl-1-3c.txt
--  and the latest version of this license is in
--     http://www.latex-project.org/lppl.txt
--  and version 1.3 or later is part of all distributions of
--  LaTeX version 2005/12/01 or later.
--  
--  This work has the LPPL maintenance status "maintained".
--  
--  This Current Maintainer of this work is Heiko Oberdiek.
--  
--  The Base Interpreter refers to any `TeX-Format',
--  because some files are installed in TDS:tex/generic//.
--  
--  This work consists of the main source file magicnum.dtx
--  and the derived files
--     magicnum.sty, magicnum.pdf, magicnum.ins, magicnum.drv, magicnum.txt,
--     magicnum-test1.tex, magicnum-test2.tex, magicnum-test3.tex,
--     magicnum-test4.tex, magicnum.lua, oberdiek.magicnum.lua.
--  
module("oberdiek.magicnum", package.seeall)
function getversion()
  tex.write("2011/04/10 v1.4")
end
local data = {
  ["tex.catcode"] = {
    [0] = "escape",
    [1] = "begingroup",
    [2] = "endgroup",
    [3] = "math",
    [4] = "align",
    [5] = "eol",
    [6] = "parameter",
    [7] = "superscript",
    [8] = "subscript",
    [9] = "ignore",
    [10] = "space",
    [11] = "letter",
    [12] = "other",
    [13] = "active",
    [14] = "comment",
    [15] = "invalid",
    ["active"] = 13,
    ["align"] = 4,
    ["begingroup"] = 1,
    ["comment"] = 14,
    ["endgroup"] = 2,
    ["eol"] = 5,
    ["escape"] = 0,
    ["ignore"] = 9,
    ["invalid"] = 15,
    ["letter"] = 11,
    ["math"] = 3,
    ["other"] = 12,
    ["parameter"] = 6,
    ["space"] = 10,
    ["subscript"] = 8,
    ["superscript"] = 7
  },
  ["etex.grouptype"] = {
    [0] = "bottomlevel",
    [1] = "simple",
    [2] = "hbox",
    [3] = "adjustedhbox",
    [4] = "vbox",
    [5] = "align",
    [6] = "noalign",
    [8] = "output",
    [9] = "math",
    [10] = "disc",
    [11] = "insert",
    [12] = "vcenter",
    [13] = "mathchoice",
    [14] = "semisimple",
    [15] = "mathshift",
    [16] = "mathleft",
    ["adjustedhbox"] = 3,
    ["align"] = 5,
    ["bottomlevel"] = 0,
    ["disc"] = 10,
    ["hbox"] = 2,
    ["insert"] = 11,
    ["math"] = 9,
    ["mathchoice"] = 13,
    ["mathleft"] = 16,
    ["mathshift"] = 15,
    ["noalign"] = 6,
    ["output"] = 8,
    ["semisimple"] = 14,
    ["simple"] = 1,
    ["vbox"] = 4,
    ["vcenter"] = 12
  },
  ["etex.iftype"] = {
    [0] = "none",
    [1] = "char",
    [2] = "cat",
    [3] = "num",
    [4] = "dim",
    [5] = "odd",
    [6] = "vmode",
    [7] = "hmode",
    [8] = "mmode",
    [9] = "inner",
    [10] = "void",
    [11] = "hbox",
    [12] = "vbox",
    [13] = "x",
    [14] = "eof",
    [15] = "true",
    [16] = "false",
    [17] = "case",
    [18] = "defined",
    [19] = "csname",
    [20] = "fontchar",
    ["case"] = 17,
    ["cat"] = 2,
    ["char"] = 1,
    ["csname"] = 19,
    ["defined"] = 18,
    ["dim"] = 4,
    ["eof"] = 14,
    ["false"] = 16,
    ["fontchar"] = 20,
    ["hbox"] = 11,
    ["hmode"] = 7,
    ["inner"] = 9,
    ["mmode"] = 8,
    ["none"] = 0,
    ["num"] = 3,
    ["odd"] = 5,
    ["true"] = 15,
    ["vbox"] = 12,
    ["vmode"] = 6,
    ["void"] = 10,
    ["x"] = 13
  },
  ["etex.nodetype"] = {
    [-1] = "none",
    [0] = "char",
    [1] = "hlist",
    [2] = "vlist",
    [3] = "rule",
    [4] = "ins",
    [5] = "mark",
    [6] = "adjust",
    [7] = "ligature",
    [8] = "disc",
    [9] = "whatsit",
    [10] = "math",
    [11] = "glue",
    [12] = "kern",
    [13] = "penalty",
    [14] = "unset",
    [15] = "maths",
    ["adjust"] = 6,
    ["char"] = 0,
    ["disc"] = 8,
    ["glue"] = 11,
    ["hlist"] = 1,
    ["ins"] = 4,
    ["kern"] = 12,
    ["ligature"] = 7,
    ["mark"] = 5,
    ["math"] = 10,
    ["maths"] = 15,
    ["none"] = -1,
    ["penalty"] = 13,
    ["rule"] = 3,
    ["unset"] = 14,
    ["vlist"] = 2,
    ["whatsit"] = 9
  },
  ["etex.interactionmode"] = {
    [0] = "batch",
    [1] = "nonstop",
    [2] = "scroll",
    [3] = "errorstop",
    ["batch"] = 0,
    ["errorstop"] = 3,
    ["nonstop"] = 1,
    ["scroll"] = 2
  },
  ["luatex.pdfliteral.mode"] = {
    [0] = "setorigin",
    [1] = "page",
    [2] = "direct",
    ["direct"] = 2,
    ["page"] = 1,
    ["setorigin"] = 0
  }
}
function get(name)
  local startpos, endpos, category, entry =
      string.find(name, "^(%a[%a%d%.]*)%.(-?[%a%d]+)$")
  if not entry then
    return
  end
  local node = data[category]
  if not node then
    return
  end
  local num = tonumber(entry)
  local value
  if num then
    value = node[num]
    if not value then
      return
    end
  else
    value = node[entry]
    if not value then
      return
    end
    value = "" .. value
  end
  tex.write(value)
end
-- 
--  End of File `magicnum.lua'.