[NTG-context] Using lua to define a macro with one optional parameter in brackets
Jaroslav Hajtmar
hajtmar at gyza.cz
Wed Jul 8 12:40:17 CEST 2015
Thanks Taco,
your solution helped me ... Based on initial tests, it seems that it
works correctly. I'll know more after thorough testing.
Once again, thank you many times.
Sincerely Jaroslav Hajtmar
Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a):
>> 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