ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Lua in LuaLaTeX is diferent??
@ 2010-06-05 20:19 Jaroslav Hajtmar
  2010-06-05 23:35 ` Jaroslav Hajtmar
  2010-06-06 11:13 ` Hans Hagen
  0 siblings, 2 replies; 10+ messages in thread
From: Jaroslav Hajtmar @ 2010-06-05 20:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,
I did a Lua application for ConTeXt, and now I wanted to adapt it to 
work even LuaLaTeX.
On what needs to be careful? Compiling  by LuaLaTeX specific messages 
appear as if the Lua in LuaLaTeX didnt know some Lua commands (i.e. 
split, find .... ).

On what needs to be careful generaly when programming applications for 
LuaLaTeX?

Thanx Jaroslav
___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-05 20:19 Lua in LuaLaTeX is diferent?? Jaroslav Hajtmar
@ 2010-06-05 23:35 ` Jaroslav Hajtmar
  2010-06-06  2:46   ` Khaled Hosny
  2010-06-06 11:42   ` Hans Hagen
  2010-06-06 11:13 ` Hans Hagen
  1 sibling, 2 replies; 10+ messages in thread
From: Jaroslav Hajtmar @ 2010-06-05 23:35 UTC (permalink / raw)
  To: ntg-context

Hi,

I am sending examples of functions:

The first function is functional in ConTeXt MKIV even LuaLaTeX.

-- Global variables for setup in library (it be used when glob. vars 
Sep, Ld, Rd is not setting in main aplication):
UserCSVSeparator=';'
UserCSVLeftDelimiter=''
UserCSVRightDelimiter=''




function ParseCSVdata(s)
     local Sep = (Sep == nil) and UserCSVSeparator or Sep
     local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
     local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
     if Ld ~= '' or Rd ~= '' then
        local s=string.sub(s, string.find(s, Ld)+1, string.find(s, 
Rd,-1)-1)
     end
     local fieldsep=tostring(Rd..Sep..Ld)
     local result = {}
   local from  = 1
   local sep_from, sep_to = string.find( s, fieldsep, from  )
   while sep_from do
     table.insert( result, string.sub( s, from , sep_from-1 ) )
     from  = sep_to + 1
     sep_from, sep_to = string.find( s, fieldsep, from  )
   end
   table.insert( result, string.sub( s, from  ) )
   return result
end


The second is more universal, but it only works in ConTeXt MKIV.
LuaLaTeX report error:  "attempt to call field 'split' (a nil value) ... ."

function ParseCSVdata(string2parse, separator, leftdelimiter, 
rightdelimiter)
     Sep = (Sep == nil) and UserCSVSeparator or Sep
     Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
     Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
   local separator = (separator == nil) and Sep or separator
     local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter
     local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter
     local result={}
         if leftdelimiter ~= '' and rightdelimiter ~= '' then
             string.gsub(string2parse, 
leftdelimiter.."(.-)"..rightdelimiter, function(a) 
table.insert(result,a) end )
         else
           result=string.split(string2parse,separator)
         end
     return result
end


I would like to benefit from the second function, but I want the 
application was applicable even LuaLaTeX

Thanx Jaroslav




Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a):
> Hi,
> I did a Lua application for ConTeXt, and now I wanted to adapt it to 
> work even LuaLaTeX.
> On what needs to be careful? Compiling  by LuaLaTeX specific messages 
> appear as if the Lua in LuaLaTeX didnt know some Lua commands (i.e. 
> split, find .... ).
>
> On what needs to be careful generaly when programming applications for 
> LuaLaTeX?
>
> Thanx Jaroslav
> ___________________________________________________________________________________ 
>
> 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
> ___________________________________________________________________________________ 
>
>

___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-05 23:35 ` Jaroslav Hajtmar
@ 2010-06-06  2:46   ` Khaled Hosny
  2010-06-06  6:15     ` Jaroslav Hajtmar
  2010-06-06 11:42   ` Hans Hagen
  1 sibling, 1 reply; 10+ messages in thread
