# [NTG-context] constructing block content partly with lua

Sanjoy Mahajan sanjoy at olin.edu
Tue Feb 5 16:01:47 CET 2019

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

\def\onearg#1{{\bf #1}}
\def\noarg{{\it fixed argument}}

\starttext

\startluacode
context("\\onearg{Test parameter}")
\stopluacode
This is part of the answer.