[luatex] node.traverse

Paul Isambert zappathustra at free.fr
Thu Nov 29 10:47:31 CET 2012


Selon Herbert Voss <Herbert.Voss at fu-berlin.de>:

> Hi all,
>
> am I right that I cannot use node.traverse_id for node _trees_
> like the following one?
>
> \directlua{function checknode(head)
> for t in node.traverse(head) do
>   if t.id==0 or t.id==1 then checknode(t.list) end
>   if t.id==37 then
>    if t.char>96 and t.char<122 then t.char=t.char-32 end
>   end
> end
> return true
> end
> callback.register("post_linebreak_filter",checknode)}
>
> abc2112\par And so on \dots %% converting into uppercase
>
> \bye
>
> traverse and traverse_id work only on lists, right?

I'm not sure I understand the point, but indeed traverse(_id) browses the nodes
of a list; if one of those nodes is a v/hlist, then you have to call the
function recursively on its head (it isn't done automatically, if that's what
you're asking).

> And next question: should one use t.head instead of t.list.
> I read that the name list changes to head, but I can't find
> the documentation where I read it.

You should use "head", because "list" is more or less deprecated, but for the
moment they're equivalent (I *think* "list" will disappear in v.0.80).

Best,
Paul


More information about the luatex mailing list