From: Khaled Hosny @ 2010-06-06  2:46 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On Sun, Jun 06, 2010 at 01:35:23AM +0200, Jaroslav Hajtmar wrote:
> Hi,
> 
> I am sending examples of functions:
> 
> The first function is functional in ConTeXt MKIV even LuaLaTeX.
> 
> -- Global variables for setup in library (it be used when glob. vars
> Sep, Ld, Rd is not setting in main aplication):
> UserCSVSeparator=';'
> UserCSVLeftDelimiter=''
> UserCSVRightDelimiter=''
> 
> 
> 
> 
> function ParseCSVdata(s)
>     local Sep = (Sep == nil) and UserCSVSeparator or Sep
>     local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>     local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>     if Ld ~= '' or Rd ~= '' then
>        local s=string.sub(s, string.find(s, Ld)+1, string.find(s,
> Rd,-1)-1)
>     end
>     local fieldsep=tostring(Rd..Sep..Ld)
>     local result = {}
>   local from  = 1
>   local sep_from, sep_to = string.find( s, fieldsep, from  )
>   while sep_from do
>     table.insert( result, string.sub( s, from , sep_from-1 ) )
>     from  = sep_to + 1
>     sep_from, sep_to = string.find( s, fieldsep, from  )
>   end
>   table.insert( result, string.sub( s, from  ) )
>   return result
> end
> 
> 
> The second is more universal, but it only works in ConTeXt MKIV.
> LuaLaTeX report error:  "attempt to call field 'split' (a nil value) ... ."
> 
> function ParseCSVdata(string2parse, separator, leftdelimiter,
> rightdelimiter)
>     Sep = (Sep == nil) and UserCSVSeparator or Sep
>     Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>     Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>   local separator = (separator == nil) and Sep or separator
>     local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter
>     local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter
>     local result={}
>         if leftdelimiter ~= '' and rightdelimiter ~= '' then
>             string.gsub(string2parse,
> leftdelimiter.."(.-)"..rightdelimiter, function(a)
> table.insert(result,a) end )
>         else
>           result=string.split(string2parse,separator)
>         end
>     return result
> end
> 
> 
> I would like to benefit from the second function, but I want the
> application was applicable even LuaLaTeX

You need the lualibs package, which imports some of the extended lua
librarires from ConTeXt, since string.split() is not a standad lua
function.

Regards,
 Khaled


> 
> Thanx Jaroslav
> 
> 
> 
> 
> Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a):
> >Hi,
> >I did a Lua application for ConTeXt, and now I wanted to adapt it
> >to work even LuaLaTeX.
> >On what needs to be careful? Compiling  by LuaLaTeX specific
> >messages appear as if the Lua in LuaLaTeX didnt know some Lua
> >commands (i.e. split, find .... ).
> >
> >On what needs to be careful generaly when programming applications
> >for LuaLaTeX?
> >
> >Thanx Jaroslav
> >___________________________________________________________________________________
> >
> >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
> >___________________________________________________________________________________
> >
> >
> 
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-06  2:46   ` Khaled Hosny
@ 2010-06-06  6:15     ` Jaroslav Hajtmar
  2010-06-06  6:34       ` Jaroslav Hajtmar
  2010-06-06 13:00       ` Khaled Hosny
  0 siblings, 2 replies; 10+ messages in thread
From: Jaroslav Hajtmar @ 2010-06-06  6:15 UTC (permalink / raw)
  To: Khaled Hosny; +Cc: mailing list for ConTeXt users

Thanks very much.
It is very unpleasant findings, but, it explains everything.
Can be detected using Lua whether application runs under LuaLaTeX or 
LuaPlain and then load the library?
How can I retrieve LuaLib? Where can I get more information? I did some 
Googling but without success.
Thanx Jaroslav


