ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Can't manipulate glue added by tex.preparelinebreak
@ 2022-07-26  6:18 Max Chernoff via ntg-context
  2022-07-26  8:06 ` Hans Hagen via ntg-context
  2022-07-27 16:02 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 5+ messages in thread
From: Max Chernoff via ntg-context @ 2022-07-26  6:18 UTC (permalink / raw)
  To: ntg-context; +Cc: Max Chernoff

Hi Hans,

The new tex.preparelinebreak is great (thanks again), but I can't seem
to figure out how to manipulate the parfillskip nodes that it adds.

MWE:

\newbox\testbox

   \startluacode
       function test(head)
           if head.id ~= node.id "par" then
               return head
           end
   
           new_head = node.copylist(head)
           tex.preparelinebreak(new_head)
   
           local parfillskip = node.tail(new_head)
           inspect(parfillskip) -- Confirm that this really is a parfillskip
           parfillskip.stretchorder = 0
           parfillskip.stretch = 0
   
           local broken = tex.linebreak(new_head)
           tex.setbox("global", "testbox", broken)
   
           return head
       end
   \stopluacode
   
   \starttext
       {\dorecurse{209}{Hello }\par}\page
   
       {\parfillskip=0pt\dorecurse{209}{Hello }\par}\page
   
       {\ctxlua{nodes.tasks.appendaction("processors", "after", "test")}
        \dorecurse{209}{Hello }\par}\page
   
       \box\testbox
   \stoptext

I would expect that pages 1 and 3 would be identical, and that pages 2
and 4 would be identical. However, page 4 is the same as pages 1 and 3,
which isn't what I'd expect. I can do a similar idea in LuaTeX/MkIV and
get the expected results, so I'm not too sure what I'm doing wrong here.
I'm probably just missing something obvious, but I'm not too sure what.
Any ideas?

Thanks,
-- Max
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

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

* Re: Can't manipulate glue added by tex.preparelinebreak
  2022-07-26  6:18 Can't manipulate glue added by tex.preparelinebreak Max Chernoff via ntg-context
@ 2022-07-26  8:06 ` Hans Hagen via ntg-context
  2022-07-28  7:03   ` Max Chernoff via ntg-context
  2022-07-27 16:02 ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2022-07-26  8:06 UTC (permalink / raw)
  To: Max Chernoff via ntg-context; +Cc: Hans Hagen

On 7/26/2022 8:18 AM, Max Chernoff via ntg-context wrote:
> Hi Hans,
> 
> The new tex.preparelinebreak is great (thanks again), but I can't seem
> to figure out how to manipulate the parfillskip nodes that it adds.
> 
> MWE:
> 
> \newbox\testbox
> 
>     \startluacode
>         function test(head)
>             if head.id ~= node.id "par" then
>                 return head
>             end
>     
>             new_head = node.copylist(head)
>             tex.preparelinebreak(new_head)
>     
>             local parfillskip = node.tail(new_head)
>             inspect(parfillskip) -- Confirm that this really is a parfillskip
>             parfillskip.stretchorder = 0
>             parfillskip.stretch = 0
>     
>             local broken = tex.linebreak(new_head)
>             tex.setbox("global", "testbox", broken)
>     
>             return head
>         end
>     \stopluacode
>     
>     \starttext
>         {\dorecurse{209}{Hello }\par}\page
>     
>         {\parfillskip=0pt\dorecurse{209}{Hello }\par}\page
>     
>         {\ctxlua{nodes.tasks.appendaction("processors", "after", "test")}
>          \dorecurse{209}{Hello }\par}\page
>     
>         \box\testbox
>     \stoptext
> 
> I would expect that pages 1 and 3 would be identical, and that pages 2
> and 4 would be identical. However, page 4 is the same as pages 1 and 3,
> which isn't what I'd expect. I can do a similar idea in LuaTeX/MkIV and
> get the expected results, so I'm not too sure what I'm doing wrong here.
> I'm probably just missing something obvious, but I'm not too sure what.
> Any ideas?
looks like i don't update something, i'll fix it (probably bin later today)

btw, you can do this:

         local h, t, pil, pir, pfl, pfr = tex.preparelinebreak(new_head)
         inspect(pfr)
         pfr.stretchorder = 0
         pfr.stretch = 0

as well as use

	tex.show(broken)

to see the result

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

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

* Re: Can't manipulate glue added by tex.preparelinebreak
  2022-07-26  6:18 Can't manipulate glue added by tex.preparelinebreak Max Chernoff via ntg-context
  2022-07-26  8:06 ` Hans Hagen via ntg-context
@ 2022-07-27 16:02 ` Hans Hagen via ntg-context
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2022-07-27 16:02 UTC (permalink / raw)
  To: Max Chernoff via ntg-context; +Cc: Hans Hagen

On 7/26/2022 8:18 AM, Max Chernoff via ntg-context wrote:

> The new tex.preparelinebreak is great (thanks again), but I can't seem
> to figure out how to manipulate the parfillskip nodes that it adds.
new upload (see earlier mail for rest)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

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

* Re: Can't manipulate glue added by tex.preparelinebreak
  2022-07-26  8:06 ` Hans Hagen via ntg-context
@ 2022-07-28  7:03   ` Max Chernoff via ntg-context
  2022-07-28  7:58     ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 5+ messages in thread
From: Max Chernoff via ntg-context @ 2022-07-28  7:03 UTC (permalink / raw)
  To: ntg-context; +Cc: Max Chernoff

> looks like i don't update something, i'll fix it (probably bin later
> today)

> new upload (see earlier mail for rest)

Works great! Thanks!

> btw, you can do this:
> 
>          local h, t, pil, pir, pfl, pfr = tex.preparelinebreak(new_head)
>          inspect(pfr)
>          pfr.stretchorder = 0
>          pfr.stretch = 0
> 

Ah, that's quite convenient. I'm still supporting LuaTeX, so
unfortunately I'm somewhat limited with which helpers I can take
advantage of.

> as well as use
> 
> 	tex.show(broken)
> 
> to see the result

That will be really nice for debugging. I've either been storing boxes
and typesetting them later (like shown earlier) or using node.traverse +
inspect. This will be much nicer to use.

Thanks,
-- Max
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

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

* Re: Can't manipulate glue added by tex.preparelinebreak
  2022-07-28  7:03   ` Max Chernoff via ntg-context
@ 2022-07-28  7:58     ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2022-07-28  7:58 UTC (permalink / raw)
  To: Max Chernoff via ntg-context; +Cc: Hans Hagen

On 7/28/2022 9:03 AM, Max Chernoff via ntg-context wrote:

> That will be really nice for debugging. I've either been storing boxes
> and typesetting them later (like shown earlier) or using node.traverse +
> inspect. This will be much nicer to use.
when you set

\tracingnodes

to a positive value (1, 2) you'll also see node numbers

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

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

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

end of thread, other threads:[~2022-07-28  7:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26  6:18 Can't manipulate glue added by tex.preparelinebreak Max Chernoff via ntg-context
2022-07-26  8:06 ` Hans Hagen via ntg-context
2022-07-28  7:03   ` Max Chernoff via ntg-context
2022-07-28  7:58     ` Hans Hagen via ntg-context
2022-07-27 16:02 ` Hans Hagen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).