[luatex] Strategy for creating a nodelist

Hans Hagen pragma at wxs.nl
Tue Mar 9 20:02:59 CET 2010


On 9-3-2010 19:35, Patrick Gundlach wrote:
> Hello,
>
> I wonder what is the best strategy for creating a (double linked) node list.
>
> Let's say I want to create a list containing the three gylph_nodes T, E, and X. One way would be
>
> ----------
> t = node.new(glyph_node)
> t.font = 1
> t.char = string.byte("T")
>
> e = node.new(glyph_node)
> e.font = 1
> e.char = string.byte("E")
>
> x = node.new(glyph_node)
> x.font = 1
> x.char = string.byte("X")
>
> t.next = e
> e.next = x
>
> node.slide(t)
> ----------
>
> Looking at the documentation, node.insert_after() looks very much like what I want to use. But I don't quite understand its use when the head node is nil.
>
> For node.insert_after() I need a valid "current" node and a valid "new" node. But that would mean that I already have a head in form of the "current" node, right?

i normally just use something

t = node.new(glyph_node)
t.font = 1
t.char = string.byte("T")

e = node.new(glyph_node)
e.font = 1
e.char = string.byte("E")

e.prev = t
t.next = e

x = node.new(glyph_node)
x.font = 1
x.char = string.byte("X")

x.prev = t
t.next = e

no need to slide

in most cases you can forget about the prev as luatex itself will slide 
when needed (in order to be sure of a proper list)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list