Dne 6.6.2010 4:46, Khaled Hosny napsal(a):
> On Sun, Jun 06, 2010 at 01:35:23AM +0200, Jaroslav Hajtmar wrote:
>    
>> Hi,
>>
>> I am sending examples of functions:
>>
>> The first function is functional in ConTeXt MKIV even LuaLaTeX.
>>
>> -- Global variables for setup in library (it be used when glob. vars
>> Sep, Ld, Rd is not setting in main aplication):
>> UserCSVSeparator=';'
>> UserCSVLeftDelimiter=''
>> UserCSVRightDelimiter=''
>>
>>
>>
>>
>> function ParseCSVdata(s)
>>      local Sep = (Sep == nil) and UserCSVSeparator or Sep
>>      local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>>      local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>>      if Ld ~= '' or Rd ~= '' then
>>         local s=string.sub(s, string.find(s, Ld)+1, string.find(s,
>> Rd,-1)-1)
>>      end
>>      local fieldsep=tostring(Rd..Sep..Ld)
>>      local result = {}
>>    local from  = 1
>>    local sep_from, sep_to = string.find( s, fieldsep, from  )
>>    while sep_from do
>>      table.insert( result, string.sub( s, from , sep_from-1 ) )
>>      from  = sep_to + 1
>>      sep_from, sep_to = string.find( s, fieldsep, from  )
>>    end
>>    table.insert( result, string.sub( s, from  ) )
>>    return result
>> end
>>
>>
>> The second is more universal, but it only works in ConTeXt MKIV.
>> LuaLaTeX report error:  "attempt to call field 'split' (a nil value) ... ."
>>
>> function ParseCSVdata(string2parse, separator, leftdelimiter,
>> rightdelimiter)
>>      Sep = (Sep == nil) and UserCSVSeparator or Sep
>>      Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>>      Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>>    local separator = (separator == nil) and Sep or separator
>>      local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter
>>      local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter
>>      local result={}
>>          if leftdelimiter ~= '' and rightdelimiter ~= '' then
>>              string.gsub(string2parse,
>> leftdelimiter.."(.-)"..rightdelimiter, function(a)
>> table.insert(result,a) end )
>>          else
>>            result=string.split(string2parse,separator)
>>          end
>>      return result
>> end
>>
>>
>> I would like to benefit from the second function, but I want the
>> application was applicable even LuaLaTeX
>>      
> You need the lualibs package, which imports some of the extended lua
> librarires from ConTeXt, since string.split() is not a standad lua
> function.
>
> Regards,
>   Khaled
>
>
>    
>> Thanx Jaroslav
>>
>>
>>
>>
>> Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a):
>>      
>>> Hi,
>>> I did a Lua application for ConTeXt, and now I wanted to adapt it
>>> to work even LuaLaTeX.
>>> On what needs to be careful? Compiling  by LuaLaTeX specific
>>> messages appear as if the Lua in LuaLaTeX didnt know some Lua
>>> commands (i.e. split, find .... ).
>>>
>>> On what needs to be careful generaly when programming applications
>>> for LuaLaTeX?
>>>
>>> Thanx Jaroslav
>>> ___________________________________________________________________________________
>>>
>>> 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
>>> ___________________________________________________________________________________
>>>
>>>
>>>        
>> ___________________________________________________________________________________
>> 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
>> ___________________________________________________________________________________
>>      
>    

___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-06  6:15     ` Jaroslav Hajtmar
@ 2010-06-06  6:34       ` Jaroslav Hajtmar
  2010-06-06 11:17         ` Hans Hagen
  2010-06-06 13:00       ` Khaled Hosny
  1 sibling, 1 reply; 10+ messages in thread
From: Jaroslav Hajtmar @ 2010-06-06  6:34 UTC (permalink / raw)
  To: hajtmar; +Cc: mailing list for ConTeXt users

Thanks very much.
It is very unpleasant findings, but, it explains everything.
Can be detected using Lua whether application runs under LuaLaTeX or 
LuaPlain and then load the library?
How can I retrieve LuaLib? Where can I get more information? I did some 
Googling but without success.
Thanx Jaroslav

