String is not properly parsed when keys are numbers
paternal opened this issue · comments
Hello,
when I compile the following document:
\documentclass{article}
\begin{document}
\directlua{
local luakeys = require("luakeys")
luakeys.parse([[ A=letter, "2"=quotednumber, 3=number ]], {debug=true})
}
\end{document}
I get:
{
['A'] = 'letter',
['2'] = 'quotednumber',
['number'] = true,
}
We can see that A=letter
and "2"=quotednumber
are correctly parsed, but with 3=number
, I get ['number']=true
, while I expected [3] = 'number'
(or maybe ['3'] = 'number'
).
Is this an expected behavior of luakeys?
Regards,
Louis
Hello!
As you probably know, Lua has no lists or arrays etc. List values are stored under an integer as key in the table. A post process function converts this standalone values into keys with the value true
. This post process function can be disabled using the option naked_as_value=true
. I believe luakeys
works as expected in this case.
\documentclass{article}
\begin{document}
\directlua{
local luakeys = require("luakeys")
luakeys.parse([[ A=letter, "2"=quotednumber, 3=number ]],
{debug=true, naked_as_value=true})
}
\end{document}
gives:
{
['2'] = 'quotednumber',
['A'] = 'letter',
[3] = 'number',
}
Thanks. I am new to Lua, so I did not understand that naked_as_value
was the solution here, but it now works.
Thanks for your quick answers!