[luatex] Multi-paragraph insert confuses linebreak filters.

Paul Isambert zappathustra at free.fr
Thu Aug 5 11:38:38 CEST 2010

Hello all,

Here's a document:

\directlua{%
if context == "" then
context = "main"
end
texio.write_nl("The context is " .. context)
end
callback.register("pre_linebreak_filter", what_context)
}%
\long\def\Insert#1{%
\directlua{texio.write_nl("<< Start of insert")}%
\insert\footins{#1}%
\directlua{texio.write_nl("End of insert >>")}%
}

Hello \Insert{world}

Hello \Insert{world\par}
\bye

For each paragraph, it writes the context in which it is typeset to the log. Now
the log looks like this:

<< Start of insert
The context is insert
End of insert >>
The context is main
<< Start of insert
The context is main % !!!
End of insert >>
The context is main

The problem, as you can see, is that the paragraph of the second insert, with
the explicit \par command, "thinks" it is in the main vertical list.

Some observations:
- My changing context = "" into context = "main" is of course immaterial, as is
the \Insert macro - they just (hopefully) make things easier to read.
- Of course, the problem doesn't depend on the type of insert (I've used plain's
\footins here, but the problem occurred in my own footnote inserts, as well as
in any \newinsert).
- \endgraf produces the same result (the contrary would be surprising, but who
knows?), and \vskip too, so the problem seems to stem from explicitly turning to
vertical mode in an insert.
- If the insert contains other paragraphs, they return "insert" as context. So
only the first paragraph is affected.
- The same thing happens with post_linebreak_filter.

I'm using 0.62 rev 3794 - since thanks to the gentle pressure of some people
here and Manuel's precious help I'm now a Subversion- and build-it-yourself
guy...

Sorry if I seem to spend my time hunting bugs instead of contributing to the
march forward... (although those bugs tend to appear when I devise macros which
in the back of my mind would fit in a TUGboat paper about some nice things you
can do with LuaTeX)

Best,
Paul