ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Passing TeX parameters to the lua functions
@ 2011-12-05 20:22 Jaroslav Hajtmar
  2011-12-05 20:33 ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Jaroslav Hajtmar @ 2011-12-05 20:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing TeX parameters to the lua functions
  2011-12-05 20:22 Passing TeX parameters to the lua functions Jaroslav Hajtmar
@ 2011-12-05 20:33 ` Wolfgang Schuster
  2011-12-05 21:06   ` Jaroslav Hajtmar
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2011-12-05 20:33 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users


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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing TeX parameters to the lua functions
  2011-12-05 20:33 ` Wolfgang Schuster
@ 2011-12-05 21:06   ` Jaroslav Hajtmar
  2011-12-05 21:08     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Jaroslav Hajtmar @ 2011-12-05 21:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
>    

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing TeX parameters to the lua functions
  2011-12-05 21:06   ` Jaroslav Hajtmar
@ 2011-12-05 21:08     ` Wolfgang Schuster
  2011-12-05 21:19       ` Jaroslav Hajtmar
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2011-12-05 21:08 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users


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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Passing TeX parameters to the lua functions
  2011-12-05 21:08     ` Wolfgang Schuster
@ 2011-12-05 21:19       ` Jaroslav Hajtmar
  0 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Hajtmar @ 2011-12-05 21:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
>    

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-05 21:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-05 20:22 Passing TeX parameters to the lua functions Jaroslav Hajtmar
2011-12-05 20:33 ` Wolfgang Schuster
2011-12-05 21:06   ` Jaroslav Hajtmar
2011-12-05 21:08     ` Wolfgang Schuster
2011-12-05 21:19       ` Jaroslav Hajtmar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).