# [Dev-luatex] Recalculating tail of the list in ligaturing callback

Hans Hagen j.hagen at xs4all.nl
Wed Nov 14 14:14:36 CET 2018

```On 11/14/2018 12:47 PM, Esger Renkema wrote:
> Dear list,
>
> Running the following one-liner:
>
> \directlua{callback.register('ligaturing', node.ligaturing)}ffi\bye
>
> results in:
>
> -------------------------------------------
> This is LuaTeX, Version 1.09.0 (TeX Live 2019/dev/Debian)
> restricted system commands enabled.
> **\directlua{callback.register('ligaturing', node.ligaturing)}ffi\bye
> ! error:  (linebreak): invalid list tail, probably missing glue
> !  ==> Fatal error occurred, no output PDF file produced!
> -------------------------------------------
>
> The problem seems to be that, when restoring the original ‘tail of the
> list’ after applying the ligaturing callback (in this case consisting of
> the parfillskip glue), it is appended to the tail of the /original/
> list-to-be-ligatured. The latter, of course, has been lost if the
> paragraph ends in a ligature.

the user of a callback is responsible for returning the right result

you can locate the for your case proper end node and pass that one as
second argument

> According to the manual, the first node of the list passed to the
> callback is guaranteed not to be a glyph_node. Should the same not hold
> for the last one, too? The manual states that it ‘normally’ is a glue,
> but that is clearly not the case here.
contextual ligature building can be influences by glue nodes (i.e.
spaces) so the whole list gets passed