Re: [NTG-context] issue in Lua syntax formatting

2022-05-31 Thread Max Chernoff via ntg-context
the formatting of Lua multi-line strings messes up the source structure, 
in the following MWE, the "one" is displayed after "[[":


\starttext

\startLUA
words = [[
   one
   two
   three
]]
\stopLUA

\stoptext


I can reproduce this. As a workaround, you can insert a non-breaking 
space (U+00A0) immediately after the "[[":


\starttext

\startLUA
words = [[
one
two
three
]]
\stopLUA

\stoptext

(You can't see the NBSP, but it's there)

You can also use the Scite syntax highlighting:

\usemodule[scite]

\starttext

\startLUA
words = [[
one
two
three
]]
\stopLUA

\stoptext

It produces different (but usually better) output than the default 
highlighter. This module is installed by default with ConTeXt LMTX.


There's also the Vim module:

\usemodule[vim]
\definevimtyping[LUA][syntax=lua]

\starttext

\startLUA
words = [[
one
two
three
]]
\stopLUA

\stoptext

You would need to install this module manually though.

-- Max

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] issue in Lua syntax formatting

2022-05-30 Thread Henning Hraban Ramm via ntg-context

Hi,
the formatting of Lua multi-line strings messes up the source structure, 
in the following MWE, the "one" is displayed after "[[":


\starttext

\startLUA
words = [[
  one
  two
  three
]]
\stopLUA

\stoptext

(Denis recognized that in his MAPS/CGJ article on ligature handling.)

Hraban
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] MKIV - LMTX difference: stripping of leading white space in verbatim text

2020-09-03 Thread Christoph Reller
On Thu, Sep 3, 2020 at 5:53 AM Wolfgang Schuster <
wolfgang.schuster.li...@gmail.com> wrote:

> Christoph Reller schrieb am 03.09.2020 um 05:29:
> > Dear List,
> >
> > I am using ConTeXt LMTX 2018.05.19 21:46. Consider the following MWE:
> >
> > \starttext
> > \startLUA
> >  whatever
> > \stopLUA
> > \stoptext
> >
> > In contrast to ConTeXt MKIV, the leading four spaces in front of
> > "whatever" are not removed when processing the verbatim text:
> >
> > MKIV output:
> > whatever
> >
> > LMTX output:
> >  whatever
> >
> > Is there a way to get the old MKIV behavior back?
>
> \setuptyping[LUA][strip=yes]


Thank you, 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] MKIV - LMTX difference: stripping of leading white space in verbatim text

2020-09-02 Thread Wolfgang Schuster

Christoph Reller schrieb am 03.09.2020 um 05:29:

Dear List,

I am using ConTeXt LMTX 2018.05.19 21:46. Consider the following MWE:

\starttext
\startLUA
     whatever
\stopLUA
\stoptext

In contrast to ConTeXt MKIV, the leading four spaces in front of 
"whatever" are not removed when processing the verbatim text:


MKIV output:
whatever

LMTX output:
     whatever

Is there a way to get the old MKIV behavior back?


\setuptyping[LUA][strip=yes]

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] MKIV - LMTX difference: stripping of leading white space in verbatim text

2020-09-02 Thread Christoph Reller
Dear List,

I am using ConTeXt LMTX 2018.05.19 21:46. Consider the following MWE:

\starttext
\startLUA
whatever
\stopLUA
\stoptext

In contrast to ConTeXt MKIV, the leading four spaces in front of "whatever"
are not removed when processing the verbatim text:

MKIV output:
whatever

LMTX output:
whatever

Is there a way to get the old MKIV behavior back?

Cheers,

Christoph
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] conditional for undefined references

2020-03-29 Thread Wolfgang Schuster

Pablo Rodriguez schrieb am 29.03.2020 um 13:53:

Dear list,

consider the following sample:

 \setuppapersize[A8]
 \starttext
 \ConTeXt:

 \in[seac]

 Is it defined?:
 \doifelse{\in[seac]}{??}{undefined}{defined}

 \Lua:

 \ctxlua{context([[{\in[seac]}]])}

 Is it defined?:
 \startlua
 if [[{\in[seac]}]] == "??" then
 context("undefined")
   else
 context("defined")
 end
 \stoplua
 \stoptext


Is there a way to deal with undefined references?

I mean, I need a conditional to handle undefined references.

Why do I have undefined references in my documents? Well, I have almost
90 (Markdown) documents that I need to compile as single documents and
also as one document. When compiling as single documents, there are a
few references to other documents. This is the reason why they are
undefined.

Any chance to be able to catch a "??" output (or \dummyreference) from
"\in[reference]"?

Many thanks for your help,


ConTeXt gives you a message about missing references in the log-file but 
there is no simple way to show the in the PDF which is a step backwards 
because in MkII it was able to get a small message in the margins about 
unknown references.


What you can do is to use the \doifelsereferencefound command to check 
if the requested reference exists before you get the page number etc.


\starttext

Take a look at
\doifelsereferencefound{unknown:1}
  {\at{page}[unknown:1]}
  {\dummyreference\inright[style=\ttxx]{Missing reference}}.

This line ha a reference.\pagereference[unknown:2]

Take a look at
\doifelsereferencefound{unknown:2}
  {\at{page}[unknown:2]}
  {\dummyreference\inright[style=\ttxx]{Missing reference}}.

\stoptext

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] conditional for undefined references

2020-03-29 Thread Pablo Rodriguez
Dear list,

consider the following sample:

\setuppapersize[A8]
\starttext
\ConTeXt:

\in[seac]

Is it defined?:
\doifelse{\in[seac]}{??}{undefined}{defined}

\Lua:

\ctxlua{context([[{\in[seac]}]])}

Is it defined?:
\startlua
if [[{\in[seac]}]] == "??" then
context("undefined")
  else
context("defined")
end
\stoplua
\stoptext


Is there a way to deal with undefined references?

I mean, I need a conditional to handle undefined references.

Why do I have undefined references in my documents? Well, I have almost
90 (Markdown) documents that I need to compile as single documents and
also as one document. When compiling as single documents, there are a
few references to other documents. This is the reason why they are
undefined.

Any chance to be able to catch a "??" output (or \dummyreference) from
"\in[reference]"?

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] passing variables/data between context and lua

2019-10-05 Thread Rudolf Bahr
> A solution which uses only existing commands in the document.
> 
> \startsetups [martin]
>     \startlua
> local points = tonumber(\getvariable{martin}{question}) or 0 ;
>   points = points * 92 ;
> local answer = 42 ;
> context.setvariable("martin","points",points) ;
> context.setvariable("martin","answer",answer) ;
> \stoplua
> \stopsetups
> 
> \setvariable{martin}{set}{\directsetup{martin}}
> 
> \starttext
> 
> \setvariables [martin] [question=44]
> 
> Points: \getvariable{martin}{points}
> 
> The answer is \getvariable{martin}{answer}.
> 
> \stoptext



Hello Wolfgang,

what exactly does the command
"\setvariable{martin}{set}{\directsetup{martin}}"?

I don't understand it. Has it something to do with "Command/datasetvariable"?
Especially what does "\directsetup"?

Rudolf
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] passing variables/data between context and lua

2019-09-29 Thread Martin Althoff
Thanks for the quick answers. Both suggestions work for me. 

@Massi Thanks for the pointer into the cld-mkiv.pdf 

@Wolfgang: I have to admit that I don't completely comprehend your solution, 
though it
works. Searching around for the commands you use, I came across an older 
posting you
answered too:

https://mailman.ntg.nl/pipermail/ntg-context/2012/064326.html

That helps too. However I can find little documentation on the \setvariable/s 
commands.
I'll play around with the solution to understand it better. 




> \defineexpandable\question{44}

> A solution which uses only existing commands in the document.
> 
> \startsetups [martin]
>  \startlua
>  local points = tonumber(\getvariable{martin}{question}) or 0 ;
>points = points * 92 ;
>  local answer = 42 ;
>  context.setvariable("martin","points",points) ;
>  context.setvariable("martin","answer",answer) ;
>  \stoplua
> \stopsetups
> 
> \setvariable{martin}{set}{\directsetup{martin}}
> 
> \starttext
> 
> \setvariables [martin] [question=44]
> 
> Points: \getvariable{martin}{points}
> 
> The answer is \getvariable{martin}{answer}.
> 
> \stoptext
> 
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] passing variables/data between context and lua

2019-09-27 Thread Wolfgang Schuster

Martin Althoff schrieb am 27.09.2019 um 06:59:

Hi, I am trying to pass variables/data between context and lua. Lua would be 
used for
calculations on data coming from context.

Unfortunately I can't figure out what to do. The code below doesn't work, but 
is there to
illustrate my idea.

Any help would be much appreciated. Thanks, Martin


\define\question{44}

\defineexpandable\question{44}

\starttext

\startluacode
local points = \question * 92
-- do some calculations with points and return to to context
answer=42
\stopluacode

% lots of Text in between
The answer is \answer

\stoptext

A solution which uses only existing commands in the document.

\startsetups [martin]
    \startlua
    local points = tonumber(\getvariable{martin}{question}) or 0 ;
  points = points * 92 ;
    local answer = 42 ;
    context.setvariable("martin","points",points) ;
    context.setvariable("martin","answer",answer) ;
    \stoplua
\stopsetups

\setvariable{martin}{set}{\directsetup{martin}}

\starttext

\setvariables [martin] [question=44]

Points: \getvariable{martin}{points}

The answer is \getvariable{martin}{answer}.

\stoptext

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Fwd: [garden] debug getinfo error

2019-07-10 Thread Hans Hagen


context --debug 



Begin forwarded message:

*From: *husu...@t-online.de <mailto:husu...@t-online.de>
*Subject: **[garden] debug getinfo error*
*Date: *10 July 2019 at 11:52:55 CEST
*To: *garden...@contextgarden.net <mailto:garden...@contextgarden.net>


There is a lua error after "debug.getinfo()". Why?

Thanks for help
G.Lauber

-
mtx-context | run 1: luatex 
--fmt="/opt/context/beta-2018.09.01/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en" 
--jobname="texweb" 
--lua="/opt/context/beta-2018.09.01/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui" 
--c:currentrun=1 --c:fulljobname="./texweb.tex" 
--c:input="./texweb.tex" --c:kindofrun=1 --c:maxnofruns=9 
--c:texmfbinpath="/opt/context/beta-2018.09.01/tex/texmf-linux-64/bin" 
"cont-yes.mkiv"


This is LuaTeX, Version 1.10.1 (TeX Live 2019)
system commands enabled.
open source > level 1, order 1, name 
'/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv'

system  >
system  > ConTeXt  ver: 2019.07.04 12:29 MKIV beta  fmt: 
2019.7.10  int: english/english

system  >
system  > 'cont-new.mkiv' loaded
open source > level 2, order 2, name 
'/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'

system  > beware: some patches loaded from cont-new.mkiv
close source    > level 2, order 2, name 
'/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system  > files > jobname 'texweb', input './texweb', result 
'texweb'

fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > level 2, order 3, name '/tmp/uhd8RE/texweb.tex'
fonts   > preloading latin modern fonts (second stage)
fonts   > 'fallback modern-designsize rm 12pt' is loaded

lua error   > lua error on line 6 in file /tmp/uhd8RE/texweb.tex:

[ctxlua]:1: attempt to call a nil value (field 'getinfo')

1 % generated by live script
2 \setupexternalfigures[location={local,global,default}]
3 \starttext
4 \startlua
5 debug.getinfo(2)
6 >>  \stoplua
7 \stoptext
8

mtx-context | fatal error: return code: 256




Taco Hoekwater
Elvenkind BV





___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___




--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Fwd: [garden] debug getinfo error

2019-07-10 Thread Taco Hoekwater


> Begin forwarded message:
> 
> From: husu...@t-online.de
> Subject: [garden] debug getinfo error
> Date: 10 July 2019 at 11:52:55 CEST
> To: garden...@contextgarden.net
> 
> 
> There is a lua error after "debug.getinfo()". Why?
> 
> Thanks for help
> G.Lauber
> 
> -
> mtx-context | run 1: luatex 
> --fmt="/opt/context/beta-2018.09.01/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en"
>  --jobname="texweb" 
> --lua="/opt/context/beta-2018.09.01/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui"
>  --c:currentrun=1 --c:fulljobname="./texweb.tex" --c:input="./texweb.tex" 
> --c:kindofrun=1 --c:maxnofruns=9 
> --c:texmfbinpath="/opt/context/beta-2018.09.01/tex/texmf-linux-64/bin" 
> "cont-yes.mkiv"
> 
> This is LuaTeX, Version 1.10.1 (TeX Live 2019) 
> system commands enabled.
> open source > level 1, order 1, name 
> '/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv'
> system  > 
> system  > ConTeXt  ver: 2019.07.04 12:29 MKIV beta  fmt: 2019.7.10  
> int: english/english
> system  > 
> system  > 'cont-new.mkiv' loaded
> open source > level 2, order 2, name 
> '/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
> system  > beware: some patches loaded from cont-new.mkiv
> close source> level 2, order 2, name 
> '/opt/context/beta-2018.09.01/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
> system  > files > jobname 'texweb', input './texweb', result 'texweb'
> fonts   > latin modern fonts are not preloaded
> languages   > language 'en' is active
> open source > level 2, order 3, name '/tmp/uhd8RE/texweb.tex'
> fonts   > preloading latin modern fonts (second stage)
> fonts   > 'fallback modern-designsize rm 12pt' is loaded
> 
> lua error   > lua error on line 6 in file /tmp/uhd8RE/texweb.tex:
> 
> [ctxlua]:1: attempt to call a nil value (field 'getinfo')
> 
> 1 % generated by live script
> 2 \setupexternalfigures[location={local,global,default}]
> 3 \starttext
> 4 \startlua
> 5 debug.getinfo(2)
> 6 >>  \stoplua
> 7 \stoptext
> 8 
> 
> mtx-context | fatal error: return code: 256
> 
> 

Taco Hoekwater
Elvenkind BV




___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Use of context in lua

2018-08-15 Thread Henri Menke



On 15/08/18 17:46, Jan U. Hasecke wrote:

On 14.08.2018 16:58, Pablo Rodriguez wrote:

I rewrote your sample as (xtables are the only tables I know in ConTeXt):

 \starttext
 \startlua
 context.startxtable()
 context.startxrow()
  context.startxcell()
   context("Note 1")
  context.stopxcell()
  context.startxcell()
   context("Note 2")
  context.stopxcell()
 context.stopxrow()
 context.startxrow()
  context.startxcell()
   context("Note 3")
  context.stopxcell()
  context.startxcell()
   context("Note 4")
  context.stopxcell()
 context.stopxrow()
 context.stopxtable()
 \stoplua
 \stoptext


Seeing this example I wonder if there is already an example taking a
csv-file and creating a table based on its content. I guess building
blocks are readfile, loops and setting the stop sign (; oder ,).


It already exists:
- Database module
  http://wiki.contextgarden.net/M-database
- handlecsv module

https://modules.contextgarden.net/cgi-bin/module.cgi/ruid=55907888/action=view/id=86



As I know a bit of Python, at least, I might be able to search for the
building blocks in the doku. ;-)

juh
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] Use of context in lua (was: date calculated with currentdate plus n days)

2018-08-14 Thread Jan U. Hasecke
On 14.08.2018 16:58, Pablo Rodriguez wrote:
> I rewrote your sample as (xtables are the only tables I know in ConTeXt):
> 
> \starttext
>     \startlua
> context.startxtable()
> context.startxrow()
>  context.startxcell()
>   context("Note 1")
>  context.stopxcell()
>  context.startxcell()
>   context("Note 2")
>  context.stopxcell()
> context.stopxrow()
> context.startxrow()
>  context.startxcell()
>   context("Note 3")
>  context.stopxcell()
>  context.startxcell()
>   context("Note 4")
>  context.stopxcell()
> context.stopxrow()
> context.stopxtable()
> \stoplua
> \stoptext

Seeing this example I wonder if there is already an example taking a
csv-file and creating a table based on its content. I guess building
blocks are readfile, loops and setting the stop sign (; oder ,).

As I know a bit of Python, at least, I might be able to search for the
building blocks in the doku. ;-)

juh
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] date calculated with currentdate plus n days

2018-08-14 Thread Pablo Rodriguez
On 08/14/2018 09:24 AM, Henri Menke wrote:
> On 14/08/18 17:29, Pablo Rodriguez wrote:
>> [...]
>> Where are those context.* Lua commands documented?
>>
>> I want to generate an xtable using Lua code, but I don’t know where to read.
> 
> They aren't documented because they are just the context commands.  You 
> can read more about how it works in 
> http://www.pragma-ade.nl/general/manuals/cld-mkiv.pdf

Many thanks for your reply, Henri.

I remember paging through the manual, it’s included in the distribution.

I rewrote your sample as (xtables are the only tables I know in ConTeXt):

\starttext
\startlua
context.startxtable()
context.startxrow()
 context.startxcell()
  context("Note 1")
 context.stopxcell()
 context.startxcell()
  context("Note 2")
 context.stopxcell()
context.stopxrow()
context.startxrow()
 context.startxcell()
  context("Note 3")
 context.stopxcell()
 context.startxcell()
  context("Note 4")
 context.stopxcell()
context.stopxrow()
context.stopxtable()
\stoplua
\stoptext

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] integer displayed as .0 float in Lua-5.3

2018-08-11 Thread Pablo Rodriguez
On 08/09/2018 10:25 PM, Hans Hagen wrote:
> In addition to what others already explained, you should not depend on 
> features that are implementation dependent or might disappear.

Many thanks for your detailed explanation, Hans.

I had no idea that the automatic conversion from string to number where
so dependent on the Lua version.

