Herbert Voss <[email protected]> a écrit: > Hi, > I am playing with nodes and callbacks to understand how it works. > > \directlua{ > function checknode(head) > while head do > if head.id==37 then > if head.char==string.byte("c") then > n=node.new(37) > n.char=string.byte("d") > n.font=1 > head=node.insert_after(head,head,n) > end > end > if head.id==0 or head.id==1 then checknode(head.list) end > head=head.next > end > return true > end > callback.register("post_linebreak_filter",checknode,"checknode")}
callback.register takes only two arguments. > abc1 > \bye > > I tried to test "node.insert_after()" instead of using the next and prev > fields. Is it the correct way to use > > head=node.insert_after(head,head,n) > > if I want to insert the new glyph node bwtween existing nodes? More clearly: head = node.insert_after(a, b, c) to insert c after b in the list whose head is a (actually any node in that list). > And am i right, that the prev field from node n is missing, but > doesn't hurt in this case? I know, that I can set it. Actually it IS set (try "print(n.prev)"), and I'm surprised myself, because I thought ``natural'' nodelists (created by TeX) didn't set the prev field of their nodes, but actually they're all set. (I thought that because node.slide() is said to set those prev fields, so I concluded that by default they aren't.) But anyway it wouldn't hurt, at least on the TeX side (I don't know any internal mechanism that needs prev to be set, but I might very well be wrong). Best, Paul