>
>
> Dne 6.6.2010 4:46, Khaled Hosny napsal(a):
>> On Sun, Jun 06, 2010 at 01:35:23AM +0200, Jaroslav Hajtmar wrote:
>>> Hi,
>>>
>>> I am sending examples of functions:
>>>
>>> The first function is functional in ConTeXt MKIV even LuaLaTeX.
>>>
>>> -- Global variables for setup in library (it be used when glob. vars
>>> Sep, Ld, Rd is not setting in main aplication):
>>> UserCSVSeparator=';'
>>> UserCSVLeftDelimiter=''
>>> UserCSVRightDelimiter=''
>>>
>>>
>>>
>>>
>>> function ParseCSVdata(s)
>>>      local Sep = (Sep == nil) and UserCSVSeparator or Sep
>>>      local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>>>      local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>>>      if Ld ~= '' or Rd ~= '' then
>>>         local s=string.sub(s, string.find(s, Ld)+1, string.find(s,
>>> Rd,-1)-1)
>>>      end
>>>      local fieldsep=tostring(Rd..Sep..Ld)
>>>      local result = {}
>>>    local from  = 1
>>>    local sep_from, sep_to = string.find( s, fieldsep, from  )
>>>    while sep_from do
>>>      table.insert( result, string.sub( s, from , sep_from-1 ) )
>>>      from  = sep_to + 1
>>>      sep_from, sep_to = string.find( s, fieldsep, from  )
>>>    end
>>>    table.insert( result, string.sub( s, from  ) )
>>>    return result
>>> end
>>>
>>>
>>> The second is more universal, but it only works in ConTeXt MKIV.
>>> LuaLaTeX report error:  "attempt to call field 'split' (a nil value) 
>>> ... ."
>>>
>>> function ParseCSVdata(string2parse, separator, leftdelimiter,
>>> rightdelimiter)
>>>      Sep = (Sep == nil) and UserCSVSeparator or Sep
>>>      Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
>>>      Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
>>>    local separator = (separator == nil) and Sep or separator
>>>      local leftdelimiter = (leftdelimiter == nil) and Ld or 
>>> leftdelimiter
>>>      local rightdelimiter = (rightdelimiter == nil) and Rd or 
>>> rightdelimiter
>>>      local result={}
>>>          if leftdelimiter ~= '' and rightdelimiter ~= '' then
>>>              string.gsub(string2parse,
>>> leftdelimiter.."(.-)"..rightdelimiter, function(a)
>>> table.insert(result,a) end )
>>>          else
>>>            result=string.split(string2parse,separator)
>>>          end
>>>      return result
>>> end
>>>
>>>
>>> I would like to benefit from the second function, but I want the
>>> application was applicable even LuaLaTeX
>> You need the lualibs package, which imports some of the extended lua
>> librarires from ConTeXt, since string.split() is not a standad lua
>> function.
>>
>> Regards,
>>   Khaled
>>
>>
>>> Thanx Jaroslav
>>>
>>>
>>>
>>>
>>> Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a):
>>>> Hi,
>>>> I did a Lua application for ConTeXt, and now I wanted to adapt it
>>>> to work even LuaLaTeX.
>>>> On what needs to be careful? Compiling  by LuaLaTeX specific
>>>> messages appear as if the Lua in LuaLaTeX didnt know some Lua
>>>> commands (i.e. split, find .... ).
>>>>
>>>> On what needs to be careful generaly when programming applications
>>>> for LuaLaTeX?
>>>>
>>>> Thanx Jaroslav
>>>> ___________________________________________________________________________________ 
>>>>
>>>>
>>>> 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
>>>> ___________________________________________________________________________________ 
>>>>
>>>>
>>>>
>>> ___________________________________________________________________________________ 
>>>
>>> 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
>>> ___________________________________________________________________________________ 
>>>
>

___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-05 20:19 Lua in LuaLaTeX is diferent?? Jaroslav Hajtmar
  2010-06-05 23:35 ` Jaroslav Hajtmar
@ 2010-06-06 11:13 ` Hans Hagen
  2010-06-06 18:24   ` Jaroslav Hajtmar
  1 sibling, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2010-06-06 11:13 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On 5-6-2010 10:19, Jaroslav Hajtmar wrote:
> Hi,
> I did a Lua application for ConTeXt, and now I wanted to adapt it to
> work even LuaLaTeX.
> On what needs to be careful? Compiling by LuaLaTeX specific messages
> appear as if the Lua in LuaLaTeX didnt know some Lua commands (i.e.
> split, find .... ).
>
> On what needs to be careful generaly when programming applications for
> LuaLaTeX?

In context there is quite some lua code that can be used by users for 
their applications. The l-*.lua files can considered to be more general 
libraries and most ofthat is unlikely to change (extended for sure). At 
some point I will make a manual for that. Of course you can always load 
such modules using 'require'.

Using other context lua code outside context is more tricky as it also 
assumes the system to be designed in a certain way. I hope to have much 
if that stable within the next few years. As long as one does not mess 
with the namespaces not much harm can be done.

I'm not following lualatex dev but i know that it uses some of the font 
code. The reason that this code can be shared is that it's sort of 
isolated and specific functionality needed is wrapped up in *-dum.lua 
modules. Probbably some stripping down will happen to prevent clashes 
etc. Here the reference is luatex-plain.tex (and luatex-fonts.tex) in 
the context distribution.

Also, the reverse is also tricky: lualatex speicific code is unlikely to 
work in context.

BTW, Sharing macro code between context and latex is non trivial either 
as both are different systems and developed completely independent.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua in LuaLaTeX is diferent??
  2010-06-06  6:34       ` Jaroslav Hajtmar
