[NTG-context] Hooking \stoptext

Procházka Lukáš Ing. - Pontex s. r. o. LPr at pontex.cz
Wed Mar 7 16:57:14 CET 2012


... Yes, that's it! Thanks a lot!

Best regards,

Lukas


On Wed, 07 Mar 2012 16:50:01 +0100, Philipp Gesang <gesang at stud.uni-heidelberg.de> wrote:

> On 2012-03-07 15:28, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
>> Hello,
>>
>> I'd need to to hook \stoptext by Lua - I'd need to write something right before the end of the text.
>>
>> See the simple example:
>>
>> ---- t-Hook.mkiv
>> \startluacode
>>   local stoptext_p = context.stoptext
>>
>>   context.stoptext = function(...)
>>     context("END")
>>     stoptext_p(...)
>>   end
>> \stopluacode
>>
>> \starttext
>>   \input knuth
>> \stoptext % To be hooked by Lua
>> ----
>>
>> This code should write "END" right before the end of the document, but it doesn't.
>
> context.stoptext() just calls “\stoptext”, not the other way
> round. Btw CLD are implemented as metatable so afaik you would
> have to redefine the “__index” attribute.
>
>> How to achieve that?
>
> ········································································
> \startluacode
>   local old_stoptext = commands.stoptext
>
>   commands.stoptext = function(...)
>     context"END"
>     old_stoptext(...)
>   end
> \stopluacode
>
> \starttext
>   \input knuth
> \stoptext % To be hooked by Lua
> ········································································
>
> Cf. file.job.mkvi at line 107.
>
> Hth
> Philipp
>
>
>>
>> - I'd rather Lua to TeX do the job as I need Lua to do more complicated things (the example above is very simplified).
>>
>> TIA.
>>
>> Best regards,
>>
>> Lukas
>>
>>
>> --
>> Ing. Lukáš Procházka [mailto:LPr at pontex.cz]
>> Pontex s. r. o.      [mailto:pontex at pontex.cz] [http://www.pontex.cz]
>> Bezová 1658
>> 147 14 Praha 4
>>
>> Tel: +420 244 062 238
>> Fax: +420 244 461 038
>
>
>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>>
>> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive  : http://foundry.supelec.fr/projects/contextrev/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
>
>


-- 
Ing. Lukáš Procházka [mailto:LPr at pontex.cz]
Pontex s. r. o.      [mailto:pontex at pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038



More information about the ntg-context mailing list