[NTG-context] Callbacks in LuaMetaTeX

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

Hi list,

I've been playing around with some of the Lua callbacks in LuaMetaTeX,
and I have a few questions/comments.

Context: I'm writing a Plain/LaTeX/ConTeXt module called
"lua-widow-control" that uses Lua callbacks to automatically remove
widows and orphans from documents. The relevant Lua code is at:


https://github.com/gucci-on-fleek/lua-widow-control/blob/master/source/lua-widow-control.lua

in case you're curious about how I'm using these callbacks, but you
shouldn't need to look there since this email is self-contained.

1. In LMTX, calling "tex.linebreak" produces a
   
   luatex warning  > tex: left parfill skip is gone


   warning. I don't get this warning in Plain LuaTeX, LuaLaTeX, or MkIV,
   so I think that it's specific to LuaMetaTeX. The LuaMetaTeX manual
   hardly mentions "left parfill skip"/"parfillleftskip", so I'm not too
   sure what to do to avoid this warning.

   You can reproduce the warning with this code (but any call to
   "tex.linebreak" also works):

   \startluacode
   function test(head)
   tex.linebreak(node.copylist(head))
   
   return head

   end
   
   nodes.tasks.appendaction("processors", "after", "test")

   \stopluacode
   
   \starttext

   Hello!
   \stoptext

2. The LuaMetaTeX manual says that "pre_linebreak_filter" is called
   after the parfillskip glue has been added, but this doesn't seem to
   be the case. With LuaLaTeX/Plain LuaTeX, this is true, but the node
   list passed to the callback in MkXL is missing the parfillskip. (I
   don't have an MkIV installation to test here.)

   This MkXL code:

   \startluacode
   function test(head)
   local last = node.slide(head)
   
   print "START"

   for i=1,3 do
   print(last)
   print(
   node.type(last.id),
   node.subtypes(last.id)[last.subtype],
   last.width,
   last.stretchorder,
   last.stretch
   )
   
   last = last.prev

   end
   print "STOP"
   
   return head

   end
   
   nodes.tasks.appendaction("processors", "after", "test")

   \stopluacode
   
   \starttext

   Hello!
   \stoptext

   produces:

   START
   nil : glue spaceskip>
   gluespaceskip   341648  0   384354
  2258 : glyph unset>
   glyph   nil 213792  nil nil
  2521 : glyph unset>
   glyph   nil 385140  nil nil
   STOP
   START
   nil : glue userskip>
   glueuserskip0   2   65536
  2357 : glyph unset>
   glyph   nil 385140  nil nil
  2611 : rule strut>
   rulestrut   0   nil nil
   STOP

   while this (presumably) equivalent Plain LuaTeX code:

   \directlua{
   function test(head)
   local last = node.slide(head)
   
   print "START"

   for i=1,3 do
   print(last)
   print(
   node.type(last.id),
   node.subtypes(last.id)[last.subtype],
   last.width,
   last.stretch_order,
   last.stretch
   )
   
   last = last.prev

   end
   print "STOP"
   
   return head

   end
   
   callback.register("pre_linebreak_filter", test)

   }
   
   Hello!
   
   \bye


   produces:

   START
   nil : glue 15>
   glueparfillskip 0   2   65536
   298 : penalty 2>
   penalty linepenalty nil nil nil
82 : glyph 0>
   glyph   unset   182045  nil nil
   STOP

   I'm not sure if this is a doc bug, an engine bug, or if I'm just
   doing something wrong.

3. The LuaTeX/LuaMetaTeX engine manuals say that for node callbacks, you
   can return "true" if you don't need to replace the passed node list.
   This works fine with raw LuaTeX callbacks and the luatexbase
   wrappers, but it doesn't work with the ConTeXt "nodes.tasks" wrapper
   functions.

   This Plain example works:

   \directlua{
   callback.register("pre_linebreak_filter", function ()
   return true
   end)
   }
   
   Hello!
   
   \bye


   But this MkXL example doesn't:

   \startluacode
   function test(head)
   return true
   end
   
   nodes.tasks.appendaction("processors", "after", "test")

   \stopluacode
   
   \starttext

   Hello!
   \stoptext

   I'm not sure if this behaviour is expected or not. Saving the node
   passed to the callback then 

Re: [NTG-context] recursion in a table

2022-05-01 Thread Aditya Mahajan via ntg-context
On Sun, 1 May 2022, Henning Hraban Ramm via ntg-context wrote:

> Hi,
> I was playing with the example from 
> https://wiki.contextgarden.net/Scaling_Rotating_Mirroring_Clipping#Location_parameter
>  
> and tried to put it in a tabulate:
> 
> 
> \useMPlibrary[dum]
> \setupexternalfigures[width=3em,height=2em,frame=on,]
> 
> %\def\TXT{\ruledhbox{\bf(XyX)}}
> \def\TXT{\externalfigure[pic]}
> 
> \starttabulate[|l|l|l|l|l|l|]
>  \NC\NC normal\NC depth\NC fit\NC broad\NC high\NC\NR
>  \HL
> \dostepwiserecurse{0}{359}{45}{%
> %\expanded{\setuprotate[rotation=\recurselevel]}
>  \NC{\expanded{\recurselevel}˚}%

Untested, but I think that you might need:

\expanded{\NC \recurselevel \noexpand\NC ... }

> This works, but \recurselevel is always 0. I know I must expand it (like 
> in the original example), but I can’t make it work within the tabulation.
> In the first column, \expanded{\recurselevel} stays 0, and 
> rotation=\expanded{\recurselevel} gives an error, while the \setuprotate 
> line has no effect (if I remove "rotation=\recurselevel", of course).
> 
> How would that work?

Remind me of a more-than-a-decade-old discussion on the mailing list, 
summarized here:

https://adityam.github.io/context-blog/post/tex-programming/

> Also, \HL doesn’t work at the end, and the second line of the error 
> message makes no sense:

I find that in such cases, using Lua (CLD) is the simplest solution

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] recursion in a table

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

Hi,
I was playing with the example from 
https://wiki.contextgarden.net/Scaling_Rotating_Mirroring_Clipping#Location_parameter 
and tried to put it in a tabulate:



\useMPlibrary[dum]
\setupexternalfigures[width=3em,height=2em,frame=on,]

%\def\TXT{\ruledhbox{\bf(XyX)}}
\def\TXT{\externalfigure[pic]}

\starttabulate[|l|l|l|l|l|l|]
\NC\NC normal\NC depth\NC fit\NC broad\NC high\NC\NR
\HL
\dostepwiserecurse{0}{359}{45}{%
%\expanded{\setuprotate[rotation=\recurselevel]}
\NC{\expanded{\recurselevel}˚}%

\NC{\ruledhbox{X\rotate[location=normal,rotation=\recurselevel]{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=depth,rotation=\recurselevel] 
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=fit,rotation=\recurselevel] 
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=broad,rotation=\recurselevel] 
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=high,rotation=\recurselevel] 
{\TXT}X}}%

  \NC\NR}