> That said 
> ...
> 
> \startTEXpage[offset=1em]
> \ctxlua{context([[\lastpage]])}.
> \stopTEXpage
> 
> Why do you convert \lastpage to a string using [[\lastpage]] which will 
> use the string to number conversion?

Well, I must confess that this is a new knowledge to me.

I thought that "[[ ]]" was the form to escape what I think it is the
escape character in Lua.

How I came to that assumption? Probably because I tried to add a raw
command to \ctxlua or inside a \startlua...\stoplua.

> You can just do:
> 
> \startTEXpage[offset=1em]
> \ctxlua{context(\lastpage + 1)}.
> \stopTEXpage

From this sample, I understand that "\" doesn’t need to be escaped
inside context(), does it?

> or if you really want to [[ ]]
> 
> \startTEXpage[offset=1em]
> \the\numexpr\ctxlua{context([[lastpage]] + 1)}\relax .
> \stopTEXpage
> 
> endless possibities here.

I don’t need "[[ ]]", I only thought I needed them.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] SHA512 for LuaTeX-5.2

2018-07-22 Thread Pablo Rodriguez
Dear list,

I have the following sample (adapted from
https://stackoverflow.com/q/50442185):

✂️
\starttext
\startlua
--
-- UTILITY FUNCTIONS
--
-- transform a string of bytes in a string of hexadecimal digits
local function str2hexa (s)
local h = string.gsub(s, ".", function(c)
return string.format("%02x", string.byte(c))
end)
return h
end

-- transforms number 'l' into a big-endian sequence of 'n' bytes
--(coded as a string)
local function num2string(l, n)
local s = ""
for i = 1, n do
--most significant byte of l
local remainder = l % 256
s = string.char(remainder) .. s
--remove from l the bits we have already transformed
l = (l-remainder) / 256
end
return s
end

-- transform the big-endian sequence of eight bytes starting at
-- index 'i' in 's' into a number
local function s264num (s, i)
local n = 0
for i = i, i + 7 do
n = n*256 + string.byte(s, i)
end
return n
end

--
-- MAIN SECTION
--

-- FIRST STEP: INITIALIZE HASH VALUES
--(second 32 bits of the fractional parts of the square roots of the
first 9th through 16th primes 23..53)

local HH = {}

local function initH512(H)
H = {0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b,
0xa54ff53a5f1d36f1, 0x510e527fade682d1, 0x9b05688c2b3e6c1f,
0x1f83d9abfb41bd6b, 0x5be0cd19137e2179}
return H
end

-- SECOND STEP: INITIALIZE ROUND CONSTANTS
--(first 80 bits of the fractional parts of the cube roots of the first
80 primes 2..409)

local k = {
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f,
0xe9b5dba58189dbbc, 0x3956c25bf348b538,
0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,
0xd807aa98a3030242, 0x12835b0145706fbe,
0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f,
0x80deb1fe3b1696b1, 0x9bdc06a725c71235,
0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3,
0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4,
0x76f988da831153b5, 0x983e5152ee66dfab,
0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,
0xc6e00bf33da88fc2, 0xd5a79147930aa725,
0x06ca6351e003826f, 0x142929670a0e6e70, 0x27b70a8546d22ffc,
0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed,
0x53380d139d95b3df, 0x650a73548baf63de, 0x766a0abb3c77b2a8,
0x81c2c92e47edaee6, 0x92722c851482353b,
0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791,
0xc76c51a30654be30, 0xd192e819d6ef5218,
0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,
0x19a4c116b8d2d0c8, 0x1e376c085141ab53,
0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x391c0cb3c5c95a63,
0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373,
0x682e6ff3d6b2b8a3, 0x748f82ee5defb2fc, 0x78a5636f43172f60,
0x84c87814a1f0ab72, 0x8cc702081a6439ec,
0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915,
0xc67178f2e372532b, 0xca273eceea26619c,
0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,
0x06f067aa72176fba, 0x0a637dc5a2c898a6,
0x113f9804bef90dae, 0x1b710b35131c471b, 0x28db77f523047d84,
0x32caab7b40c72493, 0x3c9ebe0a15c9bebc,
0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a,
0x5fcb6fab3ad6faec, 0x6c44198c4a475817
}

-- THIRD STEP: PRE-PROCESSING (padding)

local function preprocess(toProcess, len)
--append a single '1' bit
--append K '0' bits, where K is the minimum number >= 0 such that L
+ 1 + K = 896mod1024
local extra = 128 - (len + 9) % 128
len = num2string(8 * len, 8)
toProcess = toProcess .. "\\128" .. string.rep("\\0", extra) .. len
assert(#toProcess % 128 == 0)
return toProcess
end

local function rrotate(rot, n)
return (rot >> n) | ((rot << 64 - n))
end

local function digestblock(msg, i, H)
local w = {}
for j = 1, 16 do w[j] = s264num(msg, i + (j - 1)*4) end
for j = 17, 80 do
local v = w[j - 15]
local s0 = rrotate(v, 1) ~ rrotate(v, 8) ~ (v >> 7)
v = w[j - 2]
w[j] = w[j - 16] + s0 + w[j - 7] + ((rrotate(v, 19) ~ rrotate(v,
61)) ~ (v >> 6))
end

local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6],
H[7], H[8]
for i = 1, 80 do
a, b, c, d, e, f, g, h = a , b , c , d , e , f , g , h
local s0 = rrotate(a, 28) ~ (rrotate(a, 34) ~ rrotate(a, 39))
local maj = ((a & b) ~ (a & c)) ~ (b & c)
local t2 = s0 + maj
local s1 = rrotate(e, 14) ~ (rrotate(e, 18) ~ rrotate(e, 41))
local ch = (e & f) ~ (~e & g)
local t1 = h + s1 + ch + k[i] + w[i]
h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
end

H[1] = (H[1] + a)
H[2] = (H[2] + b)
H[3] = (H[3] + c)
H[4] = (H[4] + d)
H[5] = (H[5] + e)
H[6] = (H[6] + f)
H[7] = (H[7] + g)
H[8] = (H[8] + h)
end

local function finalresult512 (H)
-- Produce the final hash value:
retu

Re: [NTG-context] issue with string.collapsespaces()

2018-02-12 Thread Hans Hagen

On 2/12/2018 5:00 PM, Pablo Rodriguez wrote:

Dear list,

I have the following sample:

 \starttext
 \startlua
 a = "a bc de"
 context(string.collapsespaces(a))
 \stoplua
 \stoptext

Sorry for the stupid question, but isn’t the collapsespaces function
intended to remove spaces?

What am I missing here?

that it collapses multiple spaces into one

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] issue with string.collapsespaces()

2018-02-12 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\starttext
\startlua
a = "a bc de"
context(string.collapsespaces(a))
\stoplua
\stoptext

Sorry for the stupid question, but isn’t the collapsespaces function
intended to remove spaces?

What am I missing here?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] type and typing comments for TeX and Lua

2017-12-26 Thread SteamedFish
You can try vim module.

It supports all the formats that vim is able to support and it is a builtin 
module.




\usemodule[t-vim]

\definevimtyping [TEX] [syntax=context]
\definevimtyping [XML] [syntax=xml]
\definevimtyping [LUA] [syntax=lua]

\starttext
\startTEXpage[offset=2em]

a \TEX\ inline comment: \inlineTEX{ag%befe}

\Lua\ inline comment: \inlineLUA{agb --efe}

\startTEX
This is text. % a comment, not \comment
\stopTEX

\startXML
This is text.
\stopXML

\startLUA
if code=="code" then --this is a comment
\stopLUA
\stopTEXpage
\stoptext



> On 22 Dec 2017, at 4:16 AM, Pablo Rodriguez <oi...@gmx.es> wrote:
> 
> On 12/21/2017 05:04 PM, Christoph Reller wrote:
>> Dear Pablo,
>> 
>> At least for XML you could use my module highlight-xml:
>> 
>> \usemodule[highlight-xml]
>> \definetype[xml][option=xml]
>> [...]
>> Note that even partial XML is highlighted correctly.
> Dear Christoph,
> 
> many thanks for your reply.
> 
> Your module is really great fine. It supports both \setuptype and
> \setuptyping options.
> 
> It is really a pity that it lacks TeX, since I’m focused on ConTeXt yet
> (after all, it would be a Spanish introduction to ConTeXt ;-)). XML will
> come later.
> 
> I’m afraid that XML comments are colored the same way with your module
> and with standard ConTeXt.
> 
> Comment marks in are colored as standard tags, I’m afraid. I mean,
> "" are colored in blue as "".
> 
> To show a comment as a whole, setting up both comment text and marks in
> a single and unique color is required.
> 
> This is why I thought that SnippetCommentMark and SnippetCommentText
> would be a fine way to typeset full comments.
> 
> Sorry for insisting. It isn’t perfectionism. My friends and family
> members aren’t computer scientists. I have to explain what a comment is
> from the very beginning. If colors are misleading, they are lost.
> 
> This is why I have to solve this before resuming text composition.
> 
> It would be great that you also offered a highlight-tex (with
> SnippetCommentText and SnippetCommentMark). Or to ease the module
> loading, it would be useful to have a context-highlight (or similar name).
> 
> If your implementation could be latter added (if Hans agrees) to the
> ConTeXt core.
> 
> Many thanks for your help,
> 
> Pablo
> -- 
> http://www.ousia.tk
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] type and typing comments for TeX and Lua

2017-12-21 Thread Pablo Rodriguez
On 12/20/2017 10:18 PM, Hans Hagen wrote:
> On 12/20/2017 8:45 PM, Pablo Rodriguez wrote:
>> [...]
>> Would it be possible that there are two SnippetComments for all lexers:
>> SnippetCommentMark and SnippetCommentText?
> > very low priority ... there is some logic behind these that i don't want
> to break

Then I will have to wait for that implementation. Sorry for not being
able to provide the patch myself.

scite is great for coloring, but it lacks the options from \setuptype
and \setuptyping. I don’t need escapes, but many of the other options.

I need both complete comment coloring (otherwise it is really hard for
newbies to see what a comment may be) and \setuptyping (and \setuptype)
options.

BTW, I’m afraid there is a bug with multiline comments in Lua. The first
line break is removed in multiline:

%~ \usemodule[scite] % to check the bug
\starttext
\startTEXpage[offset=2em]
\startLUA
--[[
multiline comment
]]--

---[[
multiline comment
]]---
\stopLUA
\stopTEXpage
\stoptext

Many thanks for your help again,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] type and typing comments for TeX and Lua

2017-12-21 Thread Christoph Reller
On Tue, Mon, 18 Dec 2017 23:50:09 +0100, Pablo Rodriguez <oi...@gmx.es> wrote:
> I have the following sample:
>
> \definetype[context][option=tex]
> \definetype[lua][option=lua]
> \starttext
> \startTEXpage[offset=2em]
>
> a \TEX\ inline comment: \context{ag%befe}
>
> \Lua\ inline comment: \lua{agb --efe}
>
> \startTEX
> This is text. % a comment, not \comment
> \stopTEX
>
> \startXML
> This is text.
> \stopXML
>
> \startLUA
> if code=="code" then --this is a comment
> \stopLUA
> \stopTEXpage
> \stoptext
>
> Would it be possible that all comments in type and typing (at least, for
> Lua, XML and TeX) would have the same formatting for the whole comment
> contents, including the comment signs?

Dear Pablo,

At least for XML you could use my module highlight-xml:

\usemodule[highlight-xml]
\definetype[xml][option=xml]
\starttext
\startTEXpage[offset=2em]
  \xml{attr="value"}\crlf
  \xml{This is text.}
  \startXML
This is text.
  \stopXML
\stopTEXpage
\stoptext

Note that even partial XML is highlighted correctly.

Cheers,

Christoph
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] type and typing comments for TeX and Lua

2017-12-20 Thread Hans Hagen

On 12/18/2017 11:50 PM, Pablo Rodriguez wrote:

Hans,

sorry for insisting, but I really need this.

I have the following sample:

 \definetype[context][option=tex]
 \definetype[lua][option=lua]
 \starttext
 \startTEXpage[offset=2em]

 a \TEX\ inline comment: \context{ag%befe}

 \Lua\ inline comment: \lua{agb --efe}

 \startTEX
 This is text. % a comment, not \comment
 \stopTEX

 \startXML
 This is text.
 \stopXML

 \startLUA
 if code=="code" then --this is a comment
 \stopLUA
 \stopTEXpage
 \stoptext

Would it be possible that all comments in type and typing (at least, for
Lua, XML and TeX) would have the same formatting for the whole comment
contents, including the comment signs?

Sorry, but with the current output, it is hard to see (for total
newbies) what is part of the comment and what not. And the text editor
will display something different.


It depends on the lexer ...

% \usemodule[scite] % use editor logic

% DIffers per lexer:

\definestartstop
[XmlSnippetComment]
[color=,
 style=]


I’m afraid that the scite module isn’t an option for me.

Then you need to configure the highligheters yourself

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] type and typing comments for TeX and Lua

2017-12-19 Thread Aditya Mahajan

On Mon, 18 Dec 2017, Pablo Rodriguez wrote:


   \definetype[context][option=tex]
   \definetype[lua][option=lua]
   \starttext
   \startTEXpage[offset=2em]

   a \TEX\ inline comment: \context{ag%befe}

   \Lua\ inline comment: \lua{agb --efe}

   \startTEX
   This is text. % a comment, not \comment
   \stopTEX

   \startXML
   This is text.
   \stopXML

   \startLUA
   if code=="code" then --this is a comment
   \stopLUA
   \stopTEXpage
   \stoptext

Would it be possible that all comments in type and typing (at least, for
Lua, XML and TeX) would have the same formatting for the whole comment
contents, including the comment signs?

Sorry, but with the current output, it is hard to see (for total
newbies) what is part of the comment and what not. And the text editor
will display something different.

I’m afraid that the scite module isn’t an option for me.


t-vim parses this correctly, but IIRC, you don't want to use the vim 
module either, right?


Aditya___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] type and typing comments for TeX and Lua

2017-12-18 Thread Pablo Rodriguez
Hans,

sorry for insisting, but I really need this.

I have the following sample:

\definetype[context][option=tex]
\definetype[lua][option=lua]
\starttext
\startTEXpage[offset=2em]

a \TEX\ inline comment: \context{ag%befe}

\Lua\ inline comment: \lua{agb --efe}

\startTEX
This is text. % a comment, not \comment
\stopTEX

\startXML
This is text.
\stopXML

\startLUA
if code=="code" then --this is a comment
\stopLUA
\stopTEXpage
\stoptext

Would it be possible that all comments in type and typing (at least, for
Lua, XML and TeX) would have the same formatting for the whole comment
contents, including the comment signs?

Sorry, but with the current output, it is hard to see (for total
newbies) what is part of the comment and what not. And the text editor
will display something different.

I’m afraid that the scite module isn’t an option for me.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] three issues with \setuptyping

2017-10-21 Thread Pablo Rodriguez
Hans,

[I have reported this before the meeting, but it was wiser to wait after
the meeting was over.]

I have the following sample:

%~ \usemodule[scite]
\starttext
\startTEXpage[offset=2em]
\startTEX
This is text. % a comment, not \comment
\stopTEX

\startXML
This is text.
\stopXML

\startLUA
if code=="code" then --this is a comment

--[[
this is a

multiline comment
--]]

not part of the comment

---[[
this isn’t a

multiline comment
---]]
\stopLUA
\stopTEXpage
\stoptext

I’m experiencing three issues:

1. Both TeX and Lua comments only mark (in bold and darkyellow) the
comment character, but not the comment content.

2. Multiline Lua comments remove the first line break after the comment
begins. Brackets are also affected from first issue.

3. XML comment characters are marked as standard tags.

Using the scite module removes the three issues (XML comment chars are
in a different color, both from comment content and from any other
element). But the scite module doesn’t allow the options \setuptyping has.

Would it be possible that whole comments may be formatted in the same
color and font (TeX, Lua and XML)?

Could you fix the issue with removed line break in multiline comments?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] (again) issues with typing

2017-08-16 Thread Pablo Rodriguez
Dear list,

sorry for insisting, but I need to solve this.

I have to explain to newcomers (in my Spanish introduction to ConTeXt)
what comments are and multiple lines don’t affect the final PDF document.

I have the following sample:

\setuptyping[lines=yes]
\starttext
\startTEXpage[offset=1em]
\startTEX
This is text. % and this is a comment
\stopTEX

\startXML
This is text.
\stopXML

\startLUA
if code=="code" then --this is a comment

--[[
this is a

multiline comment
--]]

---[[
this isn’t a


multiline comment
--]]
\stopLUA
\stopTEXpage
\stoptext

I have three questions:

1. How do I enable that multiple blank lines are displayed as more than
a single one?

The Lua code contains one, two and three blank lines and they are
displayed always as separation from single lines.

I thought lines=yes should do that, but it doesn’t.

