[NTG-context] lua error in `back-exp.lmt`

2024-05-29 Thread Sylvain Hubert
ConTeXt LMTX version: 2024.05.27 18:16

Sample tex file:

\setupbackend[export=yes]

\starttext
x
\startsectionlevel
\startitemize
\item
\startitemize
\item
\startitemize
\item
\stopitemize
\stopitemize
\stopitemize
\stopsectionlevel

\stoptext

Error log:

tex error   > tex error on line 1 in file ./input.tex:
lua error:
registered function call [252]:
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1426: attempt
to get length of a nil value (local 'td')
stack traceback:
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1426:
in upvalue 'pushcontent'
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1597:
in upvalue 'collectresults'
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1867:
in upvalue 'collectresults'
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1867:
in upvalue 'collectresults'
.
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1867:
in upvalue 'collectresults'
...mtx/tex/texmf-context/tex/context/base/mkxl/back-exp.lmt:1969:
in upvalue 'nodes_handlers_export'
[string "local tonut  = nodes.tonut..."]:27: in function <[string
"local tonut  = nodes.tonut..."]:12>
(...tail calls...)
...mtx/tex/texmf-context/tex/context/base/mkxl/node-shp.lmt:38: in
function <...mtx/tex/texmf-context/tex/context/base/mkxl/node-shp.lmt:37>
(...tail calls...)

 1 >>  \setupbackend[export=yes]
 2
 3 \starttext
 4 x
 5 \startsectionlevel
 6 \startitemize
 7 \item
 8   \startitemize
 9   \item
10 \startitemize
11 \item
mtx-context | fatal error: return code: 1
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] lua error in `strc-lev.lua`

2024-05-28 Thread Sylvain Hubert
ConTeXt LMTX version: 2024.05.27 18:16

Reproducible example:

\definesectionlevels
[default]
[section, subsection, subsubsection, subsubsubsection, subsubsubsubsection]

\starttext
\startsectionlevel
\startsectionlevel
\startsectionlevel
\startsectionlevel
\startsectionlevel
\startsectionlevel
\startsectionlevel
\stopsectionlevel
\stopsectionlevel
\stopsectionlevel
\stopsectionlevel
\stopsectionlevel
\stopsectionlevel
\stopsectionlevel
\stoptext

lua error   > lua error on line 19 in file ./input.tex:

registered function call [969]:
...mtx/tex/texmf-context/tex/context/base/mkiv/strc-lev.lua:75: attempt to
index a nil value (field '?')
stack traceback:
...mtx/tex/texmf-context/tex/context/base/mkiv/strc-lev.lua:75: in
function <...mtx/tex/texmf-context/tex/context/base/mkiv/strc-lev.lua:66>
(...tail calls...)
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] LUA API for page numbers

2024-05-21 Thread Luc Chabassier
Hi everyone,

I have recently migrated my PhD dissertation from LaTeX to ConTeXt. In
LaTeX I was using kaobook, a template with lots of margin notes, but I
was frustrated with the automatic placement of the notes.

I implemented a system using overlays that automatically places the
notes using lua. To know where the ideal placement should be (if they do
not interact with each other), I use lua to insert a latelua whatsit
that uses lpdf.getpos() to get the coordinate on the rendered page.
However, I haven't found a way to get the page number using lua, and the
tex macro \pagenumber is unreliable near pagebreaks.

Furthermore, it would be helpful to know if there is a way to access the
position and sizes of figures at the end.

Thanks,
Luc

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Lua and inject.path to make a disconnected MetaPost path?

2024-01-08 Thread Gavin via ntg-context
Hello LuaMetaFun Fans,

Can I use mp.inject.path in Lua to create a disconnected path in MetaPost?

This is for my module that draws globes. I currently do something like this for 
drawing the continents. (This MWE has two triangular continents.)

\startluacode
  continents = {}
  continents[1] = {{0,0}, {-1,-1}, {-1,0}, cycle = true }
  continents[2] = {{0,1}, {1,0}, {1,-1}, cycle = true }
  function mp.getglobepath(continentnum)
mp.inject.path(continents[continentnum])
  end
\stopluacode

\startMPpage
  path p[], q ;
  p1 = (lua.mp.getglobepath(1) scaled 1cm) ;
  p2 = (lua.mp.getglobepath(2) scaled 1cm) ;
  q = p1 && p2 && cycle ;
  draw p1 withpen pencircle scaled 2pt withcolor .7 ;
  draw p2 withpen pencircle scaled 2pt withcolor .7 ;
  fill q withcolor 0.9 ;
  draw q withcolor red ;
\stopMPpage

The path q has both of the continents, disconnected.

I’d like to produce the two continents in Lua and pass them to MetaPost as a 
single disconnected path, using something like this: 

\startluacode
  continents = {
{0,0}, {-1,-1}, {-1,0}, — Change this to make a disconnected path!
{0,1}, {1,0}, {1,-1},
cycle = true }
  function mp.getglobepath()
mp.inject.path(continents)
  end
\stopluacode

\startMPpage
  path p ;
  p = (lua.mp.getglobepath() scaled 1cm) ;
  fill p withcolor 0.9 ;
  draw p withcolor red ;
\stopMPpage

If I can make the path p disconnected, this would allow me to make exactly the 
path I want in Lua, before passing it to MetaPost, rather than passing lots of 
paths and connecting them in MetaPost with the mysterious (to me) && or .

Thanks!
Gavin


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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


Re: [NTG-context] lua-widow-control module error in LMTX

2022-05-14 Thread Max Chernoff via ntg-context

Hi all,

I've pushed lwc v2.1.0 to CTAN and the Garden Modules site. This new 
version fully supports the ConTeXt grid snapping (MkIV/MkXL), and it 
also adds some improved logging. You can download this directly at


https://modules.contextgarden.net/dl/lua-widow-control-v2.1.0.zip

I believe that this resolves all of the issues in this thread, but as 
always, feel free to let me know if something doesn't work.


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


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-29 Thread Eduardo Bohoyo via ntg-context


Now, I don't have any widows in my document, and I only count 2 broken 
hyphens.


However, I think this is at the expense of the shenanigans the module 
has "perpetrated" elsewhere, because, apart from the crazy horizontal 
spacing of some paragraph in the bibliography, the module lies to me in 
the log.


Yes, the log output fools me. There is no "Widow/Orphan NOT removed". 
But this is not true:


To the 2 broken hyphens must be added 4 orphan lines that the log claims 
to have resolved. But what worries me the most is that it counts as 
successful one occasion with an empty line, another occasion with two 
empty lines in a row, and 4 occasions with no less than 7 empty lines in 
a row at the beginning of a chapter.


I don't know if this information can provide any more clues to adjust 
the module for the grid mode, but I hope it helps.


Greetings,

Edu.

El 29/4/22 a las 2:38, Max Chernoff escribió:

On 2022-04-28 3:30 a.m., Henning Hraban Ramm wrote:
I’m afraid the above release introduced a bug; while the offical 
release ran through, I now get:


module  > lua-widow-control > Widow/orphan detected. 
Attempting to remove.

lua error   > lua error on line 112 in file de/c_intro.tex:

callback error: 
...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: 
attempt to perform arithmetic on a nil value (field 'height')

stack traceback:
 ...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: 
in function 
<...local/tex/luatex/lua-widow-control/lua-widow-control.lua:360>


On 2022-04-28 4:54 a.m., Eduardo Bohoyo wrote:

Here testing that beta version.

As you know, my book is in grid mode, but I get the same error 
message as Hraban when the compilation crashes.


However, when I comment grid again in my document, it does compile 
the pdf.


Well that's why it was a beta :) Looks like I made some questionable 
assumptions
about the order of the hlist/baselineskip nodes, so the module 
completely broke

with things as simple as section headings.

Hopefully this new beta should fix things:

https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-5e240b2ebb76f33c32ecbc673af09a1c64773033

Grid snapping is a little peculiar, so let me know if you find any 
more bugs.


And thanks for the bug reports.
-- 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
___


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-28 Thread Max Chernoff via ntg-context

On 2022-04-28 3:30 a.m., Henning Hraban Ramm wrote:
I’m afraid the above release introduced a bug; while the offical release 
ran through, I now get:


module  > lua-widow-control > Widow/orphan detected. Attempting 
to remove.

lua error   > lua error on line 112 in file de/c_intro.tex:

callback error: 
...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: attempt 
to perform arithmetic on a nil value (field 'height')

stack traceback:
 ...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: in 
function <...local/tex/luatex/lua-widow-control/lua-widow-control.lua:360>


On 2022-04-28 4:54 a.m., Eduardo Bohoyo wrote:

Here testing that beta version.

As you know, my book is in grid mode, but I get the same error message 
as Hraban when the compilation crashes.


However, when I comment grid again in my document, it does compile the pdf.


Well that's why it was a beta :) Looks like I made some questionable assumptions
about the order of the hlist/baselineskip nodes, so the module completely broke
with things as simple as section headings.

Hopefully this new beta should fix things:


https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-5e240b2ebb76f33c32ecbc673af09a1c64773033

Grid snapping is a little peculiar, so let me know if you find any more bugs.

And thanks for the bug reports.
-- 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
___


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-28 Thread Henning Hraban Ramm via ntg-context

Am 28.04.22 um 12:54 schrieb Eduardo Bohoyo via ntg-context:

Hi Max:

Here testing that beta version.

As you know, my book is in grid mode, but I get the same error message 
as Hraban when the compilation crashes.


However, when I comment grid again in my document, it does compile the pdf.


Oops, my book *was* accidentally in grid mode. It made no sense. No 
wonder I had troubles with spacing.


But I get the error with your beta release also without grid mode.

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] lua-widow-control module error in LMTX

2022-04-28 Thread Eduardo Bohoyo via ntg-context

Hi Max:

Here testing that beta version.

As you know, my book is in grid mode, but I get the same error message 
as Hraban when the compilation crashes.


However, when I comment grid again in my document, it does compile the pdf.

Thanks,

Edu

El 28/4/22 a las 9:25, Max Chernoff escribió:

On 2022-04-27 3:59 p.m., Eduardo Bohoyo wrote:
When I uncomment grid=yes in my \setuplayout, lwc makes its real 
appearance on the scene.

So it looks like lwc was broken with grid snapping. This surprised me --
I originally wrote lwc *specifically* to use with grid snapping -- but it
looks like I quickly forgot about that goal and never actually tested it
with grids.

I suppose that in other documents than mine, i.e. less complex, this 
performance would be a success. But in my file it is, considering my 
current aesthetic requirements, a failure. This is because for me 
grid=yes is a non-negotiable part of my code.


I _think_ that I've fixed it now. Can you try the beta version at

https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-47ff19d9804f6ecea64dda59426664680d9756e0

please? Hopefully this solves the issue.

Do you want the new pdf with lwc actually acting on my file? Then you 
can get a better idea of what I mean by the end of some pages when I 
comment grid=yes (apart from the mischief that happens with the 
horizontal spaces in some paragraphs of the bibliographic section).


Or, if you prefer, and you need more feedback, I can send you my 
current code to use it as a test bench for " daring " texts.


I was able to reproduce the issue just by adding

    \setuplayout[grid=yes]

to my "standard" test files, so I shouldn't need anything else, provided
that the above beta actually fixes anything. If there are still lingering
issues, then having the TeX source would likely simplify things on my 
end.


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


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-28 Thread Henning Hraban Ramm via ntg-context

Am 28.04.22 um 09:25 schrieb Max Chernoff via ntg-context:

I _think_ that I've fixed it now. Can you try the beta version at
 
https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-47ff19d9804f6ecea64dda59426664680d9756e0 


please? Hopefully this solves the issue.


Hi Max,
thank you for this module that I didn’t know.

I’m afraid the above release introduced a bug; while the offical release 
ran through, I now get:


module  > lua-widow-control > Widow/orphan detected. Attempting 
to remove.

lua error   > lua error on line 112 in file de/c_intro.tex:

callback error: 
...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: attempt 
to perform arithmetic on a nil value (field 'height')

stack traceback:
	...local/tex/luatex/lua-widow-control/lua-widow-control.lua:510: in 
function <...local/tex/luatex/lua-widow-control/lua-widow-control.lua:360>


My book is not in grid mode.


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] lua-widow-control module error in LMTX

2022-04-28 Thread Max Chernoff via ntg-context

On 2022-04-27 3:59 p.m., Eduardo Bohoyo wrote:
When I uncomment grid=yes in my \setuplayout, lwc makes its real 
appearance on the scene.

So it looks like lwc was broken with grid snapping. This surprised me --
I originally wrote lwc *specifically* to use with grid snapping -- but it
looks like I quickly forgot about that goal and never actually tested it
with grids.

I suppose that in other documents than mine, 
i.e. less complex, this performance would be a success. But in my file 
it is, considering my current aesthetic requirements, a failure. This is 
because for me grid=yes is a non-negotiable part of my code.


I _think_ that I've fixed it now. Can you try the beta version at


https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-47ff19d9804f6ecea64dda59426664680d9756e0

please? Hopefully this solves the issue.
 
Do you want the new pdf with lwc actually acting on my file? Then you 
can get a better idea of what I mean by the end of some pages when I 
comment grid=yes (apart from the mischief that happens with the 
horizontal spaces in some paragraphs of the bibliographic section).


Or, if you prefer, and you need more feedback, I can send you my current 
code to use it as a test bench for " daring " texts.


I was able to reproduce the issue just by adding

\setuplayout[grid=yes]

to my "standard" test files, so I shouldn't need anything else, provided
that the above beta actually fixes anything. If there are still lingering
issues, then having the TeX source would likely simplify things on my end.

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


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-27 Thread Max Chernoff via ntg-context

Quick question before I begin: are you using any especially "interesting"
ConTeXt features? By "interesting" I mean things like grid typesetting,
pagecolumns, bidirectional text, etc. I haven't tested lwc with every
possible ConTeXt feature, so there may be some adverse interaction. If
you are using something like this, try disabling it and see if that solves
anything (then let me know so that I can fix it!)

On 2022-04-26 3:45 a.m., Eduardo Bohoyo wrote:


I can see "modules > 'lua-widow-control' is loaded".

But, luckily, I can also see this:

open source > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl' 

resolvers   > lua > loading file 
'/opt/luametatex/texmf-modules/tex/luatex/lua-widow-control/lua-widow-control.lua' 
succeeded
close source    > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl' 


module  > lua-widow-control > Already enabled


Ok, so this is good; lwc is for sure being loaded successfully.


No line such as "Widow/orphan detected. Attempting to delete".

I see interleaved new groups with the same line always repeating a 
warning message throughout the whole file. In short, there are 613 new 
lines with the message "luatex warning > tex: left parfill skip is gone".
But I didn't give it any importance, because I interpreted that they 
could be inherent to the module.


Well this at least narrows the issue down quite a bit. Lwc runs in pretty
much two stages: when a paragraph has finished being broken by TeX, lwc
saves the paragraph. The second stage is ran just before each time the
output routine is triggered so that lwc can remove the widows and orphans.

Due to an lwc bug, the first stage results in the "left parfill skip"
warning being printed twice for each paragraph. Normally this is quite
annoying, but here it is good -- we know for sure that the first stage
is running just fine.

It is the second stage where you should get the "Widow/orphan detected"
message, but this isn't happening. The code here is at lwc.lua:362-388.

Here is a list of all possible reasons, in order of likelihood, why
"Widow/orphan detected" wouldn't be printed when there is actually
a widow or orphan:

(Just listing all of these to make sure that *I* don't forget anything. I'd
 say that 1 and 2 are the only ones that are actually likely -- you can
 probably ignore all of the others)

 1. "\clubpenalty" and/or "\widowpenalty" are either zero or infinite

In these cases, lwc can't distinguish a widow or orphan from other
penalties, so it doesn't do anything. You can check for this with

\showthe\widowpenalty
\showthe\clubpenalty

some time after "\starttext". This will print the values to the log
file. The values should probably be "1", but things like "150" and
"5000" are fine too. If you see negative values, "0", or values
greater than ten thousand, then something is wrong here.

 2. Something is "hiding" the widow/orphan penalties from lwc.

Something like "\vadjust{\penalty X}" or the e-TeX "\-penalties"
commands could potentially do this.

One potential solution for (a subset of) this problem would be to
modify lwc.mkxl to insert "\directsetup{*reset}" at line 52, to
get:

\startsetups[*default]
\directsetup{*reset}
\clubpenalty=\lwcparameter{orphanpenalty}
\widowpenalty=\lwcparameter{widowpenalty}
\displaywidowpenalty=\lwcparameter{widowpenalty}
\brokenpenalty=\lwcparameter{brokenpenalty}
\stopsetups

If that doesn't do anything, keep the above modifications but also insert

\setups[*default]

after "\starttext" in your test document.

 3. Lwc hasn't saved any paragraphs since the last output routine.

Since we know that the first stage is running, this shouldn't be
possible unless there is a weird bug somewhere else.

 4. A weird engine/format bug.

The LMTX test file was successful on Debian x86_64 three days ago


https://github.com/gucci-on-fleek/lua-widow-control/runs/6144354147?check_suite_focus=true

so something quite weird would have to be going on here.

 5. Something is overwriting the "pre_output_filter" callback.

Now this is an interesting one. ConTeXt has frozen most of the core
engine callbacks, but "pre_output_filter" is unfrozen and unassigned.
There is a ConTeXt interface for most of the other callbacks, but here
I need to fallback to the low-level interface. With this interface,
you can only register a single callback, so it is possible that some
other package is overwriting the callback. To test this, the very
beginning of your document should look like:

\usemodule[lua-widow-control]

\startluacode
lwc.callbacks.disable_box_warnings.enable = function () end
lwc.callbacks.disable_

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-26 Thread Eduardo Bohoyo via ntg-context

Erratum: When I wrote script, I meant hyphen.

El 26/4/22 a las 11:45, Eduardo Bohoyo escribió:

Hi:

No line such as "Widow/orphan detected. Attempting to delete".

I see interleaved new groups with the same line always repeating a 
warning message throughout the whole file. In short, there are 613 new 
lines with the message "luatex warning > tex: left parfill skip is gone".
But I didn't give it any importance, because I interpreted that they 
could be inherent to the module.


I can see "modules > 'lua-widow-control' is loaded".

But, luckily, I can also see this:

open source > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'
resolvers   > lua > loading file 
'/opt/luametatex/texmf-modules/tex/luatex/lua-widow-control/lua-widow-control.lua' 
succeeded
close source    > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'

module  > lua-widow-control > Already enabled


