[luatex] reverse node lists

Arno Trautmann Arno.Trautmann at gmx.de
Mon Oct 31 12:50:21 CET 2011


Hi all,

this is again a rather simple question and I am sorry for taking your 
time for this …
In short, I want to reverse all glyph nodes in a line, and/or all lines 
in a paragraph. I tried something like the following (with the idea to 
store all lines in a list, then replace the lines with the list in 
reversed order):

function reverse(head)

newlines = {}
i = 1
   for line in node.traverse_id(node.id"hhead",head) do
     newlines[i] = line
     i = i+1
   end

j = #newlines

   for line in node.traverse_id(node.id"hhead",head) do
     node.insert_before(head,line,newlines[j])
     j = j-1
   end
   return head
end

to be registered in the post_linebreak_callback. But then LuaTeX just 
stops, without errors or something. Using a node.remove in the second 
loop also does not help, and in total, everything I tried did not work 
as suspected. I guess I'm doing something small wrong again, but just 
can't figure out what …

cheers
Arno


More information about the luatex mailing list