[lltx] luatexbase.is_in_callback

Arno Trautmann Arno.Trautmann at gmx.de
Thu Jul 21 14:56:23 CEST 2011

Patrick Gundlach wrote:
> Am 21.07.2011 um 14:34 schrieb Arno Trautmann:
>> Patrick Gundlach wrote:
>>> Am 21.07.2011 um 14:11 schrieb Arno Trautmann:
>>>> I'd like to use the post_linebreak_filter to manipulate the node list, but only if a macro appears in that given paragraph.
>>> Can you use attributes there? Then you can test whether certain attributes are in a paragraph and apply your code.
>> Yes, and I do in fact. But I'm not sure how this solves my problem here? Maybe I'll be more precise on what I want to do:
>> I've written a function randomcolor that inserts a color whatsit before (push) and after (pull) every glyph in a paragraph, using the post_linebreak_filter. Now I want to provide a command \textrandomcolor{} that does the same, but only with the text in the argument. For this, I use the same function as above, but set an attribute at the beginning of the argument and unset it at the end, and in the function, I test for this attribute. Fine.
> That's what I wanted to write.
>> However, in a paragraph that does /not/ contain any \textrandomcolor, I don't want the function to loop through all nodes. Let's say, for performance reasons …
> Does it really differ (performance wise)?

After a short test on 300 pages of blindtext, it's about 0.4s, and 
actually below uncertainty …
But I might want to construct some more complex functions, and then it 
may differ measureably. Besides, I just want to have nice code – that's 
what LuaTeX is about, no?
(ok, Patrick is maybe the wrong person for “nice code” ;) )


More information about the lualatex-dev mailing list