2. I accidentally discovered that the block comment opening (--[[)
removes break with next line. I think it should be fixed.

3. The most important issue is that the whole comment (both markers and
content) is displayed with \darkyellow.

I wonder why comments aren’t display in typing as in any other editor.
All comment characters should be displayed the same, since none of them
would affect to the final output.

How can I get the same color for the whole comment (again, both markers
and content)?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] comment colors in \typebuffers

2017-08-08 Thread Pablo Rodriguez
Hans,

I have the following sample:

\starttext
\startTEXpage[offset=1em]
\startTEX
This is text. % and this is a comment
\stopTEX

\startXML
This is text.
\stopXML

\startLUA
if code=="code" then --this is a comment

--[[
and this is a
multiline comment
--]]
\stopLUA
\stopTEXpage
\stoptext

All comments are colored in darkyellow, but the issue is that in Lua and
TeX only the comment markers are colored, while in XML only the comment
content is colored.

Because it is basic to display what it won’t affect to the
interpretation or compilation of the code, would it be possible that the
whole comments (both markers and content) could be colored?

Sorry, but in all the code editors I have used in my life, comment
coloring involved both markers (or delimiters) and content.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Modes in Lua

2017-06-01 Thread Henning Hraban Ramm
Thank you all!

Greetlings, Hraban
---
http://www.fiee.net
http://wiki.contextgarden.net
GPG Key ID 1C9B22FD

Am 2017-05-31 um 18:57 schrieb Hans Hagen <pra...@wxs.nl>:

> On 5/31/2017 4:51 PM, Pablo Rodriguez wrote:
>> This is the way to detect system modes, but I don’t know how to do it
>> for \mainlanguage (**en).
>> \mainlanguage[es]
>>     \starttext
>> \en\startlua
>> if tex.systemmodes['en'] then
>> context('Language is English.')
>> else
>> context('Language is not English.')
>> end
>> context('\\par')
>> if tex.modes['es'] then
>> context('Main language is Spanish.')
>> else
>> context('Main language is not Spanish.')
>> end
>> \stoplua
>> \stoptext
>> Just in case it help,
> tex.modes['*en']
> tex.modes['**en']
> 
> tex.systemmodes['en']
> tex.systemmodes['*en']
> 

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Modes in Lua

2017-05-31 Thread Hans Hagen

On 5/31/2017 4:51 PM, Pablo Rodriguez wrote:

On 05/31/2017 11:03 AM, MF wrote:

if tex.modes['specialmode'] then
 context('I’m special.')
end
  
Best greetings,

Massi


Hi, this should be easy:

How can I access ConTeXt’s modes in Lua? Is it any different with
language modes (*en)?


This is the way to detect system modes, but I don’t know how to do it
for \mainlanguage (**en).

 \mainlanguage[es]
 \starttext
 \en\startlua
 if tex.systemmodes['en'] then
 context('Language is English.')
 else
 context('Language is not English.')
 end
 context('\\par')
 if tex.modes['es'] then
 context('Main language is Spanish.')
 else
 context('Main language is not Spanish.')
 end
 \stoplua
 \stoptext

Just in case it help,

tex.modes['*en']
tex.modes['**en']

tex.systemmodes['en']
tex.systemmodes['*en']

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Modes in Lua

2017-05-31 Thread Pablo Rodriguez
On 05/31/2017 04:51 PM, Pablo Rodriguez wrote:
> [...]
> This is the way to detect system modes, but I don’t know how to do it
> for \mainlanguage (**en).

It was simple (not even using tex.systemmodes):

\mainlanguage[es]
\starttext
\en\startlua
if tex.modes['*en'] then
context('Language is English.')
else
context('Language is not English.')
end
context('\\par')
if tex.modes['**es'] then
context('Main language is Spanish.')
else
context('Main language is not Spanish.')
end
\stoplua
\stoptext

Just in case it helps,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] Modes in Lua

2017-05-31 Thread Pablo Rodriguez
On 05/31/2017 11:03 AM, MF wrote:
> if tex.modes['specialmode'] then
> context('I’m special.')
> end
>  
> Best greetings,
> Massi
> 
>> Hi, this should be easy:
>>
>> How can I access ConTeXt’s modes in Lua? Is it any different with
>> language modes (*en)?

This is the way to detect system modes, but I don’t know how to do it
for \mainlanguage (**en).

\mainlanguage[es]
\starttext
\en\startlua
if tex.systemmodes['en'] then
context('Language is English.')
else
context('Language is not English.')
end
context('\\par')
if tex.modes['es'] then
context('Main language is Spanish.')
else
context('Main language is not Spanish.')
end
\stoplua
\stoptext

Just in case it help,

Pablo
-- 
http://www.ousia.tk
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] How to define a TeX logic function with a boolean returned from a Lua function and \edef fixed value

2017-01-18 Thread Hans Hagen

On 1/18/2017 4:29 PM, DesdeChaves wrote:


Dear sirs,

Is there a way to compare, in TeX environment,  a value returned from a
lua function with a TeX variable?

Please see this code:

\def\aleatorioValue{
\startlua
local nu = math.random(1,10);
if nu<5 return 1 else return 0 end
\stoplua
}

\edef\controlValue{1}
\edef\inferior{Number too small \\}
\edef\superior{Number too big \\}

\def\myfunction{\ifx\aleatorioValue\controlValue\inferior\else\superior\fi}


\starttext

\dorecurse{20}{\myfunction}

\stoptext


\def\aleatorioValue{%
\ctxlua{context(math.random(1,10) < 5 and 1 or 0)}%
}

\def\aleatorioValue{%
\cldcontext{math.random(1,10) < 5 and 1 or 0}%
}

\edef\controlValue{1}
\edef\inferior{Number too small \\}
\edef\superior{Number too big \\}

\def\myfunction{\ifnum\aleatorioValue=\controlValue\relax\inferior\else\superior\fi}



--

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] How to define a TeX logic function with a boolean returned from a Lua function and \edef fixed value

2017-01-18 Thread DesdeChaves
Dear sirs,

Is there a way to compare, in TeX environment,  a value returned from a lua
function with a TeX variable?

Please see this code:

\def\aleatorioValue{
\startlua
local nu = math.random(1,10);
if nu<5 return 1 else return 0 end
\stoplua
}

\edef\controlValue{1}
\edef\inferior{Number too small \\}
\edef\superior{Number too big \\}

\def\myfunction{\ifx\aleatorioValue\controlValue\inferior\else\superior\fi}


\starttext

\dorecurse{20}{\myfunction}

\stoptext

Thanks a lot. Have a nice day

Jorge
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] scancsv module and lua

2017-01-16 Thread DesdeChaves
Fixed. Sorry for the noise.

2017-01-16 17:35 GMT+00:00 DesdeChaves <desdecha...@gmail.com>:

> Dear sirs,
>
> In my project I need to format some data from a csv file. The csv file is
> scanned using the scancsv module and part of this information is formatted
> inside luacode environment, but the text.print("") and the  context("")
>  functions don´t be able to send the formatted data to the output. The
> result is a empty pdf.
>
> The example attached is from a old question.
>
> Thanks a lot for your time
>
> Jorge M.
>
> --- example --
>
> \usemodule[scancsv]
>
> \def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
> \startlua
>  local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
>  local day=tonumber(parsedate[1]);
>  local month=tonumber(parsedate[2]);
>  local year=tonumber(parsedate[3]);
> -- tex.print(day..'#3'..month..'#3'..year);
>  text.print("Hello");
> \stoplua
> }
>
> \unexpanded\def\lineaction{
>  \Name\ arrived on \ddmm{\Date}{/}{.\\,} \\
> }
>
>
> % Name;Date
> % ME;11/10/14
> % You;05/02/14
> % He;15/02/2014
> % She;03/03/12
> % It;03/03/14
>
> \setheader
>   \setsep{;}
>   \setfiletoscan{mail.csv}
>
> \starttext
> \filelineaction
> \stoptext
>



-- 
Atentamente

DesdeChaves
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] scancsv module and lua

2017-01-16 Thread DesdeChaves
Dear sirs,

In my project I need to format some data from a csv file. The csv file is
scanned using the scancsv module and part of this information is formatted
inside luacode environment, but the text.print("") and the  context("")
 functions don´t be able to send the formatted data to the output. The
result is a empty pdf.

The example attached is from a old question.

Thanks a lot for your time

Jorge M.

--- example --

\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
 local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
 local day=tonumber(parsedate[1]);
 local month=tonumber(parsedate[2]);
 local year=tonumber(parsedate[3]);
-- tex.print(day..'#3'..month..'#3'..year);
 text.print("Hello");
\stoplua
}

\unexpanded\def\lineaction{
 \Name\ arrived on \ddmm{\Date}{/}{.\\,} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
  \setsep{;}
  \setfiletoscan{mail.csv}

\starttext
\filelineaction
\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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] A macro which gives a random name

2015-04-19 Thread Otared Kavian
 as random names that 
 there are elements in the list, but sometimes I don’t know what is this 
 number.
 
 Thanks for any insight and help.
 Best regards: OK
  begin random-names.tex
 \setuprandomize[2015] % set a seed
 
 \starttext
 
 \startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define[3]\RandomName{%
\setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
 \define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}
 
 \dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
 Give an example of a function $\RandomFunctionName : {\Bbb R} 
 \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and 
 such that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
  begin random-names.tex
 
 You can access the size of your Name table with #Name but have to replace # 
 with \letterhash when you use it in a TeX command because # is already 
 taken for the TeX arguments.
 
 \starttext
 
 \startluacode
 Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}
 
 \dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb 
 R} \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and 
 such that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
 
 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
 ___
 
 ___
 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
 ___
 
 
 
 -- 
 
 -
  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
 ___

___
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
___

Re: [NTG-context] A macro which gives a random name

2015-04-19 Thread Hans Hagen
 this can be done in a more clever way 
without using a numerical macro created with math.random in Lua. The 
shortcoming of the macro below is that before hand I must know the nomber of 
elements in the list of names (for instance 5 in the example below), while it 
may happen that I need to create as many as random names that there are 
elements in the list, but sometimes I don’t know what is this number.

Thanks for any insight and help.
Best regards: OK
 begin random-names.tex
\setuprandomize[2015] % set a seed

\starttext

\startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

\define[3]\RandomName{%
\setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
\define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}

\dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
Give an example of a function $\RandomFunctionName : {\Bbb R} \longrightarrow 
{\Bbb R}$ which has a derivative only at the origin, and such that 
$\RandomFunctionName(0) = 1$.\par \hairline\par}

\stoptext
 begin random-names.tex


You can access the size of your Name table with #Name but have to replace # 
with \letterhash when you use it in a TeX command because # is already taken 
for the TeX arguments.

\starttext

\startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

\define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}

\dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb R} 
\longrightarrow {\Bbb R}$ which has a derivative only at the origin, and such 
that $\RandomFunctionName(0) = 1$.\par \hairline\par}

\stoptext

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
___


___
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
___




--

-
  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
___


___
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
___




--

-
  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
___

Re: [NTG-context] A macro which gives a random name

2015-04-18 Thread Wolfgang Schuster

 Am 18.04.2015 um 18:55 schrieb Otared Kavian ota...@gmail.com:
 
 Hi everyone,
 
 In the example below I define a macro which chooses at random a name from a 
 list of names. But I wonder whether this can be done in a more clever way 
 without using a numerical macro created with math.random in Lua. The 
 shortcoming of the macro below is that before hand I must know the nomber of 
 elements in the list of names (for instance 5 in the example below), while it 
 may happen that I need to create as many as random names that there are 
 elements in the list, but sometimes I don’t know what is this number.
 
 Thanks for any insight and help.
 Best regards: OK
  begin random-names.tex
 \setuprandomize[2015] % set a seed
 
 \starttext
 
 \startluacode
   Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define[3]\RandomName{%
   \setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
 \define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}
 
 \dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
 Give an example of a function $\RandomFunctionName : {\Bbb R} \longrightarrow 
 {\Bbb R}$ which has a derivative only at the origin, and such that 
 $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
  begin random-names.tex

You can access the size of your Name table with #Name but have to replace # 
with \letterhash when you use it in a TeX command because # is already taken 
for the TeX arguments.

\starttext

\startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

\define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}

\dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb R} 
\longrightarrow {\Bbb R}$ which has a derivative only at the origin, and such 
that $\RandomFunctionName(0) = 1$.\par \hairline\par}

\stoptext

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
___

Re: [NTG-context] A macro which gives a random name

2015-04-18 Thread Otared Kavian
Hi Wolfgang,

Thanks for your attention, but the problem with your solution is that each 
instance of \RandomFunctionName changes the name chosen, but I need something 
wihich remains the same name within a given situation (say each problem) but 
changes from problem to problem. 

For instance when using your solution with the source code

Give an example of a function $\RandomFunctionName : {\Bbb R} 
\longrightarrow {\Bbb R}$ which has a 
derivative only at the origin, and such that $\RandomFunctionName(0) = 
1$.
gives:
Give an example of a function 퐺 : R ⟶ R which has a derivative only at 
the origin, and such that 푊(0) = 1. 

while what I need is 
Give an example of a function 퐺 : R ⟶ R which has a derivative only at 
the origin, and such that G(0) = 1. 

(The macro I sent earlier does this, but unfortunately it cannot use the 
solution you sent).
Is there a solution ?

Best regards: OK

 On 18 Apr 2015, at 19:23, Wolfgang Schuster schuster.wolfg...@gmail.com 
 wrote:
 
 
 Am 18.04.2015 um 18:55 schrieb Otared Kavian ota...@gmail.com:
 
 Hi everyone,
 
 In the example below I define a macro which chooses at random a name from a 
 list of names. But I wonder whether this can be done in a more clever way 
 without using a numerical macro created with math.random in Lua. The 
 shortcoming of the macro below is that before hand I must know the nomber of 
 elements in the list of names (for instance 5 in the example below), while 
 it may happen that I need to create as many as random names that there are 
 elements in the list, but sometimes I don’t know what is this number.
 
 Thanks for any insight and help.
 Best regards: OK
  begin random-names.tex
 \setuprandomize[2015] % set a seed
 
 \starttext
 
 \startluacode
  Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define[3]\RandomName{%
  \setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
 \define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}
 
 \dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
 Give an example of a function $\RandomFunctionName : {\Bbb R} 
 \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and 
 such that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
  begin random-names.tex
 
 You can access the size of your Name table with #Name but have to replace # 
 with \letterhash when you use it in a TeX command because # is already taken 
 for the TeX arguments.
 
 \starttext
 
 \startluacode
   Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}
 
 \dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb R} 
 \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and such 
 that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
 
 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
 ___

___
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
___

Re: [NTG-context] A macro which gives a random name

2015-04-18 Thread Hans Hagen

On 4/18/2015 10:24 PM, Otared Kavian wrote:

Hi again Wolfgang,

Thanks to your hint, I could solve the problem…
In case someone else would encounter a similar problem to solve, below is a 
macro which chooses an element from a list, it creates a control sequence (CS) 
containing that element and it keeps the CS until the next time the macro is 
invoked again to choose another element.

Thanks again and best regards: OK

 begin choose-element.tex
\setuprandomize[1989] % set a seed

\starttext

% here is a list from which a name is chosen
\startluacode
ListOfNames = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

% this macro has two arguments:
% the first argument is the control sequence name attached to Chosen,
% the second argument is the name of the list from which something is chosen
\define[2]\RandomChoice{%
\setevalue{Chosen#1}{\ctxlua{%
local listsize = \letterhash #2 ;
local LName = #2 ;
tex.print(LName[math.random(1,listsize)])}}}

\dorecurse{10}{\RandomChoice{Function}{ListOfNames}%
Give an example of a function $\ChosenFunction : {\Bbb R} \longrightarrow {\Bbb 
R}$ which has a derivative only at the origin, and such that 
${\ChosenFunction}'(0) = 1$.\par \hairline\par}

\stoptext
 end choose-element.tex


\starttext

\startluacode
local FunctionNames = { G , W }
local FunctionName  = FunctionNames[1]

function document.SetFunctionNames(list)
FunctionNames = utilities.parsers.settings_to_array(list)
end
function document.GetFunctionName(new)
if new then
FunctionName = FunctionNames[math.random(1,#FunctionNames)]
end
context(FunctionName)
end
\stopluacode

\def\SetFunctionNames[#1]{\ctxlua{document.SetFunctionNames(#1)}}
\def\NewFunctionName {\ctxlua{document.GetFunctionName(true)}}
\def\GetFunctionName {\ctxlua{document.GetFunctionName()}}

\SetFunctionNames[a,b,c,d]

\dorecurse{10}{
Give an example of a function
$\NewFunctionName : {\Bbb R} \longrightarrow {\Bbb R}$
which has a derivative only at the origin, and such that
$\GetFunctionName(0) = 1$.
\par \hairline\par
}


\stoptext




On 18 Apr 2015, at 19:23, Wolfgang Schuster schuster.wolfg...@gmail.com wrote:



Am 18.04.2015 um 18:55 schrieb Otared Kavian ota...@gmail.com:

Hi everyone,

In the example below I define a macro which chooses at random a name from a 
list of names. But I wonder whether this can be done in a more clever way 
without using a numerical macro created with math.random in Lua. The 
shortcoming of the macro below is that before hand I must know the nomber of 
elements in the list of names (for instance 5 in the example below), while it 
may happen that I need to create as many as random names that there are 
elements in the list, but sometimes I don’t know what is this number.

Thanks for any insight and help.
Best regards: OK
 begin random-names.tex
\setuprandomize[2015] % set a seed

\starttext

\startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

\define[3]\RandomName{%
\setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
\define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}

\dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
Give an example of a function $\RandomFunctionName : {\Bbb R} \longrightarrow 
{\Bbb R}$ which has a derivative only at the origin, and such that 
$\RandomFunctionName(0) = 1$.\par \hairline\par}

\stoptext
 begin random-names.tex


You can access the size of your Name table with #Name but have to replace # 
with \letterhash when you use it in a TeX command because # is already taken 
for the TeX arguments.

\starttext

\startluacode
Name = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

\define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}

\dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb R} 
\longrightarrow {\Bbb R}$ which has a derivative only at the origin, and such 
that $\RandomFunctionName(0) = 1$.\par \hairline\par}

\stoptext

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
___


___
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

Re: [NTG-context] A macro which gives a random name

2015-04-18 Thread Otared Kavian
Hi again Wolfgang,