@ 2010-06-06 11:17         ` Hans Hagen
  0 siblings, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2010-06-06 11:17 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On 6-6-2010 8:34, Jaroslav Hajtmar wrote:
> Thanks very much.
> It is very unpleasant findings, but, it explains everything.
> Can be detected using Lua whether application runs under LuaLaTeX or
> LuaPlain and then load the library?

something

if not context then
   require "l-string"
end

(I will provide another way too.)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua in LuaLaTeX is diferent??
  2010-06-05 23:35 ` Jaroslav Hajtmar
  2010-06-06  2:46   ` Khaled Hosny
@ 2010-06-06 11:42   ` Hans Hagen
  1 sibling, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2010-06-06 11:42 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On 6-6-2010 1:35, Jaroslav Hajtmar wrote:

> The second is more universal, but it only works in ConTeXt MKIV.
> LuaLaTeX report error: "attempt to call field 'split' (a nil value) ... ."
>
> function ParseCSVdata(string2parse, separator, leftdelimiter,
> rightdelimiter)
> Sep = (Sep == nil) and UserCSVSeparator or Sep
> Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
> Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
> local separator = (separator == nil) and Sep or separator
> local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter
> local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter
> local result={}
> if leftdelimiter ~= '' and rightdelimiter ~= '' then
> string.gsub(string2parse, leftdelimiter.."(.-)"..rightdelimiter,
> function(a) table.insert(result,a) end )
> else
> result=string.split(string2parse,separator)
> end
> return result
> end

You probably mean something ...

UserCSVSeparator      = ';'
UserCSVLeftDelimiter  = ''
UserCSVRightDelimiter = ''

function ParseCSVdata(string2parse, separator, leftdelimiter, 
rightdelimiter)
     leftdelimiter  = leftdelimiter  or Ld or UserCSVLeftDelimiter  or ""
     rightdelimiter = rightdelimiter or Rd or UserCSVRightDelimiter or ""
     if leftdelimiter ~= '' and rightdelimiter ~= '' then
         local result = { }
         local pattern = string.esc(leftdelimiter) .. "(.-)" .. 
string.esc(rightdelimiter)
         for s in string.gmatch(string2parse,pattern) do
             table.insert(result,s)
         end
         return result
     else
         return string.split(string2parse,separator or Sep or 
UserCSVSeparator or ";")
     end
end

but anyhow, this might (name) clash at some point i guess, for instance 
because of using globals like Ld

In order to be more or less compatible with the context module and third 
party code setup, in context you need to do:

thirddata = thirddata or { }

thirddata.cvs = {
     separator      = ';',
     leftdelimiter  = '',
     rightdelimiter = '',
}

function 
thirddata.cvs.parse(string2parse,separator,leftdelimiter,rightdelimiter)
     leftdelimiter  = leftdelimiter  or thirddata.leftdelimiter  or ""
     rightdelimiter = rightdelimiter or thirddata.rightdelimiter or ""
     if leftdelimiter ~= "" and rightdelimiter ~= "" then
         local result = { }
         local pattern = string.esc(leftdelimiter) .. "(.-)" .. 
string.esc(rightdelimiter)
         for s in string.gmatch(string2parse,pattern) do
             table.insert(result,s)
         end
         return result
     else
         return string.split(string2parse,separator or 
thirddata.separator or ";")
     end
