summaryrefslogtreecommitdiff
path: root/tex/context/base/toks-map.lua
blob: 9120c2084e66a09b21fbd875ea97ae672c8fde98 (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
if not modules then modules = { } end modules ['toks-map'] = {
    version   = 1.001,
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- Even more experimental ... this used to be part of toks-ini but as
-- this kind of remapping has not much use it is not loaded in the
-- core. We just keep it here for old times sake.

-- local remapper      = { }  -- namespace
-- collectors.remapper = remapper
--
-- local remapperdata  = { }  -- user mappings
-- remapper.data       = remapperdata
--
-- function remapper.store(tag,class,key)
--     local s = remapperdata[class]
--     if not s then
--         s = { }
--         remapperdata[class] = s
--     end
--     s[key] = collectordata[tag]
--     collectordata[tag] = nil
-- end
--
-- function remapper.convert(tag,toks)
--     local data         = remapperdata[tag]
--     local leftbracket  = utfbyte('[')
--     local rightbracket = utfbyte(']')
--     local skipping     = 0
--     -- todo: math
--     if data then
--         local t, n = { }, 0
--         for s=1,#toks do
--             local tok = toks[s]
--             local one, two = tok[1], tok[2]
--             if one == 11 or one == 12 then
--                 if two == leftbracket then
--                     skipping = skipping + 1
--                     n = n + 1 ; t[n] = tok
--                 elseif two == rightbracket then
--                     skipping = skipping - 1
--                     n = n + 1 ; t[n] = tok
--                 elseif skipping == 0 then
--                     local new = data[two]
--                     if new then
--                         if #new > 1 then
--                             for n=1,#new do
--                                 n = n + 1 ; t[n] = new[n]
--                             end
--                         else
--                             n = n + 1 ; t[n] = new[1]
--                         end
--                     else
--                         n = n + 1 ; t[n] = tok
--                     end
--                 else
--                     n = n + 1 ; t[n] = tok
--                 end
--             else
--                 n = n + 1 ; t[n] = tok
--             end
--         end
--         return t
--     else
--         return toks
--     end
-- end