Thanks to your hint, I could solve the problem…
In case someone else would encounter a similar problem to solve, below is a 
macro which chooses an element from a list, it creates a control sequence (CS) 
containing that element and it keeps the CS until the next time the macro is 
invoked again to choose another element.

Thanks again and best regards: OK

 begin choose-element.tex
\setuprandomize[1989] % set a seed

\starttext

% here is a list from which a name is chosen
\startluacode
ListOfNames = {'F', 'G', 'u', 'v', 'W'}
\stopluacode

% this macro has two arguments:
% the first argument is the control sequence name attached to Chosen,
% the second argument is the name of the list from which something is chosen
\define[2]\RandomChoice{%
\setevalue{Chosen#1}{\ctxlua{%
local listsize = \letterhash #2 ;
local LName = #2 ; 
tex.print(LName[math.random(1,listsize)])}}}

\dorecurse{10}{\RandomChoice{Function}{ListOfNames}%
Give an example of a function $\ChosenFunction : {\Bbb R} \longrightarrow {\Bbb 
R}$ which has a derivative only at the origin, and such that 
${\ChosenFunction}'(0) = 1$.\par \hairline\par}

\stoptext
 end choose-element.tex

 On 18 Apr 2015, at 19:23, Wolfgang Schuster schuster.wolfg...@gmail.com 
 wrote:
 
 
 Am 18.04.2015 um 18:55 schrieb Otared Kavian ota...@gmail.com:
 
 Hi everyone,
 
 In the example below I define a macro which chooses at random a name from a 
 list of names. But I wonder whether this can be done in a more clever way 
 without using a numerical macro created with math.random in Lua. The 
 shortcoming of the macro below is that before hand I must know the nomber of 
 elements in the list of names (for instance 5 in the example below), while 
 it may happen that I need to create as many as random names that there are 
 elements in the list, but sometimes I don’t know what is this number.
 
 Thanks for any insight and help.
 Best regards: OK
  begin random-names.tex
 \setuprandomize[2015] % set a seed
 
 \starttext
 
 \startluacode
  Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define[3]\RandomName{%
  \setevalue{Named#1}{\ctxlua{tex.print(math.random(#2,#3))}}}
 \define\RandomFunctionName{\ctxlua{tex.print(Name[\NamedFunctionNumber])}}
 
 \dorecurse{10}{\RandomName{FunctionNumber}{1}{5}%
 Give an example of a function $\RandomFunctionName : {\Bbb R} 
 \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and 
 such that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
  begin random-names.tex
 
 You can access the size of your Name table with #Name but have to replace # 
 with \letterhash when you use it in a TeX command because # is already taken 
 for the TeX arguments.
 
 \starttext
 
 \startluacode
   Name = {'F', 'G', 'u', 'v', 'W'}
 \stopluacode
 
 \define\RandomFunctionName
  {\startlua
   local listsize= \letterhash Name ;
   local randomvalue = math.random(1,listsize) ;
   context(Name[randomvalue])
   \stoplua}
 
 \dorecurse{10}{Give an example of a function $\RandomFunctionName : {\Bbb R} 
 \longrightarrow {\Bbb R}$ which has a derivative only at the origin, and such 
 that $\RandomFunctionName(0) = 1$.\par \hairline\par}
 
 \stoptext
 
 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
 ___

___
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
___

Re: [NTG-context] expand date from CSV file

2014-12-18 Thread Jaroslav Hajtmar

Hi Pablo

Here is a quick solution. However, it not treat the incorrect input 
data, ie it requires, however, correct input, otherwise it will collapse ...


Jaroslav Hajtmar



\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
day=tonumber(parsedate[1]);
month=tonumber(parsedate[2]);
year=tonumber(parsedate[3]);
if (year2000) then year=year+2000 end;
tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
\Name\ arrived on \ddmm{\Date}{/}{.} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

\starttext
   \filelineaction
\stoptext





Dne 17.12.2014 22:20, Pablo Rodriguez napsal(a):

Dear list,

I have the following sample:

 \usemodule[scancsv]

 \unexpanded\def\lineaction{
 \Name\ arrived on \Date\\
 }

 \setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

 \starttext
 \filelineaction
 \stoptext

that reads data from mail.csv:

 Name;Date
 ME;11/10/14
 You;05/02/14
 He;15/02/2014
 She;03/03/12
 It;03/03/14

My question is simple (and not related to CSV data import): how can I
define a command (ConTeXt or Lua) that changes date format from DD/MM/YY
to DD/MM/ when required?

Many thanks for your help,


Pablo


___
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
___

Re: [NTG-context] expand date from CSV file

2014-12-18 Thread Jaroslav Hajtmar

Hi Pablo,
I am sending still slightly modified version (use local variables and 
better typographic output).
It use of much variables, but at least it is clear how it works. For 
solution occurred me to use parsing function that I have been defined in 
the library, so that it can be successfully used.


Sincerely
Jaroslav Hajtmar



\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
local day=tonumber(parsedate[1]);
local month=tonumber(parsedate[2]);
local year=tonumber(parsedate[3]);
if (year2000) then year=year+2000 end;
tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
\Name\ arrived on \ddmm{\Date}{/}{.\\,} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

\starttext
   \filelineaction
\stoptext




Dne 18.12.2014 9:39, Jaroslav Hajtmar napsal(a):

Hi Pablo

Here is a quick solution. However, it not treat the incorrect input 
data, ie it requires, however, correct input, otherwise it will 
collapse ...


Jaroslav Hajtmar



\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
day=tonumber(parsedate[1]);
month=tonumber(parsedate[2]);
year=tonumber(parsedate[3]);
if (year2000) then year=year+2000 end;
tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
\Name\ arrived on \ddmm{\Date}{/}{.} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

\starttext
   \filelineaction
\stoptext





Dne 17.12.2014 22:20, Pablo Rodriguez napsal(a):

Dear list,

I have the following sample:

 \usemodule[scancsv]

 \unexpanded\def\lineaction{
 \Name\ arrived on \Date\\
 }

 \setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

 \starttext
 \filelineaction
 \stoptext

that reads data from mail.csv:

 Name;Date
 ME;11/10/14
 You;05/02/14
 He;15/02/2014
 She;03/03/12
 It;03/03/14

My question is simple (and not related to CSV data import): how can I
define a command (ConTeXt or Lua) that changes date format from DD/MM/YY
to DD/MM/ when required?

Many thanks for your help,


Pablo


___ 

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
___

Re: [NTG-context] expand date from CSV file

2014-12-18 Thread Pablo Rodriguez
On 12/18/2014 01:24 PM, Jaroslav Hajtmar wrote:
 Hi Pablo,
 I am sending still slightly modified version (use local variables and 
 better typographic output).
 It use of much variables, but at least it is clear how it works. For 
 solution occurred me to use parsing function that I have been defined in 
 the library, so that it can be successfully used.

Many thanks for your reply, Jaroslav.

This is exactly what I need.

Many thanks for your help,

Pablo


 \usemodule[scancsv]
 
 \def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
 \startlua
  local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
  local day=tonumber(parsedate[1]);
  local month=tonumber(parsedate[2]);
  local year=tonumber(parsedate[3]);
  if (year2000) then year=year+2000 end;
  tex.print(day..'#3'..month..'#3'..year);
 \stoplua
 }
 
 \unexpanded\def\lineaction{
  \Name\ arrived on \ddmm{\Date}{/}{.\\,} \\
 }
 
 
 % Name;Date
 % ME;11/10/14
 % You;05/02/14
 % He;15/02/2014
 % She;03/03/12
 % It;03/03/14
 
 \setheader
   \setsep{;}
   \setfiletoscan{mail.csv}
 
 \starttext
 \filelineaction
 \stoptext
 
 
 
 
 Dne 18.12.2014 9:39, Jaroslav Hajtmar napsal(a):
 Hi Pablo

 Here is a quick solution. However, it not treat the incorrect input 
 data, ie it requires, however, correct input, otherwise it will 
 collapse ...

 Jaroslav Hajtmar



 \usemodule[scancsv]

 \def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
 \startlua
 parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
 day=tonumber(parsedate[1]);
 month=tonumber(parsedate[2]);
 year=tonumber(parsedate[3]);
 if (year2000) then year=year+2000 end;
 tex.print(day..'#3'..month..'#3'..year);
 \stoplua
 }

 \unexpanded\def\lineaction{
 \Name\ arrived on \ddmm{\Date}{/}{.} \\
 }


 % Name;Date
 % ME;11/10/14
 % You;05/02/14
 % He;15/02/2014
 % She;03/03/12
 % It;03/03/14

 \setheader
  \setsep{;}
  \setfiletoscan{mail.csv}

 \starttext
\filelineaction
 \stoptext





 Dne 17.12.2014 22:20, Pablo Rodriguez napsal(a):
 Dear list,

 I have the following sample:

  \usemodule[scancsv]

  \unexpanded\def\lineaction{
  \Name\ arrived on \Date\\
  }

  \setheader
  \setsep{;}
  \setfiletoscan{mail.csv}

  \starttext
  \filelineaction
  \stoptext

 that reads data from mail.csv:

  Name;Date
  ME;11/10/14
  You;05/02/14
  He;15/02/2014
  She;03/03/12
  It;03/03/14

 My question is simple (and not related to CSV data import): how can I
 define a command (ConTeXt or Lua) that changes date format from DD/MM/YY
 to DD/MM/ when required?

 Many thanks for your help,


 Pablo


-- 
http://www.ousia.tk
___
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
___

Re: [NTG-context] expand date from CSV file

2014-12-18 Thread Jaroslav Hajtmar

Hi Pablo.
Peter pointed out an error in my solution. Thanks Peter! His message but 
pointed out that in fact is not the task as simple as it seems at first 
glance. In fact, a lot depends on what target group for those you solve 
a problem resp. whether e.g. date of birth of persons. What does it mean 
03/01/00? It means 1/3/1900? Or does it mean 01/03/2000? Particular job 
you have to deal specifically separately. It occurred to me yet 
following solution that respects the current year as the year when he 
could anyone born. E.g. 19/12/14 means a newborn soul (ie. In fact, 
12/19/2014), while 01/02/15 mean old man ie. in fact 01/02/1915. For the 
specific case you have to modify or create the solution separately.


Greetings
Jaroslav Hajtmar

Here is new minimal example:

\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
local day=tonumber(parsedate[1]);
local month=tonumber(parsedate[2]);
local year=tonumber(parsedate[3]);
if (year100) then % when is only two digits year format then
if year=14 then % it is very young person
year=year+2000
else % this person has more than one hundred years
year=year+1900;
end;
end;
tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
\Name\ born \Date\quad  (\ddmm{\Date}{/}{.\\,}) \\
}

% Content of CSV file:
% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14
% A;11/11/1999
% B;01/2/1964
% C;02/3/23
% D;03/4/64
% E;04/5/00
% F;05/6/01
% G;05/7/15
% H;05/7/1915
% Test0;1/2/00
% Test1;1/2/01
% Test2;1/2/02
% Test3;1/2/03
% Test4;1/2/04
% Test5;1/2/05
% Test6;1/2/06
% Test7;1/2/07
% Test8;1/2/08
% Test9;1/2/09
% Test10;1/2/10
% Test11;1/2/11
% Test12;1/2/12
% Test13;1/2/13
% Test14;1/2/14
% Test15;1/2/15
% Test16;1/2/16
% Test17;1/2/17
% Test18;1/2/18
% Test19;1/2/19
% Test20;1/2/20

\setheader
 \setsep{;}
 \setfiletoscan{mail.csv}

\starttext
   \filelineaction
\stoptext



Dne 18.12.2014 19:07, Pablo Rodriguez napsal(a):

On 12/18/2014 01:24 PM, Jaroslav Hajtmar wrote:

Hi Pablo,
I am sending still slightly modified version (use local variables and
better typographic output).
It use of much variables, but at least it is clear how it works. For
solution occurred me to use parsing function that I have been defined in
the library, so that it can be successfully used.

Many thanks for your reply, Jaroslav.

This is exactly what I need.

Many thanks for your help,

Pablo



\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
  local parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
  local day=tonumber(parsedate[1]);
  local month=tonumber(parsedate[2]);
  local year=tonumber(parsedate[3]);
  if (year2000) then year=year+2000 end;
  tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
  \Name\ arrived on \ddmm{\Date}{/}{.\\,} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
   \setsep{;}
   \setfiletoscan{mail.csv}

\starttext
 \filelineaction
\stoptext




Dne 18.12.2014 9:39, Jaroslav Hajtmar napsal(a):

Hi Pablo

Here is a quick solution. However, it not treat the incorrect input
data, ie it requires, however, correct input, otherwise it will
collapse ...

Jaroslav Hajtmar



\usemodule[scancsv]

\def\ddmm#1#2#3{% #1 - date, #2 - old separator, #3 - new separator
\startlua
 parsedate=thirddata.scancsv.ParseCSVLine('#1','#2');
 day=tonumber(parsedate[1]);
 month=tonumber(parsedate[2]);
 year=tonumber(parsedate[3]);
 if (year2000) then year=year+2000 end;
 tex.print(day..'#3'..month..'#3'..year);
\stoplua
}

\unexpanded\def\lineaction{
 \Name\ arrived on \ddmm{\Date}{/}{.} \\
}


% Name;Date
% ME;11/10/14
% You;05/02/14
% He;15/02/2014
% She;03/03/12
% It;03/03/14

\setheader
  \setsep{;}
  \setfiletoscan{mail.csv}

\starttext
\filelineaction
\stoptext





Dne 17.12.2014 22:20, Pablo Rodriguez napsal(a):

Dear list,

I have the following sample:

  \usemodule[scancsv]

  \unexpanded\def\lineaction{
  \Name\ arrived on \Date\\
  }

  \setheader
  \setsep{;}
  \setfiletoscan{mail.csv}

  \starttext
  \filelineaction
  \stoptext

that reads data from mail.csv:

  Name;Date
  ME;11/10/14
  You;05/02/14
  He;15/02/2014
  She;03/03/12
  It;03/03/14

My question is simple (and not related to CSV data import): how can I
define a command (ConTeXt or Lua) that changes date format from DD/MM/YY
to DD/MM/ when required?

Many thanks for your help,


Pablo




___
If your question is of interest to others

Re: [NTG-context] Ctx: list of commands

2012-09-18 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

@Philipp:


1) is there a Ctx command/switch which would generate list of all current 
ConTeXt commands? E.g.


Hi Lukáš, if you interpret “current Context commands” as “macros
known to TeX”, you may try dumping the hashtable with these lines:

···
\starttext
  \startluacode
table.print(tex.hashtokens())
  \stopluacode
\stoptext
···


thanks for the idea.

Unfortunately, current Context commands don't need to be necessarily macros known to 
TeX, as ConTeXt may have defined many macros that are not for public use.

It seems that my question is not so straightforward - I didn't think it would it could be problem 
to separate public macros (= public ConTeXt commands = these that are cited in manuals, 
on wiki or simply - which you can use).

Maybe - if I know ALL macros - it would be easy to distinguish between public ones and 
protected ones - supposing the latter have always at least one of the special chars - 
_@?! (or other?) in it.

I tried your idea, but in this part of the output:


...
[startJScode]={ 127, 290597, 60096 },
[startJSpreamble]={ 127, 290644, 49920 },
[startLUA]={ 127, 245948, 28541 },
[startLuaSnippet]={ 127, 244345, 530 },
[startLuaSnippetBoundary]={ 127, 246417, 46341 },
[startLuaSnippetComment]={ 127, 247113, 23071 },
[startLuaSnippetName]={ 127, 246301, 9781 },
[startLuaSnippetNameBase]={ 127, 244439, 46291 },
[startLuaSnippetNameCore]={ 127, 245803, 61132 },
[startLuaSnippetNameLibraries]={ 127, 246257, 38877 },
[startLuaSnippetQuote]={ 127, 246898, 19907 },
[startLuaSnippetSpecial]={ 127, 247006, 23901 },
[startLuaSnippetString]={ 127, 246646, 61126 },
[startMP]={ 127, 245820, 14236 },
...


- the command/macro \startluacode is missing (why?) and

- e.g. the macro \startLuaSnippetNameBase is not mentioned for public use I 
guess, but also is not detectable by presence of any special char (@_!?).

So I'm not sure this way is usable.

@Hans:

How exactly did you mean to use:


\starttext
   \startluacode
 table.print(tex.hashtokens())
   \stopluacode
\stoptext
···


or

\enabledirectives[system.dumphash]

\enabledirectives[system.dumpdelta]


This:


\starttext
  \enabledirectives[system.dumphash]
  \enabledirectives[system.dumpdelta]
\stoptext


gives nothing useful.

How exactly to use the command/switch --textpad or --text with 
context.exe?

Best regards,

Lukas


--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___
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
___

Re: [NTG-context] expansion and \processaction

2012-06-07 Thread Wolfgang Schuster