end

-- print(table.serialize(thirddata.cvs.parse("11,ss,cc",",")))
-- print(table.serialize(thirddata.cvs.parse("[11] [ss] [cc]","","[","]")))


but i have no clue how this is used so there might be better approaches

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua in LuaLaTeX is diferent??
  2010-06-06  6:15     ` Jaroslav Hajtmar
  2010-06-06  6:34       ` Jaroslav Hajtmar
@ 2010-06-06 13:00       ` Khaled Hosny
  1 sibling, 0 replies; 10+ messages in thread
From: Khaled Hosny @ 2010-06-06 13:00 UTC (permalink / raw)
  To: Jaroslav Hajtmar; +Cc: mailing list for ConTeXt users

Lualibs is available on CTAN, it is a repackages l-*.lua ConTeXt
modules.

On Sun, Jun 06, 2010 at 08:15:23AM +0200, Jaroslav Hajtmar wrote:
> Thanks very much.
> It is very unpleasant findings, but, it explains everything.
> Can be detected using Lua whether application runs under LuaLaTeX or
> LuaPlain and then load the library?
> How can I retrieve LuaLib? Where can I get more information? I did
> some Googling but without success.
> Thanx Jaroslav
> 
> 
> Dne 6.6.2010 4:46, Khaled Hosny napsal(a):
> >On Sun, Jun 06, 2010 at 01:35:23AM +0200, Jaroslav Hajtmar wrote:
> >>Hi,
> >>
> >>I am sending examples of functions:
> >>
> >>The first function is functional in ConTeXt MKIV even LuaLaTeX.
> >>
> >>-- Global variables for setup in library (it be used when glob. vars
> >>Sep, Ld, Rd is not setting in main aplication):
> >>UserCSVSeparator=';'
> >>UserCSVLeftDelimiter=''
> >>UserCSVRightDelimiter=''
> >>
> >>
> >>
> >>
> >>function ParseCSVdata(s)
> >>     local Sep = (Sep == nil) and UserCSVSeparator or Sep
> >>     local Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
> >>     local Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
> >>     if Ld ~= '' or Rd ~= '' then
> >>        local s=string.sub(s, string.find(s, Ld)+1, string.find(s,
> >>Rd,-1)-1)
> >>     end
> >>     local fieldsep=tostring(Rd..Sep..Ld)
> >>     local result = {}
> >>   local from  = 1
> >>   local sep_from, sep_to = string.find( s, fieldsep, from  )
> >>   while sep_from do
> >>     table.insert( result, string.sub( s, from , sep_from-1 ) )
> >>     from  = sep_to + 1
> >>     sep_from, sep_to = string.find( s, fieldsep, from  )
> >>   end
> >>   table.insert( result, string.sub( s, from  ) )
> >>   return result
> >>end
> >>
> >>
> >>The second is more universal, but it only works in ConTeXt MKIV.
> >>LuaLaTeX report error:  "attempt to call field 'split' (a nil value) ... ."
> >>
> >>function ParseCSVdata(string2parse, separator, leftdelimiter,
> >>rightdelimiter)
> >>     Sep = (Sep == nil) and UserCSVSeparator or Sep
> >>     Ld = (Ld == nil) and UserCSVLeftDelimiter or Ld
> >>     Rd = (Rd == nil) and UserCSVRightDelimiter or Rd
> >>   local separator = (separator == nil) and Sep or separator
> >>     local leftdelimiter = (leftdelimiter == nil) and Ld or leftdelimiter
> >>     local rightdelimiter = (rightdelimiter == nil) and Rd or rightdelimiter
> >>     local result={}
> >>         if leftdelimiter ~= '' and rightdelimiter ~= '' then
> >>             string.gsub(string2parse,
> >>leftdelimiter.."(.-)"..rightdelimiter, function(a)
> >>table.insert(result,a) end )
> >>         else
> >>           result=string.split(string2parse,separator)
> >>         end
> >>     return result
> >>end
> >>
> >>
> >>I would like to benefit from the second function, but I want the
> >>application was applicable even LuaLaTeX
> >You need the lualibs package, which imports some of the extended lua
> >librarires from ConTeXt, since string.split() is not a standad lua
> >function.
> >
> >Regards,
> >  Khaled
> >
> >
> >>Thanx Jaroslav
> >>
> >>
> >>
> >>
> >>Dne 5.6.2010 22:19, Jaroslav Hajtmar napsal(a):
> >>>Hi,
> >>>I did a Lua application for ConTeXt, and now I wanted to adapt it
> >>>to work even LuaLaTeX.
> >>>On what needs to be careful? Compiling  by LuaLaTeX specific
> >>>messages appear as if the Lua in LuaLaTeX didnt know some Lua
> >>>commands (i.e. split, find .... ).
> >>>
> >>>On what needs to be careful generaly when programming applications
> >>>for LuaLaTeX?
> >>>
> >>>Thanx Jaroslav
> >>>___________________________________________________________________________________
> >>>
> >>>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
> >>>___________________________________________________________________________________
> >>>
> >>>
> >>___________________________________________________________________________________
> >>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
> >>___________________________________________________________________________________

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer
___________________________________________________________________________________
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] 10+ messages in thread

* Re: Lua in LuaLaTeX is diferent??
  2010-06-06 11:13 ` Hans Hagen
