[luatex] nodes

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sat Dec 15 23:48:48 CET 2012


Hi all

I do not really understand how node.insert_before works.
In the following example I want to draw a red line before each
new line (just for fun). As can be seen it works only for the
beginning of the paragraph, not for the other lines in a paragraph.
However, if I change it to node.insert_after it works for all
lines. So what is wrong with the
List,w=node.insert_before(START,List,w) ???

Herbert


\directlua{
function markList(List)
  local startLine=true
  local START=List
  while List do
   if List.id == 0 or List.id == 1 then
     markList(List.head)
   end
   texio.write(tostring(List.id.." \string\\n"))
   if List.id==37 and startLine then
    texio.write("new line\string\\n")
    startLine=false
    w = node.new("whatsit","pdf_literal")
    w.data = string.format("q 1 0 0 RG 1 w 0 -0.1 m 0 10 l S Q")
    List,w=node.insert_before(START,List,w)
%   List,w=node.insert_after(START,List,w)
   end
   List=List.next
  end
  return true
end
callback.register("post_linebreak_filter",markList,"markList")}

%\begin{document}
\hsize=4cm\parindent=0pt
Some Text which runs over several lines to see what happens.\par
%
red: line begins\par
green:  word begins\par
blue: line end

\bye


More information about the luatex mailing list