Am 07.06.2012 um 17:34 schrieb Philipp Gesang:

 Hi Wolfgang!
 
 ···date: 2012-06-07, Thursday···from: Wolfgang Schuster···
 
 
 Am 07.06.2012 um 14:05 schrieb Philipp Gesang:
 
 Hi all,
 
 my goal is a macro \definestates[foo][...,...] which takes a comma
 list and creates a monadic macro \foo[n]. \foo[n] should return
 either the nth item or, if (n  list length), a default. I
 thought the right tools were \processcommalist to generate the
 mapping n-list item, as well as \processaction to retrieve the
 items. But naively I didn’t consider expansion ...
 
 My code so far:
 
 ··8
 \unprotect
 
 \def\definestates{\dodoubleempty\do_define_states}
 
 \def\do_define_states[#1][#2]{%
 \expandafter\edef\csname#1_states\endcsname{%
   \nstates0
   %% this is supposed to be expanded so we employ the \raw... variety
   \rawprocesscommalist[#2]\add_one_state%
   unknown=\dummystate,%
   default=\dummystate,%
 }%
 \do_do_define_states{#1}%
 }
 
 \let\dummystate\empty
 
 \newcount\nstates
 \unexpanded\def\add_one_state#1{%
 \advance\nstates\plusone
 \the\nstates=#1,%
 }
 
 \def\do_do_define_states#1{%
 \expandafter\def\csname#1\endcsname
   {\expandafter\dosingleempty\csname do_#1\endcsname}%
 \expandafter\def\csname do_#1\endcsname[##1]{%
   \iffirstargument
 % [DBG] cmd:#1, state:##1\par
 \edef\currentstates{\csname#1_states\endcsname}%
 %% At this point \currentstates should yield the whole mapping so
 %% we can use it with \processaction. But ...
 % \show\currentstates
 % \currentstates\par
 %% ... here it still contains
 %%\nstates 0 \rawprocesscommalist [foo,bar,baz] ...
 %% and the next directive has an empty result:
 \rawprocessaction[##1][\currentstates]%
   \fi
 }%
 }
 
 \protect
 \starttext
 
 \definestates[mystates][foo,bar,baz]
 %% At this point I’d like \mystates_states to contain (literally)
 %%   “1=foo,2=bar,3=baz,unknown=,default=,”
 %% so the following command
 \mystates[1]  % - foo
 %% would be equivalent to
 %%\processaction[1][1=foo,2=bar,3=baz,unknown=,default=,]
 \mystates[2]  % - bar
 \mystates[42] % - dummy
 
 \stoptext
 ··8
 
 My question: How can I use \[raw]processcommalist in an expanded
 definition? How can I get \[raw]processcommalist to operate on
 the expansion of its second argument? Does this even make sense?
 If not, what is the proper way?
 
 \unprotect
 
 \unexpanded\def\definestates
  {\dodoubleargument\definestates_indeed}
 
 \def\definestates_indeed[#1][#2]%
  {\setuevalue{#1}{\states_entry[#2]}}
 
 \unexpanded\def\states_entry
  {\dodoubleargument\states_entry_indeed}
 
 \def\states_entry_indeed[#1][#2]%
  {\getcommalistsize[#1]%
   \ifnum#2\commalistsize
 {\tttf NO ENTRY!}%
   \else
 \getfromcommalist[#1][#2]\commalistelement
   \fi}
 
 Thanks very much. This solves my problem. Very convenient that I
 can rewrite it to use comma command.

You can also try to use a Lua variant.

\def\states_entry_indeed[#1][#2]%
 {\startlua
  local entries = utilities.parsers.settings_to_array(#1)
  local entry   = entries[#2]
  if entry then
context(entry)
  else
context(\\tttf NO ENTRY!)
  end
  \stoplua}

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
___


Re: [NTG-context] expansion and \processaction

2012-06-07 Thread Hans Hagen

On 7-6-2012 18:02, Wolfgang Schuster wrote:


You can also try to use a Lua variant.

\def\states_entry_indeed[#1][#2]%
  {\startlua
   local entries = utilities.parsers.settings_to_array(#1)
   local entry   = entries[#2]
   if entry then
 context(entry)
   else
 context(\\tttf NO ENTRY!)


shouldn't that be grouped?


   end
   \stoplua}


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
___


Re: [NTG-context] expansion and \processaction

2012-06-07 Thread Wolfgang Schuster

Am 07.06.2012 um 18:16 schrieb Hans Hagen:

 On 7-6-2012 18:02, Wolfgang Schuster wrote:
 
 You can also try to use a Lua variant.
 
 \def\states_entry_indeed[#1][#2]%
  {\startlua
   local entries = utilities.parsers.settings_to_array(#1)
   local entry   = entries[#2]
   if entry then
 context(entry)
   else
 context(\\tttf NO ENTRY!)
 
 shouldn't that be grouped?

Yes, of course.

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
___


Re: [NTG-context] CLD: context.getvariable as Lua variable

2012-01-05 Thread Wolfgang Schuster

Am 05.01.2012 um 15:49 schrieb Wagner Macedo:

 Hello,
 
 I'm relatively quite new to TeX world. This is my first message to list. I 
 hope you understand me, English isn't my mother language.
 
 I'm trying to use a variable set by \setvariable in Lua. I tried some 
 combinations, based on manual but I couldn't succeed. The code below 
 exemplifies what I wanted to do.
 
 \starttext
 \setvariable{namespace}{var}{Some context}
 \ctxlua{
   local s = context.getvariable(namespace, var)
 
   if s ==  then
 ...
   else
 ...
   end
 }
 \stoptext
 
 I know that I can use some of \if* TeX commands, but coding in Lua is better 
 to me.


What you’re trying is not possible but there are other ways to check the 
content of the variable in Lua.

\startluacode

userdata = userdata or { }

function userdata.checkvariable(variable)
if variable ==  then
context(EMPTY)
else
context(NOT EMPTY)
end
end

\stopluacode

\setvariable{wagner}{name}{Wagner Macedo}

\starttext

\ctxlua{userdata.checkvariable(\getvariable{wagner}{name})}

% This does only with \startlua or \ctxlua

\startlua

local name = \getvariable{wagner}{name}

if name ==  then
context(No Text)
else
name = Name:  .. name
context(name)
end

\stoplua

\stoptext

A different method is to save the \setvariables entries in a Lua table and 
check the entries of the table.

\startluacode

userdata= userdataor { }
userdata.macedo = userdata.macedo or { }

userdata.macedo.data = { }

function userdata.macedo.savevariables(variables)
userdata.macedo.data = variables
end

function userdata.macedo.checkvariables()
local variables = userdata.macedo.data
-- check for name 
if variables.name ==  then
context(Name: No name set)
context.par()
else
context(Name: ..variables.name)
context.par()
end
-- check for address
if variables.address ==  then
context(Address: No address set)
context.par()
else
context(Address: ..variables.address)
context.par()
end
end

\stopluacode

\starttexdefinition SaveVariables
\startlua
userdata.macedo.savevariables{
name= \getvariable{macedo}{name},
address = \getvariable{macedo}{address},
}
\stoplua
\stoptexdefinition

\setvariables[macedo][set=\SaveVariables]

\starttext

\setvariables[macedo][name=Wagner Macedo]

\ctxlua{userdata.macedo.checkvariables()}

\setvariables[macedo][address=Secret]

\ctxlua{userdata.macedo.checkvariables()}

\stoptext

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
___

Re: [NTG-context] CLD: context.getvariable as Lua variable

2012-01-05 Thread Wagner Macedo
Firstly, thanks by answer.

The second way is nice, but could be generic (e.g. save any variable in a
namespace)?

--
Wagner Macedo


On 5 January 2012 13:04, Wolfgang Schuster schuster.wolfg...@googlemail.com
 wrote:


 Am 05.01.2012 um 15:49 schrieb Wagner Macedo:

 Hello,

 I'm relatively quite new to TeX world. This is my first message to list. I
 hope you understand me, English isn't my mother language.

 I'm trying to use a variable set by \setvariable in Lua. I tried some
 combinations, based on manual but I couldn't succeed. The code below
 exemplifies what I wanted to do.

 \starttext
 \setvariable{namespace}{var}{Some context}
 \ctxlua{
   local s = context.getvariable(namespace, var)

   if s ==  then
 ...
   else
 ...
   end
 }
 \stoptext

 I know that I can use some of \if* TeX commands, but coding in Lua is
 better to me.


 What you’re trying is not possible but there are other ways to check the
 content of the variable in Lua.

 \startluacode

 userdata = userdata or { }

 function userdata.checkvariable(variable)
 if variable ==  then
  context(EMPTY)
 else
 context(NOT EMPTY)
  end
 end

 \stopluacode

 \setvariable{wagner}{name}{Wagner Macedo}

 \starttext

 \ctxlua{userdata.checkvariable(\getvariable{wagner}{name})}

 % This does only with \startlua or \ctxlua

 \startlua

 local name = \getvariable{wagner}{name}

 if name ==  then
 context(No Text)
 else
 name = Name:  .. name
  context(name)
 end

 \stoplua

 \stoptext

 A different method is to save the \setvariables entries in a Lua table and
 check the entries of the table.

 \startluacode

 userdata= userdataor { }
 userdata.macedo = userdata.macedo or { }

 userdata.macedo.data = { }

 function userdata.macedo.savevariables(variables)
 userdata.macedo.data = variables
 end

 function userdata.macedo.checkvariables()
  local variables = userdata.macedo.data
 -- check for name
 if variables.name ==  then
  context(Name: No name set)
 context.par()
 else
  context(Name: ..variables.name)
 context.par()
 end
  -- check for address
 if variables.address ==  then
 context(Address: No address set)
  context.par()
 else
 context(Address: ..variables.address)
  context.par()
 end
 end

 \stopluacode

 \starttexdefinition SaveVariables
  \startlua
 userdata.macedo.savevariables{
 name= \getvariable{macedo}{name},
  address = \getvariable{macedo}{address},
 }
 \stoplua
 \stoptexdefinition

 \setvariables[macedo][set=\SaveVariables]

 \starttext

 \setvariables[macedo][name=Wagner Macedo]

 \ctxlua{userdata.macedo.checkvariables()}

 \setvariables[macedo][address=Secret]

 \ctxlua{userdata.macedo.checkvariables()}

 \stoptext

 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

 ___

___
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
___

Re: [NTG-context] \inpu

2012-01-01 Thread Wolfgang Schuster

Am 01.01.2012 um 08:00 schrieb luigi scarso:

 On Sun, Jan 1, 2012 at 4:28 AM, Michael Talbot-Wilson m...@view.net.au 
 wrote:
 I thought I'd see if I could use ConTeXt.  Here is my first try, hello.tex.
 
 \starttext
 \input header
 Hello, World!\startlua
 a = 1.5
 b = 1.8
 c = a * b
 tex.print(c)
 \stoplua plus1.
 \stoptext
 
 Didn't work because the file header.tex could not be found, even
 though kpsewhich can find it.
 I'm not sure that mkiv uses kpsewhich….

No, MkIV use a different system to find files.

 You should use mtxrun --locate, i.e.
 mtxrun --locate --all knuth

The file list is updated with “mtxrun --generate” or “context --generate” 
(which will then run mtxrun).

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
___


[NTG-context] \inpu

2011-12-31 Thread Michael Talbot-Wilson

I thought I'd see if I could use ConTeXt.  Here is my first try, hello.tex.

\starttext
\input header
Hello, World!\startlua
a = 1.5
b = 1.8
c = a * b
tex.print(c)
\stoplua plus1.
\stoptext

Didn't work because the file header.tex could not be found, even
though kpsewhich can find it.




(hello.tex
publications: loading formatting style from bxml-apa
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/bxml-apa.mkiv)

ConTeXt  ver: 2010.06.23 12:45 MKIV  fmt: 2011.12.24  int: english/english

system  : cont-new loaded
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/cont-new.tex
systems : beware: some patches loaded from cont-new.tex
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/cont-new.mkiv))
system  : cont-fil loaded
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/cont-fil.tex
loading : ConTeXt File Synonyms
)
system  : cont-sys.rme loaded
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/user/cont-sys.rme 
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/type-def.mkiv) 
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/type-lua.mkiv) 
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/type-siz.mkiv) 
(/usr/local/libexec/ConTeXt/tex/texmf-context/tex/context/base/type-otf.mkiv))
system  : hello.top loaded
%
%   begin of optionfile
%
%   % runtime options files (command line driven)
%   \unprotect
%   % feedback and basic job control
%   % handy for special styles
%   \startluacode
%   document = document or { }
%   document.arguments={
%   }
%   document.files={
%hello,
%   }
%   \stopluacode
%   % process info
%   \setupsystem[inputfile=hello]
%   \setupsystem[\c!n=1,\c!m=1]
%   % modes
%   % options (not that important)
%   \startsetups *runtime:options
%   \setupoutput[pdftex]
%   \stopsetups
%   % styles and modules
%   \startsetups *runtime:modules
%   \stopsetups
%   % done
%   \protect \endinput
%
%   end of optionfile
%
(hello.top)
fonts   : preloading latin modern fonts
{/usr/local/libexec/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-math.map}{/usr/local/libexec/ConTeXt/tex/texmf/fonts/map/dvips/lm/lm-rm.map}{/usr/local/libexec/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
bodyfont: 12pt rm is loaded
language: language en is active
systems : begin file hello at line 1
! I can't find file `header'.
l.2 \input header

Please type another input file name: 
! Emergency stop.

l.2 \input header

End of file on the terminal!

!  == Fatal error occurred, no output PDF file produced!
___
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
___


Re: [NTG-context] \inpu

2011-12-31 Thread luigi scarso
On Sun, Jan 1, 2012 at 4:28 AM, Michael Talbot-Wilson m...@view.net.au wrote:
 I thought I'd see if I could use ConTeXt.  Here is my first try, hello.tex.

 \starttext
 \input header
 Hello, World!\startlua
 a = 1.5
 b = 1.8
 c = a * b
 tex.print(c)
 \stoplua plus1.
 \stoptext

 Didn't work because the file header.tex could not be found, even
 though kpsewhich can find it.
I'm not sure that mkiv uses kpsewhich
You should use mtxrun --locate, i.e.
mtxrun --locate --all knuth

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

Re: [NTG-context] mkiv: verbatim lua eats my quotes

2011-01-10 Thread Hans Hagen

On 9-1-2011 10:16, Thomas A. Schmitz wrote:

\starttext

\startLUA
require 'lpeg'

sep = lpeg.P(,)
\stopLUA

\stoptext


I'll put a beta on the ftp for testing. You can configure the string 
content as well as the quotes.


-
  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
___


Re: [NTG-context] mkiv: verbatim lua eats my quotes

2011-01-10 Thread Thomas A. Schmitz

On Jan 10, 2011, at 2:14 PM, Hans Hagen wrote:

 On 9-1-2011 10:16, Thomas A. Schmitz wrote:
 \starttext
 
 \startLUA
 require 'lpeg'
 
 sep = lpeg.P(,)
 \stopLUA
 
 \stoptext
 
 I'll put a beta on the ftp for testing. You can configure the string content 
 as well as the quotes.
 
Hi Hans,

sorry, was away from my computer all day. Latest beta shows quotes in luacode 
again, so all is golden, thanks a lot!

Thomas

___
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
___


[NTG-context] mkiv: verbatim lua eats my quotes

2011-01-09 Thread Thomas A. Schmitz
Hi all, 

is this a bug or a feature: in verbatim lua code, my  double and ' single 
quotation marks are eaten up in mkiv (everything is colorless, but correct in 
mkii). Example:

\starttext

\startLUA
require 'lpeg'

sep = lpeg.P(,)
\stopLUA

\stoptext

Thanks

Thomas
___
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
___


Re: [NTG-context] problem with \setuptyping[option=LUA, escape=//]

2010-08-26 Thread Peter Münster
On Wed, Aug 25 2010, Hans Hagen wrote:

 \definetyping[LUA]
 \setuptyping[LUA][option=LUA,escape={/btex,/etex}]
 
 Hopefully you wikify this

Hello Hans,

I don't know what to wikify, because I don't understand what is supposed to
work and what is not. Here another example with strange behaviour:

\startbuffer[typefile-test]
btex-etex:  // /btex \em sometex /etex
xxx-yyy:// XXX \em sometex YYY
zzz:// ZZZ \em sometex
\stopbuffer
\savebuffer[typefile-test][typefile-test]
\definetyping[LUA]

\starttext
\section{file=zzz}
\start
\setuptyping[file][option=LUA, escape=ZZZ]
\typefile{typefile-test} % problem here
\stop

\section{file=zzz, lua=xxx-yyy}
\start
\setuptyping[file][option=LUA, escape=ZZZ]
\setuptyping[LUA][option=LUA, escape={XXX,YYY}]
\startLUA
btex-etex:  // /btex \em sometex /etex
xxx-yyy:// XXX \em sometex YYY
zzz:// ZZZ \em sometex
\stopLUA
\typefile{typefile-test} % problem here
\stop

\section{file=zzz, lua=btex-etex}
\start
\setuptyping[file][option=LUA, escape=ZZZ]
\setuptyping[LUA][option=LUA, escape={/btex,/etex}]
\startLUA
btex-etex:  // /btex \em sometex /etex
xxx-yyy:// XXX \em sometex YYY
zzz:// ZZZ \em sometex
\stopLUA
\typefile{typefile-test} % problem here
\stop

\section{file=zzz, lua=zzz}
\start
\setuptyping[file][option=LUA, escape=ZZZ]
\setuptyping[LUA][option=LUA, escape=ZZZ]
\typefile{typefile-test} % problem here
\stop

\section{file=zzz, lua=zzz}
\start
\setuptyping[file][option=LUA, escape=ZZZ]
\setuptyping[LUA][option=LUA, escape=ZZZ]
\startLUA
\stopLUA
\typefile{typefile-test} % now it works
\stop

\stoptext

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___
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
___


Re: [NTG-context] [***SPAM***] problem with \setuptyping[option=LUA, escape=//]

2010-08-25 Thread Hans Hagen

On 25-8-2010 3:04, Peter Münster wrote:

The escape=// option is ignored here:

\setuptyping[option=LUA, escape=//]
\starttext
\starttyping
   bla // \em sometex
\stoptyping
\stoptext

What could be done, to make it work?


\definetyping[LUA]

\setuptyping[LUA][option=LUA,escape={/btex,/etex}]

\starttext
\startLUA
  bla // /btex\em sometex /etex
\stopLUA
\stoptext

Hopefully you wikify this

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
___


[NTG-context] funny bug

2010-05-10 Thread Peter Münster
Hello,

\starttext
\startLUA
printbla  -- words are transposed!
\stopLUA
\stoptext

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___
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
___


Re: [NTG-context] funny bug

2010-05-10 Thread Hans Hagen

On 10-5-2010 10:43, Peter Münster wrote:

\starttext
\startLUA
printbla-- words are transposed!
\stopLUA
\stoptext


in pret-lua.lua, line 265:

elseif c == '' or c == ' then
if word then
state = flush_lua_word(state,word)
word = nil
end



-
  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
___


Re: [NTG-context] tab disappears in LUA environment.

2010-04-07 Thread Hans Hagen

On 7-4-2010 5:13, Hongwen Qiu wrote:

\startLUA
string.format(%s %d, person, total)
\stopLUA


space handling fixed in next beta

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


[NTG-context] tab disappears in LUA environment.

2010-04-06 Thread Hongwen Qiu
\startLUA
string.format(%s %d, person, total)
\stopLUA

produces the result as following:

string.format(%s%d, person, total)

while the following code has no such problem:

\starttyping
string.format(%s %d, person, total)
\stoptyping

$ context --version
MTXrun | current version: 2010.03.30 18:56

$ luatex --version
This is LuaTeX, Version beta-0.60.0-2010040422
___
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
___


Re: [NTG-context] Why are pretty printer names uppercased?

2009-08-26 Thread Hans Hagen

Matthijs Kooijman wrote:

Hi all,

according to the wiki, and the current code, the arguments to
\installprettytype should be uppercased. E.g.:


because want uppercase

\startTEX
\stopTEX

\startMP
\stopMP

\startLUA
\stopLUA


  \installprettytype [PHP][PHP]

Referring to them should be uppercased as well:
  \definetyping[PHP]   [option=PHP]


defining indeed, as it is an instance, but option also accepts lowercase


However, the filename should be lowercase, e.g. pret-php.lua and the pretty
printer should register itself in lowercase as well:
buffers.newvisualizer(lua). The first thing that happens to the arguments of
installprettytype is to lowercase them, and every option= argument that points
to a pretty printer is lowercased by setvisualizer in lua before being used.


indeed. as i don't like casing in filenames, and function names


If everything is lowercased, why do we still recommend the arguments to
\installprettytype and option= to be uppercase? IMHO this makes things
confusing when trying to understand which PHP refers to which php or PHP in
the greater picture of things. 


because they generate commands and it's quite valid to say

\definetyping[myphp]

etc


Why not recommend people to use lowercase identifiers instead, since we're
changing everything into lowercase anyway? Or perhaps go a bit further and
remove the lowercasing code alltogether, since I don't see any real gain. If
the strings / filenames should just match exactly, things will get a lot more
predictable?


actually, the advice is that user definitions use uppercase

\definehead[MySection][section]

etc, just to avoid clashes with built in commands

Hans

-
  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
___


Re: [NTG-context] t-vim: inline typing?

2009-07-20 Thread Aditya Mahajan
 = mk_grid_world(r, c, p, obstacle, terminal, absorb, wrap_around, noop);
% Add rewards for terminal states
nstates = r*c + 1;
if noop
  nact = 5;
else
  nact = 4;
end
R = action_cost*ones(nstates, nact);
R(10,:) = 1;
R(11,:) = -1;
R(nstates,:) = 0;
discount_factor = 1;

V = value_iteration(T, R, discount_factor);
%reshape(V(1:end-1),[r c])
%0.81160.86780.91781.
%0.76160.79640.6603   -1.
%0.70530.65530.61140.3878
% Same as the book p501

Q = Q_from_V(V, T, R, discount_factor);
[V, p] = max(Q, [], 2);


use_val_iter = 1;
% (I-gT) is singular since g=1 and there is an absorbing state (i.e., T(i,i)=1)
% Hence we cannot use value determination.
[p,V] = policy_iteration(T, R, discount_factor, use_val_iter);

%reshape(V(1:end-1),[r c])
%0.81150.86780.91781.
%0.76150.79640.6603   -1.
%0.70480.65390.60850.3824
\stopMATLAB

\title{Lua Code Listing -- Black and White}

\definevimtyping  [LUA]  [syntax=lua,colorscheme=blackandwhite]

\startLUA
-- version   : 1.0.0 - 07/2005
-- author: Hans Hagen - PRAGMA ADE - www.pragma-ade.com
-- copyright : public domain or whatever suits
-- remark: part of the context distribution

-- TODO: name space for local functions

-- loading: scite-ctx.properties

-- generic functions

local crlf = \n

function traceln(str)
trace(str .. crlf)
io.flush()
end

table.len  = table.getn
table.join = table.concat

function table.found(tab, str)
local l, r, p
if string.len(str) == 0 then
return false
else
l, r = 1, table.len(tab)
while l = r do
p = math.floor((l+r)/2)
if str  tab[p] then
r = p - 1
elseif str  tab[p] then
l = p + 1
else
return true
end
end
return false
end
end

function string.grab(str, delimiter)
local list = {}
for snippet in string.gfind(str,delimiter) do
table.insert(list, snippet)
end
return list
end

function string.join(list, delimiter)
local size, str = table.len(list), ''
if size  0 then
str = list[1]
for i = 2, size, 1 do
str = str .. delimiter .. list[i]
end
end
return str
end

function string.spacy(str)
if string.find(str,^%s*$) then
return true
else
return false
end
end

function string.alphacmp(a,b,i) -- slow but ok
if i and i  0 then
return string.lower(string.gsub(string.sub(a,i),'0',' '))  string.lower(string.gsub(string.sub(b,i),'0',' '))
else
return string.lower(a)  string.lower(b)
end
end

function table.alphasort(list,i)
table.sort(list, function(a,b) return string.alphacmp(a,b,i) end)
end

function io.exists(filename)
local ok, result, message = pcall(io.open,filename)
if result then
io.close(result)
return true
else
return false
end
end

function os.envvar(str)
if os.getenv(str) ~= '' then
return os.getenv(str)
elseif os.getenv(string.upper(str)) ~= '' then
return os.getenv(string.upper(str))
elseif os.getenv(string.lower(str)) ~= '' then
return os.getenv(string.lower(str))
else
return ''
end
end

function string.expand(str)
return string.gsub(str, ENV%((%w+)%), os.envvar)
end

function string.strip(str)
return string.gsub(string.gsub(str,^%s+,''),%s+$,'')
end

function string.replace(original,pattern,replacement)
local str = string.gsub(original,pattern,replacement)
-- print(str) -- indirect, since else str + nofsubs
return str -- indirect, since else str + nofsubs
end

\stopLUA

% \title{Source Code of the Module}

% \typevimfile[numbering=on,numbercolor=red,step=5]{\jobname.tex}

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


[NTG-context] Problem Passing \starttabulate into Lua

2008-12-27 Thread Tad Ashlock
I'm trying to create a ConTeXt macro (mkiv) that will manipulate the 
macro argument's text with Lua and then feed it back into ConTeXt with 
tex.print().  My approach worked correctly until I called the macro with 
\starttabulate ... \stoptabulate in the macro's argument.  So I started 
reducing the problem down to a minimum example which surprisingly turned 
out to have nothing to do with the manipulations I was performing.


Here is the working example (without \starttabulate):

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
   testing}
\stoptext


Here is the broken example:

\long\def\testmacro#1{\directlua0{d='\luaescapestring{#1}'}}
\starttext
Hello, world!
\testmacro{%
   testing
   \starttabulate
 \NC 0 \NC testing tabulate. \NC \NR
   \stoptabulate}
\stoptext

Here's the output:
=
MtxRun | loading configuration for C:/context/tex/texmf/web2c from 
C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/trees/53ad5f8b88994bdd02baa17501789699
MtxRun | run 1: luatex 
--fmt=C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en 
--lua=C:/context/tex/texmf-cache/luatex-cache/context/2fea56f92e5267d7cc9662e4d5f52e1e/formats/cont-en.lua 
./test.tex

(test.tex

ConTeXt  ver: 2008.10.31 13:58 MKIV  fmt: 2008.12.24  int: english/english

language   : language en is active
system : cont-new loaded
(C:/context/tex/texmf-context/tex/context/base/cont-new.tex
systems : beware: some patches loaded from cont-new.tex
(C:/context/tex/texmf-context/tex/context/base/cont-new.mkiv) 
(C:/context/tex/texmf-context/tex/context/base/cont-mtx.tex))

system : cont-fil loaded
(C:/context/tex/texmf-context/tex/context/base/cont-fil.tex
loading: Context File Synonyms
)
system : cont-sys.rme loaded
(C:/context/tex/texmf-context/tex/context/user/cont-sys.rme 
(C:/context/tex/texmf-context/tex/context/base/type-tmf.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-siz.tex) 
(C:/context/tex/texmf-context/tex/context/base/type-otf.tex))

bodyfont   : 12pt rm is loaded
specials   : pdftex loaded
system : test.top loaded
(test.top) (test.tuo) (test.tuo)
systems: begin file test at line 2
! Argument of \dodoubletestempty has an extra }.
inserted text
   \par
to be read again
  }
\doifnextcharelse ...token =#1\def \!!stringa {#2}
 \def \!!stringb 
{#3}\futur...

argument testing \starttabulate
 \NC 0 \NC testing tabulate. \NC \NR 
\stopt...

\testmacro ...\directlua 0{d='\luaescapestring {#1
 }'}
l.8 \stoptabulate}

?
=

I've tried all sorts of variations on the above example including using 
\ctxlua, \startlua, \startluacode, etc.  I tried using '[[...]]' and 
'[===[...]===]' instead of \luaescapestring.  I tried \def with and 
without \long.  I tried other \start* ... \stop* commands (different 
errors, but still broken).  Plus many more variations.


At this point I'm convinced that there's something fundamental that I'm 
not understanding.  What is the general method for taking any chunk of 
ConTeXt code and passing it into Lua so that it can be written back out 
with tex.print()?


Info: running on Windows XP, SP3 -- ConTeXt: 2008.10.31 -- LuaTeX, 
Version snapshot-0.31.2-2008121200, build 1659


(The older versions of ConTeXt and LuaTeX are necessary because of the 
problem the latest Windows versions are having.  See the Serious Bug? 
thread.)


Thank you,
Tad Ashlock




___
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
___


[NTG-context] passing buffer to lua functions

2008-09-29 Thread Olivier
Dear all,

I'm trying to implement a very simple filter mechanism in lua like this:

\def\test#1{%
  \startlua
local pipe, str
pipe = io.popen(./my_filter '\luaescapestring{#1}', r)
str = pipe:read(*a) 
tex.print(str)
pipe:close()
  \stoplua
}

\test{%
  line 1
  line 2
}

The issue I have is that the argument of test has its line breaks
removed in the process (i.e. the filter my_filter sees a single line
argument).  How to prevent this while keeping the lua escape at the same
time? (I know I can implement such a thing with executecommand and using
buffers written to files, but I would like to avoid writing on the hard disk.)

Olivier
___
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
___


Re: [NTG-context] missing btex ..etex in mp figure

2008-05-17 Thread Hans Hagen
Taco Hoekwater wrote:
 
 luigi scarso wrote:
 In

 \starttext
 \startTEXpage
 \startlua
 metapost.process(metafun,{beginfig(1);,
 a=.7in; b=0.5in;,
 z0=(0,0); z1=(a,0); z2=(0,b);,
 z0=.5[z1,z3]=.5[z2,z4];,
 draw z1..z2..z3..z4..cycle;,
 drawarrow z0..z1;,
 drawarrow z0..z2;,
 label.top(btex $a$ etex, .5[z0,z1]);,
 label.lft(btex $b$ etex, .5[z0,z2]);,
 endfig;})
 \stoplua
 \stopTEXpage
 \stoptext

 there are no labels, but I believe that it's wrong.
 
 The MPlib library embedded in luatex does not actually
 support btex .. etex blocks.
 
 It is planned to intercept such blocks in the mkiv lua
 code, but for now, just use textext().

why not use

\starttext
\startMPpage
a=.7in; b=0.5in;
z0=(0,0); z1=(a,0); z2=(0,b);
z0=.5[z1,z3]=.5[z2,z4];
draw z1..z2..z3..z4..cycle;
drawarrow z0..z1;
drawarrow z0..z2;
label.top(btex $a$ etex, .5[z0,z1]);
label.lft(btex $b$ etex, .5[z0,z2]);
endfig;
\stopMPpage
\stoptext

this uses:

metapost.graphic(mpsformat,str,preamble)

which does intercept the btex/etex


-
   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
___


Re: [NTG-context] missing btex ..etex in mp figure

2008-05-16 Thread Taco Hoekwater


luigi scarso wrote:
 In
 
 \starttext
 \startTEXpage
 \startlua
 metapost.process(metafun,{beginfig(1);,
 a=.7in; b=0.5in;,
 z0=(0,0); z1=(a,0); z2=(0,b);,
 z0=.5[z1,z3]=.5[z2,z4];,
 draw z1..z2..z3..z4..cycle;,
 drawarrow z0..z1;,
 drawarrow z0..z2;,
 label.top(btex $a$ etex, .5[z0,z1]);,
 label.lft(btex $b$ etex, .5[z0,z2]);,
 endfig;})
 \stoplua
 \stopTEXpage
 \stoptext
 
 there are no labels, but I believe that it's wrong.

The MPlib library embedded in luatex does not actually
support btex .. etex blocks.

It is planned to intercept such blocks in the mkiv lua
code, but for now, just use textext().

Best wishes,
Taco

___
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
___


[NTG-context] missing btex ..etex in mp figure

2008-05-15 Thread luigi scarso
In

\starttext
\startTEXpage
\startlua
metapost.process(metafun,{beginfig(1);,
a=.7in; b=0.5in;,
z0=(0,0); z1=(a,0); z2=(0,b);,
z0=.5[z1,z3]=.5[z2,z4];,
draw z1..z2..z3..z4..cycle;,
drawarrow z0..z1;,
drawarrow z0..z2;,
label.top(btex $a$ etex, .5[z0,z1]);,
label.lft(btex $b$ etex, .5[z0,z2]);,
endfig;})
\stoplua
\stopTEXpage
\stoptext

there are no labels, but I believe that it's wrong.


-- 
luigi
it's new .
it's powerful .
it's luatex .
http://www.luatex.org
___
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
___


Re: [NTG-context] mplib

2008-04-23 Thread Wolfgang Werners-Lucchini
Hallo Taco et al
  \startlua
  local function finder(name, mode, ftype)
   if mode==w then
   return name
   else
   return kpse.find_file(name,ftype)
   end
  end
  
  Jein!
  
 
 Try this, a little more elaborate, version of finder:
 
local function finder(name, mode, ftype)
local found
if mode==w then
   found = name
else
   found = kpse.find_file(name,ftype)
end
print(MPlib finder:  .. name ..  -  .. found)
return found
end
 
 maybe that will give a clue.

Example 1: my test file with your finder.
--
MPlib finder: mpost.mp - d:/context/tex/texmf/metapost/base/mpost.mp
MPlib finder: mpost.map - 
MPlib finder: plain.mp - d:/context/tex/texmf/metapost/base/plain.mp
t={
 [log]=This is MetaPost, Version 1.003 (INIMP)  23 APR 2008 07:51 
(mpost.mp(plain.mp\
Preloading the plain mem file, version 0.99),
 [status]=0,
 [term]=This is MetaPost, Version 1.003 (Cweb version 0.40) 
(INIMP)\
 (mpost.mp(plain.mp\
Preloading the plain mem file, version 0.99),
}
MPlib finder: mpost.mem - 
t={
 [log]= )\
Beginning to dump on file mpost.mem\
 (mem=mpost 8.4.23)\
at most 736 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
,
 [status]=0,
 [term]= )\
Beginning to dump on file mpost.mem\
 (mem=mpost 8.4.23)\
at most 736 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
Transcript written on mpost.log.\
,
}
--
found = 
no mpost.mem, no mpost.log

Example 2: my test file with your finder and (wb not w)
--
MPlib finder: mpost.mp - d:/context/tex/texmf/metapost/base/mpost.mp
MPlib finder: mpost.map - 
MPlib finder: plain.mp - d:/context/tex/texmf/metapost/base/plain.mp
t={
 [log]=This is MetaPost, Version 1.003 (INIMP)  23 APR 2008 07:58 
(mpost.mp(plain.mp\
Preloading the plain mem file, version 0.99),
 [status]=0,
 [term]=This is MetaPost, Version 1.003 (Cweb version 0.40) 
(INIMP)\
 (mpost.mp(plain.mp\
Preloading the plain mem file, version 0.99),
}
MPlib finder: mpost.mem - mpost.mem
t={
 [log]= )\
Beginning to dump on file mpost.mem\
 (mem=mpost 8.4.23)\
at most 736 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
,
 [status]=0,
 [term]= )\
Beginning to dump on file mpost.mem\
 (mem=mpost 8.4.23)\
at most 736 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
Transcript written on mpost.log.\
,
}
--
mpost.mem gets written now
but no mpost.log

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


Re: [NTG-context] mplib

2008-04-19 Thread Wolfgang Werners-Lucchini
  \startlua
  local function finder(name, mode, ftype)
   if mode==w then
   return name
   else
   return kpse.find_file(name,ftype)
   end
  end

Jein!

The only file in my tex tree which could play that roule is

cont-en-mpost.mem

in the cache

\tex\texmf-cache\luatex-
cache\context\c80dc1fd5292ec817c6e82c295beaf1e\formats

this file causes from a metapost:process run
and is not overwritten by my example.

So, there is not written any mpost.mem in the whole tree.

Gruß, 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] mplib

2008-04-19 Thread Hans Hagen
Wolfgang Werners-Lucchini wrote:
 \startlua
 local function finder(name, mode, ftype)
  if mode==w then
  return name
  else
  return kpse.find_file(name,ftype)
  end
 end
 
 Jein!
 
 The only file in my tex tree which could play that roule is
 
 cont-en-mpost.mem
 
 in the cache
 
 \tex\texmf-cache\luatex-
 cache\context\c80dc1fd5292ec817c6e82c295beaf1e\formats
 
 this file causes from a metapost:process run
 and is not overwritten by my example.
 
 So, there is not written any mpost.mem in the whole tree.

mkiv adds cont-en infront of the format name, in order to avoid clashes, 
also formats are only created once

Hans

-
   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
___


Re: [NTG-context] mplib

2008-04-19 Thread Taco Hoekwater
Wolfgang Werners-Lucchini wrote:
 \startlua
 local function finder(name, mode, ftype)
  if mode==w then
  return name
  else
  return kpse.find_file(name,ftype)
  end
 end
 
 Jein!
 

Try this, a little more elaborate, version of finder:

   local function finder(name, mode, ftype)
   local found
   if mode==w then
  found = name
   else
  found = kpse.find_file(name,ftype)
   end
   print(MPlib finder:  .. name ..  -  .. found)
   return found
   end

maybe that will give a clue.

Best wishes,
Taco
___
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
___


Re: [NTG-context] mplib

2008-04-18 Thread Wolfgang Werners-Lucchini
)
mkiv lua stats : metapost processing time  - 0.000 seconds, loading: 
0.000 seconds, execution: 0.000 seconds, n: 0
mkiv lua stats : current memory usage  - 50679203 bytes
mkiv lua stats : cleaned up reserved nodes - 16 nodes, 8 lists of 100
mkiv lua stats : node memory usage - 19 glue_spec, 2 dir
mkiv lua stats : loaded patterns   - en:en:pat:exc:2
mkiv lua stats : loaded fonts  - file:lmroman10-
bolditalic*default:otf file:lmroman10-italic*default:otf 
file:lmroman12-bold*default:otf file:lmroman12-italic*default:otf 
file:lmroman12-regular*default:otf file:lmroman7-bold*default:otf 
file:lmroman7-regular*default:otf file:lmroman9-bold*default:otf 
file:lmroman9-italic*default:otf file:lmroman9-regular*default:otf 
file:lmromancaps10-regular*default:otf file:lmromanslant10-
bold*default:otf file:lmromanslant10-regular*default:otf 
file:lmromanslant12-regular*default:otf file:lmromanslant9-
regular*default:otf lmex10:tfm lmmi12:tfm lmmi7:tfm lmmi9:tfm 
lmsy10:tfm lmsy7:tfm lmsy9:tfm msam10:tfm msam7:tfm msbm10:tfm 
msbm7:tfm rm-lmr12:tfm rm-lmr7:tfm rm-lmr9:tfm
mkiv lua stats : runtime   - 1.922 seconds, 1 
processed pages, 1 shipped pages, 0.520 pages/second


LuaTools | running command: luatex --fmt=C:/tex/texmf-cache/luatex-
cache/context/71ddae2d1527093aac63e0e1aa139641/formats/cont-en --
lua=C:/tex/texmf-cache/luatex-
cache/context/71ddae2d1527093aac63e0e1aa139641/formats/cont-en.luc 
mplibtest.tex 
LuaTools | 
LuaTools | runtime: 2.313 secondsTeXUtil | parsing file mplibtest.tui
TeXUtil | shortcuts : 0
TeXUtil | expansions: 0
TeXUtil | reductions: 0
TeXUtil | divisions : 0
TeXUtil | loaded files: 1
TeXUtil | temporary files: 0
TeXUtil | commands: 8
TeXUtil | programs: 0
TeXUtil | tuo file saved
TeXExec | renaming mplibtest.tua into mplibtest.tuc
TeXExec | runtime: 2.406


 
 I tried the same with 'mpost'. This has the advantage that one has
 not to adapt 'plain.mp'.
 
 But here too, there is no 'mpost.mem' and no 'mpost.log'.
 
 I have included a test before and after mp:finish().
 
 Can anybody with a minimal under windows run this example?
 ---
 \starttext
 % start low-level
 \startlua
 local function finder(name, mode, ftype)
  if mode==w then
  return name
  else
  return kpse.find_file(name,ftype)
  end
 end
 mp = mplib.new ( {
  hash_size = 10,
  main_memory = 200,
  param_size = 10,
  find_file = finder,
  ini_version = true
 } )
 if mp then
  res = mp:execute(mpost)
  tex.print([ .. tostring(res.status) .. ])
  print(table.serialize(res))
  if io.open(mpost.mem,r) then
print(found)
  else
print(nothing)
  end
  res = mp:finish()
  print(table.serialize(res))
  if io.open(mpost.mem,r) then
print(found)
  else
print(nothing)
  end
 end
 \stoplua
 % stop low-level
 \stoptext
 ---
 
Grusz, 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] mplib

2008-04-16 Thread Wolfgang Werners-Lucchini
On 16 Apr 2008 at 1:52, [EMAIL PROTECTED] wrote:

Hallo,

  (I have temporary appended 'dump;' to plain.mp)
  After the above, you should have plain.mem in the local
 directory.
  
  No.
  There is neither a 'plain.fmt' nor a 'plain.mem'!
 
 Everything I read below says there should be a 'plain.mem'
 in the folder where you ran theat file in.  If there
 really really isn't, then my only advise to you is to buy
 a less thieving operating system, as it seems this one steals
 your files before you can even have an admiring look at them. :-)

I tried the same with 'mpost'. This has the advantage that one has 
not to adapt 'plain.mp'.

But here too, there is no 'mpost.mem' and no 'mpost.log'.

I have included a test before and after mp:finish().

Can anybody with a minimal under windows run this example?
---
\starttext
% start low-level
\startlua
local function finder(name, mode, ftype)
 if mode==w then
 return name
 else
 return kpse.find_file(name,ftype)
 end
end
mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 find_file = finder,
 ini_version = true
} )
if mp then
 res = mp:execute(mpost)
 tex.print([ .. tostring(res.status) .. ])
 print(table.serialize(res))
 if io.open(mpost.mem,r) then
   print(found)
 else
   print(nothing)
 end
 res = mp:finish()
 print(table.serialize(res))
 if io.open(mpost.mem,r) then
   print(found)
 else
   print(nothing)
 end
end
\stoplua
% stop low-level
\stoptext
---

Gruß, 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Unable to generate luatex formats

2008-04-15 Thread John Devereux
Mojca Miklavec [EMAIL PROTECTED] writes:

 On Tue, Apr 15, 2008 at 1:25 PM, John Devereux wrote:

 Mojca Miklavec writes:

Setting TEXMF was missing from the instructions in debian... Or perhaps 
 I
messed up my configuration in the past.
  
 luatools --ini --compile cont-en
  
works now.
  
I will start playing with it.
  
A quick try of the example snippet did not work (see dump at end of
message) but I will look into it more and try Mojcas advice re
ctxtools --update.
  
   ctxtools --update won't help you as you have some missing fonts 
 (msam7.tfm).
   http://packages.debian.org/etch/all/texlive-base/filelist claims that
   the file should be present in texlive-base in Debian, so it's a bit
   confusing.
  
   Mojca

  Hi Mojca,

  There is a file here:

   /usr/share/texmf-texlive/fonts/tfm/public/ams/msam7.tfm

  But I don't know what else is needed.

 I would say that the installation might be slightly broken, even if
 only a few variables are missing. How exactly did you install LuaTeX
 and latest ConTeXt?

Mojca,

I followed the instructions here, where applicable for debian sid:

http://wiki.contextgarden.net/Debian_installation

Then the instruction in the README.MarkIV that appeared in the pckage
documentation directory (appended to end of post).

However I have been using context for years, and may well have messed
something up! It seems to work OK with my normal documents. Except I
notice \usemodule[gnuplot] does not work.

John

  Setting TEXMF was missing from the instructions in debian...

 This should not happen, but once you answer the question about how you
 have installed it, it might become clearer.

 Some time ago there was some problem on debian since Hans's lua
 scripts were unable to parse TEXMFCNF (texmf.cnf) files properly, but
 this might have been resolved in the meantime.



README.luatex
=

Mark IV is the name of the LuaTeX-aware part of ConTeXt; that is, when you
use ConTeXt over the LuaTeX engine instead of PDFTeX or XeTeX. You run it
with texexec --lua.

Currently the integration of Mark IV into Debian is not completely done,
especially because the details are currently worked out (see the dev-context
mailing list).

If you want to start using Mark IV the following the following few points
should get you started:

1) Right versions:
luatex = 0.20.2
context = 2007.12.20

2) environment variables and luatex-cache
   Mark IV ships its own implementation of file searching and doesn't
   use the ls-R databases, but luatex-cache. You have to tell luatools
   where to find texmf.cnf, and then generate the cache:
export TEXMFCNF=/usr/share/texmf/web2c
luatools --generate --verbose
   This will generate the luatex-cache in $HOME. If you want to put it
   somewhere else set (and export) the TEXMFCACHE variable (like
   export TEXMFCACHE=/tmp)

3) Generate a Mark IV format
   This is not integrated into the usual format building process, and 
   probably will need some time to be worked out completely as the 
   current fmtutil cannot cope with Mark IV formats. Call
luatools --ini --compile cont-en

4) Now you can try some simple document like (thanks to Arthur Reutenauer)
\starttext

\ctxlua{a = 1.5 ; b = 1.8 ; c = a*b ; tex.print(c) ;}
or the equivalent:
\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua

You can also do more elaborate calculations with the lua math library:
\ctxlua{tex.print($\string\\sqrt{2} =  .. math.sqrt(2) .. $)}

\stoptext
  and run it with
texexec --lua filename.tex


-- 

John Devereux
___
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
___


Re: [NTG-context] Unable to generate luatex formats

2008-04-15 Thread Hans van der Meer
On 15 apr 2008, at 14:52, John Devereux wrote:

 4) Now you can try some simple document like (thanks to Arthur  
 Reutenauer)
   \starttext
 some statements deleted 

   \startlua
   a = 1.5
   b = 1.8
   c = a*b
   tex.print(c)
   \stoplua
   \stoptext
  and run it with
   texexec --lua filename.tex

