How can you pass multiple arguments from a tex command to a lua function, whilst also escaping them
Or how do I modify
(imports)
\usepackage{luacode}
\newcommand{\example}[1]{
\directlua{
function debug(...)
local arr = {...}
for i, v in pairs(arr) do
print(v)
end
end
debug(#1)
}
}
such that
\example{\notDefined, aNilValue, 5}
produces standard output of
\notDefined
aNilValue
5
instead of throwing
- Undefined control sequence (latex error)
- or printing nothing because the variable
aNilValue
is not defined
I've tried using \luastring{\unexpanded{...}}
with \docsvlist
but i keep getting runaway arguments
EDIT
Clearification, all passed arguments should be strings so local arr = {...}
should equal in the example {"\\notDefined", "aNilValue", "5"}
debug("\\notDefined", "aNilValue", "5")
but it seems you want to pass 5 as an integer and aNilValue as an undefined Lua variable?\luastring
andunexpanded
.\luastring
isn't a defined command, you are presumably using an unspecified package that defines it?