ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* String in Luatex
@ 2007-08-26  8:49 luigi scarso
  2007-08-26 13:58 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: luigi scarso @ 2007-08-26  8:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

The following macro is wrong:
\def\TestC{%
\directlua0{%
\obeyspaces \obeylines
code =[[
class Test(object):
  def __init__(self):
    self.a=[0,3,81,2,-1]
    self.b=self.a[:]
    self.a.sort()

  def get(self):
    return self.a,self.b
]]
}}

! LuaTeX error [string "luas[0]"]:1: unexpected symbol near '\'.
\TestC ...def get(self): return self.a,self.b ]] }


I must preserve spaces and newlines.

Any idea ?
Thanks in advance

--
luigi
----------------------------------------------------------------
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: String in Luatex
  2007-08-26  8:49 String in Luatex luigi scarso
@ 2007-08-26 13:58 ` Hans Hagen
  2007-08-27  2:21   ` luigi scarso
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2007-08-26 13:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

luigi scarso wrote:
> The following macro is wrong:
> \def\TestC{%
> \directlua0{%
> \obeyspaces \obeylines

hm, you want to expand this kin dof stuff inside the directlua?

> code =[[
> class Test(object):
>   def __init__(self):
>     self.a=[0,3,81,2,-1]
>     self.b=self.a[:]
>     self.a.sort()
> 
>   def get(self):
>     return self.a,self.b
> ]]
> }}
> 
> ! LuaTeX error [string "luas[0]"]:1: unexpected symbol near '\'.
> \TestC ...def get(self): return self.a,self.b ]] }
> 
> 
> I must preserve spaces and newlines.
> 
> Any idea ?

just use

\startluacode

\stopluacode

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: String in Luatex
  2007-08-26 13:58 ` Hans Hagen
@ 2007-08-27  2:21   ` luigi scarso
  0 siblings, 0 replies; 3+ messages in thread
From: luigi scarso @ 2007-08-27  2:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 8/26/07, Hans Hagen <pragma@wxs.nl> wrote:
> luigi scarso wrote:
> > The following macro is wrong:
> > \def\TestC{%
> > \directlua0{%
> > \obeyspaces \obeylines
>
> hm, you want to expand this kin dof stuff inside the directlua?
As a last resorse to preserve spaces
> > I must preserve spaces and newlines.
> >
> > Any idea ?
>
> just use
>
> \startluacode
>
> \stopluacode

No, it doesn't work for my needs because it doesn't preserve spaces and newline.
This works, after putting code in testD.lua
\def\TestD#1{%
\directlua0{dofile('testD.lua')}%
}



-- 
luigi
----------------------------------------------------------------
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2007-08-27  2:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-26  8:49 String in Luatex luigi scarso
2007-08-26 13:58 ` Hans Hagen
2007-08-27  2:21   ` luigi scarso

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).