Not true. This code used to work, it DID WORK. But now it gives an  
error:
system : cont-sys loaded
(/Users/hans/TeX/texmf-private/tex/context/user/cont-sys.tex
! Undefined control sequence.
l.182 \forceMPTEXgraphictrue

ConTeXt  ver: 2008.04.11 00:07 MKIV  fmt: 2008.4.14  int: english/ 
english

I am not happy to see something so simple now being broken!!

Hans van der Meer

___
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
___


Re: [NTG-context] Unable to generate luatex formats

2008-04-15 Thread Hans Hagen
Hans van der Meer wrote:
 On 15 apr 2008, at 14:52, John Devereux wrote:
 
 4) Now you can try some simple document like (thanks to Arthur  
 Reutenauer)
  \starttext
 . some statements deleted 
  \startlua
  a = 1.5
  b = 1.8
  c = a*b
  tex.print(c)
  \stoplua
  \stoptext
  and run it with
  texexec --lua filename.tex
 
 Not true. This code used to work, it DID WORK. But now it gives an  
 error:
 system : cont-sys loaded
 (/Users/hans/TeX/texmf-private/tex/context/user/cont-sys.tex
 ! Undefined control sequence.
 l.182 \forceMPTEXgraphictrue
 
 ConTeXt  ver: 2008.04.11 00:07 MKIV  fmt: 2008.4.14  int: english/ 
 english
 
 I am not happy to see something so simple now being broken!!

the upcoming release will

\let\forceMPTEXgraphictrue\relax

actually nothin gis really broken, it's just that supp-mps is no longer 
used in mkiv and so we have to provide placeholders (the less the better)

Hans

-
   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
___


Re: [NTG-context] mplib

2008-04-15 Thread Wolfgang Werners-Lucchini
On 15 Apr 2008 at 13:31, [EMAIL PROTECTED] wrote:

Hallo Taco,

  (I have temporary appended 'dump;' to plain.mp)
 
 After the above, you should have plain.mem in the local directory.

No.
There is neither a 'plain.fmt' nor a 'plain.mem'!

I have searched in the local directory, where it should be.
It is not in 'D:\context\tex\texmf-mswin\web2c' where format-files 
usally exist.
It is not in the cache.

I run this:
---
\enableregime[utf-8]
\starttext
% start low-level
\startlua
local function finder(name, mode, ftype)
 if mode==w then
 return name
 else
 return kpse.find_file(name,ftype)
 end
end
mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 find_file = finder,
 ini_version = true
} )
if mp then
 res = mp:execute(plain)
 print(table.serialize(res))
 res = mp:finish()
 print(table.serialize(res))
