Re: [NTG-context] accessing tex.sprint from pure Lua code.

2022-08-30 Thread Hans Hagen via ntg-context

On 8/30/2022 8:02 PM, Hans van der Meer wrote:

In Terminal (say Unix window) calling

lua some-file.lua

and within that file code like
tex.sprint ...
token...

Thus calling in the tex-library outside ConTeXt.
no, tex is not a library .. but of course you can make a small tex file 
that wraps your lua and run that file with context


keep in mind that tex is a ecosystem: fotns, languages etc

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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] accessing tex.sprint from pure Lua code.

2022-08-30 Thread Hans Hagen via ntg-context

On 8/30/2022 7:34 PM, Hans van der Meer via ntg-context wrote:

How can ik access the tex library in pure Lua for tex.sprint and token.setmacro?
I guess something like
require XYZ
?

what do you mean with pure lua

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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] accessing tex.sprint from pure Lua code.

2022-08-30 Thread Hans van der Meer via ntg-context
How can ik access the tex library in pure Lua for tex.sprint and token.setmacro?
I guess something like
require XYZ
?

dr. 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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Parallel texts: verse with blanks between stanzas via tabulate

2022-08-30 Thread Denis Maier via ntg-context
> -Ursprüngliche Nachricht-
> Von: Hans Hagen 
> Gesendet: Dienstag, 30. August 2022 14:31
> An: Maier, Denis Christian (UB) ; mailing list for
> ConTeXt users 
> Betreff: Re: AW: [NTG-context] Parallel texts: verse with blanks between
> stanzas via tabulate
> 
> On 8/30/2022 1:40 PM, denis.ma...@unibe.ch wrote:
> 
> > Thanks for the updated version. So, that means the basic restriction
> > is that blanks will need to be inserted between rows, right? We cannot
> > have to two completely independent formatted poems, right? (For
> > reference, see the attached PNG. This was done with paragraphs, and
> > works as longs as this stays on a single page. One is one long stanza,
> > the other one consists of multiple smaller stanzas.)
> You need to be more prececise in defining what you want .. this example is not
> a parallel obe right? Just two columns.
> 

Sorry for not being precise enough.

I'm not sure I understand. This example shows two poems side by side. Both are 
totally different in structure. One has a heading, and consists of multiple 
paragraphs. The other is just one long stanza. Until now, I've used tabulate 
for these kind of sidebyside texts. Usually there are not poems, just regular 
paragraphs, but with poems I've realized that blanks seem not be supported in 
individual table cells.

Denis

\startbuffer[lines1]
\startlines[inbetween={\blank}]
this
is
a
poem
with
one 
longer 
stanza
\stoplines
\stopbuffer

\startbuffer[lines2]
\startlines[inbetween={\blank}]
this
is
a
poem

with
some
stanzas

here is 
another one

and another one
\stoplines
\stopbuffer

\starttext

Just the buffers.

One:

\getbuffer[lines1]

Two:

\getbuffer[lines2]


Via paragraphs

\defineparagraphs[paraverse][n=2 ]
\setupparagraphs[paraverse][1][
   width=.45\textwidth, distance=2em,
   align={verytolerant,stretch}]

\startparaverse
\getbuffer[lines1]
\nextparaverse
\getbuffer[lines2]
\stopparaverse

Via tabulate
\starttabulate[|p|p|]
\NC \getbuffer[lines1]
\NC \getbuffer[lines2]
\NC\NR
\stoptabulate

\stoptext

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Parallel texts: verse with blanks between stanzas via tabulate

2022-08-30 Thread Hans Hagen via ntg-context

On 8/30/2022 1:40 PM, denis.ma...@unibe.ch wrote:


Thanks for the updated version. So, that means the basic restriction is that 
blanks will need to be inserted between rows, right? We cannot have to two 
completely independent formatted poems, right? (For reference, see the attached 
PNG. This was done with paragraphs, and works as longs as this stays on a 
single page. One is one long stanza, the other one consists of multiple smaller 
stanzas.)
You need to be more prececise in defining what you want .. this example 
is not a parallel obe right? Just two columns.


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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Parallel texts: verse with blanks between stanzas via tabulate

2022-08-30 Thread Denis Maier via ntg-context
> -Ursprüngliche Nachricht-