@ 2010-06-06 18:24   ` Jaroslav Hajtmar
  0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Hajtmar @ 2010-06-06 18:24 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users

Hi, Hans
Thanks a lot for advice and inspiration. With your contribution of my 
applications running under LuaPlain well below LuaLaTeX :-).
Application process CSV tables and allows you to easily print the data 
in CSV tables (mailmerges, cards, etc). Now I do not know whether 
somebody else will be interested in my application. ConTeXt uses the few 
people around me. Therefore, I try to modify it to LuaTeXu and LuaPlain. 
I think I'm just a lousy programmer, and therefore do not anticipate 
that the application could become a larger library, you could use 
others.  Thanks again for your time and valuable advice
Have a nice day
Jaroslav




Dne 6.6.2010 13:13, Hans Hagen napsal(a):
> On 5-6-2010 10:19, Jaroslav Hajtmar wrote:
>> Hi,
>> I did a Lua application for ConTeXt, and now I wanted to adapt it to
>> work even LuaLaTeX.
>> On what needs to be careful? Compiling by LuaLaTeX specific messages
>> appear as if the Lua in LuaLaTeX didnt know some Lua commands (i.e.
>> split, find .... ).
>>
>> On what needs to be careful generaly when programming applications for
>> LuaLaTeX?
>
> In context there is quite some lua code that can be used by users for 
> their applications. The l-*.lua files can considered to be more 
> general libraries and most ofthat is unlikely to change (extended for 
> sure). At some point I will make a manual for that. Of course you can 
> always load such modules using 'require'.
>
> Using other context lua code outside context is more tricky as it also 
> assumes the system to be designed in a certain way. I hope to have 
> much if that stable within the next few years. As long as one does not 
> mess with the namespaces not much harm can be done.
>
> I'm not following lualatex dev but i know that it uses some of the 
> font code. The reason that this code can be shared is that it's sort 
> of isolated and specific functionality needed is wrapped up in 
> *-dum.lua modules. Probbably some stripping down will happen to 
> prevent clashes etc. Here the reference is luatex-plain.tex (and 
> luatex-fonts.tex) in the context distribution.
>
> Also, the reverse is also tricky: lualatex speicific code is unlikely 
> to work in context.
>
> BTW, Sharing macro code between context and latex is non trivial 
> either as both are different systems and developed completely 
> independent.
>
> Hans
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2010-06-06 18:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-05 20:19 Lua in LuaLaTeX is diferent?? Jaroslav Hajtmar
2010-06-05 23:35 ` Jaroslav Hajtmar
2010-06-06  2:46   ` Khaled Hosny
2010-06-06  6:15     ` Jaroslav Hajtmar
2010-06-06  6:34       ` Jaroslav Hajtmar
2010-06-06 11:17         ` Hans Hagen
2010-06-06 13:00       ` Khaled Hosny
2010-06-06 11:42   ` Hans Hagen
2010-06-06 11:13 ` Hans Hagen
2010-06-06 18:24   ` 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).