1if not modules then modules = { } end modules ['math-ren'] = {
2 version = 1.001,
3 comment = "companion to math-ren.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
9local next = next
10local gsub = string.gsub
11
12local settings_to_array = utilities.parsers.settings_to_array
13local allocate = storage.allocate
14
15local renderings = { }
16mathematics.renderings = renderings
17
18local mappings = allocate()
19renderings.mappings = mappings
20
21local numbers = allocate()
22renderings.numbers = numbers
23
24local sets = allocate()
25renderings.sets = sets
26
27mappings["blackboard-to-bold"] = {
28 [0x1D538] = 0x1D400, [0x1D539] = 0x1D401, [0x02102] = 0x1D402, [0x1D53B] = 0x1D403, [0x1D53C] = 0x1D404,
29 [0x1D53D] = 0x1D405, [0x1D53E] = 0x1D406, [0x0210D] = 0x1D407, [0x1D540] = 0x1D408, [0x1D541] = 0x1D409,
30 [0x1D542] = 0x1D40A, [0x1D543] = 0x1D40B, [0x1D544] = 0x1D40C, [0x02115] = 0x1D40D, [0x1D546] = 0x1D40E,
31 [0x02119] = 0x1D40F, [0x0211A] = 0x1D410, [0x0211D] = 0x1D411, [0x1D54A] = 0x1D412, [0x1D54B] = 0x1D413,
32 [0x1D54C] = 0x1D414, [0x1D54D] = 0x1D415, [0x1D54E] = 0x1D416, [0x1D54F] = 0x1D417, [0x1D550] = 0x1D418,
33 [0x02124] = 0x1D419,
34}
35
36mappings["mikaels-favourites"] = {
37 [0x211D] = 0x1D411,
38 [0x211A] = 0x1D410,
39 [0x2124] = 0x1D419,
40 [0x2115] = 0x1D40D,
41}
42
43local function renderset(list)
44 local tag = gsub(list," ","")
45 local n = sets[tag]
46 if not n then
47 local list = settings_to_array(tag)
48 local mapping = { }
49 for i=1,#list do
50 local m = mappings[list[i]]
51 if m then
52 for k, v in next, m do
53 mapping[k] = v
54 end
55 end
56 end
57 if next(mapping) then
58 n = #numbers + 1
59 numbers[n] = mapping
60 else
61 n = attributes.unsetvalue
62 end
63 sets[tag] = n
64 end
65 return n
66end
67
68mathematics.renderset = renderset
69
70interfaces.implement {
71 name = "mathrenderset",
72 actions = { renderset, context },
73 arguments = "string",
74}
75 |