[luatex] Behavior of node lists.

Paul Isambert zappathustra at free.fr
Mon Jul 4 09:06:50 CEST 2011

Hello all,

Problem 1:

local done
for n in node.traverse(tex.box[0].head) do
   texio.write_nl("Considering " .. string.char(n.char))
   if not done then
     local next = n.next
     done = true
     tex.box[0].head = node.remove(tex.box[0].head, n)
     tex.box[0].head = node.remove(tex.box[0].head, next)

\box0 \bye

When you consider "0", you remove both "0" and "1", so you'd expect the 
loop to end there; but no, "1" is considered too (even though the box is 
really empty). The strange things is that if you do not remove "0", then 
"1" isn't considered; as if node.traverse is a bit lost when you remove 
both the current node and the one it's supposed to scan next. (As far as 
I can see, this doesn't hinge on "0" being the head of the list.) Is 
this a bug, or have I misunderstood something?

Problem 2: -- A question, rather.
The manual says you're in charge of ensuring that in 
"node.insert_after(H, N, x)", N is in the list denoted by H. The thing 
is, H doesn't seem to matter at all, unless it's nil:


local n = node.copy(tex.box[0].head)
node.insert_after(tex.box[0].head, tex.box[1].head, n)
% Works too:
% node.insert_after(tex.nest[tex.nest.ptr].head, tex.box[1].head, n)


So what's the need to denote the list where the insertion occurs if it 
is ignored? In other words, couldn't node.insert_after and associates 
work with only two arguments?


More information about the luatex mailing list