Passing TeX parameters to the lua functions
Hello ConTeXist. Sorry for the beginner question, more for Lua(TeX) experts. Can somehow be achieved that the parameter of TeX macro get to luafunction unchanged? In the debug.txt file is the result obtained. Thanx Jaroslav \startluacode debug=io.open("debug.txt","w+") function testfun(param) debug:write(param) -- tex.print(param) end \stopluacode \def\testmac#1{\directlua{testfun('#1')}} \starttext $\frac{x_\alpha+y_\beta}{z_\gamma}$ \testmac{\frac{x_\alpha+y_\beta}{z_\gamma}} \stoptext
Am 05.12.2011 um 21:22 schrieb Jaroslav Hajtmar:
Hello ConTeXist. Sorry for the beginner question, more for Lua(TeX) experts. Can somehow be achieved that the parameter of TeX macro get to luafunction unchanged? In the debug.txt file is the result obtained.
Thanx Jaroslav
\startluacode debug=io.open("debug.txt","w+")
function testfun(param)
Use the thirddata or userdata namespace for for functions.
debug:write(param) -- tex.print(param) end
\stopluacode
\def\testmac#1{\directlua{testfun('#1')}}
\unprotect \def\testmac#1{\ctxlua{testfun(\!!bs\detokenize{#1}\!!es)}} \protect Wolfgang
Thanx Wolfgang. In ConTeXt this solution works well. Exist any similar solution in pure LuaTeX? I need solve one problem in pure LuaTeX. But solutions in Context I will also throw - thanx. Jaroslav Dne 5.12.2011 21:33, Wolfgang Schuster napsal(a):
Am 05.12.2011 um 21:22 schrieb Jaroslav Hajtmar:
Hello ConTeXist. Sorry for the beginner question, more for Lua(TeX) experts. Can somehow be achieved that the parameter of TeX macro get to luafunction unchanged? In the debug.txt file is the result obtained.
Thanx Jaroslav
\startluacode debug=io.open("debug.txt","w+")
function testfun(param)
Use the thirddata or userdata namespace for for functions.
debug:write(param) -- tex.print(param) end
\stopluacode
\def\testmac#1{\directlua{testfun('#1')}}
\unprotect \def\testmac#1{\ctxlua{testfun(\!!bs\detokenize{#1}\!!es)}} \protect
Wolfgang
Great, great, great... It works very well Thanx very much... Jaroslav Dne 5.12.2011 22:08, Wolfgang Schuster napsal(a):
Am 05.12.2011 um 22:06 schrieb Jaroslav Hajtmar:
Thanx Wolfgang. In ConTeXt this solution works well. Exist any similar solution in pure LuaTeX? I need solve one problem in pure LuaTeX.
\def\…#1{\directlua{…([==[\detokenize{#1}]==])}}
Wolfgang
participants (2)
-
Jaroslav Hajtmar
-
Wolfgang Schuster