> On 13 Dec 2023, at 17:13, Gerion Entrup <gerion.ent...@flump.de> wrote: > > Is there a simple way to define a new command/environment and handle > the keyword arguments in Lua? For example defining a frontend command > like this:
I don't have the answer to your other questions but I do have an example for this one. It's not mine - I'm fairly sure it came from this list but I can't find who that was any more. \startluacode userdata = userdata or { } function userdata.mycommand(keywords, keyvals, str) keyword_options = utilities.parsers.settings_to_array(keywords) named_values = utilities.parsers.settings_to_hash(keyvals) context('First option = ' .. keyword_options[1]) context('\\par') context('Color chosen = ' .. named_values['color']) context('\\par') context('Curly braces = ' .. str) context('\\par') end \stopluacode \def\mycommand[#1][#2]#3{\ctxlua{ userdata.mycommand('#1', '#2', [==[#3]==])}} \starttext \mycommand[top, inmargin, now][color=green, roof=gabled]{Anne of Green Gables?} \stoptext — Bruce Horrocks Hampshire, UK ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________