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

Max Chernoff mseven at telus.net
Wed Apr 27 09:14:40 CEST 2022


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_box_warnings.disable = function () end
             callback = nil
         \stopluacode

     If you get a really strange error from some other package/module (not
     lwc), then this may be the issue. Fairly unlikely.

  6. The values of "\club/widowpenalty" change between the paragraph
     being typeset and the output routine being triggered.

     I can't imagine this happening for *every* page in a document
     except unless you are specifically trying to do this. Fairly
     unlikely.

  7. You have the exact Lua code
     
         lwc.callbacks.remove_widows.disable()
     
     written in your document. Exceedingly unlikely.

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

Well as long as you aren't seeing

     Widow/Orphan NOT removed

in your log file then your text should be fine.

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

There's probably not too much else in there -- and the documentation
is a bit of a mess right now anyways.

---

If none of the above solutions solved anything, then what I'll need to
debug further will be for you to insert

     \setuplwc[debug=true]

into your document right after you load lwc. Then, send me the full
log file -- probably as a link since it will be quite large.

Thanks.

-- Max



More information about the ntg-context mailing list