[NTG-context] Using lua to define a macro with one optional parameter in brackets
Jaroslav Hajtmar
hajtmar at gyza.cz
Wed Jul 8 11:05:07 CEST 2015
Hello ConTeXist.
Within the one very complex problem I need to solve the following case.
I want using lua code to define a macro with one optional parameter in
brackets. I tried it using commands context.setgvalue, or find something
on the wiki
(http://wiki.contextgarden.net/System_Macros/Definitions_and_Assignments),
but each time I broke a tooth on it.
Can you, please, someone advise how something can be it done? Suffice
some reference to solve a similar problem.
Thanks Jaroslav Hajtmar
Here is my minimal example:
\starttext
\def\lastname{\dosingleempty\dolastname}
\def\dolastname[#1]{\iffirstargument #1\else nothing\fi}
\lastname
\lastname[Smith]
% Not working
% \ctxlua{
% context([[\def\firstname{\dosingleempty\dofirstname}]])
% context([[\def\dofirstname[#1]{\iffirstargument #1\else {nothing}\fi}]])
% }
%
% \firstname
%
% \firstname['Peter']
\stoptext
More information about the ntg-context
mailing list