[NTG-context] constructing block content partly with lua

Hans Hagen j.hagen at xs4all.nl
Tue Feb 5 17:21:50 CET 2019


On 2/5/2019 4:28 PM, Sanjoy Mahajan wrote:
> On 2019-02-05 16:24, Hans Hagen <j.hagen at xs4all.nl> wrote:
> 
>>> \startluacode
>>>     context.beginanswer()
>>>     context("\\onearg{Test parameter}")
>>
>> does
>>
>> context.onearg("Test parameter")
>>
>> work?
> 
> Sorry, I forgot to say that I had tried that version too but also with
> no luck.  Also, either version of onerg works as expected if I delete
> the context.beginanswer() and the \endanswer lines.
the problem is that you effectively use buffers so you have a different 
catcode regime ... i'm not sure what you want but thsi might give a clue

\starttext

\defineblock[foo]

\beginfoo
     test 1
\endfoo

\startluacode
buffers.assign("temp","test 2")
structures.blocks.save("foo",nil,nil,"temp")
\stopluacode

\useblocks[foo]

\stoptext

there are mechanisms for templates for constructing more meaningful 
content than "test 2" (see test suite)

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list