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 -----------------------------------------------------------------