| 1 |
local accent_t = node.id'accent' |
| 2 |
local math_char_t = node.id'math_char' |
| 3 |
local noad_t = node.id'noad' |
| 4 |
local sub_mlist_t = node.id'sub_mlist' |
| 5 |
|
| 6 |
local whatsit_id = luatexbase.new_whatsit'not' |
| 7 |
not_whatsit = whatsit_id -- Needed for dots module |
| 8 |
|
| 9 |
local func = luatexbase.new_luafunction'not' |
| 10 |
token.set_lua("not", func, 'protected') |
| 11 |
|
| 12 |
lua.get_functions_table()[func] = function(id) |
| 13 |
check_math(id) |
| 14 |
write_whatsit_wrapped(whatsit_id, 100, 0, 2) |
| 15 |
end |
| 16 |
|
| 17 |
local not_lookup = { |
| 18 |
-- sed -nre '/^([0-9A-F]+);[^;]*;[^;]*;[^;]*;[^;]*;([0-9A-F]+) 0338;.*/{s// [0x\2] = 0x\1,/;p}' < $(kpsewhich UnicodeData.txt) |
| 19 |
[0x2190] = 0x219A, |
| 20 |
[0x2192] = 0x219B, |
| 21 |
[0x2194] = 0x21AE, |
| 22 |
[0x21D0] = 0x21CD, |
| 23 |
[0x21D4] = 0x21CE, |
| 24 |
[0x21D2] = 0x21CF, |
| 25 |
[0x2203] = 0x2204, |
| 26 |
[0x2208] = 0x2209, |
| 27 |
[0x220B] = 0x220C, |
| 28 |
[0x2223] = 0x2224, |
| 29 |
[0x2225] = 0x2226, |
| 30 |
[0x223C] = 0x2241, |
| 31 |
[0x2243] = 0x2244, |
| 32 |
[0x2245] = 0x2247, |
| 33 |
[0x2248] = 0x2249, |
| 34 |
[0x003D] = 0x2260, |
| 35 |
[0x2261] = 0x2262, |
| 36 |
[0x224D] = 0x226D, |
| 37 |
[0x003C] = 0x226E, |
| 38 |
[0x003E] = 0x226F, |
| 39 |
[0x2264] = 0x2270, |
| 40 |
[0x2265] = 0x2271, |
| 41 |
[0x2272] = 0x2274, |
| 42 |
[0x2273] = 0x2275, |
| 43 |
[0x2276] = 0x2278, |
| 44 |
[0x2277] = 0x2279, |
| 45 |
[0x227A] = 0x2280, |
| 46 |
[0x227B] = 0x2281, |
| 47 |
[0x2282] = 0x2284, |
| 48 |
[0x2283] = 0x2285, |
| 49 |
[0x2286] = 0x2288, |
| 50 |
[0x2287] = 0x2289, |
| 51 |
[0x22A2] = 0x22AC, |
| 52 |
[0x22A8] = 0x22AD, |
| 53 |
[0x22A9] = 0x22AE, |
| 54 |
[0x22AB] = 0x22AF, |
| 55 |
[0x227C] = 0x22E0, |
| 56 |
[0x227D] = 0x22E1, |
| 57 |
[0x2291] = 0x22E2, |
| 58 |
[0x2292] = 0x22E3, |
| 59 |
[0x22B2] = 0x22EA, |
| 60 |
[0x22B3] = 0x22EB, |
| 61 |
[0x22B4] = 0x22EC, |
| 62 |
[0x22B5] = 0x22ED, |
| 63 |
[0x2ADD] = 0x2ADC, |
| 64 |
} |
| 65 |
|
| 66 |
math_whatsit_processors[whatsit_id] = function(_style, n, parent_head, parent) |
| 67 |
assert(parent) |
| 68 |
local after = parent.next |
| 69 |
if not after then |
| 70 |
node.free(n) |
| 71 |
parent.nucleus = node.new(math_char_t) |
| 72 |
parent.nucleus.fam, parent.nucleus.char = main_fam, 0x0338 |
| 73 |
return parent_head, parent |
| 74 |
end |
| 75 |
if after.id == noad_t then |
| 76 |
local nucleus = after.nucleus |
| 77 |
if nucleus and nucleus.id == math_char_t and nucleus.fam == main_fam then |
| 78 |
local mapped = not_lookup[nucleus.char] |
| 79 |
if mapped then |
| 80 |
nucleus.char = mapped |
| 81 |
parent_head = node.remove(parent_head, parent) |
| 82 |
node.free(parent) |
| 83 |
return parent_head, nil, after |
| 84 |
end |
| 85 |
end |
| 86 |
|
| 87 |
local acc = node.new(accent_t) |
| 88 |
acc.overlay_accent = node.new(math_char_t) |
| 89 |
acc.overlay_accent.fam, acc.overlay_accent.char = main_fam, 0x0338 |
| 90 |
acc.sub, acc.sup, after.sub, after.sup = after.sub, after.sup, nil, nil |
| 91 |
acc.nucleus = nucleus |
| 92 |
|
| 93 |
nucleus = node.new(sub_mlist_t) |
| 94 |
nucleus.head = acc |
| 95 |
after.nucleus = nucleus |
| 96 |
|
| 97 |
parent_head = node.remove(parent_head, parent) |
| 98 |
node.free(parent) |
| 99 |
return parent_head, nil, after |
| 100 |
end |
| 101 |
|
| 102 |
local acc = node.new(accent_t) |
| 103 |
acc.overlay_accent = node.new(math_char_t) |
| 104 |
acc.overlay_accent.fam, acc.overlay_accent.char = main_fam, 0x0338 |
| 105 |
acc.sub, acc.sup, after.sub, after.sup = after.sub, after.sup, nil, nil |
| 106 |
local nucleus = node.new(sub_mlist_t) |
| 107 |
nucleus.head = after |
| 108 |
acc.nucleus = nucleus |
| 109 |
|
| 110 |
node.insert_after(parent_head, after, acc) |
| 111 |
parent_head = node.remove(parent_head, after) |
| 112 |
parent_head = node.remove(parent_head, parent) |
| 113 |
after.prev, after.next = nil, nil |
| 114 |
node.free(parent) |
| 115 |
|
| 116 |
return parent_head, nil, acc |
| 117 |
end |