[NTG-context] Using lua to define a macro with one optional parameter in brackets
Taco Hoekwater
taco at elvenkind.com
Wed Jul 8 12:07:22 CEST 2015
> On 08 Jul 2015, at 11:05, Jaroslav Hajtmar <hajtmar at gyza.cz> wrote:
>
> 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.
Simplest solution I know is this:
\startluacode
interfaces.definecommand ('dolastname', {
arguments = { { "option", "string" } },
macro = function (opt_1)
if #opt_1>0 then context(opt_1) else context('nothing') end
end
})
interfaces.definecommand ('lastname', {
macro = function ()
context.dosingleempty()
context.dolastname()
end
})
\stopluacode
Best wishes,
Taco
More information about the ntg-context
mailing list