![](https://secure.gravatar.com/avatar/e0f8d84b235b67d60a3c7fd0e326db8d.jpg?s=120&d=mm&r=g)
On 13 Dec 2023, at 17:13, Gerion Entrup
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