Re: [NTG-context] constructing block content partly with lua
On 2019-02-05 17:21, Hans Hagen wrote: > i'm not sure what you want but thsi might give a clue > ... > \startluacode > buffers.assign("temp","test 2") > structures.blocks.save("foo",nil,nil,"temp") > \stopluacode Ah, thanks, that looks like what I need, or at least part of it, and will keep me busy making more experiments. -Sanjoy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] constructing block content partly with lua
On 2/5/2019 4:28 PM, Sanjoy Mahajan wrote: On 2019-02-05 16:24, Hans Hagen 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] constructing block content partly with lua
On 2019-02-05 16:24, Hans Hagen 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. -Sanjoy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] constructing block content partly with lua
On 2/5/2019 4:01 PM, Sanjoy Mahajan wrote: Dear List, I've been trying to construct part of a block's content programmatically with Lua. Despite many experiments and much rereading of the cld manual (especially chapter 3 on functions), the following attempt fails for reasons that perplex me. Below is the MNWE (Minimal NonWorking Example). It fails with these lines in the log file: structure > sectioning > subject @ level 3 : 0.0.0 -> Answers tex error > tex error on line 1 in file virtual://block.answer.1: ! Undefined control sequence l.1 \oneargTestparameter That is, when the "answer" block is included via \useblocks, somehow the beginning of the answer, which should be "\onearg{Test parameter}", has its curly braces and spaces elided. What characteristic(s) of the Lua interface am I missing? Thank you if you happen to where I've gone wrong. I've also tried steppers without much luck (and, admittedly, without really understanding their use). === testluabeginblock.tex === \defineblock[answer] \hideblocks[answer] \def\onearg#1{{\bf #1}} \def\noarg{{\it fixed argument}} \starttext \startluacode context.beginanswer() context("\\onearg{Test parameter}") does context.onearg("Test parameter") work? \stopluacode This is part of the answer. \endanswer \subject{Answers} \useblocks[answer] \stoptext === end testluabeginblock.tex === -Sanjoy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] constructing block content partly with lua
Dear List, I've been trying to construct part of a block's content programmatically with Lua. Despite many experiments and much rereading of the cld manual (especially chapter 3 on functions), the following attempt fails for reasons that perplex me. Below is the MNWE (Minimal NonWorking Example). It fails with these lines in the log file: structure > sectioning > subject @ level 3 : 0.0.0 -> Answers tex error > tex error on line 1 in file virtual://block.answer.1: ! Undefined control sequence l.1 \oneargTestparameter That is, when the "answer" block is included via \useblocks, somehow the beginning of the answer, which should be "\onearg{Test parameter}", has its curly braces and spaces elided. What characteristic(s) of the Lua interface am I missing? Thank you if you happen to where I've gone wrong. I've also tried steppers without much luck (and, admittedly, without really understanding their use). === testluabeginblock.tex === \defineblock[answer] \hideblocks[answer] \def\onearg#1{{\bf #1}} \def\noarg{{\it fixed argument}} \starttext \startluacode context.beginanswer() context("\\onearg{Test parameter}") \stopluacode This is part of the answer. \endanswer \subject{Answers} \useblocks[answer] \stoptext === end testluabeginblock.tex === -Sanjoy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___