> Von: ntg-context 
> mailto:ntg-context-boun...@ntg.nl>> Im Auftrag 
> von Hans Hagen

> via ntg-context

> Gesendet: Montag, 29. August 2022 13:58

> An: ntg-context@ntg.nl

> Cc: Hans Hagen mailto:j.ha...@xs4all.nl>>

> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas

> via tabulate

>

> On 8/29/2022 1:31 PM, Denis Maier via ntg-context wrote:

> >> -Ursprüngliche Nachricht-

> >> Von: Hans Hagen mailto:j.ha...@freedom.nl>>

> >> Gesendet: Sonntag, 28. August 2022 10:41

> >> An: mailing list for ConTeXt users 
> >> mailto:ntg-context@ntg.nl>>

> >> Cc: Maier, Denis Christian (UB) 
> >> mailto:denis.ma...@unibe.ch>>

> >> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between

> >> stanzas via tabulate

> >>

> >> On 8/27/2022 11:25 PM, Denis Maier via ntg-context wrote:

> >>> Thanks, Wolfgang. That gives me a blank between the verses. However

> >>> the

> >> blank is rather huge and I don't see how I could make it smaller? Is

> >> it possible to do this?

> >> morning exercise attached (you can run the file)

> >>

> >> Hans

> >

> > Another, more general question on this: why is the function

> poetry.sidebyside defined twice? If I understand correctly, depending on the

> input one or the other will be used, but I don't see where that happens...

> the first can be commented as it is the first simple variant

>



I see.



Thanks for the updated version. So, that means the basic restriction is that 
blanks will need to be inserted between rows, right? We cannot have to two 
completely independent formatted poems, right? (For reference, see the attached 
PNG. This was done with paragraphs, and works as longs as this stays on a 
single page. One is one long stanza, the other one consists of multiple smaller 
stanzas.)



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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Merging two lua tables

2022-08-30 Thread BPJ via ntg-context
Come to think of it you may also want to check that numeric indices are
indeed positive integers before appending their value. I usually don't
because their not being so is rare.

Den tis 30 aug. 2022 10:56BPJ  skrev:

>
>
> Den mån 29 aug. 2022 20:13Hans Hagen via ntg-context 
> skrev:
>
>> On 8/29/2022 7:33 PM, BPJ via ntg-context wrote:
>> > Hi,
>> >
>> > I use the attached Lua function to merge array, map and mixed tables
>> alike
>> > (but differently! :-) The trick is to check if each key is numeric or
>> not,
>> > append if it is and overwrite if it isn't.
>>
>> you really want something like this then:
>>
>> local  tab = table.pack(...)
>> local  rv  = {}
>>
>
> Thanks. I was manually translating from MoonScript (https://moonscript.org)
> where variables are local by default.
>
>
>> > This function just ignores non-table arguments because that is what I
>> > usually want. You may want to throw an error instead. Also it uses
>> > table.pack. You might need to use `tab = {...}` and ipairs, or implement
>> > pack:
>> I might add table.himerged (hash and index) but slightly different (and
>> some 30% faster) to util-tab but i think merging mixed hash/indexed
>> tables is rare.
>>
>> 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 /
>> https://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>>
>> ___
>>
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Merging two lua tables

2022-08-30 Thread BPJ via ntg-context
Den mån 29 aug. 2022 20:13Hans Hagen via ntg-context 
skrev:

> On 8/29/2022 7:33 PM, BPJ via ntg-context wrote:
> > Hi,
> >
> > I use the attached Lua function to merge array, map and mixed tables
> alike
> > (but differently! :-) The trick is to check if each key is numeric or
> not,
> > append if it is and overwrite if it isn't.
>
> you really want something like this then:
>
> local  tab = table.pack(...)
> local  rv  = {}
>

Thanks. I was manually translating from MoonScript (https://moonscript.org)
where variables are local by default.


> > This function just ignores non-table arguments because that is what I
> > usually want. You may want to throw an error instead. Also it uses
> > table.pack. You might need to use `tab = {...}` and ipairs, or implement
> > pack:
> I might add table.himerged (hash and index) but slightly different (and
> some 30% faster) to util-tab but i think merging mixed hash/indexed
> tables is rare.
>
> 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 /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___