end
\stoplua
% stop low-level
\stoptext
---

with the following output:

---
t={
 [log]=This is MetaPost, Version 1.003 (INIMP)  15 APR 2008 21:00 
(plain.mpPreloading the plain mem file, version 0.99,
 [status]=0,
 [term]=This is MetaPost, Version 1.003 (Cweb version 0.40) 
(INIMP)\
 (plain.mpPreloading the plain mem file, version 0.99,
}
t={
 [log]= )\
Beginning to dump on file plain.mem\
 (mem=plain 8.4.15)\
at most 735 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
,
 [status]=0,
 [term]= )\
Beginning to dump on file plain.mem\
 (mem=plain 8.4.15)\
at most 735 strings of total length 3629\
3326 memory locations dumped; current usage is 10212227\
501 symbolic tokens\
Transcript written on plain.log.\
,
}
---

Can you see, what I am missing?

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


Re: [NTG-context] mplib

2008-04-14 Thread Wolfgang Werners-Lucchini
On 13 Apr 2008 at 13:31, [EMAIL PROTECTED] wrote:

Hallo Taco,

thank you for your example.

 % start low-level
 \startlua
 local function finder(name, mode, ftype)
  if mode==w then
  return name
  else
  return kpse.find_file(name,ftype)
  end
 end
 mp = mplib.new ( {
  hash_size = 10,
  main_memory = 200,
  param_size = 10,
  find_file = finder,
  ini_version = true
 } )
 if mp then
  res = mp:execute('plain')
  mp:finish()
 end

this first step runs with res=0, but there is no 'plain.mem' dumped.
(I have temporary appended 'dump;' to plain.mp)
this first step runs with res=0 with mp:execute('mpost'), but no 
'mpost.mem'
the first step even runs with res=0 and mp:execute('\\plain; dump;'), 
but no 'plain.mem'

after that I produced 'plain.mem' executing
'texmfstart texexec --make plain'

 
 mp = mplib.new ( {
  hash_size = 10,
  main_memory = 200,
  param_size = 10,
  find_file = finder,
 } )
 
 if mp then
  res = mp:execute(
 \\beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye; )
  tex.print([ .. tostring(res.status) .. ])
  mp:finish()
 end
 \stoplua
 % stop low-level
 

this second step returns res=3.

Is there a find_file function necessary to find the mem-file given in 
'mem_name' or is such a function only necessary for file-names in 
'mp:execute'?

Wolfgang

-- 
Musensturm-Verlag -- Postfach 1249 -- 36126 Gersfeld 
 http://www.musensturm.de

___
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
___


Re: [NTG-context] mplib

2008-04-13 Thread Taco Hoekwater
Wolfgang Werners-Lucchini wrote:
 On 12 Apr 2008 at 9:39, [EMAIL PROTECTED] wrote:
 
 \startlua
 mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 } )

 if mp then
 res = mp:execute(
 beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye; )
 tex.print([ .. tostring(res.status) .. ])
 mp:finish()
 end
 \stoplua
 no format, so beginfig, draw etc are unknown
 
 I thought 'plain.mem' is the default. But I see, there exists only 
 'metafun.mem'.

If you want to do the low-level thing, you have to read the
luatex manual carefully. MPlib is just like standalone metapost
in that it wants to load a mem file in non-ini mode, and that
file has to be generated before being used. Here is what you
wanted to do, using just the library core (I did cheat just a
little bit though, I added dump; at the end of my plain.mp):

% start low-level
\startlua
local function finder(name, mode, ftype)
 if mode==w then
 return name
 else
 return kpse.find_file(name,ftype)
 end
end
mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 find_file = finder,
 ini_version = true
} )
if mp then
 res = mp:execute('plain')
 mp:finish()
end

mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 find_file = finder,
} )

if mp then
 res = mp:execute(\\beginfig(1) draw (0,0) .. (1,1) .. (2,1); 
endfig; bye; )
 tex.print([ .. tostring(res.status) .. ])
 mp:finish()
end
\stoplua
% stop low-level

If you just want to run plain metapost images inside of
a context document (instead of metafun), it is much easier
to use Hans' high-level API (once again, you need dump;
at the end of plain.mp):

\startlua
metapost.process(
   metapost.format(plain),
   beginfig(0); draw (0,0) .. (1,1) .. (2,1); endfig;)
\stoplua

This makes sure that all memory values are the same,
that the mem file is cached inbetween runs, removes the
need for \\ and bye; etc.

Best wishes,
Taco
___
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
___


Re: [NTG-context] mplib

2008-04-12 Thread Hans Hagen
Wolfgang Werners-Lucchini wrote:
 Hallo,
 
 the following compiles ok, but gives me an status 3=fatal error.
 Can someone please point me to the error?
 
 \startlua
 mp = mplib.new ( {
 hash_size = 10,
 main_memory = 200,
 param_size = 10,
 } )
 
 if mp then
 res = mp:execute(
 beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye; )
 tex.print([ .. tostring(res.status) .. ])
 mp:finish()
 end
 \stoplua

