diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-24 13:11:46 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-09-24 13:11:46 +0200 |
commit | 236690a6367b25187d37013e1e7fc196c5c44eb8 (patch) | |
tree | a1c9520899dc817b2cf492750c10a1990331c273 /tex/context/base/mkiv/node-ser.lua | |
parent | 9858ddd23d54c56b2ce9e1f5580190d3210d18ed (diff) | |
download | context-236690a6367b25187d37013e1e7fc196c5c44eb8.tar.gz |
2016-09-24 12:45:00
Diffstat (limited to 'tex/context/base/mkiv/node-ser.lua')
-rw-r--r-- | tex/context/base/mkiv/node-ser.lua | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/node-ser.lua b/tex/context/base/mkiv/node-ser.lua index b00268828..847db7a15 100644 --- a/tex/context/base/mkiv/node-ser.lua +++ b/tex/context/base/mkiv/node-ser.lua @@ -26,6 +26,7 @@ local nodecodes = nodes.nodecodes local subtcodes = nodes.codes local noadcodes = nodes.noadcodes local getfields = nodes.fields +local nodekeys = nodes.keys local tonode = nodes.tonode @@ -105,7 +106,7 @@ nodes.ignorablefields = ignore local function astable(n,sparse) -- not yet ok, might get obsolete anyway n = tonode(n) - local f, t = getfields(n), { } + local f = getfields(n) for i=1,#f do local v = f[i] local d = n[v] @@ -258,3 +259,40 @@ function nodes.print(head,n) head = head.next end end + +-- quick hack, nicer is to have a proper expand per node type +-- already prepared + +local function apply(n,action) + while n do + action(n) + local id = n.id + if id == hlist_code or id == vlist_code then + apply(n.list,action) + end + n = n.next + end +end + +nodes.apply = apply + +local nuts = nodes.nuts +local getid = nuts.getid +local getlist = nuts.getlist +local getnext = nuts.getnext + +local function apply(n,action) + while n do + action(n) + local id = getid(n) + if id == hlist_code or id == vlist_code then + local list = getlist(n,action) + if list then + apply(list,action) + end + end + n = getnext(n) + end +end + +nuts.apply = apply |