summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-aux.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-aux.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-aux.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-aux.lua b/Master/texmf-dist/tex/context/base/node-aux.lua
index 0b44f77248d..43624adfd3a 100644
--- a/Master/texmf-dist/tex/context/base/node-aux.lua
+++ b/Master/texmf-dist/tex/context/base/node-aux.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['node-aux'] = {
license = "see context related readme files"
}
+-- todo: n1 .. n2 : __concat metatable
+
local type, tostring = type, tostring
local nodes, node = nodes, node
@@ -37,6 +39,8 @@ local slide_nodes = node.slide
local insert_node_after = node.insert_after
local isnode = node.is_node
+local current_font = font.current()
+
local texbox = tex.box
function nodes.repackhlist(list,...)
@@ -308,6 +312,8 @@ local function link(head,tail,list,currentfont,currentattr)
tail = n
end
end
+ else
+ -- permitting nil is convenient
end
end
return head, tail
@@ -317,3 +323,39 @@ function nodes.link(...)
local currentfont = font.current
return link(nil,nil,{...},currentfont,currentattr)
end
+
+local function locate(start,wantedid,wantedsubtype)
+ for n in traverse_nodes(start) do
+ local id = n.id
+ if id == wantedid then
+ if not wantedsubtype or n.subtype == wantedsubtype then
+ return n
+ end
+ elseif id == hlist_code or id == vlist_code then
+ local found = locate(n.list,wantedid,wantedsubtype)
+ if found then
+ return found
+ end
+ end
+ end
+end
+
+nodes.locate = locate
+
+function nodes.concat(list) -- no slide !
+ local head, tail
+ for i=1,#list do
+ local li = list[i]
+ if not li then
+ -- skip
+ elseif head then
+ tail.next = li
+ li.prev = tail
+ tail = li
+ else
+ head = li
+ tail = li
+ end
+ end
+ return head, tail
+end