On the other hand, the distribution and size of my paragraphs take 
great care that their "design" optimises the module's goodness, 
except, of course, for the first pages of each of the nine dummy text 
chapters (they start at a third of a page).
But it is very curious that, even so, only the two orphan lines I 
mentioned, and only two of the five widows relate to two or three of 
those "supposedly problematic" first chapter pages (as I said, nine in 
total). And the case of the broken scripts is even stranger: only two 
of the six breakages concern a couple of those early chapter pages.


I will go over the lua-widow-control.pdf document once more in case 
there is a tiny detail I am missing, but I think, if I keep going at 
this pace, I will end up learning it by heart.


Well, joking aside, thanks again for your advice, Max.

Edu.

El 26/4/22 a las 4:42, Max Chernoff escribió:

On 2022-04-25 6:51 p.m., Eduardo Bohoyo wrote:
First things first.  I want to acknowledge and thank you for the 
tough mission that surely involves maintaining this module for the 
benefit of the TeX community and, most especially, for LMTX in 
particular, due to the very reasons you have just explained.


Well thanks :) These days I write most of my documents in LMTX, so 
the LMTX

support is pretty self-serving -- I'm admittedly surprised that there's
another lwc + LMTX user.

Regarding your remarks, you are right in your assumptions: I didn't 
have the required lua file installed in its corresponding folder. 
That's what I was missing, and, logically, what made my compilation 
crash.


Yeah, it's a pretty easy mistake to make. For Knuth TeX, shared files go
in texmf/tex/generic and Plain-specific files go in texmf/tex/plain, but
with LuaTeX there's just texmf/tex/luatex so it gets a little confusing.

Now I finally get the pdf. But unfortunately, this "new" pdf is the 
same with the module uncommented as when I had it commented. There 
is no difference at all. And you're right: even context --make 
doesn't solve the problem. To give you an idea, although my dummy 
document has 78 pages, only 55 can really be said to be dummy text 
that can benefit from the module. Well, only in those 55 pages I 
have 2 orphans, 5 widows and 6 broken hyphens.


So the first step here is to check the log file. If you see lines like

    module  > lua-widow-control > Widow/orphan detected. 
Attempting to remove.
    module  > lua-widow-control > Widow/Orphan NOT removed on 
page X.


then that means that lwc found a widow/orphan, but gave up. This usually
only happens if the page has only really short paragraphs, but it can 
also
happen if there aren't any paragraphs that both start and finish on 
the page.
I've got some neat graphs for this (see the upcoming TUGboat issue), 
but with

default settings this should happen for much less than 10% of potential
widows/orphans, so it seems unlikely that this is happening for every 
page.


If this actually is the issue, then you can try raising the 
"emergencystretch"
value in "\setuplwc", but that's probably going to give terrible 
results. The real
solution is to rewrite something, but that should usually be pretty 
rare.


---

If you see lines like

    module  > lua-widow-control > Widow/orphan detected. 
Attempting to remove.
    module  > lua-widow-control > Widow/orphan successfully 
removed at paragraph X on page Y.


but the widows/orphans weren't actually removed, then something 
really weird
is going on and definitely means that there's a bug in lwc. Rerun the 
document with


    \setuplwc[debug=true]

immediately after "\usemodule[lua-widow-control]" and either reply 
with the log

or post a new issue on the lwc GitHub.

---

If you only see

    modules > 'lua-widow-control' is loaded

but not any other lines mentioning lwc, then something weird is going 
on, and
lwc is loaded but not enabled. If this is the case, same as la

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-26 Thread Eduardo Bohoyo via ntg-context

Hi:

No line such as "Widow/orphan detected. Attempting to delete".

I see interleaved new groups with the same line always repeating a 
warning message throughout the whole file. In short, there are 613 new 
lines with the message "luatex warning > tex: left parfill skip is gone".
But I didn't give it any importance, because I interpreted that they 
could be inherent to the module.


I can see "modules > 'lua-widow-control' is loaded".

But, luckily, I can also see this:

open source > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'
resolvers   > lua > loading file 
'/opt/luametatex/texmf-modules/tex/luatex/lua-widow-control/lua-widow-control.lua' 
succeeded
close source    > level 2, order 4, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'

module  > lua-widow-control > Already enabled


On the other hand, the distribution and size of my paragraphs take great 
care that their "design" optimises the module's goodness, except, of 
course, for the first pages of each of the nine dummy text chapters 
(they start at a third of a page).
But it is very curious that, even so, only the two orphan lines I 
mentioned, and only two of the five widows relate to two or three of 
those "supposedly problematic" first chapter pages (as I said, nine in 
total). And the case of the broken scripts is even stranger: only two of 
the six breakages concern a couple of those early chapter pages.


I will go over the lua-widow-control.pdf document once more in case 
there is a tiny detail I am missing, but I think, if I keep going at 
this pace, I will end up learning it by heart.


Well, joking aside, thanks again for your advice, Max.

Edu.

El 26/4/22 a las 4:42, Max Chernoff escribió:

On 2022-04-25 6:51 p.m., Eduardo Bohoyo wrote:
First things first.  I want to acknowledge and thank you for the 
tough mission that surely involves maintaining this module for the 
benefit of the TeX community and, most especially, for LMTX in 
particular, due to the very reasons you have just explained.


Well thanks :) These days I write most of my documents in LMTX, so the 
LMTX

support is pretty self-serving -- I'm admittedly surprised that there's
another lwc + LMTX user.

Regarding your remarks, you are right in your assumptions: I didn't 
have the required lua file installed in its corresponding folder. 
That's what I was missing, and, logically, what made my compilation 
crash.


Yeah, it's a pretty easy mistake to make. For Knuth TeX, shared files go
in texmf/tex/generic and Plain-specific files go in texmf/tex/plain, but
with LuaTeX there's just texmf/tex/luatex so it gets a little confusing.

Now I finally get the pdf. But unfortunately, this "new" pdf is the 
same with the module uncommented as when I had it commented. There is 
no difference at all. And you're right: even context --make doesn't 
solve the problem. To give you an idea, although my dummy document 
has 78 pages, only 55 can really be said to be dummy text that can 
benefit from the module. Well, only in those 55 pages I have 2 
orphans, 5 widows and 6 broken hyphens.


So the first step here is to check the log file. If you see lines like

    module  > lua-widow-control > Widow/orphan detected. 
Attempting to remove.
    module  > lua-widow-control > Widow/Orphan NOT removed on 
page X.


then that means that lwc found a widow/orphan, but gave up. This usually
only happens if the page has only really short paragraphs, but it can 
also
happen if there aren't any paragraphs that both start and finish on 
the page.
I've got some neat graphs for this (see the upcoming TUGboat issue), 
but with

default settings this should happen for much less than 10% of potential
widows/orphans, so it seems unlikely that this is happening for every 
page.


If this actually is the issue, then you can try raising the 
"emergencystretch"
value in "\setuplwc", but that's probably going to give terrible 
results. The real

solution is to rewrite something, but that should usually be pretty rare.

---

If you see lines like

    module  > lua-widow-control > Widow/orphan detected. 
Attempting to remove.
    module  > lua-widow-control > Widow/orphan successfully 
removed at paragraph X on page Y.


but the widows/orphans weren't actually removed, then something really 
weird
is going on and definitely means that there's a bug in lwc. Rerun the 
document with


    \setuplwc[debug=true]

immediately after "\usemodule[lua-widow-control]" and either reply 
with the log

or post a new issue on the lwc GitHub.

---

If you only see

    modules > 'lua-widow-control' is loaded

but not any other lines mentioning lwc, then something weird is going 
on, and
lwc is loaded but not enabled. If this is the case, same as last time: 
enable

debug mode and reply with the log.

---

If you don't see

    modules >

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-25 Thread Max Chernoff via ntg-context

On 2022-04-25 6:51 p.m., Eduardo Bohoyo wrote:
First things first.  I want to acknowledge and thank you for the tough 
mission that surely involves maintaining this module for the benefit of 
the TeX community and, most especially, for LMTX in particular, due to 
the very reasons you have just explained.


Well thanks :) These days I write most of my documents in LMTX, so the LMTX
support is pretty self-serving -- I'm admittedly surprised that there's
another lwc + LMTX user.

Regarding your remarks, you are right in your assumptions: I didn't have 
the required lua file installed in its corresponding folder. That's what 
I was missing, and, logically, what made my compilation crash.


Yeah, it's a pretty easy mistake to make. For Knuth TeX, shared files go
in texmf/tex/generic and Plain-specific files go in texmf/tex/plain, but
with LuaTeX there's just texmf/tex/luatex so it gets a little confusing.

Now I finally get the pdf. But unfortunately, this "new" pdf is the same 
with the module uncommented as when I had it commented. There is no 
difference at all. And you're right: even context --make doesn't solve 
the problem. To give you an idea, although my dummy document has 78 
pages, only 55 can really be said to be dummy text that can benefit from 
the module. Well, only in those 55 pages I have 2 orphans, 5 widows and 
6 broken hyphens.


So the first step here is to check the log file. If you see lines like

module  > lua-widow-control > Widow/orphan detected. Attempting to 
remove.
module  > lua-widow-control > Widow/Orphan NOT removed on page X.

then that means that lwc found a widow/orphan, but gave up. This usually
only happens if the page has only really short paragraphs, but it can also
happen if there aren't any paragraphs that both start and finish on the page.
I've got some neat graphs for this (see the upcoming TUGboat issue), but with
default settings this should happen for much less than 10% of potential
widows/orphans, so it seems unlikely that this is happening for every page.

If this actually is the issue, then you can try raising the "emergencystretch"
value in "\setuplwc", but that's probably going to give terrible results. The 
real
solution is to rewrite something, but that should usually be pretty rare.

---

If you see lines like

module  > lua-widow-control > Widow/orphan detected. Attempting to 
remove.
module  > lua-widow-control > Widow/orphan successfully removed at 
paragraph X on page Y.

but the widows/orphans weren't actually removed, then something really weird
is going on and definitely means that there's a bug in lwc. Rerun the document 
with

\setuplwc[debug=true]

immediately after "\usemodule[lua-widow-control]" and either reply with the log
or post a new issue on the lwc GitHub.

---

If you only see

modules > 'lua-widow-control' is loaded

but not any other lines mentioning lwc, then something weird is going on, and
lwc is loaded but not enabled. If this is the case, same as last time: enable
debug mode and reply with the log.

---

If you don't see

modules > 'lua-widow-control' is loaded

at all, then you're not actually loading lwc. This probably means that ConTeXt
can't find the file, there should hopefully be clues somewhere in the log file.


Thanks again for your work and yours observations.


No problem; glad to help.

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


Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-25 Thread Eduardo Bohoyo via ntg-context

Hi, Max:

First things first.  I want to acknowledge and thank you for the tough 
mission that surely involves maintaining this module for the benefit of 
the TeX community and, most especially, for LMTX in particular, due to 
the very reasons you have just explained.


Regarding your remarks, you are right in your assumptions: I didn't have 
the required lua file installed in its corresponding folder. That's what 
I was missing, and, logically, what made my compilation crash.


To make my confusion even worse, I had done a strict search inside the 
mkxl code. It wouldn't take me to line 63 because I had added the 
extension (lua-widow-control.lua, not just lua-widow-control).


Anyway, a mess only due to my ignorance.

Now I finally get the pdf. But unfortunately, this "new" pdf is the same 
with the module uncommented as when I had it commented. There is no 
difference at all. And you're right: even context --make doesn't solve 
the problem. To give you an idea, although my dummy document has 78 
pages, only 55 can really be said to be dummy text that can benefit from 
the module. Well, only in those 55 pages I have 2 orphans, 5 widows and 
6 broken hyphens.


I have read several times all the options of the module in the 
/lua-widow-control.pdf/ document, but I don't even dare to mess with 
those options because it seems to me very radical that my output pdf is 
the same with the module uncommented in my code.


Of course, mtxrun --find-file lua-widow-control.lua yields what you 
would expect:


/opt/luametatex/texmf-modules/tex/luatex/lua-widow-control/lua-widow-control.lua

Thanks again for your work and yours observations.

Edu.

El 25/4/22 a las 22:00, Max Chernoff escribió:

(Please keep me CC'd as I'm not subscribed to the list)

Hi, I'm the lua-widow-control author.

> lua error > lua error on line 74 in file
> 
/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl

>
> The odd thing is that line 75 of the t-lua-widow-control file is empty.

The \setuplwc command ends on line 74, which then triggers 
\everysetuplwc which then calls \ctxlua{lwc.enable_callbacks()}. This 
fails since lwc is undefined because the Lua file isn't loaded because 
ConTeXt can't seem to find the file.


In Plain LuaTeX and LuaLaTeX, a missing Lua file is a fatal error:

    $ luatex "\nonstopmode\directlua{require 'not-a-real-file'}\bye"

    This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
 restricted system commands enabled.

    [\directlua]:1: module 'not-a-real-file' not found:
    no field package.preload['not-a-real-file']
    [kpse lua searcher] file not found: 'not-a-real-file'
    stack traceback:
    [C]: in function 'require'
    [\directlua]:1: in main chunk.
    <*> \nonstopmode\directlua{require 'not-a-real-file'}
  \bye
    (see the transcript file for additional information)
    warning  (pdf backend): no pages of output.
    Transcript written on texput.log.

so I'm a little surprised that ConTeXt just issues a warning here when 
it can't find the file:


   resolvers > lua > unknown file 'lua-widow-control.lua'

> when it says it doesn't know the lua-widow-control.lua file. I don't 
see

> any mention of this file within the t-lua-widow-control module.

lua-widow-control.lua is loaded at line 63 of the .mkxl:
    \ctxloadluafile{lua-widow-control}

> Could it be that this module is not yet mature for lmtx

Lua-widow-control is certainly more stable with Plain/LaTeX, but it 
usually runs fine with LMTX. The entire lwc manual is written in 
ConTeXt/LMTX so I (usually) notice pretty quickly when things break.


The only real "issue" with LMTX is that the engine changes pretty 
quickly, so lwc may sometimes be broken for a few days between an 
engine update and whenever I push out a fix. This doesn't happen with 
Plain/LaTeX since the LuaTeX engine is mostly frozen.


Interestingly, the MkXL version of lwc actually predates the MkIV 
version, although only by a few months.


> I have \usemodule[lua-widow-control] in my tex document, and
> I haven't forgotten to do the prescribed mtxrun --generate after
> including the module in my third-party folder of my luametatex
> installation on Arch.

Hmm, that's odd then. I'm not entirely sure why this is happening, so 
I'm going to take a random guess:


Maybe you installed lwc using a zipfile from either GitHub or the 
ConTeXt Garden modules site, then you copied the files into your 
texmf-modules/ folder, *but* you only copied the "tex/context/" folder 
and not all of the folders in the "tex" folder. The 
"lua-widow-control.lua" file is in the "tex/luatex/" folder, so if you 
didn't also copy that across you're going to have problems.


Again, just a random guess.  If that doesn't work, you could maybe try 
running

    context --make
but I doubt that that would fix anything here. You could also try 
deleting the filename cache files 

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-25 Thread Max Chernoff via ntg-context

(Please keep me CC'd as I'm not subscribed to the list)

Hi, I'm the lua-widow-control author.

> lua error > lua error on line 74 in file
> 
/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl

>
> The odd thing is that line 75 of the t-lua-widow-control file is empty.

The \setuplwc command ends on line 74, which then triggers 
\everysetuplwc which then calls \ctxlua{lwc.enable_callbacks()}. This 
fails since lwc is undefined because the Lua file isn't loaded because 
ConTeXt can't seem to find the file.


In Plain LuaTeX and LuaLaTeX, a missing Lua file is a fatal error:

$ luatex "\nonstopmode\directlua{require 'not-a-real-file'}\bye"

This is LuaTeX, Version 1.13.2 (TeX Live 2021/W32TeX)
 restricted system commands enabled.

[\directlua]:1: module 'not-a-real-file' not found:
no field package.preload['not-a-real-file']
[kpse lua searcher] file not found: 'not-a-real-file'
stack traceback:
[C]: in function 'require'
[\directlua]:1: in main chunk.
<*> \nonstopmode\directlua{require 'not-a-real-file'}
  \bye
(see the transcript file for additional information)
warning  (pdf backend): no pages of output.
Transcript written on texput.log.

so I'm a little surprised that ConTeXt just issues a warning here when 
it can't find the file:


   resolvers > lua > unknown file 'lua-widow-control.lua'

> when it says it doesn't know the lua-widow-control.lua file. I don't see
> any mention of this file within the t-lua-widow-control module.

lua-widow-control.lua is loaded at line 63 of the .mkxl:
\ctxloadluafile{lua-widow-control}

> Could it be that this module is not yet mature for lmtx

Lua-widow-control is certainly more stable with Plain/LaTeX, but it 
usually runs fine with LMTX. The entire lwc manual is written in 
ConTeXt/LMTX so I (usually) notice pretty quickly when things break.


The only real "issue" with LMTX is that the engine changes pretty 
quickly, so lwc may sometimes be broken for a few days between an engine 
update and whenever I push out a fix. This doesn't happen with 
Plain/LaTeX since the LuaTeX engine is mostly frozen.


Interestingly, the MkXL version of lwc actually predates the MkIV 
version, although only by a few months.


> I have \usemodule[lua-widow-control] in my tex document, and
> I haven't forgotten to do the prescribed mtxrun --generate after
> including the module in my third-party folder of my luametatex
> installation on Arch.

Hmm, that's odd then. I'm not entirely sure why this is happening, so 
I'm going to take a random guess:


Maybe you installed lwc using a zipfile from either GitHub or the 
ConTeXt Garden modules site, then you copied the files into your 
texmf-modules/ folder, *but* you only copied the "tex/context/" folder 
and not all of the folders in the "tex" folder. The 
"lua-widow-control.lua" file is in the "tex/luatex/" folder, so if you 
didn't also copy that across you're going to have problems.


Again, just a random guess.  If that doesn't work, you could maybe try 
running

context --make
but I doubt that that would fix anything here. You could also try 
deleting the filename cache files at:

{CONTEXT}/texmf-cache/luametatex-cache/context/*/trees/*.lu?
then rerunning
mtxrun --generate
I've never deleted those files before, but it's in a folder called 
"cache" so it's _probably_ safe to delete (make a backup just in case 
though).


If none of that works, then the issue could be something else on your 
end, or I could have screwed something up in lwc. In that case, try running

find /opt/luametatex/texmf-modules/ -path '*widow*' -print
and
mtxrun --find-file lua-widow-control.lua
and reply with the output.

Oh, and one more note. ConTeXt version "2022-04-11 19:20" renamed some 
of the engine Lua functions, so make sure to update to lwc v2.0.6 (if 
you're using a recent ConTeXt version). Otherwise after you fix the 
"unknown file" error, you would get an "attempt to call a nil value" 
error which isn't any better.


Let me know if you have any other issues.

 -- 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] lua-widow-control module error in LMTX

2022-04-21 Thread Eduardo Bohoyo via ntg-context

Hi,
I would like to know if anyone has experienced the same error with the 
lua-widow-control module when compiling the pdf:


modules > 'lua-widow-control' is loaded
open source > level 2, order 3, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'.

resolvers > lua > unknown file 'lua-widow-control.lua'
lua error > lua error on line 74 in file 
/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl


The odd thing is that line 75 of the t-lua-widow-control file is empty.
On the other hand, I confess that I don't know what "resolvers" means 
when it says it doesn't know the lua-widow-control.lua file. I don't see 
any mention of this file within the t-lua-widow-control module.


Could it be that this module is not yet mature for lmtx, or am I missing 
something? I have \usemodule[lua-widow-control] in my tex document, and 
I haven't forgotten to do the prescribed mtxrun --generate after 
including the module in my third-party folder of my luametatex 
installation on Arch.


Kind regards,

Edu

___
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] lua-widow-control module error in LMTX

2022-04-21 Thread Eduardo Bohoyo via ntg-context


El 21/4/22 a las 22:08, Eduardo Bohoyo escribió:

Hi,
I would like to know if anyone has experienced the same error with the 
lua-widow-control module when compiling the pdf:


modules > 'lua-widow-control' is loaded
open source > level 2, order 3, name 
'/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl'.

resolvers > lua > unknown file 'lua-widow-control.lua'
lua error > lua error on line 75 in file 
/opt/luametatex/texmf-modules/tex/context/third/lua-widow-control/t-lua-widow-control.mkxl


The odd thing is that line 75 of the t-lua-widow-control file is empty.
On the other hand, I confess that I don't know what "resolvers" means 
when it says it doesn't know the lua-widow-control.lua file. I don't 
see any mention of this file within the t-lua-widow-control module.


Could it be that this module is not yet mature for lmtx, or am I 
missing something? I have \usemodule[lua-widow-control] in my tex 
document, and I haven't forgotten to do the prescribed mtxrun 
--generate after including the module in my third-party folder of my 
luametatex installation on Arch.


Kind regards,

Edu


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

2021-08-17 Thread Hans Hagen via ntg-context

On 8/17/2021 4:47 PM, Taco Hoekwater via ntg-context wrote:

Hi Hans,


On 17 Aug 2021, at 16:39, Hans van der Meer via ntg-context 
 wrote:

I am still interested in this luacondition 733 allthough the culprit has been 
spotted. Very nasty typo and hard to spot fo me.


The “luacondition 733” is the \ifxmlatt . You get these numbers because the 
command is
defined using lua ‘interfaces.implement’ (lxml-ini.lua) instead of directly as 
a TeX conditional.

And yes indeed, the new lua-defined commands are hard to derive from the log 
information
(for the other Hans: is this reporting not controlled via ‘public=true’ ? ).
no, that's just namespacing, but we have a trick that can be used to 
resolve it and I simply hadn't that one plugged into the conditions 
stuff (only in functions) ... so i did that and next time HvdM will see:


(\end occurred when luacondition \ifxmlatt on line 13 was incomplete)

although of course he will never make that mistake again so he will not 
notice this new feature


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] lua

2021-08-17 Thread Hans Hagen via ntg-context

On 8/17/2021 4:39 PM, Hans van der Meer via ntg-context wrote:
I am still interested in this luacondition 733 allthough the culprit has 
been spotted. Very nasty typo and hard to spot fo me.

Shudder and enjoy:

\ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModuleFlushTEX\fi


wel, that let something to \fi and thereby gobles the \fi so you never 
end \ifxmlatt



instead of
\ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModule\FlushTEX\fi

dr. Hans van der Meer


On 17 Aug 2021, at 15:49, Hans van der Meer via ntg-context 
mailto:ntg-context@ntg.nl>> wrote:


Where is this message on luacondition 733 coming from? I would be glad 
to get rid of it. The message does not pinpoint the problem location 
enough for me to find its cause.


close source    > level 2, order 7, name './modules-docs.tex'
close source    > level 1, order 7, name 'cont-yes.mkiv'
(\end occurred when luacondition 733 on line 8 was incomplete)


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




--

-
  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] lua

2021-08-17 Thread Hans Hagen via ntg-context

On 8/17/2021 3:49 PM, Hans van der Meer via ntg-context wrote:
Where is this message on luacondition 733 coming from? I would be glad 
to get rid of it. The message does not pinpoint the problem location 
enough for me to find its cause.


close source    > level 2, order 7, name './modules-docs.tex'
close source    > level 1, order 7, name 'cont-yes.mkiv'
(\end occurred when luacondition 733 on line 8 was incomplete)

quite likely a missing \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
___


Re: [NTG-context] lua

2021-08-17 Thread Taco Hoekwater via ntg-context
Hi Hans,

> On 17 Aug 2021, at 16:39, Hans van der Meer via ntg-context 
>  wrote:
> 
> I am still interested in this luacondition 733 allthough the culprit has been 
> spotted. Very nasty typo and hard to spot fo me. 

The “luacondition 733” is the \ifxmlatt . You get these numbers because the 
command is
defined using lua ‘interfaces.implement’ (lxml-ini.lua) instead of directly as 
a TeX conditional.

And yes indeed, the new lua-defined commands are hard to derive from the log 
information
(for the other Hans: is this reporting not controlled via ‘public=true’ ? ).

Best wishes,
Taco

> Shudder and enjoy:
> 
> \ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModuleFlushTEX\fi
> instead of
> \ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModule\FlushTEX\fi
> 
> dr. Hans van der Meer
> 
> 
>> On 17 Aug 2021, at 15:49, Hans van der Meer via ntg-context 
>>  wrote:
>> 
>> Where is this message on luacondition 733 coming from? I would be glad to 
>> get rid of it. The message does not pinpoint the problem location enough for 
>> me to find its cause.
>> 
>> close source> level 2, order 7, name './modules-docs.tex'
>> close source> level 1, order 7, name 'cont-yes.mkiv'
>> (\end occurred when luacondition 733 on line 8 was incomplete)
>> 
>> 
>> 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 / 
>> 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
> ___

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)



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

2021-08-17 Thread Hans van der Meer via ntg-context
I am still interested in this luacondition 733 allthough the culprit has been 
spotted. Very nasty typo and hard to spot fo me. 
Shudder and enjoy:

\ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModuleFlushTEX\fi
instead of
\ifxmlatt{#1}{regime}{xml}\let\Flush\ModuleFlushXML\else\let\FlushModule\FlushTEX\fi

dr. Hans van der Meer


> On 17 Aug 2021, at 15:49, Hans van der Meer via ntg-context 
>  wrote:
> 
> Where is this message on luacondition 733 coming from? I would be glad to get 
> rid of it. The message does not pinpoint the problem location enough for me 
> to find its cause.
> 
> close source> level 2, order 7, name './modules-docs.tex'
> close source> level 1, order 7, name 'cont-yes.mkiv'
> (\end occurred when luacondition 733 on line 8 was incomplete)
> 
> 
> 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 / 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] lua

2021-08-17 Thread Hans van der Meer via ntg-context
Where is this message on luacondition 733 coming from? I would be glad to get 
rid of it. The message does not pinpoint the problem location enough for me to 
find its cause.

close source> level 2, order 7, name './modules-docs.tex'
close source> level 1, order 7, name 'cont-yes.mkiv'
(\end occurred when luacondition 733 on line 8 was incomplete)


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 / 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] Lua code and table

2021-02-20 Thread Fabrice Couvreur
Hi Hans
The xx.tex file works for me
Thanks
Fabrice

Le ven. 19 févr. 2021 à 14:28, Hans Hagen  a écrit :

> On 2/19/2021 2:12 PM, Jano Kula wrote:
> > Hi,
> >
> > On Fri, 19 Feb 2021 at 13:06, Hans Hagen  > > wrote:
> >
> > On 2/19/2021 12:42 PM, Fabrice Couvreur wrote:
> >  > Hi Hans,Thanks again for the ideas to improve my code. However, I
> > am new
> >  > to Lua and my level is far from sufficient to understand
> > everything. Why
> >  > in no table do the crosses appear in the cells; which was my
> > original
> >  > idea.Thank you.Fabrice
> > I get a cross (see attached).
> >
> >
> > I've got no crosses with ConTeXt  ver: 2021.02.05 17:45 LMTX.
> > Fresh install of ConTeXt  ver: 2021.02.19 13:15 LMTX gives me no
> > crosses, too.
> > No missing fonts in both cases.
> > Log and tuc attached.
> And with the previously attached xx.tex file? maybe the mailer messes up
> something?
>
> 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
>
> ___
>
___
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] Lua code and table

2021-02-19 Thread Hans Hagen

On 2/19/2021 2:12 PM, Jano Kula wrote:

Hi,

On Fri, 19 Feb 2021 at 13:06, Hans Hagen > wrote:


On 2/19/2021 12:42 PM, Fabrice Couvreur wrote:
 > Hi Hans,Thanks again for the ideas to improve my code. However, I
am new
 > to Lua and my level is far from sufficient to understand
everything. Why
 > in no table do the crosses appear in the cells; which was my
original
 > idea.Thank you.Fabrice
I get a cross (see attached).


I've got no crosses with ConTeXt  ver: 2021.02.05 17:45 LMTX.
Fresh install of ConTeXt  ver: 2021.02.19 13:15 LMTX gives me no 
crosses, too.

No missing fonts in both cases.
Log and tuc attached.
And with the previously attached xx.tex file? maybe the mailer messes up 
something?


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] Lua code and table

2021-02-19 Thread Jano Kula
Hi,

On Fri, 19 Feb 2021 at 13:06, Hans Hagen  wrote:

> On 2/19/2021 12:42 PM, Fabrice Couvreur wrote:
> > Hi Hans,Thanks again for the ideas to improve my code. However, I am new
> > to Lua and my level is far from sufficient to understand everything. Why
> > in no table do the crosses appear in the cells; which was my original
> > idea.Thank you.Fabrice
> I get a cross (see attached).
>

I've got no crosses with ConTeXt  ver: 2021.02.05 17:45 LMTX.
Fresh install of ConTeXt  ver: 2021.02.19 13:15 LMTX gives me no crosses,
too.
No missing fonts in both cases.
Log and tuc attached.

Jano


hans-metapost.log
Description: Binary data


hans-metapost.tuc
Description: Binary data
___
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] Lua code and table

2021-02-19 Thread Hans Hagen

On 2/19/2021 12:42 PM, Fabrice Couvreur wrote:
Hi Hans,Thanks again for the ideas to improve my code. However, I am new 
to Lua and my level is far from sufficient to understand everything. Why 
in no table do the crosses appear in the cells; which was my original 
idea.Thank you.Fabrice

I get a cross (see attached).

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
-
\setupbodyfont[pagella]

\starttext

\definextable
  [MyTable]
  [align={middle,lohi},
   width=0.8cm,
   offset=0.8ex,
   bodyfont=9pt,
   framecolor=cyan]

\startluacode
function document.MyTable(specification)

local pattern= specification.pattern
local action = specification.action
local conversion = specification.conversion or "Characters"

local n = #pattern

--  context.startxtable { align = "middle,lohi", width = "0.8cm", offset = 
"0.8ex", bodyfont = "9pt", framecolor = "cyan" }
context.startxtable { "MyTable" }
context.startxrow()
context.startxcell { frame = "off" }
context()
context.stopxcell()
for i=1,n do
context.startxcell()
context.convertnumber(conversion,i)
context.stopxcell()
end
context.stopxrow()
for i=1,n do
context.startxrow()
context.startxcell()
context.convertnumber(conversion,i)
context.stopxcell()
for j=1,n do
context.startxcell { align = "middle" }
action(string.sub(pattern[i],j,j))
context.stopxcell()
end
context.stopxrow()
end
context.stopxtable()

end
\stopluacode

\startuniqueMPgraphic{cross}{width,height,depth,color,line}
draw image (
draw (\MPvar{depth},\MPvar{height}) -- (\MPvar{width},0) ;
draw (\MPvar{depth},0) -- (\MPvar{width},\MPvar{height}) ;
)
withpen pencircle scaled \MPvar{line}
withcolor \MPvar{color} ;
\stopuniqueMPgraphic

\definesymbol
  [MyRedCross]
  [\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=red,line=.2ex}]

\definesymbol
  [MyGreenCross]
  
[\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=green,line=.2ex}]

\startluacode
document.MyTable {
action = function(value)
context(value == "X" and 1 or 0)
end,
conversion = "Characters",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
context(value == "X" and 1 or 0)
end,
conversion = "Greek",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
if value == "X" then
context.symbol { "MyRedCross" }
end
end,
conversion = "Romannumerals",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
context.symbol { value == "X" and "MyRedCross"  or "MyGreenCross" }
end,
conversion = "Romannumerals",
pattern = {
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\stoptext


xx.pdf
Description: Adobe PDF document
___
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] Lua code and table

2021-02-19 Thread Fabrice Couvreur
Hi Hans, Thanks again for the ideas to improve my code. However, I am new
to Lua and my level is far from sufficient to understand everything. Why in
no table do the crosses appear in the cells; which was my original idea. Thank
you. Fabrice

Le jeu. 18 févr. 2021 à 16:28, Fabrice Couvreur 
a écrit :

> Hello Jano,
> Thanks.
> Fabrice
>
> Le jeu. 18 févr. 2021 à 16:27, Jano Kula  a écrit :
>
>> Hello Fabrice,
>>
>>
>>
>> On Thu, 18 Feb 2021 at 16:19, Fabrice Couvreur <
>> fabrice1.couvr...@gmail.com> wrote:
>>
>>> Hi all, Thanks to you, I'm not at your level with Lua, but I'm learning
>>> thanks to you
>>> Hans, I compiled your code and I get an error message :
>>>
>>> lua error   > lua error on line 50 in file ./table_1.tex:
>>>
>>> token call, syntax: [ctxlua]:11: unexpected symbol near '='
>>>
>>> 13 \startluacode
>>> 14  function document.MyTable(specification)
>>> 15
>>> 16  local pattern= specification.pattern
>>> 17  local action = specification.action
>>> 18  local conversion = specification.conversion or
>>> "Characters"
>>> 19
>>> 20  local n = #pattern
>>> 21
>>> 22  --  context.startxtable { align = "middle,lohi", width =
>>> "0.8cm",
>>> 23 >>  offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
>>>
>>
>> Just comment out line 23, too, or join 22 + 23 to one line.
>>
>> Jano
>>
>>
>>
>> ___
>> 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] Lua code and table

2021-02-18 Thread Fabrice Couvreur
Hello Jano,
Thanks.
Fabrice

Le jeu. 18 févr. 2021 à 16:27, Jano Kula  a écrit :

> Hello Fabrice,
>
>
>
> On Thu, 18 Feb 2021 at 16:19, Fabrice Couvreur <
> fabrice1.couvr...@gmail.com> wrote:
>
>> Hi all, Thanks to you, I'm not at your level with Lua, but I'm learning
>> thanks to you
>> Hans, I compiled your code and I get an error message :
>>
>> lua error   > lua error on line 50 in file ./table_1.tex:
>>
>> token call, syntax: [ctxlua]:11: unexpected symbol near '='
>>
>> 13 \startluacode
>> 14  function document.MyTable(specification)
>> 15
>> 16  local pattern= specification.pattern
>> 17  local action = specification.action
>> 18  local conversion = specification.conversion or
>> "Characters"
>> 19
>> 20  local n = #pattern
>> 21
>> 22  --  context.startxtable { align = "middle,lohi", width =
>> "0.8cm",
>> 23 >>  offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
>>
>
> Just comment out line 23, too, or join 22 + 23 to one line.
>
> Jano
>
>
>
> ___
> 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] Lua code and table

2021-02-18 Thread Jano Kula
Hello Fabrice,



On Thu, 18 Feb 2021 at 16:19, Fabrice Couvreur 
wrote:

> Hi all, Thanks to you, I'm not at your level with Lua, but I'm learning
> thanks to you
> Hans, I compiled your code and I get an error message :
>
> lua error   > lua error on line 50 in file ./table_1.tex:
>
> token call, syntax: [ctxlua]:11: unexpected symbol near '='
>
> 13 \startluacode
> 14  function document.MyTable(specification)
> 15
> 16  local pattern= specification.pattern
> 17  local action = specification.action
> 18  local conversion = specification.conversion or "Characters"
> 19
> 20  local n = #pattern
> 21
> 22  --  context.startxtable { align = "middle,lohi", width =
> "0.8cm",
> 23 >>  offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
>

Just comment out line 23, too, or join 22 + 23 to one line.

Jano
___
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] Lua code and table

2021-02-18 Thread Fabrice Couvreur
Hi all, Thanks to you, I'm not at your level with Lua, but I'm learning
thanks to you
Hans, I compiled your code and I get an error message :

lua error   > lua error on line 50 in file ./table_1.tex:

token call, syntax: [ctxlua]:11: unexpected symbol near '='

13 \startluacode
14  function document.MyTable(specification)
15
16  local pattern= specification.pattern
17  local action = specification.action
18  local conversion = specification.conversion or "Characters"
19
20  local n = #pattern
21
22  --  context.startxtable { align = "middle,lohi", width =
"0.8cm",
23 >>  offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
24  context.startxtable { "MyTable" }
25  context.startxrow()
26  context.startxcell { frame = "off" }
27  context()
28  context.stopxcell()
29  for i=1,n do
30  context.startxcell()
31  context.convertnumber(conversion,i)
32  context.stopxcell()
33  end

mtx-context | fatal error: return code: 256

TeX Output exited abnormally with code 1 at Thu Feb 18 16:13:29


Thank you very much
Fabrice

Le jeu. 18 févr. 2021 à 10:06, Hans Hagen  a écrit :

> On 2/18/2021 12:22 AM, Bruce Horrocks wrote:
>
> >> On 17 Feb 2021, at 17:40, Fabrice Couvreur 
> wrote:
> >>
> >> Hi, The code works, but is it possible to make it shorter ?
> OK, here is my take, based on earlier posts, bringing together some
> 'technologies':
>
> (1) make a document function which isolatees the code
> (2) then call it where needed
> (3) use the built in conversion code
> (4) use so called unique mp graphics (smaller files, faster run)
> (5) use symbols to get the baseline right
> (6) use a little abstraction in the table setup
>
> watch how we can pass a table instead of a string, so
>
> context.startxtable { align = "middle,lohi", width = "0.8cm", offset =
> "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
>
> is ok, but anm abstraction is even better. Now, who will wikify it ...
>
> %%% code %%%
>
> \setupbodyfont[pagella]
>
> \starttext
>
> \definextable
>[MyTable]
>[align={middle,lohi},
> width=0.8cm,
> offset=0.8ex,
> bodyfont=9pt,
> framecolor=cyan]
>
> \startluacode
>  function document.MyTable(specification)
>
>  local pattern= specification.pattern
>  local action = specification.action
>  local conversion = specification.conversion or "Characters"
>
>  local n = #pattern
>
>  --  context.startxtable { align = "middle,lohi", width = "0.8cm",
> offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }
>  context.startxtable { "MyTable" }
>  context.startxrow()
>  context.startxcell { frame = "off" }
>  context()
>  context.stopxcell()
>  for i=1,n do
>  context.startxcell()
>  context.convertnumber(conversion,i)
>  context.stopxcell()
>  end
>  context.stopxrow()
>  for i=1,n do
>  context.startxrow()
>  context.startxcell()
>  context.convertnumber(conversion,i)
>  context.stopxcell()
>  for j=1,n do
>  context.startxcell { align = "middle" }
>  action(string.sub(pattern[i],j,j))
>  context.stopxcell()
>  end
>  context.stopxrow()
>  end
>  context.stopxtable()
>
>  end
> \stopluacode
>
> \startuniqueMPgraphic{cross}{width,height,depth,color,line}
>  draw image (
>  draw (\MPvar{depth},\MPvar{height}) -- (\MPvar{width},0) ;
>  draw (\MPvar{depth},0) -- (\MPvar{width},\MPvar{height}) ;
>  )
>  withpen pencircle scaled \MPvar{line}
>  withcolor \MPvar{color} ;
> \stopuniqueMPgraphic
>
> \definesymbol
>[MyRedCross]
>
>
> [\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=red,line=.2ex}]
>
> \definesymbol
>[MyGreenCross]
>
>
> [\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=green,line=.2ex}]
>
> \startluacode
>  document.MyTable {
>  action = function(value)
>  context(value == "X" and 1 or 0)
>  end,
>  conversion = "Characters",
>  pattern = {
>  ".XXX..XX",
>  "X...XXX.",
>  "X..X.XXX",
>  "X.X.X..X",
>  ".X.X.XX.",
>  ".XX.X...",
>  "XXX.X...",
>  "X.XX"
>  }
>  }
> \stopluacode
>
> \startluacode
>  document.MyTable {
>  action = function(value)
>  context(value == "X" and 1 or 0)
> 

Re: [NTG-context] Lua code and table

2021-02-18 Thread Hans Hagen

On 2/18/2021 12:22 AM, Bruce Horrocks wrote:


On 17 Feb 2021, at 17:40, Fabrice Couvreur  wrote:

Hi, The code works, but is it possible to make it shorter ?
OK, here is my take, based on earlier posts, bringing together some 
'technologies':


(1) make a document function which isolatees the code
(2) then call it where needed
(3) use the built in conversion code
(4) use so called unique mp graphics (smaller files, faster run)
(5) use symbols to get the baseline right
(6) use a little abstraction in the table setup

watch how we can pass a table instead of a string, so

context.startxtable { align = "middle,lohi", width = "0.8cm", offset = 
"0.8ex", bodyfont = "9pt", framecolor = "cyan" }


is ok, but anm abstraction is even better. Now, who will wikify it ...

%%% code %%%

\setupbodyfont[pagella]

\starttext

\definextable
  [MyTable]
  [align={middle,lohi},
   width=0.8cm,
   offset=0.8ex,
   bodyfont=9pt,
   framecolor=cyan]

\startluacode
function document.MyTable(specification)

local pattern= specification.pattern
local action = specification.action
local conversion = specification.conversion or "Characters"

local n = #pattern

--  context.startxtable { align = "middle,lohi", width = "0.8cm", 
offset = "0.8ex", bodyfont = "9pt", framecolor = "cyan" }

context.startxtable { "MyTable" }
context.startxrow()
context.startxcell { frame = "off" }
context()
context.stopxcell()
for i=1,n do
context.startxcell()
context.convertnumber(conversion,i)
context.stopxcell()
end
context.stopxrow()
for i=1,n do
context.startxrow()
context.startxcell()
context.convertnumber(conversion,i)
context.stopxcell()
for j=1,n do
context.startxcell { align = "middle" }
action(string.sub(pattern[i],j,j))
context.stopxcell()
end
context.stopxrow()
end
context.stopxtable()

end
\stopluacode

\startuniqueMPgraphic{cross}{width,height,depth,color,line}
draw image (
draw (\MPvar{depth},\MPvar{height}) -- (\MPvar{width},0) ;
draw (\MPvar{depth},0) -- (\MPvar{width},\MPvar{height}) ;
)
withpen pencircle scaled \MPvar{line}
withcolor \MPvar{color} ;
\stopuniqueMPgraphic

\definesymbol
  [MyRedCross]

[\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=red,line=.2ex}]

\definesymbol
  [MyGreenCross]

[\uniqueMPgraphic{cross}{width=1em,height=1ex,depth=.5ex,color=green,line=.2ex}]

\startluacode
document.MyTable {
action = function(value)
context(value == "X" and 1 or 0)
end,
conversion = "Characters",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
context(value == "X" and 1 or 0)
end,
conversion = "Greek",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
if value == "X" then
context.symbol { "MyRedCross" }
end
end,
conversion = "Romannumerals",
pattern = {
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\startluacode
document.MyTable {
action = function(value)
context.symbol { value == "X" and "MyRedCross"  or 
"MyGreenCross" }

end,
conversion = "Romannumerals",
pattern = {
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX"
}
}
\stopluacode

\stoptext


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

Re: [NTG-context] Lua code and table

2021-02-17 Thread Bruce Horrocks


> On 17 Feb 2021, at 17:40, Fabrice Couvreur  
> wrote:
> 
> Hi, The code works, but is it possible to make it shorter ? 
> Thank you
> Fabrice
> 

You can reduce the size of the test by storing the pattern in a table:

\startluacode
  local background_one = {
   align = "middle",
   style = "type",
   background = "DiagonalRule",
  }

  local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" }
  local pattern_1 = { 
".XXX..XX",
"X...XXX.",
"X..X.XXX",
"X.X.X..X",
".X.X.XX.",
".XX.X...",
"XXX.X...",
"X.XX" }
  context.startxtable({"align={middle,lohi}, 
width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"})
  context.startxrow()
  context.startxcell({"frame=off"})
  context()
  context.stopxcell()
  for _, letter in ipairs(letters_1) do
context.startxcell()
context(letter) context.stopxcell()
  end
  context.stopxrow()
   for i, letter in ipairs(letters_1) do
  context.startxrow()
context.startxcell()
context(letter)
context.stopxcell()
  for j = 1, 8 do
context.startxcell( string.sub(pattern_1[i],j,j) == "X" and background_one )
  context()
  context.stopxcell()
  end
  context.stopxrow()
  end
  context.stopxtable()
\stopluacode

—
Bruce Horrocks
Hampshire, UK

___
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] Lua code and table

2021-02-17 Thread Hans Hagen

On 2/17/2021 10:26 PM, Wolfgang Schuster wrote:

Fabrice Couvreur schrieb am 17.02.2021 um 18:40:

Hi,The code works, but is it possible to make it shorter ?
Thank you
Fabrice


\startuseMPgraphic{DiagonalRule}
    rulethickness := \frameddimension{rulethickness};

    drawoptions(
      withpen pencircle scaled rulethickness
      withcolor \MPcolor{\framedparameter{framecolor}});

    pair leftcorner, rightcorner, Leftcorner, Rightcorner;
    leftcorner  := (rulethickness, \overlayheight-rulethickness);
    rightcorner := (\overlaywidth-rulethickness, rulethickness);
    Leftcorner  := ( rulethickness, rulethickness);
    Rightcorner := 
(\overlaywidth-rulethickness,\overlayheight-rulethickness);


    draw leftcorner -- rightcorner;
    draw Leftcorner -- Rightcorner;
  \stopuseMPgraphic



\startuseMPgraphic{DiagonalRule}
     drawoptions(
     withpen pencircle scaled OverlayLineWidth
     withcolor OverlayLineColor
     );

     draw ulcorner OverlayBox -- lrcorner OverlayBox ;
     draw llcorner OverlayBox -- urcorner OverlayBox ;
\stopuseMPgraphic

Often this also works:

\startuseMPgraphic{DiagonalRule}
draw image (
draw ulcorner OverlayBox -- lrcorner OverlayBox ;
draw llcorner OverlayBox -- urcorner OverlayBox ;
)
withpen pencircle scaled OverlayLineWidth
withcolor OverlayLineColor ;
\stopuseMPgraphic


-
  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] Lua code and table

2021-02-17 Thread Wolfgang Schuster

Fabrice Couvreur schrieb am 17.02.2021 um 18:40:

Hi,The code works, but is it possible to make it shorter ?
Thank you
Fabrice


\startuseMPgraphic{DiagonalRule}
    rulethickness := \frameddimension{rulethickness};

    drawoptions(
      withpen pencircle scaled rulethickness
      withcolor \MPcolor{\framedparameter{framecolor}});

    pair leftcorner, rightcorner, Leftcorner, Rightcorner;
    leftcorner  := (rulethickness, \overlayheight-rulethickness);
    rightcorner := (\overlaywidth-rulethickness, rulethickness);
    Leftcorner  := ( rulethickness, rulethickness);
    Rightcorner := 
(\overlaywidth-rulethickness,\overlayheight-rulethickness);


    draw leftcorner -- rightcorner;
    draw Leftcorner -- Rightcorner;
  \stopuseMPgraphic



\startuseMPgraphic{DiagonalRule}
drawoptions(
withpen pencircle scaled OverlayLineWidth
withcolor OverlayLineColor
);

draw ulcorner OverlayBox -- lrcorner OverlayBox ;
draw llcorner OverlayBox -- urcorner OverlayBox ;
\stopuseMPgraphic

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] Lua code and table

2021-02-17 Thread Tomas Hala
Hi Fabrice,

see below, I attached two ideas how to do it.

The best,

Tomáš

Wed, Feb 17, 2021 ve 06:40:54PM +0100 Fabrice Couvreur napsal(a):
#Hi,  The code works, but is it possible to make it shorter ?
#Thank you
#Fabrice
#\startuseMPgraphic{DiagonalRule}
#   rulethickness := \frameddimension{rulethickness};
# 
#   drawoptions(
#     withpen pencircle scaled rulethickness
#     withcolor \MPcolor{\framedparameter{framecolor}});
# 
#   pair leftcorner, rightcorner, Leftcorner, Rightcorner;
#   leftcorner  := (rulethickness, \overlayheight-rulethickness);
#   rightcorner := (\overlaywidth-rulethickness, rulethickness);
#   Leftcorner  := ( rulethickness, rulethickness);
#   Rightcorner :=
#(\overlaywidth-rulethickness,\overlayheight-rulethickness);
# 
#   draw leftcorner -- rightcorner;
#   draw Leftcorner -- Rightcorner;
# \stopuseMPgraphic
# 
#\defineoverlay
#  [DiagonalRule]
#  [\useMPgraphic{DiagonalRule}]
# 
#\define[2]\DiagonalLabel{%
#  \setuptabulate [after={\blank[\frameddimension{offset}]}]
#  \starttabulate [|p|r|]
#    \NC    \NC \bf #2 \NC\NR
#    \NC \bf #1 \NC    \NC\NR
#  \stoptabulate
#}
#\starttext
#\startluacode
#  local background_one = {
#   align = "middle",
#   style = "type",
#   background = "DiagonalRule",
#  }
# 
#  local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" }
#  context.startxtable({"align={middle,lohi},
#width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"})
#  context.startxrow()
#  context.startxcell({"frame=off"})
#  context()
#  context.stopxcell()
#  for _, letter in ipairs(letters_1) do
#    context.startxcell()
#    context(letter) context.stopxcell()
#  end
#  context.stopxrow()
#   for _, letter in ipairs(letters_1) do
#  context.startxrow()
#    context.startxcell()
#    context(letter)
#    context.stopxcell()
#  for j = 0, 7 do
#  context.startxcell(  j == 0 and letter == "B" and background_one
#  or j == 0 and letter == "C" and background_one
#  or j == 0 and letter == "D" and background_one
#  or j == 0 and letter == "G" and background_one
#  or j == 0 and letter == "H" and background_one
#  or j == 1 and letter == "A" and background_one
#  or j == 1 and letter == "E" and background_one
#  or j == 1 and letter == "F" and background_one
#  or j == 1 and letter == "G" and background_one
#  or j == 2 and letter == "A" and background_one
#  or j == 2 and letter == "D" and background_one
#  or j == 2 and letter == "F" and background_one
#  or j == 2 and letter == "G" and background_one
#  or j == 2 and letter == "H" and background_one
#  or j == 3 and letter == "A" and background_one
#  or j == 3 and letter == "C" and background_one
#  or j == 3 and letter == "E" and background_one
#  or j == 3 and letter == "H" and background_one
#  or j == 4 and letter == "B" and background_one
#  or j == 4 and letter == "D" and background_one
#  or j == 4 and letter == "F" and background_one
#  or j == 4 and letter == "G" and background_one
#  or j == 5 and letter == "B" and background_one
#  or j == 5 and letter == "C" and background_one
#  or j == 5 and letter == "E" and background_one
#  or j == 6 and letter == "A" and background_one
#  or j == 6 and letter == "B" and background_one
#  or j == 6 and letter == "C" and background_one
#  or j == 6 and letter == "E" and background_one
#  or j == 7 and letter == "A" and background_one
#  or j == 7 and letter == "C" and background_one
#  or j == 7 and letter == "D" and background_one
#  )
#  context()
#  context.stopxcell()
#  end
#  context.stopxrow()
#  end
#  context.stopxtable()
#\stopluacode
#\stoptext

%%%=
\starttext
\startluacode

function test()
  for x=0,7 do 
for y=65,72 do 
  local yy=string.char(y)
  context(x)  
  context(" "..yy)
  context(f1(x,yy)..f2(x,yy)..f3(x,yy))
  context.par()
  end end
end

local background_one = true

function f1 (j,letter)
  local res=
   j == 0  and  letter == "B"  and  background_one  
or j == 0  and  letter == "C"  and  background_one 
or j == 0  and  letter == "D"  and  background_one 
or j == 0  and  letter == "G"  and  background_one 
or j == 0  and  letter == "H"  and  background_one 
or j == 1  and  letter == "A"  and  background_one 
or j == 1  and  letter == "E"  and  background_one 
or j == 1  and  letter == "F"  and  background_one 
or j == 1  and  letter == "G"  and  background_one 
or j == 2  and  letter == "A"  and  background_one 
or j == 2  and  letter == "D"  and  background_one 
or j == 2  and  letter == "F"  and  background_one 
or j == 2  and  letter == "G"  and  background_one 
or j == 2  and  letter == "H"  and  backgro

[NTG-context] Lua code and table

2021-02-17 Thread Fabrice Couvreur
Hi, The code works, but is it possible to make it shorter ?
Thank you
Fabrice


\startuseMPgraphic{DiagonalRule}
   rulethickness := \frameddimension{rulethickness};

   drawoptions(
 withpen pencircle scaled rulethickness
 withcolor \MPcolor{\framedparameter{framecolor}});

   pair leftcorner, rightcorner, Leftcorner, Rightcorner;
   leftcorner  := (rulethickness, \overlayheight-rulethickness);
   rightcorner := (\overlaywidth-rulethickness, rulethickness);
   Leftcorner  := ( rulethickness, rulethickness);
   Rightcorner :=
(\overlaywidth-rulethickness,\overlayheight-rulethickness);

   draw leftcorner -- rightcorner;
   draw Leftcorner -- Rightcorner;
 \stopuseMPgraphic

\defineoverlay
  [DiagonalRule]
  [\useMPgraphic{DiagonalRule}]

\define[2]\DiagonalLabel{%
  \setuptabulate [after={\blank[\frameddimension{offset}]}]
  \starttabulate [|p|r|]
\NC\NC \bf #2 \NC\NR
\NC \bf #1 \NC\NC\NR
  \stoptabulate
}
\starttext
\startluacode
  local background_one = {
   align = "middle",
   style = "type",
   background = "DiagonalRule",
  }

  local letters_1 = { "A", "B", "C", "D", "E", "F", "G", "H" }
  context.startxtable({"align={middle,lohi},
width=0.8cm,offset=0.8ex,bodyfont=9pt,framecolor=cyan"})
  context.startxrow()
  context.startxcell({"frame=off"})
  context()
  context.stopxcell()
  for _, letter in ipairs(letters_1) do
context.startxcell()
context(letter) context.stopxcell()
  end
  context.stopxrow()
   for _, letter in ipairs(letters_1) do
  context.startxrow()
context.startxcell()
context(letter)
context.stopxcell()
  for j = 0, 7 do
  context.startxcell(  j == 0 and letter == "B" and background_one
  or j == 0 and letter == "C" and background_one
  or j == 0 and letter == "D" and background_one
  or j == 0 and letter == "G" and background_one
  or j == 0 and letter == "H" and background_one
  or j == 1 and letter == "A" and background_one
  or j == 1 and letter == "E" and background_one
  or j == 1 and letter == "F" and background_one
  or j == 1 and letter == "G" and background_one
  or j == 2 and letter == "A" and background_one
  or j == 2 and letter == "D" and background_one
  or j == 2 and letter == "F" and background_one
  or j == 2 and letter == "G" and background_one
  or j == 2 and letter == "H" and background_one
  or j == 3 and letter == "A" and background_one
  or j == 3 and letter == "C" and background_one
  or j == 3 and letter == "E" and background_one
  or j == 3 and letter == "H" and background_one
  or j == 4 and letter == "B" and background_one
  or j == 4 and letter == "D" and background_one
  or j == 4 and letter == "F" and background_one
  or j == 4 and letter == "G" and background_one
  or j == 5 and letter == "B" and background_one
  or j == 5 and letter == "C" and background_one
  or j == 5 and letter == "E" and background_one
  or j == 6 and letter == "A" and background_one
  or j == 6 and letter == "B" and background_one
  or j == 6 and letter == "C" and background_one
  or j == 6 and letter == "E" and background_one
  or j == 7 and letter == "A" and background_one
  or j == 7 and letter == "C" and background_one
  or j == 7 and letter == "D" and background_one
  )
  context()
  context.stopxcell()
  end
  context.stopxrow()
  end
  context.stopxtable()
\stopluacode
\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
___


[NTG-context] Lua equivalent of \getvariable{}{}

2020-10-11 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\starttext
\ctxlua{ context.setvariable("environment", "filename", "abc123") }
\ctxlua{ c = context.getvariable("environment", "filename") or "a" }
\ctxlua{ d = [[\env{filename}]] }

c: \cldcontext{c}\\
\doifelse{\cldcontext{c:match("\letterpercent d+")}}
{123}{yes}{no}\\
d: \cldcontext{d}\\
\doifelse{\cldcontext{d:match("\letterpercent d+")}}
{123}{yes}{no}
\stoptext

Which is the Lua equivalent of \getvariable{}{}? I get nil now.

BTW, I wonder why \setvariable prints the variable, botn in Lua and ConTeXt.

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] Lua related change in LuaMetaTeX?

2020-07-29 Thread Marcel Fabian Krüger
On Wed, Jul 29, 2020 at 09:37:13PM -0700, Hans Hagen wrote:
> > One other question about LuaMetaTeX 2.7.1: I noticed that the
> > terminal_input callback is gone. Does this mean that the current
> > behaviour of basically freezing when previously terminal input was
> > requested is hardcoded or is some other callback invoked which can then
> > provide some tokens?
> > 
> > Marcel
> 
> first line on console was already gone (only the filename gets pushed into 
> the input because tex forces an input

I think this is a misunderstanding. I wasn't referring to the first
line, but to lines after the main input is fully evaluated. E.g. as a
ConTeXt example

  \starttext
  \def\dosomethinguseful#1{Do something useful with #1}
  \dosomethinguseful{
Ups, I "forgot" to close this brace
  \stoptext

This used to end up asking for terminal input. Especially since the
terminal_input callback was available, it was possible to detect such
situations and trigger an error. With the current ConTeXt code, I
couldn't find a nice solution for this and when running such documents,
the interpreter basically freezes, starts consuming memory and finally
gets killed by the out of memory handler. Experients with
token.scan_next suggest that instead of asking for input, TeX keeps
seeing a special relax-like token. I was hoping that there is some
callback which can be used to intercept this and either fail gracefully
with an error message or to provide more useful tokens.
> 
> anyway, read/write channel zero are for the terminal
> 

That's good to know, thank you.

Marcel
___
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] Lua related change in LuaMetaTeX?

2020-07-29 Thread Hans Hagen

On 7/29/2020 6:11 PM, Marcel Fabian Krüger wrote:

there have been a couple of bug fixes after the formal 5.4.0 release but afaik 
not in the virtual machine code (which normally is the most sensitive); i used 
to mark low level changes so that it got signaled (in context) but the byte 
code version info changed late in 5.4 dev so i no longer do that now

although i occasionally have run into buglets in 5.4 code - which to me is 
quite natural as it concerns dev / exp versions so one gets what one downloads, 
i.e. one can only blame oneself for using such versions and hardly complain - 
lua is quite stable and reliable (given the massive amount of lua code that we 
use in context) ... so, normally patience - read: wait for updates - is the 
answer


Oh I see, I wasn't aware that the dev versions are used. After
recompiling with the latest development code the error is gone.

One other question about LuaMetaTeX 2.7.1: I noticed that the
terminal_input callback is gone. Does this mean that the current
behaviour of basically freezing when previously terminal input was
requested is hardcoded or is some other callback invoked which can then
provide some tokens?
first line on console was already gone (only the filename gets pushed 
into the input because tex forces an input


anyway, read/write channel zero are for the terminal

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] Lua related change in LuaMetaTeX?

2020-07-29 Thread Marcel Fabian Krüger
> there have been a couple of bug fixes after the formal 5.4.0 release but 
> afaik not in the virtual machine code (which normally is the most sensitive); 
> i used to mark low level changes so that it got signaled (in context) but the 
> byte code version info changed late in 5.4 dev so i no longer do that now
>
> although i occasionally have run into buglets in 5.4 code - which to me is 
> quite natural as it concerns dev / exp versions so one gets what one 
> downloads, i.e. one can only blame oneself for using such versions and hardly 
> complain - lua is quite stable and reliable (given the massive amount of lua 
> code that we use in context) ... so, normally patience - read: wait for 
> updates - is the answer

Oh I see, I wasn't aware that the dev versions are used. After
recompiling with the latest development code the error is gone.

One other question about LuaMetaTeX 2.7.1: I noticed that the
terminal_input callback is gone. Does this mean that the current
behaviour of basically freezing when previously terminal input was
requested is hardcoded or is some other callback invoked which can then
provide some tokens?

Marcel
___
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] Lua related change in LuaMetaTeX?

2020-07-29 Thread Hans Hagen

On 7/29/2020 6:22 AM, Marcel Fabian Krüger wrote:

Hi,

starting with LuaMetaTeX 2.07.01, a C library I load from Lua started to
segfault and valgrind indicates that it accesses invalid memory in
multiple places in the middle of Lua internal functions?!

The whole thing looks almost like the Lua versions in LuaMetaTeX and in
the library are incompatible, but both seem to use 5.4.0. So I asked
myself if there might be changes not reflected by the version number.

tl;dr: Has the embedded Lua interpreter changed in some non ABI-compatible
way in LuaMetaTeX 2.07.01? (Especially on Linux, x86-64. I didn't test
other platforms yet)
there have been a couple of bug fixes after the formal 5.4.0 release but 
afaik not in the virtual machine code (which normally is the most 
sensitive); i used to mark low level changes so that it got signaled (in 
context) but the byte code version info changed late in 5.4 dev so i no 
longer do that now


although i occasionally have run into buglets in 5.4 code - which to me 
is quite natural as it concerns dev / exp versions so one gets what one 
downloads, i.e. one can only blame oneself for using such versions and 
hardly complain - lua is quite stable and reliable (given the massive 
amount of lua code that we use in context) ... so, normally patience - 
read: wait for updates - is the answer


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
___


[NTG-context] Lua related change in LuaMetaTeX?

2020-07-28 Thread Marcel Fabian Krüger
Hi,

starting with LuaMetaTeX 2.07.01, a C library I load from Lua started to
segfault and valgrind indicates that it accesses invalid memory in
multiple places in the middle of Lua internal functions?!

The whole thing looks almost like the Lua versions in LuaMetaTeX and in
the library are incompatible, but both seem to use 5.4.0. So I asked
myself if there might be changes not reflected by the version number.

tl;dr: Has the embedded Lua interpreter changed in some non ABI-compatible
way in LuaMetaTeX 2.07.01? (Especially on Linux, x86-64. I didn't test
other platforms yet)

Best regards,
Marcel
___
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] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-02 Thread Gerben Wierda
Actually, the backslashes disappear before the call to textext()

G

> On 1 Apr 2020, at 23:44, Aditya Mahajan  wrote:
> 
> On Wed, 1 Apr 2020, Gerben Wierda wrote:
>> 
>> My route is probably to complex anyway, but what can I do for the curly 
>> braces to be actually typeset?
> 
> MkII had a feature called \sometxt
> http://dl.contextgarden.net/myway/sometxt.pdf
> 
> I wonder if that still works in MkIV.
> 
> 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
> ___

___
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] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Aditya Mahajan

On Wed, 1 Apr 2020, Gerben Wierda wrote:


My route is probably to complex anyway, but what can I do for the curly braces 
to be actually typeset?


MkII had a feature called \sometxt
http://dl.contextgarden.net/myway/sometxt.pdf

I wonder if that still works in MkIV.

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] Lua/TeX/METAPOST/textext string issue/puzzle

2020-04-01 Thread Gerben Wierda
I have lua code that generates this for METAPOST:

ApplicationComponentLogo( w, h, "withcolor (0.686,1.000,1.000) withtransparency 
(1,0.200)", "withcolor (0.000,0.000,0.000) withtransparency (1,1.000) withpen 
pencircle scaled 1.000", "\{Hello\}, "&ditto&"(a)"&ditto&" [World]!") shifted 
(x, -y); draw pic;

The string to be typeset, eventually is this: 

{Hello}, "(a)" [World]!

So, with double quotes in the string. The function creating the actual string 
to pass to METAPOST (above) is this:

local function mpLabelString( xmlLabelString)
  -- Returns a string where each " is replaced by a METAPOST compatible result, 
except for outer double quotes"
  rep = {
  [1] = { "\"", "\"&ditto&\""   },
  }
  local tmpString = string.formatters( "%!tex!", xmlLabelString)
  return lpeg.replacer(rep):match(tmpString)
end

That works. Then, in METAPOST the vardef ‘ApplicationComponentLogo’  calls a 
vardef makeTeXLabel 

draw makeTeXLabel( w, h, name) shifted (w/2,0);

which, for now, simplified does this:

vardef makeTeXLabel( expr w, h, name) =
  save p; picture p ;
  save s; string s;
  s := "\framed{" & name & "}”;
  % s := "\type-" & name & "-";
  p := textext( s);
  p
enddef;

But, this is what is in string s before it is sent to textext():

\framed {{Hello}, "(a)" [World]!}

In other words, the escapes on the curly braces are lost and now the curly 
braces are ignored by TeX. 

I tried adding a doubling of the backslahes to the replacement:

  rep = {
  [1] = { "\"", "\"&ditto&\""   },
  [2] = { "\\", "" },
  }

But then the string that is typeset (and given to textext()) becomes 

\framed {\\{Hello\\}, "(a)" [World]!}

And the result in the output is the same. No curly braces.

My route is probably to complex anyway, but what can I do for the curly braces 
to be actually typeset?

G___
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] Lua error using module pgfplots and shader=interp

2019-05-30 Thread Luca Donetti
On Thu, May 30, 2019 at 11:00 AM Hans Hagen  wrote:

> On 5/29/2019 10:36 PM, Luca Donetti wrote:
> > Dear all,
> >
> > The following example using module pgfplots does not work in an updated
> > context standalone nor with the texlive 2019 version.
> fixed in next beta
>

Thank you.
___
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] Lua error using module pgfplots and shader=interp

2019-05-30 Thread Hans Hagen

On 5/29/2019 10:36 PM, Luca Donetti wrote:

Dear all,

The following example using module pgfplots does not work in an updated 
context standalone nor with the texlive 2019 version.

fixed in next beta



-
  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] Lua error using module pgfplots and shader=interp

2019-05-29 Thread Luca Donetti
Dear all,

The following example using module pgfplots does not work in an updated
context standalone nor with the texlive 2019 version.

%% Workaround for using tikz version in texlive 2019.
%% See https://github.com/pgf-tikz/pgf/issues/675
%\unprotect
%\def\XC@tgt@mod#1{#1}
%\def\XC@sdef#1#2{\edef#1{#2}}
%\protect

\setupcolors[state=start]
\usemodule[pgfplots]
\starttext
\starttikzpicture
  \startaxis
\addplot3 [
  surf,
  shader=interp, % works with shader=flat
  samples=10,
  domain=0:1,
  ] {x^2*y};
  \stopaxis
\stoptikzpicture
\stoptext

The  error is the following (where line 19 contains "\stopaxis")
lua error   > lua error on line 19 in file [...]:
...781ce0dde776fb1556f32e/formats/luatex/lpdf-ini-macro.lua:887: pdf.obj():
object "type" missing

I'm attaching the test file, with the .the log and  ...-error.log files.
Please note that to reproduce the error with the context version of texlive
2019 the first lines must be uncommented due to a bug in the newer version
of tikz.

I suspect that the problem is with context because same file works with
context from texlive 2018 (which has the same pgfplots version) and an
equivalent latex version works with lualatex.

Could you suggest any workaround? If not I'll file a bug with pgfplots.

Thank you in advance,
LD
open source > level 1, order 1, name '/home/luca/software/context/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv'
job > passes > version mismatch: 1.3 <> 1.31
system  > 
system  > ConTeXt  ver: 2019.05.25 10:45 MKIV beta  fmt: 2019.5.27  int: english/english
system  > 
system  > 'cont-new.mkiv' loaded
open source > level 2, order 2, name '/home/luca/software/context/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 '/home/luca/software/context/tex/texmf-context/tex/context/base/mkiv/cont-new.mkiv'
system  > files > jobname 'minimal_shading', input './minimal_shading', result 'minimal_shading'
fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > level 2, order 3, name '/home/luca/Nextcloud/personal/tmpcontext/minimal_shading.tex'
colors  > 'rgb' color space is supported
colors  > 'cmyk' color space is supported
modules > 'pgfplots' is loaded
open source > level 3, order 4, name '/home/luca/software/context/tex/texmf-modules/tex/context/third/pgfplots/t-pgfplots.tex'
loading > ConTeXt User Module / Pgfplots
open source > level 4, order 5, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgfplots/pgfplots.revision.tex'
close source> level 4, order 5, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgfplots/pgfplots.revision.tex'
modules > 'tikz' is loaded
open source > level 4, order 6, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/frontendlayer/t-tikz.tex'
loading > ConTeXt User Module / tikz
open source > level 5, order 7, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/basiclayer/t-pgf.tex'
loading > ConTeXt User Module / pgf
open source > level 6, order 8, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/basiclayer/t-pgfcor.tex'
loading > ConTeXt User Module / pgfcor
open source > level 7, order 9, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/systemlayer/t-pgfsys.tex'
loading > ConTeXt User Module / pgfsys
open source > level 8, order 10, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/utilities/t-pgfrcs.tex'
loading > ConTeXt User Module / pgfrcs
open source > level 9, order 11, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/utilities/t-pgfmod.tex'
loading > ConTeXt User Module / pgfmodules
close source> level 9, order 11, name '/home/luca/software/context/tex/texmf-modules/tex/context/pgf/utilities/t-pgfmod.tex'
open source > level 9, order 12, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-common.tex'
open source > level 10, order 13, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-common-lists.tex'
close source> level 10, order 13, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-common-lists.tex'
close source> level 9, order 13, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-common.tex'
open source > level 9, order 14, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-context.def'
close source> level 9, order 14, name '/home/luca/software/context/tex/texmf-modules/tex/generic/pgf/utilities/pgfutil-context.def'
open source > level 9, order 15, name '/home/luca/software/context/tex/texm

[NTG-context] Lua os.date() localization in context

2019-04-29 Thread Romain Diss
Hi all,

I would like to print the day name of a date in french using my current
locale.

In lua I can do:
> os.setlocale('fr_FR.UTF-8',all)
> print(os.date("%A"))

But in a cld document it doesn't work. Context complains about using
"os.locale in a supposedly locale neutral enviroment" and it prints the
day name in english.

How can I translate the day names without hardcoding everything?

Thanks in advance.

Best.

-- 
Romain Diss
___
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] Lua error in latest beta?

2019-04-29 Thread Alan Bowen
When I process files using the latest standalone  ConTeXt  ver: 2019.04.29
08:52 MKIV beta  fmt:  LuaTeX, Version 1.10.0 (TeX Live 2019)), I now get
the following error message:

lua error   > lua error on line 8 in file env_Brill-01.tex:


...eXt/tex/texmf-context/tex/context/base/mkiv/font-oup.lua:1317: bad
argument #1 to 'concat' (table expected, got number)

The error log is as follows:

return {
 ["filename"]="env_Brill-01.tex",
 ["lastcontext"]="\
\\font_helpers_low_level_define ...nsize }{\\m_font_designsize
}\\scaledfontmode \
  \\relax \\ifcase
\\scaledfont...\
\\font_fallbacks_clone_unique ...w_level_define
{#1}\\v_font_identifier_basic \
  \\csname
\\v_font_identifier...\
l.8 }\
\
\\font_fallbacks_prepare #1->\\clf_fontcollectionprepare {#1}\
  \
\\font_fallbacks_prepare_indeed ... \\lastrawfontcall
\\font_fallbacks_prepare #1\
  \\endgroup \
 ...nt_fallbacks_prepare_indeed \\m_font_fallbacks \
  \\fi \\fi \
...\
l.215 \\setupbodyfont[mainface, 10pt]\
   ",
 
["lastluaerror"]="...eXt/tex/texmf-context/tex/context/base/mkiv/font-oup.lua:1317:
bad argument #1 to 'concat' (table expected, got number)",
 ["lasttexerror"]="?",
 ["linenumber"]=8,
 ["luaerrorline"]="1317",
 ["offset"]=10,
}

This files process as they should with earlier versions. I will try to
produce an mwe if needed but hope that it is not.

Alan
___
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] Lua error with fontstrip in today’s beta

2019-04-12 Thread Hans Hagen

On 4/12/2019 11:19 PM, Henning Hraban Ramm wrote:

I just updated my minimals installation (2019.04.12 17:43, still not lmtx) and 
run into this error:

lua error   > lua error on line 1 in file fontstriptest.tex:

...xmf/tex/texmf-context/tex/context/base/mkiv/node-nut.lua:284: attempt to 
call a nil value (global 'setfield')

1 >>  \starttext
2
3 \showfontstrip
4
5 \stoptext


MWE:

\starttext

\showfontstrip

\stoptext

i'll fix it (side effect of transition to lmtx as alan mentioned)

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] Lua error with fontstrip in today’s beta

2019-04-12 Thread Alan Braslau
On Fri, 12 Apr 2019 23:19:34 +0200
Henning Hraban Ramm  wrote:

> minimals installation (2019.04.12 17:43, still not lmtx)

Ah, when I first started using ConTeXt, MkIV was somewhat experimental and it 
was still recommended to use MkII (with pdftex) for "production". Now we are 
generally surprised when someone comes up with MkII questions or examples ... 
and as this has become old hat. So Hans came up with lmtx just to animate the 
mailing list. Keeps us on our toes!

:-)

Alan

P.S. your MWE works fine with the latest lmtx...
___
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] Lua error with fontstrip in today’s beta

2019-04-12 Thread Henning Hraban Ramm
I just updated my minimals installation (2019.04.12 17:43, still not lmtx) and 
run into this error:

lua error   > lua error on line 1 in file fontstriptest.tex:

...xmf/tex/texmf-context/tex/context/base/mkiv/node-nut.lua:284: attempt to 
call a nil value (global 'setfield')

1 >>  \starttext
2 
3 \showfontstrip
4 
5 \stoptext


MWE:

\starttext

\showfontstrip

\stoptext



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

___
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] lua-error when asking for the fontame

2019-03-09 Thread Willi Egger
Thank you Hans!


> On 9 Mar 2019, at 10:12, Hans Hagen  wrote:
> 
> On 3/8/2019 11:16 PM, Willi Egger wrote:
>> \setupbodyfont[pagella,rm,12pt]
>> \starttext
>> This text is written in  \font\fontname
>> \stoptext
> 
> > This text is written in  \fontname\font
> 
> 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
> ___

___
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] lua-error when asking for the fontame

2019-03-09 Thread Alan Braslau
On Sat, 9 Mar 2019 10:12:06 +0100
Hans Hagen  wrote:

> On 3/8/2019 11:16 PM, Willi Egger wrote:
> > \setupbodyfont[pagella,rm,12pt]
> > \starttext
> > This text is written in  \font\fontname
> > \stoptext  
> 
>  > This text is written in  \fontname\font  

We also have:

\fontclass \the\globalbodyfontsize

Alan
___
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] lua-error when asking for the fontame

2019-03-09 Thread Hans Hagen

On 3/8/2019 11:16 PM, Willi Egger wrote:

\setupbodyfont[pagella,rm,12pt]
\starttext
This text is written in  \font\fontname
\stoptext


> This text is written in  \fontname\font

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
___


[NTG-context] lua-error when asking for the fontame

2019-03-08 Thread Willi Egger
Hello,


today I updated ConTeXt to the version of 2019-03-05.

While testing a type-script I got an error, when I ask for the font name.

lua error   > lua error on line 1 in file /test.tex:

...ext/tex/texmf-context/tex/context/base/mkiv/font-syn.lua:519: bad argument 
#1 to 'lower' (string expected, got nil)

MWE:

\setupbodyfont[pagella,rm,12pt]
\starttext
This text is written in  \font\fontname
\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] lua lpeg + utf8

2019-01-06 Thread Thomas A. Schmitz

On 06.01.19 23:08, Hans Hagen wrote:

what do you mean with "running luatex alone" ; you can run scripts with

mtxrun --script yourscript foo.txt

(or do you mean something different)


Hi Hans,

thanks, this is what I meant! I guess I was trying to reinvent the wheel 
and doing things in pure Lua, but processing utf8 is indeed much easier 
with all the context functions. So thanks, I hope I can take it from here!


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

Re: [NTG-context] lua lpeg + utf8

2019-01-06 Thread Hans Hagen

On 1/6/2019 8:14 PM, Thomas A. Schmitz wrote:

On 06.01.19 19:20, Wolfgang Schuster wrote:

\starttext

\startluacode

print("abcdeφὴὰabcde")

local remap = utf.remapper { a = "y", c = "z", ὴ = "ή", ὰ = "ά" }

print(remap("abcdeφὴὰabcde"))

\stopluacode

\stoptext


Wolfgang, thank you, I should have looked into this manual! Is there an 
easy way to load the necessary additional libraries if I'm running 
luatex alone, outside of mtxrun?

what do you mean with "running luatex alone" ; you can run scripts with

mtxrun --script yourscript foo.txt

(or do you mean something different)


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] lua lpeg + utf8

2019-01-06 Thread Thomas A. Schmitz

On 06.01.19 19:20, Wolfgang Schuster wrote:

\starttext

\startluacode

print("abcdeφὴὰabcde")

local remap = utf.remapper { a = "y", c = "z", ὴ = "ή", ὰ = "ά" }

print(remap("abcdeφὴὰabcde"))

\stopluacode

\stoptext


Wolfgang, thank you, I should have looked into this manual! Is there an 
easy way to load the necessary additional libraries if I'm running 
luatex alone, outside of mtxrun?


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

Re: [NTG-context] lua lpeg + utf8

2019-01-06 Thread Wolfgang Schuster

Thomas A. Schmitz schrieb am 06.01.19 um 18:53:

Hi everybody,

best wishes for (the still new) 2019! My question is not strictly a 
ConTeXt problem, but about the way luatex (and pure Lua) can handle utf8 
in lpeg. Here is my Lua example:


mystring = "abcdeφὴὰabcde"

local replace_table = {
   a = "y",
   c = "z",
   ὴ = "ή",
   ὰ = "ά",
}

function replace(s)
 local patt = (lpeg.Cs(1)) / replace_table
 local parser = lpeg.Cs((patt + 1)^0)
 t = parser:match(s)
 return t
end

newstring = replace(mystring)

print(newstring)

This will successfully replace "a" and "c," but not "ὴ" or "ὰ" because 
lpeg.Cs(1) sees only the first byte of these multibyte characters. Pure 
Lua complains with an error message; luatex runs, but does not do the 
replacement. What would be a good way to work around this limitation?


Below is a modified version of the example on page 103 of the ConTeXt 
Lua Documents (cld-mkiv.pdf) manual.


\starttext

\startluacode

print("abcdeφὴὰabcde")

local remap = utf.remapper { a = "y", c = "z", ὴ = "ή", ὰ = "ά" }

print(remap("abcdeφὴὰabcde"))

\stopluacode

\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] lua lpeg + utf8

2019-01-06 Thread Thomas A. Schmitz

Hi everybody,

best wishes for (the still new) 2019! My question is not strictly a 
ConTeXt problem, but about the way luatex (and pure Lua) can handle utf8 
in lpeg. Here is my Lua example:


mystring = "abcdeφὴὰabcde"

local replace_table = {
  a = "y",
  c = "z",
  ὴ = "ή",
  ὰ = "ά",
}

function replace(s)
local patt = (lpeg.Cs(1)) / replace_table
local parser = lpeg.Cs((patt + 1)^0)
t = parser:match(s)
return t
end

newstring = replace(mystring)

print(newstring)

This will successfully replace "a" and "c," but not "ὴ" or "ὰ" because 
lpeg.Cs(1) sees only the first byte of these multibyte characters. Pure 
Lua complains with an error message; luatex runs, but does not do the 
replacement. What would be a good way to work around this limitation?


All best

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

Re: [NTG-context] Lua problem with tagging or setups

2017-10-09 Thread Hans Hagen

On 10/9/2017 6:11 PM, Rik Kabel wrote:

Consider the following almost-minimal example:

\setuptagging    [state=start]
\setuppapersize  [A6]
\setupexternalfigures[location=default]
\definemakeup    [cover4][page=left,doublesided=no]
\definelayer [isbn][width=\pagewidth,height=\pageheight]
\define  \Title {A Primer on Omphaloskepsis}
\startsetups [placeisbn]
   \setlayer [isbn][preset=rightbottom,hoffset=5mm,voffset=5mm]
   {\externalfigure[cow.pdf][width=3cm]}
\stopsetups
\starttext
   \setupbackgrounds  [page][setups=placeisbn,background=isbn]
   \startmakeup   [cover4]
   \scale [width=\textwidth] {\red \Title}
   \stopmakeup
\stoptext

For me  (Win64, current standalone beta), compilation halts with:

lua error   > lua error on line 4 in file
C://Users/rik/Desktop/xxx.tex:

...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823:
attempt to index local 'spec' (a nil value)
stack traceback:
...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: in
function <...ext/tex/texmf-context/tex/conte
xt/base/mkiv/back-exp.lua:818>

(It always points to line 4 of the file, no matter the file.) When the 
halt is answered with a CR, the processing runs to completion with no 
apparent errors.


When the first line is removed, or the state set to stop, compilation 
completes normally.


When the content of the setup (the two-line \setlayer) is moved out of 
the setup, compilation completes normally (without regard to tagging).


(I use a setup here because, in the real work on which this is based, 
there are other items in the layer that cannot be properly handled until 
after \starttext processing.

fixed in next beta (no tagging of backgrounds)


-
  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] Lua problem with tagging or setups

2017-10-09 Thread Rik Kabel
No, cow.pdf is in the default location and is found with no problem when 
tagging is off or the setlayer is moved out of the setup. The Lua error 
does not occur with most commands, but does occur with external figures.


--
Rik

On 2017-10-09 12:32, Floris van Manen wrote:

if i omit the line with the \externalfigure it does work
is that cow.pdf missing?



On 9 Oct 2017, at 18:11, Rik Kabel  wrote:

Consider the following almost-minimal example:

\setuptagging[state=start]
\setuppapersize  [A6]
\setupexternalfigures[location=default]
\definemakeup[cover4][page=left,doublesided=no]
\definelayer [isbn][width=\pagewidth,height=\pageheight]
\define  \Title {A Primer on Omphaloskepsis}
\startsetups [placeisbn]
   \setlayer   [isbn][preset=rightbottom,hoffset=5mm,voffset=5mm]
   {\externalfigure[cow.pdf][width=3cm]}
\stopsetups
\starttext
   \setupbackgrounds  [page][setups=placeisbn,background=isbn]
   \startmakeup   [cover4]
   \scale [width=\textwidth] {\red \Title}
   \stopmakeup
\stoptext
For me  (Win64, current standalone beta), compilation halts with:

lua error   > lua error on line 4 in file C://Users/rik/Desktop/xxx.tex:

...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: attempt to 
index local 'spec' (a nil value)
stack traceback:
 ...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: in 
function <...ext/tex/texmf-context/tex/conte
xt/base/mkiv/back-exp.lua:818>
(It always points to line 4 of the file, no matter the file.) When the halt is 
answered with a CR, the processing runs to completion with no apparent errors.
When the first line is removed, or the state set to stop, compilation completes 
normally.

When the content of the setup (the two-line \setlayer) is moved out of the 
setup, compilation completes normally (without regard to tagging).

(I use a setup here because, in the real work on which this is based, there are 
other items in the layer that cannot be properly handled until after \starttext 
processing.




___
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] Lua problem with tagging or setups

2017-10-09 Thread Floris van Manen
if i omit the line with the \externalfigure it does work
is that cow.pdf missing?


> On 9 Oct 2017, at 18:11, Rik Kabel  wrote:
> 
> Consider the following almost-minimal example:
> 
> \setuptagging[state=start]
> \setuppapersize  [A6]
> \setupexternalfigures[location=default]
> \definemakeup[cover4][page=left,doublesided=no]
> \definelayer [isbn][width=\pagewidth,height=\pageheight]
> \define  \Title {A Primer on Omphaloskepsis}
> \startsetups [placeisbn]
>   \setlayer   [isbn][preset=rightbottom,hoffset=5mm,voffset=5mm]
>   {\externalfigure[cow.pdf][width=3cm]}
> \stopsetups
> \starttext
>   \setupbackgrounds  [page][setups=placeisbn,background=isbn]
>   \startmakeup   [cover4]
>   \scale [width=\textwidth] {\red \Title}
>   \stopmakeup
> \stoptext
> For me  (Win64, current standalone beta), compilation halts with:
> 
> lua error   > lua error on line 4 in file C://Users/rik/Desktop/xxx.tex:
> 
> ...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: attempt to 
> index local 'spec' (a nil value)
> stack traceback:
> ...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: in 
> function <...ext/tex/texmf-context/tex/conte
> xt/base/mkiv/back-exp.lua:818>
> (It always points to line 4 of the file, no matter the file.) When the halt 
> is answered with a CR, the processing runs to completion with no apparent 
> errors.
> When the first line is removed, or the state set to stop, compilation 
> completes normally.
> 
> When the content of the setup (the two-line \setlayer) is moved out of the 
> setup, compilation completes normally (without regard to tagging).
> 
> (I use a setup here because, in the real work on which this is based, there 
> are other items in the layer that cannot be properly handled until after 
> \starttext processing.
> 
> --
> Rik
> ___
> 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
> ___



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
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] Lua problem with tagging or setups

2017-10-09 Thread Rik Kabel

Consider the following almost-minimal example:

   \setuptagging    [state=start]
   \setuppapersize  [A6]
   \setupexternalfigures[location=default]
   \definemakeup    [cover4][page=left,doublesided=no]
   \definelayer [isbn][width=\pagewidth,height=\pageheight]
   \define  \Title {A Primer on Omphaloskepsis}
   \startsetups [placeisbn]
  \setlayer [isbn][preset=rightbottom,hoffset=5mm,voffset=5mm]
  {\externalfigure[cow.pdf][width=3cm]}
   \stopsetups
   \starttext
  \setupbackgrounds  [page][setups=placeisbn,background=isbn]
  \startmakeup   [cover4]
  \scale [width=\textwidth] {\red \Title}
  \stopmakeup
   \stoptext

For me  (Win64, current standalone beta), compilation halts with:

   lua error   > lua error on line 4 in file
   C://Users/rik/Desktop/xxx.tex:

   ...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823:
   attempt to index local 'spec' (a nil value)
   stack traceback:
   ...ext/tex/texmf-context/tex/context/base/mkiv/back-exp.lua:823: in
   function <...ext/tex/texmf-context/tex/conte
   xt/base/mkiv/back-exp.lua:818>

(It always points to line 4 of the file, no matter the file.) When the 
halt is answered with a CR, the processing runs to completion with no 
apparent errors.


When the first line is removed, or the state set to stop, compilation 
completes normally.


When the content of the setup (the two-line \setlayer) is moved out of 
the setup, compilation completes normally (without regard to tagging).


(I use a setup here because, in the real work on which this is based, 
there are other items in the layer that cannot be properly handled until 
after \starttext processing.


--
Rik

___
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] lua error when --synctex is used

2017-07-14 Thread Hans Hagen

On 7/13/2017 11:40 PM, Ulrike Fischer wrote:

When I run a minimal context file with the -synctex-switch

context --synctex context-test.tex

then I get a lua error:

lua error   > lua error on line 1 in file
C:/Users/XXX/Documents/tests/contexttext/context-test.tex:

...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490:
attempt to call upvalue 'collect' (a nil value)
stack traceback:
...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490: in
function 'luatex_synctex_collect'
[string "local nodes_references_handler = nodes.refere..."]:14: in
function <[string "local nodes_references_handler =
nodes.refere..."]:7>
(...tail calls...)

1 >>  \starttext
2 context text
3 \stoptext


Without the synctex switch there is no problem.
wil be fixed in next beta (no upload yet as i'm playing with some font 
code)



-
  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] lua error when --synctex is used

2017-07-13 Thread Henri Menke
On Fri, 2017-07-14 at 00:55 +0200, Ulrike Fischer wrote:
> Am Fri, 14 Jul 2017 10:32:44 +1200 schrieb Henri Menke:
> 
> > 
> > > 
> > > When I run a minimal context file with the -synctex-switch
> > > 
> > > context --synctex context-test.tex
> > > 
> > > then I get a lua error:
> > See https://mailman.ntg.nl/pipermail/ntg-context/2017/089121.html
> Ah. Thanks I hadn't seen this (or already forgotten). Well if this
> error stays then it probably means that I should inform the winedt
> author that the switch should be better removed from the scripts
> starting context. 

Hans' answer was inconclusive.

> i'll have to upload a new beta ...

I don't know whether that means he'll fix it or he'll remove it.

> 
> 
___
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] lua error when --synctex is used

2017-07-13 Thread Ulrike Fischer
Am Fri, 14 Jul 2017 10:32:44 +1200 schrieb Henri Menke:

>> When I run a minimal context file with the -synctex-switch
>> 
>> context --synctex context-test.tex
>> 
>> then I get a lua error:
> 
> See https://mailman.ntg.nl/pipermail/ntg-context/2017/089121.html

Ah. Thanks I hadn't seen this (or already forgotten). Well if this
error stays then it probably means that I should inform the winedt
author that the switch should be better removed from the scripts
starting context. 


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

Re: [NTG-context] lua error when --synctex is used

2017-07-13 Thread Henri Menke
On Thu, 2017-07-13 at 23:40 +0200, Ulrike Fischer wrote:
> When I run a minimal context file with the -synctex-switch
> 
> context --synctex context-test.tex
> 
> then I get a lua error:

See https://mailman.ntg.nl/pipermail/ntg-context/2017/089121.html

> 
> lua error   > lua error on line 1 in file
> C:/Users/XXX/Documents/tests/contexttext/context-test.tex:
> 
> ...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490:
> attempt to call upvalue 'collect' (a nil value)
> stack traceback:
>   ...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490: in
> function 'luatex_synctex_collect'
>   [string "local nodes_references_handler = nodes.refere..."]:14: in
> function <[string "local nodes_references_handler =
> nodes.refere..."]:7>
>   (...tail calls...)
> 
> 1 >>  \starttext
> 2 context text
> 3 \stoptext
> 
> 
> Without the synctex switch there is no problem.
> 
> 
>  
___
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] lua error when --synctex is used

2017-07-13 Thread Ulrike Fischer
When I run a minimal context file with the -synctex-switch

context --synctex context-test.tex

then I get a lua error:

lua error   > lua error on line 1 in file
C:/Users/XXX/Documents/tests/contexttext/context-test.tex:

...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490:
attempt to call upvalue 'collect' (a nil value)
stack traceback:
...ext/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:490: in
function 'luatex_synctex_collect'
[string "local nodes_references_handler = nodes.refere..."]:14: in
function <[string "local nodes_references_handler =
nodes.refere..."]:7>
(...tail calls...)

1 >>  \starttext
2 context text
3 \stoptext


Without the synctex switch there is no problem.


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

Re: [NTG-context] Lua code and percent sign

2017-02-27 Thread Antoine Cailliau
Thank you
___
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] Lua code and percent sign

2017-02-27 Thread Hans Hagen

On 2/27/2017 2:11 PM, Antoine Cailliau wrote:

The following code, from the wiki, results in a compilation error:

\starttext
\ctxlua{context(string.format("\%.2f", math.pi))}
\stoptext


\startluacode
 ...
\stopluacode


but not in macros where the % is normally a comment again



The error is:

[\directlua]:1: invalid escape sequence near '\%'
1 \starttext
2
3 >>  \ctxlua{context(string.format("\%.2f", math.pi))}
4
5 \stoptext


I ended using \letterpercent command but it is not very convenient.

Any help is welcome,

Antoine C.

Full log:

mtx-context | warning: synctex is enabled
mtx-context | run 1: luatex

--fmt="/usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en"
--jobname="luapercent"

--lua="/usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en.lui"
--no-parse-first-line --synctex=1 --c:autogenerate --c:currentrun=1
--c:directives="system.synctex=1"
--c:fulljobname="/Users/acailliau/Desktop/luapercent.tex"
--c:input="/Users/acailliau/Desktop/luapercent.tex" --c:kindofrun=1
--c:maxnofruns=9 --c:synctex="1" "cont-yes.mkiv"
This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238)
 \write18 enabled.
system  > synctex functionality is enabled (1)!
open source > 1 > 1 >
/usr/local/texlive/2015/texmf-dist/tex/context/base/cont-yes.mkiv
ConTeXt  ver: 2015.05.18 12:26 MKIV current  fmt: 2016.4.25  int:
english/english
system  > 'cont-new.mkiv' loaded
open source > 2 > 2 >
/usr/local/texlive/2015/texmf-dist/tex/context/base/cont-new.mkiv
close source> 2 > 2 >
/usr/local/texlive/2015/texmf-dist/tex/context/base/cont-new.mkiv
system  > files > jobname 'luapercent', input
'/Users/acailliau/Desktop/luapercent', result 'luapercent'
fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > 2 > 3 > /Users/acailliau/Desktop/luapercent.tex
fonts   > preloading latin modern fonts (second stage)
fonts   > 'fallback modern-designsize rm 12pt' is loaded
lua error   > error on line 3 in file
/Users/acailliau/Desktop/luapercent.tex:
[\directlua]:1: invalid escape sequence near '\%'
1 \starttext
2
3 >>  \ctxlua{context(string.format("\%.2f", math.pi))}
4
5 \stoptext

? Type  to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
? close source> 2 > 3 > /Users/acailliau/Desktop/luapercent.tex
close source> 1 > 3 >
/usr/local/texlive/2015/texmf-dist/tex/context/base/cont-yes.mkiv
mkiv lua stats  > used config file:
selfautoparent:/texmfcnf.lua;selfautoparent:/texmf-dist/web2c/texmfcnf.lua
mkiv lua stats  > used cache path:

/usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9
mkiv lua stats  > synctex tracing: synctex has been enabled (extra
log file generated)
mkiv lua stats  > resource resolver: loadtime 0.117 seconds, 0 scans
with scantime 0.000 seconds, 0 shared scans, 8 found files, scanned
paths:
mkiv lua stats  > stored bytecode data: 371 modules (0.309 sec), 78
tables (0.008 sec), 449 chunks (0.316 sec)
mkiv lua stats  > traced context: maxstack: 1132, freed: 0,
unreachable: 1132
mkiv lua stats  > running in nuts mode: yes
mkiv lua stats  > cleaned up reserved nodes: 41 nodes, 439 lists of 438
mkiv lua stats  > node memory usage: 2 glue, 2 penalty, 6 attribute,
26 glue_spec, 2 attribute_list, 2 temp
mkiv lua stats  > node list callback tasks: 6 unique task lists, 2
instances (re)created, 3 calls
mkiv lua stats  > used backend: pdf (backend for directly generating
pdf output)
mkiv lua stats  > loaded patterns: en::2, load time: 0.000
mkiv lua stats  > jobdata time: 0.001 seconds saving, 0.000 seconds
loading
mkiv lua stats  > callbacks: 60 direct, 243 indirect, 303 total
mkiv lua stats  > result saved in file: luapercent.pdf,
compresslevel 3, objectcompresslevel 3
mkiv lua stats  > loaded fonts: 2 files: latinmodern-math.otf,
lmroman12-regular.otf
mkiv lua stats  > fonts load time: 0.180 seconds
mkiv lua stats  > used platform: osx-64, type: unix, binary subtree: bin
mkiv lua stats  > luatex banner: this is luatex, version beta-0.80.0
(tex live 2015) (rev 5238)
mkiv lua stats  > control sequences: 43101 of 65536 + 10
mkiv lua stats  > lua properties: engine: lua, used memory: 67 MB
(ctx: 66 MB), hash type: lua, hash chars: min(64,40), symbol mask:
utf (τεχ)
mkiv lua stats  > runtime: 0.540 seconds
mtx-context 

[NTG-context] Lua code and percent sign

2017-02-27 Thread Antoine Cailliau
The following code, from the wiki, results in a compilation error:

\starttext
> \ctxlua{context(string.format("\%.2f", math.pi))}
> \stoptext


The error is:

[\directlua]:1: invalid escape sequence near '\%'
> 1 \starttext
> 2
> 3 >>  \ctxlua{context(string.format("\%.2f", math.pi))}
> 4
> 5 \stoptext


I ended using \letterpercent command but it is not very convenient.

Any help is welcome,

Antoine C.

Full log:

mtx-context | warning: synctex is enabled
> mtx-context | run 1: luatex
> --fmt="/usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en"
> --jobname="luapercent"
> --lua="/usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en.lui"
> --no-parse-first-line --synctex=1 --c:autogenerate --c:currentrun=1
> --c:directives="system.synctex=1"
> --c:fulljobname="/Users/acailliau/Desktop/luapercent.tex"
> --c:input="/Users/acailliau/Desktop/luapercent.tex" --c:kindofrun=1
> --c:maxnofruns=9 --c:synctex="1" "cont-yes.mkiv"
> This is LuaTeX, Version beta-0.80.0 (TeX Live 2015) (rev 5238)
>  \write18 enabled.
> system  > synctex functionality is enabled (1)!
> open source > 1 > 1 >
> /usr/local/texlive/2015/texmf-dist/tex/context/base/cont-yes.mkiv
> ConTeXt  ver: 2015.05.18 12:26 MKIV current  fmt: 2016.4.25  int:
> english/english
> system  > 'cont-new.mkiv' loaded
> open source > 2 > 2 >
> /usr/local/texlive/2015/texmf-dist/tex/context/base/cont-new.mkiv
> close source> 2 > 2 >
> /usr/local/texlive/2015/texmf-dist/tex/context/base/cont-new.mkiv
> system  > files > jobname 'luapercent', input
> '/Users/acailliau/Desktop/luapercent', result 'luapercent'
> fonts   > latin modern fonts are not preloaded
> languages   > language 'en' is active
> open source > 2 > 3 > /Users/acailliau/Desktop/luapercent.tex
> fonts   > preloading latin modern fonts (second stage)
> fonts   > 'fallback modern-designsize rm 12pt' is loaded
> lua error   > error on line 3 in file
> /Users/acailliau/Desktop/luapercent.tex:
> [\directlua]:1: invalid escape sequence near '\%'
> 1 \starttext
> 2
> 3 >>  \ctxlua{context(string.format("\%.2f", math.pi))}
> 4
> 5 \stoptext
>
> ? Type  to proceed, S to scroll future error messages,
> R to run without stopping, Q to run quietly,
> I to insert something,
> 1 or ... or 9 to ignore the next 1 to 9 tokens of input,
> H for help, X to quit.
> ? close source> 2 > 3 > /Users/acailliau/Desktop/luapercent.tex
> close source> 1 > 3 >
> /usr/local/texlive/2015/texmf-dist/tex/context/base/cont-yes.mkiv
> mkiv lua stats  > used config file:
> selfautoparent:/texmfcnf.lua;selfautoparent:/texmf-dist/web2c/texmfcnf.lua
> mkiv lua stats  > used cache path:
> /usr/local/texlive/2015/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9
> mkiv lua stats  > synctex tracing: synctex has been enabled (extra log
> file generated)
> mkiv lua stats  > resource resolver: loadtime 0.117 seconds, 0 scans with
> scantime 0.000 seconds, 0 shared scans, 8 found files, scanned paths:
> mkiv lua stats  > stored bytecode data: 371 modules (0.309 sec), 78 tables
> (0.008 sec), 449 chunks (0.316 sec)
> mkiv lua stats  > traced context: maxstack: 1132, freed: 0, unreachable:
> 1132
> mkiv lua stats  > running in nuts mode: yes
> mkiv lua stats  > cleaned up reserved nodes: 41 nodes, 439 lists of 438
> mkiv lua stats  > node memory usage: 2 glue, 2 penalty, 6 attribute, 26
> glue_spec, 2 attribute_list, 2 temp
> mkiv lua stats  > node list callback tasks: 6 unique task lists, 2
> instances (re)created, 3 calls
> mkiv lua stats  > used backend: pdf (backend for directly generating pdf
> output)
> mkiv lua stats  > loaded patterns: en::2, load time: 0.000
> mkiv lua stats  > jobdata time: 0.001 seconds saving, 0.000 seconds loading
> mkiv lua stats  > callbacks: 60 direct, 243 indirect, 303 total
> mkiv lua stats  > result saved in file: luapercent.pdf, compresslevel 3,
> objectcompresslevel 3
> mkiv lua stats  > loaded fonts: 2 files: latinmodern-math.otf,
> lmroman12-regular.otf
> mkiv lua stats  > fonts load time: 0.180 seconds
> mkiv lua stats  > used platform: osx-64, type: unix, binary subtree: bin
> mkiv lua stats  > luatex banner: this is luatex, version beta-0.80.0 (tex
> live 2015) (rev 5238)
> mkiv lua stats  > control sequences: 43101 of 65536 + 10
> mkiv lua stats  > lua properties: engine: lua, used memory: 67 MB (ctx: 66
> MB), hash type: lua, hash chars: min(64,40), symbol mask: utf (τεχ)
> mkiv lua stats  > runtime: 0.540 seconds
> mtx-context | fatal error: return code: 1
___
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

Re: [NTG-context] lua tables - how do you cope?

2016-07-30 Thread Hans Hagen

On 7/30/2016 3:04 PM, Joseph Canedo wrote:

If the requirement is to iterate on a table having the keys, values
sorted by key (assuming the keys can be sorted), there are ways to do
this. Please see http://lua-users.org/wiki/SortedIteration for an
example (this just replaces pairs(t) with orderedPairs(t)).


or just in context

for k, v in table.sortedhash(t)
  print(k,v)
end

btw,

mtxrun --script foo.lua

has all that on board as well




Hope this helps



Joseph



*De : *Schmitz Thomas A. <mailto:thomas.schm...@uni-bonn.de>
*Envoyé le :*samedi 30 juillet 2016 12:21
*À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
*Objet :*[NTG-context] lua tables - how do you cope?



This is less a specific question about ConTeXt than a hope for good
advice: I’m maltreating my xml files with a mixture of TeX and Lua. I
want to extract and typeset information in different forms, so I first
collect everything in lua tables, rearrange and order these tables and
typeset the results. All fine and dandy. My problem is that I have to
have tables within tables within tables… you get the picture. One aspect
of Lua that is really bugging me is the fact that associative tables
have no order, which can be a pain in the butt for this kind of
operation. So I have to be careful that I have to use constructs that
will keep the order in which items have been added and loop through them
via ipairs() instead of pairs(). I find it difficult to keep track of
what’s inside my layers upon layers of tables. So my question is: how do
those of you who are more experienced with this kind of question
proceed? Do you have any handy tool to visualize a table? Any tips you
want to share?



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

___





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

Re: [NTG-context] lua tables - how do you cope?

2016-07-30 Thread Hans Hagen

On 7/30/2016 11:01 PM, Schmitz Thomas A. wrote:

Thank you, but this is not what I’m looking for. I know how to sort a table, and I 
know the Lua table tutorial (the Lua wiki is, IMHO, really terrible and 
disorganized). I have to construct deeply nested tables and sometimes lose track of 
what is at what level of my table, so I was wondering if there was an easy way of 
visualizing a nested table. On the web, you can find a number of (mostly abandoned) 
projects; the one at http://siffiejoe.github.io/lua-microscope/ says: "Many Lua 
programmers have written their own pretty-printer or data dumper and some even use 
it for (de-)serializing Lua data structures.” So I was wondering if any of the Lua 
users here on the list has something they want to share.


\startluacode
context.tocontext(yourtable)
\stopluaxcode

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

Re: [NTG-context] lua tables - how do you cope?

2016-07-30 Thread Schmitz Thomas A.

> On 30 Jul 2016, at 23:46, Lukas Prochazka  wrote:
> 
> Hello Thomas,
> 
> here is my "dump()" I've been using for several years:

Arthur, Lukas,

these are both great and very helpful, thanks a lot! I feel bad for not knowing 
table.serialize (which can even be used with the context() function to typeset 
the result, and I really like Lukas’ step-by-step breakdown of the table. Maybe 
I’ll try and think of a nice visual way to represent these Lua tables!

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] lua tables - how do you cope?

2016-07-30 Thread Lukas Prochazka
Hello Thomas,

here is my "dump()" I've been using for several years:


function dump(arg, opts) -- .seen, .pfx
  if type(opts) == "string" then print(opts); opts = nil
  elseif opts == true then print("-- (dump)"); opts = nil
  end

  local pfx = opts and opts.pfx
  local seen = opts and opts.seen or {}

  if type(arg) == "table" then
if pfx then pfx = pfx .. "]["
else
  pfx = "["
  --seen = {}
end

seen[arg] = tostring(arg) --true

local keys = {}

do
  -- Sort keys, if all are strings

  local strs_only = true

  for k in pairs(arg) do
if strs_only and type(k) ~= "string" then strs_only = false end

keys[#keys + 1] = k
  end

  if strs_only then table.sort(keys) end
end

for _, key in ipairs(keys) do
  local val = arg[key]

  io.write(pfx .. tostring(key) .. "] = " .. tostring(val) .. "\t(" .. 
type(val) .. ")")

  if type(val) == "table" then
if seen[val] then print(" (seen)")
else
  print()

  dump(val, {pfx = pfx .. tostring(key), seen = seen}) --pfx .. 
tostring(key), seen)
end
  else
print()
  end
end
  else
print(arg)
  end
end


Try:


a = {c = 1, b = 2}; a.a = a

dump(a)
dump(a, "This is 'a'.")


Improvements or parametrization of visualizing style would be possible, of 
course... 

Best regards,

Lukas


- Original Message -
From: Schmitz Thomas A. [mailto:thomas.schm...@uni-bonn.de]
To: mailing list for ConTeXt users [mailto:ntg-context@ntg.nl]
Sent: Sat, 30 Jul 2016 23:01:29 +0100
Subject: Re: [NTG-context] lua tables - how do you cope?


> Thank you, but this is not what I’m looking for. I know how to sort a table, 
> and I know the Lua table tutorial (the Lua wiki is, IMHO, really terrible and 
> disorganized). I have to construct deeply nested tables and sometimes lose 
> track of what is at what level of my table, so I was wondering if there was 
> an easy way of visualizing a nested table. On the web, you can find a number 
> of (mostly abandoned) projects; the one at 
> http://siffiejoe.github.io/lua-microscope/ says: "Many Lua programmers have 
> written their own pretty-printer or data dumper and some even use it for 
> (de-)serializing Lua data structures.” So I was wondering if any of the Lua 
> users here on the list has something they want to share.

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] lua tables - how do you cope?

2016-07-30 Thread Arthur Reutenauer
On Sat, Jul 30, 2016 at 11:01:29PM +0200, Schmitz Thomas A. wrote:
> Thank you, but this is not what I’m looking for. I know how to sort a table, 
> and I know the Lua table tutorial (the Lua wiki is, IMHO, really terrible and 
> disorganized). I have to construct deeply nested tables and sometimes lose 
> track of what is at what level of my table, so I was wondering if there was 
> an easy way of visualizing a nested table. On the web, you can find a number 
> of (mostly abandoned) projects; the one at 
> http://siffiejoe.github.io/lua-microscope/ says: "Many Lua programmers have 
> written their own pretty-printer or data dumper and some even use it for 
> (de-)serializing Lua data structures.” So I was wondering if any of the Lua 
> users here on the list has something they want to share.

  Well, there’s table.serialize from the ConTeXt core, which fits nicely
in the description you quote.

Best,

Arthur
___
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] lua tables - how do you cope?

2016-07-30 Thread Schmitz Thomas A.
Thank you, but this is not what I’m looking for. I know how to sort a table, 
and I know the Lua table tutorial (the Lua wiki is, IMHO, really terrible and 
disorganized). I have to construct deeply nested tables and sometimes lose 
track of what is at what level of my table, so I was wondering if there was an 
easy way of visualizing a nested table. On the web, you can find a number of 
(mostly abandoned) projects; the one at 
http://siffiejoe.github.io/lua-microscope/ says: "Many Lua programmers have 
written their own pretty-printer or data dumper and some even use it for 
(de-)serializing Lua data structures.” So I was wondering if any of the Lua 
users here on the list has something they want to share.

Thomas


> On 30 Jul 2016, at 16:31, Wolfgang Schuster  
> wrote:
> 
>> If the requirement is to iterate on a table having the keys, values sorted 
>> by key (assuming the keys can be sorted), there are ways to do this. Please 
>> see http://lua-users.org/wiki/SortedIteration for an example (this just 
>> replaces pairs(t) with orderedPairs(t)). 
> 
> \starttext
> 
> \startluacode
> 
> local testtable = { z = "A", y = "B", x = "C" }
> 
> for i, j in next, testtable do
> context("%s:%s",i,j)
> context.par()
> end
> 
> context.blank()
> 
> for i, j in table.sortedhash(testtable) do
> context("%s:%s",i,j)
> context.par()
> end
> 
> \stopluacode
> 
> \stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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

Re: [NTG-context] lua tables - how do you cope?

2016-07-30 Thread Wolfgang Schuster

Joseph Canedo 
30. Juli 2016 um 15:04

If the requirement is to iterate on a table having the keys, values 
sorted by key (assuming the keys can be sorted), there are ways to do 
this. Please see http://lua-users.org/wiki/SortedIteration for an 
example (this just replaces pairs(t) with orderedPairs(t)).




\starttext

\startluacode

local testtable = { z = "A", y = "B", x = "C" }

for i, j in next, testtable do
context("%s:%s",i,j)
context.par()
end

context.blank()

for i, j in table.sortedhash(testtable) do
context("%s:%s",i,j)
context.par()
end

\stopluacode

\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] lua tables - how do you cope?

2016-07-30 Thread Joseph Canedo
If the requirement is to iterate on a table having the keys, values sorted by 
key (assuming the keys can be sorted), there are ways to do this. Please see 
http://lua-users.org/wiki/SortedIteration for an example (this just replaces 
pairs(t) with orderedPairs(t)).

Hope this helps

Joseph

De : Schmitz Thomas A.___
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] lua tables - how do you cope?

2016-07-30 Thread Schmitz Thomas A.
This is less a specific question about ConTeXt than a hope for good advice: I’m 
maltreating my xml files with a mixture of TeX and Lua. I want to extract and 
typeset information in different forms, so I first collect everything in lua 
tables, rearrange and order these tables and typeset the results. All fine and 
dandy. My problem is that I have to have tables within tables within tables… 
you get the picture. One aspect of Lua that is really bugging me is the fact 
that associative tables have no order, which can be a pain in the butt for this 
kind of operation. So I have to be careful that I have to use constructs that 
will keep the order in which items have been added and loop through them via 
ipairs() instead of pairs(). I find it difficult to keep track of what’s inside 
my layers upon layers of tables. So my question is: how do those of you who are 
more experienced with this kind of question proceed? Do you have any handy tool 
to visualize a table? Any tips you want to share?

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
___

Re: [NTG-context] Lua file finder for \externalimage

2015-09-24 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

the reason I'm asking is that I'd need to perform the same lookup as is performed during 
\externalfigure with a specific "directory=" key.

In other words - when \externalfigure is able to find a picture in e.g. 
"../../../Images/Small" path, is there a a file finder in Lua (context 
namespace) which would perform the same lookup?

Sample code:


\setupexternalfigures[directory={../../../Images/Small,../../../Images/Big}]

% Suppose there in a "../../../Images/Big/Big.png"

\startluacode
  local full_name = context.ExternalFigureLocator.Find("Big.png")

  -- Is there something like "context.ExternalFigureLocator.Find(...)"?
\stopluacode



Best regards,

Lukas


On Thu, 17 Sep 2015 14:37:34 +0200, Procházka Lukáš Ing. - Pontex s. r. o. 
 wrote:


Hello,

what is the name of a Lua function (if such function exists) which performs 
lookup for an image inside \externalimage?

I'm asking especially due to the fact that the path here can be modified by 
[location={...}].

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 241 096 751
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
___

[NTG-context] Lua file finder for \externalimage

2015-09-17 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

what is the name of a Lua function (if such function exists) which performs 
lookup for an image inside \externalimage?

I'm asking especially due to the fact that the path here can be modified by 
[location={...}].

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 241 096 751
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] lua code prevents compilation

2015-04-02 Thread Pablo Rodriguez
On 04/02/2015 02:23 AM, Hans Hagen wrote:
> On 4/2/2015 1:21 AM, Pablo Rodriguez wrote:
>> [...]
>> Both lack the underscore glyph. This causes the crash, since it works
>> fine if I replace the glyph with an existing glyph in the font.
>> [...]
>> Would it be possible that ConTeXt silently ignores that the font doesn’t
>> contain the glyph?
> 
> the message is fuzzy (and i have to check a lua stack issue maybe but 
> not now) ... if char is nil then char.depth is an error
> 
>> I think this might be a bug.
> 
>  >  function document.addfunnyhyphen(tfmdata)
>  >  local underscore = utf.byte("_")
>  >  local char   = tfmdata.characters[underscore]
> 
> if not char then return end

Many thanks for your help, Hans.

This solves my issue.


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] lua code prevents compilation

2015-04-01 Thread Hans Hagen

On 4/2/2015 1:21 AM, Pablo Rodriguez wrote:

On 03/30/2015 10:33 PM, Hans Hagen wrote:

On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:

[...]
For some reason unknown to me, the only way to compile the sample is to
remove the luacode snippet.

I need the lua code to have underscore hyphenation in type commands. And
I need two extra \definehyphenationfeatures and \sethyphenationfeatures
to invoke it.

Have I hit a bug or what am I missing?


I don't know as i see nothing at all with that code .. this is more fun:


Many thanks for your reply, Hans,

The following code shows the problem:

\startluacode

 function document.addfunnyhyphen(tfmdata)
 local underscore = utf.byte("_")
 local char   = tfmdata.characters[underscore]
 tfmdata.characters[0xFE000]   = {
 width= 0,
 height   = 0,
 depth= 0,
 commands = {
 { "right", -char.width },
 { "down", char.depth },
 { "slot", 1, underscore },
 }
 }
 end


utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode
%~ \definefontfamily[ornamenta][rm][TypographyTribute]
\definehyphenationfeatures[underscore][righthyphenchar="FE000]
\setuphyphenation[method=traditional]
\sethyphenationfeatures[strict]
\setupbodyfont[ornamenta]
\starttext
\hsize\zeropoint
{\sethyphenationfeatures[underscore]\tt pandoc}
A
\stoptext

If you uncomment the line with the font definition, font loading crashes
compilation. It only crashes with this font
(http://www.dafont.com/typographytribute.font) or FontAwesome
(http://www.fontawesome.io).

Both lack the underscore glyph. This causes the crash, since it works
fine if I replace the glyph with an existing glyph in the font.

Error message:

code.tex: ! LuaTeX fatal error error in error handling
\font_helpers_low_level_define ...\scaledfontmode
   \relax \ifcase
\scaledfont...
\font_helpers_trigger_define ..._identifier_class
   \csname
\v_font_identifier...
\applyfontclassstrategies ...\fontface \endcsname
   \else \expandafter
\font_h...
\font_helpers_synchronize_font ...classstrategies
   \fi \setfalse
\c_font_auto...
\rm ->\ifmmode \mathrm \else \normalrm
\fi
\font_basics_switch_style ...ntstyle #1\endcsname
   \edef \fontstyle
{#1}\ifmm...
...

Would it be possible that ConTeXt silently ignores that the font doesn’t
contain the glyph?


the message is fuzzy (and i have to check a lua stack issue maybe but 
not now) ... if char is nil then char.depth is an error



I think this might be a bug.


>  function document.addfunnyhyphen(tfmdata)
>  local underscore = utf.byte("_")
>  local char   = tfmdata.characters[underscore]

   if not char then return end

>  tfmdata.characters[0xFE000]   = {
>  width= 0,
>  height   = 0,
>  depth= 0,
>  commands = {
>  { "right", -char.width },
>  { "down", char.depth },
>  { "slot", 1, underscore },
>  }
>  }
>  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] lua code prevents compilation

2015-04-01 Thread Pablo Rodriguez
On 03/30/2015 10:33 PM, Hans Hagen wrote:
> On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:
>> [...]
>> For some reason unknown to me, the only way to compile the sample is to
>> remove the luacode snippet.
>>
>> I need the lua code to have underscore hyphenation in type commands. And
>> I need two extra \definehyphenationfeatures and \sethyphenationfeatures
>> to invoke it.
>>
>> Have I hit a bug or what am I missing?
> 
> I don't know as i see nothing at all with that code .. this is more fun:

Many thanks for your reply, Hans,

The following code shows the problem:

\startluacode

function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte("_")
local char   = tfmdata.characters[underscore]
tfmdata.characters[0xFE000]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ "right", -char.width },
{ "down", char.depth },
{ "slot", 1, underscore },
}
}
end


utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode
%~ \definefontfamily[ornamenta][rm][TypographyTribute]
\definehyphenationfeatures[underscore][righthyphenchar="FE000]
\setuphyphenation[method=traditional]
\sethyphenationfeatures[strict]
\setupbodyfont[ornamenta]
\starttext
\hsize\zeropoint
{\sethyphenationfeatures[underscore]\tt pandoc}
A
\stoptext

If you uncomment the line with the font definition, font loading crashes
compilation. It only crashes with this font
(http://www.dafont.com/typographytribute.font) or FontAwesome
(http://www.fontawesome.io).

Both lack the underscore glyph. This causes the crash, since it works
fine if I replace the glyph with an existing glyph in the font.

Error message:

code.tex: ! LuaTeX fatal error error in error handling
\font_helpers_low_level_define ...\scaledfontmode
  \relax \ifcase
\scaledfont...
\font_helpers_trigger_define ..._identifier_class
  \csname
\v_font_identifier...
\applyfontclassstrategies ...\fontface \endcsname
  \else \expandafter
\font_h...
\font_helpers_synchronize_font ...classstrategies
  \fi \setfalse
\c_font_auto...
\rm ->\ifmmode \mathrm \else \normalrm
   \fi
\font_basics_switch_style ...ntstyle #1\endcsname
  \edef \fontstyle
{#1}\ifmm...
...

Would it be possible that ConTeXt silently ignores that the font doesn’t
contain the glyph?

I think this might be a bug.

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] lua code prevents compilation

2015-03-30 Thread Hans Hagen

On 3/30/2015 5:19 PM, Pablo Rodriguez wrote:

Dear list,

I have the following sample:

\startluacode

 function document.addfunnyhyphen(tfmdata)
 local underscore = utf.byte("_")
 local char   = tfmdata.characters[underscore]
 tfmdata.characters[0xFE000]   = {
 width= 0,
 height   = 0,
 depth= 0,
 commands = {
 { "right", -char.width },
 { "down", char.depth },
 { "slot", 1, underscore },
 }
 }
 end


utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode


\def\CoverImageFile{}%\externalfigure[TypeWriter][width=\textwidth]}
\definefontfamily[ornamenta][rm][FontAwesome]
\def\CoverImageFont{\scale[width=\textwidth]{\ornamenta }}
\def\CoverImage{\doifsomethingelse{\CoverImageFile}{\CoverImageFile}{\CoverImageFont}}

\starttext
\CoverImage
\stoptext

For some reason unknown to me, the only way to compile the sample is to
remove the luacode snippet.

I need the lua code to have underscore hyphenation in type commands. And
I need two extra \definehyphenationfeatures and \sethyphenationfeatures
to invoke it.

Have I hit a bug or what am I missing?


I don't know as i see nothing at all with that code .. this is more fun:

\startluacode

function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte("_")
local char   = tfmdata.characters[underscore]
tfmdata.characters[0xFE000]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ "right", -char.width },
{ "down", char.depth },
{ "slot", 1, underscore },
}
}
tfmdata.characters[0xFE001]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ "down", char.depth },
{ "slot", 1, underscore },
{ "right", char.width },
}
}
end



utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode

\setuplanguage[en][righthyphenchar="FE000,lefthyphenchar="FE001]

\starttext
\input tufte
\stoptext


-
  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] lua code prevents compilation

2015-03-30 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\startluacode

function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte("_")
local char   = tfmdata.characters[underscore]
tfmdata.characters[0xFE000]   = {
width= 0,
height   = 0,
depth= 0,
commands = {
{ "right", -char.width },
{ "down", char.depth },
{ "slot", 1, underscore },
}
}
end


utilities.sequencers.appendaction("aftercopyingcharacters","after","document.addfunnyhyphen")

\stopluacode


\def\CoverImageFile{}%\externalfigure[TypeWriter][width=\textwidth]}
\definefontfamily[ornamenta][rm][FontAwesome]
\def\CoverImageFont{\scale[width=\textwidth]{\ornamenta }}
\def\CoverImage{\doifsomethingelse{\CoverImageFile}{\CoverImageFile}{\CoverImageFont}}

\starttext
\CoverImage
\stoptext

For some reason unknown to me, the only way to compile the sample is to
remove the luacode snippet.

I need the lua code to have underscore hyphenation in type commands. And
I need two extra \definehyphenationfeatures and \sethyphenationfeatures
to invoke it.

Have I hit a bug or what am I missing?

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] Lua to Context Table

2014-08-02 Thread John Kitzmiller

> On Aug 2, 2014, Aditya Mahajan  wrote:
>> On Sat, 2 Aug 2014, luigi scarso wrote:
>>> On Sat, Aug 2, 2014, John Kitzmiller  wrote:
>>> Here is Lua code that prints the first nine fibonacci numbers:
>>> 
>>> local function fib(n)
>>>  f={1,1}
>>> ...the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I 
>>> am
>>> missing something.
>>> 
>> 
>> You have a *global* table f  that collides with the internals of context
>> ...
>> local function fib(n)
>> local f={1,1}
>> ...
> 
> This version recomputes all fibnocci numbers from scrach each time. Here 
> is a memoized version:
> 
> local fibs = {1, 1}
> local function fib(n)
>   if fibs[n] == nil then
> print("", "Computing fib:" .. n)
> fibs[n] = fib(n-1) + fib(n-2)
>   end
> ...


Thanks to you both! I missed the global/local conflict, and then learned a way 
to avoid double computation; thanks again!

John
___
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] Lua to Context Table

2014-08-01 Thread Aditya Mahajan

On Sat, 2 Aug 2014, luigi scarso wrote:


On Sat, Aug 2, 2014 at 12:59 AM, John Kitzmiller  wrote:


Here is Lua code that prints the first nine fibonacci numbers:

local function fib(n)
  f={1,1}
  for i=3,9 do
f[i]=f[i-1]+f[i-2]
  end
  return(f[n])
end
for n=1,9 do print(fib(n)) end

Here is Context+Lua that prints 3 x 3 table of the first nine natural
numbers:

\starttext
\setupTABLE[each][each][frame=off,align=left,width=4em,height=2em]
\startluacode
context.bTABLE()
for j = 0, 2 do
  context.bTR()
for k = 1, 3 do
  context.bTD()
context(3*j+k)
  context.eTD()
end
  context.eTR()
end
context.eTABLE()
\stopluacode
\stoptext

How can these be combined to print a 3 x 3 table of the first nine
fibonacci numbers?

I have tried a couple of ways to iterate over the lua table f in the most
indented line of context, looked at what pertinent threads I could find,
the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am
missing something.



You have a *global* table f  that collides with the internals of context
local function fib(n)
 f={1,1}
 for i=3,9 do
   f[i]=f[i-1]+f[i-2]
 end
 return(f[n])
end


\starttext
\setupTABLE[each][each][frame=off,align=left,width=8em,height=2em]

\startluacode
local function fib(n)
 local f={1,1}
 for i=3,9 do
   f[i]=f[i-1]+f[i-2]
 end
 return(f[n])
end
context.bTABLE()
for j = 0, 2 do
 context.bTR()
   for k = 1, 3 do
 context.bTD()
   context("fib(%s)=%s" ,3*j+k, fib(3*j+k) )
 context.eTD()
   end
 context.eTR()
end
context.eTABLE()
\stopluacode
\stoptext


This version recomputes all fibnocci numbers from scrach each time. Here 
is a memoized version:


\setupTABLE[each][each][frame=off,align=left,width=8em,height=2em]
\starttext

\startluacode
local fibs = {1, 1}
local function fib(n)
  if fibs[n] == nil then
print("", "Computing fib:" .. n)
fibs[n] = fib(n-1) + fib(n-2)
  end

  return fibs[n]
end

context.bTABLE()
for j = 0, 2 do
  context.bTR()
for k = 1, 3 do
  context.bTD()
context("fib(%s)=%s" ,3*j+k, fib(3*j+k) )
  context.eTD()
end
  context.eTR()
end
context.eTABLE()
\stopluacode
\stoptext


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


Re: [NTG-context] Lua to Context Table

2014-08-01 Thread luigi scarso
On Sat, Aug 2, 2014 at 12:59 AM, John Kitzmiller  wrote:

> Here is Lua code that prints the first nine fibonacci numbers:
>
> local function fib(n)
>   f={1,1}
>   for i=3,9 do
> f[i]=f[i-1]+f[i-2]
>   end
>   return(f[n])
> end
> for n=1,9 do print(fib(n)) end
>
> Here is Context+Lua that prints 3 x 3 table of the first nine natural
> numbers:
>
> \starttext
> \setupTABLE[each][each][frame=off,align=left,width=4em,height=2em]
> \startluacode
> context.bTABLE()
> for j = 0, 2 do
>   context.bTR()
> for k = 1, 3 do
>   context.bTD()
> context(3*j+k)
>   context.eTD()
> end
>   context.eTR()
> end
> context.eTABLE()
> \stopluacode
> \stoptext
>
> How can these be combined to print a 3 x 3 table of the first nine
> fibonacci numbers?
>
> I have tried a couple of ways to iterate over the lua table f in the most
> indented line of context, looked at what pertinent threads I could find,
> the Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am
> missing something.
>

You have a *global* table f  that collides with the internals of context
local function fib(n)
  f={1,1}
  for i=3,9 do
f[i]=f[i-1]+f[i-2]
  end
  return(f[n])
end


\starttext
\setupTABLE[each][each][frame=off,align=left,width=8em,height=2em]

\startluacode
local function fib(n)
  local f={1,1}
  for i=3,9 do
f[i]=f[i-1]+f[i-2]
  end
  return(f[n])
end
context.bTABLE()
for j = 0, 2 do
  context.bTR()
for k = 1, 3 do
  context.bTD()
context("fib(%s)=%s" ,3*j+k, fib(3*j+k) )
  context.eTD()
end
  context.eTR()
end
context.eTABLE()
\stopluacode
\stoptext

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

[NTG-context] Lua to Context Table

2014-08-01 Thread John Kitzmiller
Here is Lua code that prints the first nine fibonacci numbers:

local function fib(n)
  f={1,1}
  for i=3,9 do
f[i]=f[i-1]+f[i-2]
  end
  return(f[n])
end
for n=1,9 do print(fib(n)) end

Here is Context+Lua that prints 3 x 3 table of the first nine natural numbers:

\starttext
\setupTABLE[each][each][frame=off,align=left,width=4em,height=2em]
\startluacode
context.bTABLE()
for j = 0, 2 do
  context.bTR()
for k = 1, 3 do
  context.bTD()
context(3*j+k)
  context.eTD()
end
  context.eTR()
end
context.eTABLE()
\stopluacode
\stoptext

How can these be combined to print a 3 x 3 table of the first nine fibonacci 
numbers?

I have tried a couple of ways to iterate over the lua table f in the most 
indented line of context, looked at what pertinent threads I could find, the 
Wiki entries, CLD, and tried Aditya's method from Stack Exchange; I am missing 
something.

John

___
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] Lua & \let

2013-10-04 Thread Procházka Lukáš Ing . - Pontex s . r . o .

On Fri, 04 Oct 2013 10:54:37 +0200, Hans Hagen  wrote:


On 10/4/2013 10:47 AM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

Hello all,

how to call \let from within Lua?

I'd need to "\let\T=4" using Lua.

The following code doesn't work (not so surprisingly):


\startluacode
   a = 4
\stopluacode

\expandafter\let\expandafter\T=\cldcontext{a}

\starttext
   Test \T.
\stoptext


What's the correct way?


why let and not context.setvalue("T","4")

anyway ...

\startluacode
a = 4
\stopluacode

\normalexpanded{\let\noexpand\T\cldcontext{a}}

\starttext
Test \T.
\stoptext



You need more \expandafter because \cldcontext needs two expansion steps:
   
\expandafter\expandafter\expandafter\let\expandafter\expandafter\expandafter\T\expandafter\expandafter\expandafter=\cldcontext{a}
 but I wonder why you don use \def or \edef:
   \edef\T{\cldcontext{a}}


... OK, thank you, Hans & Wolfgang, for your responses.

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] Lua & \let

2013-10-04 Thread Wolfgang Schuster

Am 04.10.2013 um 10:47 schrieb Procházka Lukáš Ing. - Pontex s. r. o. 
:

> Hello all,
> 
> how to call \let from within Lua?
> 
> I'd need to "\let\T=4" using Lua.
> 
> The following code doesn't work (not so surprisingly):
> 
> 
> \startluacode
>  a = 4
> \stopluacode
> 
> \expandafter\let\expandafter\T=\cldcontext{a}
> 
> \starttext
>  Test \T.
> \stoptext
> 
> 
> What's the correct way?


You need more \expandafter because \cldcontext needs two expansion steps:

  
\expandafter\expandafter\expandafter\let\expandafter\expandafter\expandafter\T\expandafter\expandafter\expandafter=\cldcontext{a}

but I wonder why you don use \def or \edef:

  \edef\T{\cldcontext{a}}

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] Lua & \let

2013-10-04 Thread Hans Hagen

On 10/4/2013 10:47 AM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

Hello all,

how to call \let from within Lua?

I'd need to "\let\T=4" using Lua.

The following code doesn't work (not so surprisingly):


\startluacode
   a = 4
\stopluacode

\expandafter\let\expandafter\T=\cldcontext{a}

\starttext
   Test \T.
\stoptext


What's the correct way?


why let and not context.setvalue("T","4")

anyway ...

\startluacode
   a = 4
\stopluacode

\normalexpanded{\let\noexpand\T\cldcontext{a}}

\starttext
   Test \T.
\stoptext



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


  1   2   3   >