no format, so beginfig, draw etc are unknown

metapost.process(metafun,some commands)

may work better

-
   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
___


Re: [NTG-context] mplib

2008-04-12 Thread Wolfgang Werners-Lucchini
On 12 Apr 2008 at 9:39, [EMAIL PROTECTED] wrote:

  \startlua
  mp = mplib.new ( {
  hash_size = 10,
  main_memory = 200,
  param_size = 10,
  } )
  
  if mp then
  res = mp:execute(
  beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye; )
  tex.print([ .. tostring(res.status) .. ])
  mp:finish()
  end
  \stoplua
 
 no format, so beginfig, draw etc are unknown

I thought 'plain.mem' is the default. But I see, there exists only 
'metafun.mem'.

So I  wrote:
--
mp = mplib.new ( {
hash_size = 10,
main_memory = 200,
param_size = 10,
mem_name = metafun.mem
} )
--
and it get the same result

 metapost.process(metafun,some commands)
 
 may work better
--
\startlua
mp = mplib.new ( {
hash_size = 10,
main_memory = 200,
param_size = 10
} )

if mp then
res = metapost.process(metafun,beginfig(1) draw (0,0) .. (1,1) 
.. (2,1); endfig; bye;)
tex.print([ .. tostring(res.status) .. ])
mp:finish()
end
\stoplua
--

results in :

--
mplib  : loading format: metafun.mp, name: 
d:/context/tex/texmf-cache/luatex-
cache/context/c80dc1fd5292ec817c6e82c295beaf1e/formats/cont-en-
metafun.mem
! Emergency stop.
\@@expanded . ])
-- mp:finish()
-- end
}
  
l.54 \stoplua
 
!  == Fatal error occurred, no output PDF file produced!
--

why does it load 'metafun.mp'?


after that I tried

--
\startlua
mp = mplib.new ( {
hash_size = 10,
main_memory = 200,
param_size = 10,
mem_name = metafun.mem
} )

if mp then
res = metapost.process(mp,
 beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye;)
tex.print([ .. tostring(res.status) .. ])
mp:finish()
end
\stoplua
--

which gives the following error:

--
report  error: This is MetaPost, Version 1.003 (Cweb version 0.40)

I can't find the PLAIN mem file!
--


What else should I check to find the error?

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


[NTG-context] mplib

2008-04-11 Thread Wolfgang Werners-Lucchini
Hallo,

the following compiles ok, but gives me an status 3=fatal error.
Can someone please point me to the error?

\startlua
mp = mplib.new ( {
hash_size = 10,
main_memory = 200,
param_size = 10,
} )

if mp then
res = mp:execute(
beginfig(1) draw (0,0) .. (1,1) .. (2,1); endfig; bye; )
tex.print([ .. tostring(res.status) .. ])
mp:finish()
end
\stoplua

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


[NTG-context] Bibliography and luatex

2008-01-16 Thread Jean Magnan de Bornier
Hi all,

Using luatex from the minimals at minimals.contextgarden.net (linux), I am
unable to have bibtex working: here is a minimal example:
..
\usemodule[bib]
\usemodule[bibltx]
\setupbibtex [database=/home/jean/BIB/biblio.bib]
 \setuppublications[]
\setuppublicationlist[]
\setupcite[]
\starttext
Bonjour de luatex!
\blank
LUA  \cite[year][destv]
\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua
\completepublications[criterium=all]
\stoptext
..

I see this in the messages:

publications   : warning: cite argument destv is unknown on 139

pdftex and xetex engines find it without problem.

What did I miss?
-- 
Jean
___
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
___


Re: [NTG-context] Bibliography and luatex

2008-01-16 Thread Jean Magnan de Bornier
Le 16 janvier à 22:43:28 Thomas A. Schmitz [EMAIL PROTECTED] écrit 
notamment:

| I have successfully used the bib module with luatex, but I had to run  
| bibtex manually on the file once. Have you tried that?

| Thomas

Well thanks! I did it but still the same; besides I saw this in the blg
file:
This is BibTeX, Version 0.99c (Web2C 7.5.6)
The top-level auxiliary file: taist.aux
I couldn't open style file cont-no.bst

but this file is there and readable by any user!?!

| On Jan 16, 2008, at 7:56 PM, Jean Magnan de Bornier wrote:

|  Hi all,
| 
|  Using luatex from the minimals at minimals.contextgarden.net  
|  (linux), I am
|  unable to have bibtex working: here is a minimal example:
|  ..
|  \usemodule[bib]
|  \usemodule[bibltx]
|  \setupbibtex [database=/home/jean/BIB/biblio.bib]
|  \setuppublications[]
|  \setuppublicationlist[]
|  \setupcite[]
|  \starttext
|  Bonjour de luatex!
|  \blank
|  LUA  \cite[year][destv]
|  \startlua
|  a = 1.5
|  b = 1.8
|  c = a*b
|  tex.print(c)
|  \stoplua
|  \completepublications[criterium=all]
|  \stoptext
|  ..
| 
|  I see this in the messages:
| 
|  publications   : warning: cite argument destv is unknown on 139
| 
|  pdftex and xetex engines find it without problem.
| 
|  What did I miss?
|  -- 
|  Jean
|  
___
|  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
| 
___


-- 
Jean
___
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
___


[NTG-context] 'TeX capacity exceeded' problem

2007-10-11 Thread Jeong Dalyoung
Dear all,

Finally, luatools is working(gwTeX, Mac OSX  10.4).

Following the instruction given by Thomas, I succeeded to run  
'luatools --generate'
but I got an error when I run 'luatools --ini --compile --verbose  
cont-en'.
There is a memory problem for the languages.
Following the suggestion, I add a line 'trie_size = 40' at the  
end of texmf.cnf in the folder /usr/local/gwTeX/texmf.cnf.
After that  'luatools --ini --compile --verbose cont-en' is running  
without error and the format file is created in the folder /tmp/ 
luatex-cache/context/...

I test it using a simple file like
\starttext
some texts
\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua
\stoptext

and it was working nicely.


But when I tested a sample file in the wiki,

\usetypescript[palatino]
\setupbodyfont[palatino,12pt]
\starttext
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek
\stoptext

I got a fatal error. Here are some lines in log file.

.
(/usr/local/gwTeX/texmf.pkgs/tex/context/base/type-siz.tex) (/usr/ 
local/gwTeX/texmf.pkgs/tex/context/base/type-otf.tex) (/usr/local/ 
gwTeX/texmf.pkgs/tex/context/base/type-tmf.tex) (/usr/local/gwTeX/ 
texmf.pkgs/tex/context/base/type-siz.tex
! TeX capacity exceeded, sorry [parameter stack size=60].
\donormalizedbodyfontsize #1.#2#3#4\to #5-
\edef #5{#1\ifcase  
\fontdigits \o...
\docommand ...\scratchdimen \to \tempbodyfontsize
   \setevalue {\??ft  
\fontcla...
\next7 #1,-\docommand {#1}
\doprocesscommaitem
argument \relax text,
script,scriptscript,x,xx,big,small
\doprocesscommalist ...aitem \gobbleoneargument #1
   ,]\relax \global  
\advance ...
argument ...acommand [\fontsizelist ]\docommand
   \copyparameters  
[\??ft \fo...
...
l.22 \stoptypescript


node memory in use: 1601 words out of 100604 (98904 untouched)
currently available: 1:3, 2:9, 3:3, 4:7, 6:4, 8:2 nodes
!  == Fatal error occurred, no output PDF file produced!


Would you please tell me what is wrong here?

Thank you.

Best regards,

Dalyoung
___
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
___


Re: [NTG-context] 'TeX capacity exceeded' problem

2007-10-11 Thread Hans Hagen
Jeong Dalyoung wrote:
 Dear all,
 
 Finally, luatools is working(gwTeX, Mac OSX  10.4).
 
 Following the instruction given by Thomas, I succeeded to run  
 'luatools --generate'
 but I got an error when I run 'luatools --ini --compile --verbose  
 cont-en'.
 There is a memory problem for the languages.
 Following the suggestion, I add a line 'trie_size = 40' at the  
 end of texmf.cnf in the folder /usr/local/gwTeX/texmf.cnf.
 After that  'luatools --ini --compile --verbose cont-en' is running  
 without error and the format file is created in the folder /tmp/ 
 luatex-cache/context/...
 
 I test it using a simple file like
 \starttext
 some texts
 \startlua
 a = 1.5
 b = 1.8
 c = a*b
 tex.print(c)
 \stoplua
 \stoptext
 
 and it was working nicely.

problems like this will go away with the next release, since mkiv will 
load patterns at runtime (smaller format, faster loading of format, 
faster generation of format, neglectable load time of patterns at runtime)

 ..
 (/usr/local/gwTeX/texmf.pkgs/tex/context/base/type-siz.tex) (/usr/ 
 local/gwTeX/texmf.pkgs/tex/context/base/type-otf.tex) (/usr/local/ 
 gwTeX/texmf.pkgs/tex/context/base/type-tmf.tex) (/usr/local/gwTeX/ 
 texmf.pkgs/tex/context/base/type-siz.tex
 ! TeX capacity exceeded, sorry [parameter stack size=60].

strange ... looks like the config file is not read (generated by luatools)

Hans

-
   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
___


[NTG-context] Installing MKiv

2007-08-12 Thread Jean Magnan de Bornier
Hi all, Following nice reports I read on the list as well as the mag-12
instructions I installed a context minimal linux distribution and
lua-5.1.2.  After everything seemed ok I lauch a compilation of this
test-file (found on the wiki):

% engine=luatex
\starttext
Hello from luatex
\blank
LUA
\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua
\stoptext

But no pdf file appears, and here are some (hopefully) relevant parts of the
compilation message:

TeXExec | unable to fix backend map path
TeXExec | running: luatools --fmt=cont-en test.tex

LuaTools | using format name /cont-en.fmt
LuaTools | no luc/lua with name /cont-en
LuaTools |
LuaTools | runtime: 0.09 seconds
TeXUtil | unable to locate test.tui

I do have cont-en.luc and cont-en.lua!

tia 
-- 
Jean
___
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
___


Re: [NTG-context] Installing MKiv

2007-08-12 Thread luigi scarso
 Hi all, Following nice reports I read on the list as well as the mag-12
 instructions I installed a context minimal linux distribution and
 lua-5.1.2.
hmm, try
http://www.lua.org/ftp/lua-5.1.tar.gz

 % engine=luatex
 \starttext
 Hello from luatex
 \blank
 LUA
 \startlua
 a = 1.5
 b = 1.8
 c = a*b
 tex.print(c)
 \stoplua
 \stoptext
on a linux box
$texmfstart texexec --pdf test.tex
compile well.
Are you under linux ?


-- 
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
___


Re: [NTG-context] Installing MKiv

2007-08-12 Thread Hans Hagen
Jean Magnan de Bornier wrote:
 Hi all, Following nice reports I read on the list as well as the mag-12
 instructions I installed a context minimal linux distribution and
 lua-5.1.2.  After everything seemed ok I lauch a compilation of this
 test-file (found on the wiki):
 
 % engine=luatex
 \starttext
 Hello from luatex
 \blank
 LUA
 \startlua
 a = 1.5
 b = 1.8
 c = a*b
 tex.print(c)
 \stoplua
 \stoptext
 
 But no pdf file appears, and here are some (hopefully) relevant parts of the
 compilation message:
 
 TeXExec | unable to fix backend map path
 TeXExec | running: luatools --fmt=cont-en test.tex
 
 LuaTools | using format name /cont-en.fmt
 LuaTools | no luc/lua with name /cont-en

can you try with

set TEXMFCACHE=c:\temp

(remake formats)

-
   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
___


Re: [NTG-context] Installing MKiv

2007-08-12 Thread Jean Magnan de Bornier
luigi wrote:
|  Hi all, Following nice reports I read on the list as well as the mag-12
|  instructions I installed a context minimal linux distribution and
|  lua-5.1.2.
| hmm, try
| http://www.lua.org/ftp/lua-5.1.tar.gz

|  % engine=luatex
|  \starttext
|  Hello from luatex
|  \blank
|  LUA
|  \startlua
|  a = 1.5
|  b = 1.8
|  c = a*b
|  tex.print(c)
|  \stoplua
|  \stoptext
| on a linux box
| $texmfstart texexec --pdf test.tex
| compile well.
| Are you under linux ?

Yes, I ought to have said that first!!

Now here is what I tried just now:

1/ reinstall lua by hand
2/ remove everything in /usr/local context, and unzip again justtex and
linuxtex
3/ rename /usr/local/texlive to some name unknown from my path (surely
wasn't necessary, but let's try anything...)
4/ edit setuptex and defined $TMP and $TEXMFCACHE there
5/ . setuptex
6/ texexec --make --all --pdftex
7 /texexec --make --all --xetex
8/ texexec --make --all --luatex
9/ luatools --generate
10/ luatools --ini --compile --verbose cont-en

And again, context complains the same way:

TeXExec | unable to fix backend map path
TeXExec | running: luatools --fmt=cont-en test.tex

LuaTools | using format name /tmp/luatex-cache/context/formats/cont-en.fmt
LuaTools | no luc/lua with name /tmp/luatex-cache/context/formats/cont-en
LuaTools |
LuaTools | runtime: 0.12 seconds
TeXUtil | unable to locate test.tui

actually then, even pdftex is broken!

I'm certainly missing something obvious?
-- 
Jean
___
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
___


Re: [NTG-context] Installing MKiv

2007-08-12 Thread luigi scarso
On 8/12/07, Jean Magnan de Bornier [EMAIL PROTECTED] wrote:
 luigi wrote:
 |  Hi all, Following nice reports I read on the list as well as the mag-12
 |  instructions I installed a context minimal linux distribution and
 |  lua-5.1.2.
 | hmm, try
 | http://www.lua.org/ftp/lua-5.1.tar.gz
 
 |  % engine=luatex
 |  \starttext
 |  Hello from luatex
 |  \blank
 |  LUA
 |  \startlua
 |  a = 1.5
 |  b = 1.8
 |  c = a*b
 |  tex.print(c)
 |  \stoplua
 |  \stoptext
 | on a linux box
 | $texmfstart texexec --pdf test.tex
 | compile well.
 | Are you under linux ?

 Yes, I ought to have said that first!!

 Now here is what I tried just now:

 1/ reinstall lua by hand
 2/ remove everything in /usr/local context, and unzip again justtex and
 linuxtex
 3/ rename /usr/local/texlive to some name unknown from my path (surely
 wasn't necessary, but let's try anything...)
 4/ edit setuptex and defined $TMP and $TEXMFCACHE there
 5/ . setuptex
 6/ texexec --make --all --pdftex
 7 /texexec --make --all --xetex
 8/ texexec --make --all --luatex
 9/ luatools --generate
 10/ luatools --ini --compile --verbose cont-en

 And again, context complains the same way:

 TeXExec | unable to fix backend map path
 TeXExec | running: luatools --fmt=cont-en test.tex

 LuaTools | using format name /tmp/luatex-cache/context/formats/cont-en.fmt
 LuaTools | no luc/lua with name /tmp/luatex-cache/context/formats/cont-en
 LuaTools |
 LuaTools | runtime: 0.12 seconds
 TeXUtil | unable to locate test.tui

 actually then, even pdftex is broken!

 I'm certainly missing something obvious?
hmm maybe mktexlsr
5a/ mktexlsr ; luatools --generate
6/ texmfstart texexec --make --all --pdftex
7/ texmfstart texexec --make --all --luatoolss
-- 
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
___


Re: [NTG-context] luac-texluac-luatex-texlua-...

2007-08-08 Thread WN
Hi,

What I did on Ubuntu 7.04 (bash shell) was this

downloaded justtex.zip and linuxtex.zip from pragma
and unzipped them in my home directory.

uncommented all the unset commands in setuptex

downloaded luatex and the lua compiler i.e luac (found it via google)
I think from www.luatex.org and from www.lua.org. I read on the mailing list
that you don't need to download them as everything is self contained in 
the distro.

set the unix variable TMP to /TMP (export TMP=/tmp)
set the unix variable TEXMFCACHE to TMP (export TEXMFCACHE=/tmp)
I think the last step was not needed because the luatools script will 
set it to $TMP

and rename the lua scripts luatools.lua and mtxrun.lua
(from the scripts/lua directory) to their extension less counterparts and
moved them to the texmf-linux/bin directory.  Also did a chmod 755 on them
to make them executable.

I also made a copy of luatex and named it texlua and put it in the 
texmf-linux/bin
directory.

Then after reading the MyWay on MKIV I did a texexec --make --all --luatex
to generate the formats and ran succesfully the following tex script and 
produced a pdf file.

% engine=luatex
\starttext
Hello from luatex
\blank
LUA
\startlua
a = 1.5
b = 1.8
c = a*b
tex.print(c)
\stoplua
\stoptext

Could be that I forgot some steps but this is what I remember.
Hope it helps

Kind regards
Wim



 Hello,

 It is silly, but luatools urges me to have luac or texluac files, while the 
 magazine tells only about luatex/texlua. It seems like luac not is the same 
 as luatex, so I'm in despair because don't know where to get those additional 
 files. 

 // from luatools.lua //
 function utils.lua.compile(luafile, lucfile)
  -- utils.report(compiling,luafile,into,lucfile)
 os.remove(lucfile)
 local command = -s -o  .. string.quote(lucfile) ..   .. 
 string.quote(luafile)
 if os.execute(texluac  .. command) == 0 then
 return true
 elseif os.execute(luac  .. command) == 0 then
 return true
 else
 return false
 end
 end

   

___
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
___