%\HL % error
\stoptabulate


This works, but \recurselevel is always 0. I know I must expand it (like 
in the original example), but I can’t make it work within the tabulation.
In the first column, \expanded{\recurselevel} stays 0, and 
rotation=\expanded{\recurselevel} gives an error, while the \setuprotate 
line has no effect (if I remove "rotation=\recurselevel", of course).


How would that work?

Also, \HL doesn’t work at the end, and the second line of the error 
message makes no sense:

"""
I expect to see \noalign only after the \cr of an alignment.
Proceed, and I'll ignore this case.
mtx-context | fatal error: return code: 1
"""

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] Fuzzy paragraph when exporting to XML

2022-05-01 Thread Hans Hagen via ntg-context

On 5/1/2022 12:17 AM, Aditya Mahajan via ntg-context wrote:

On Sat, 30 Apr 2022, Hans Hagen via ntg-context wrote:


On 4/29/2022 4:59 PM, Aditya Mahajan via ntg-context wrote:

Hi,

I am trying to debug a bug-report for t-vim:

https://github.com/adityam/filter/issues/64 Exporting with trackers=export*
gives a warning:


  backend > export > fuzzy paragraph:

I have managed to narrow it down to the attached MWE (which does not depend

on the t-vim module at all). Compiling it using


  $context --trackers=export\* lines

gives the fuzzy paragraph warning. Any hints on how to resolve this?

As you like challenges ... you can way more narrow it down ...

\setupbackend[export=yes]

\starttext
{
  \forgetall
% \forgeteverypar
  x\strut\par
}
\stoptext

the problem is that you basically loose *all* par related tagging now so
you need to bring that back, which is (of course i had to look it up) is
done with for instance \forgeteverypar which forgets (as in \forgetall)
but not really all


Thanks!

I manually tag start and end of lines anyways (using \SYNBOL ... \SYNEOL), so I 
can add \dotagsetparcounter in \SYNBOL and that removes the warning!

dangerous ... what if you get



every line cna be a par or the while can have the same par number ...






these par numbers are used to determine what text belongs to a 
meanignful 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
___


[NTG-context] 32-bit OpenBSD

2022-05-01 Thread Mojca Miklavec via ntg-context
Hi,

How long do we want/need to keep running the builders for 32-bit OpenBSD?

It's taking 2 or 3 times longer to build binaries than for the 64-bit
OS (not that this is super relevant since ppc builder is a whole order
of magnitude slower anyway: building TL there takes about 6 hours) and
I suspect that nobody is using those 32-bit binaries anyway.

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