Closed hason closed 1 month ago
I also report a similar result when the document contains makeup. Using LWC 3.0.1 in ConTeXt LMTX 2024.03.05 11:26
callback error: ...texmf/tex/luatex/lua-widow-control/lua-widow-control.lua:160: attempt to call a nil value (upvalue 'copy')
stack traceback:
...texmf/tex/luatex/lua-widow-control/lua-widow-control.lua:160: in upvalue 'lwc_save_paragraphs'
[string "local tonut = nodes.tonut..."]:30: in function <[string "local tonut = nodes.tonut..."]:13>
(...tail calls...)
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PORTADILLA
2 \startmakeup[antetitulo]
3 \start\bf\raggedleft\dontleavehmode\switchtobodyfont[14pt]\getvariable{document}{titulouno}\space\getvariable{document}{titulodos}\stop
4 >> \stopmakeup
(sorry for the delay in replying)
Lua-widow-control has unfortunately been completely broken with LMTX since mid-June. So even if you don't use descriptions/makeup and ConTeXt doesn't crash, lua-widow-control isn't actually doing anything.
Fixing this is pretty high on my todo list since the the manual requires LMTX to compile: https://github.com/gucci-on-fleek/lua-widow-control/blob/49fb91b634338af0b5842cff11129dff5bc4340c/docs/manual/lwc-manual.tex#L6-L9 (that's why version 3.0.1 still contains the 3.0.0 manual)
When I wrote the first version of lua-widow-control, LuaMetaTeX was still closed-source, so I had to guess at lots of the interfaces. But the engine is now open source, and it looks like there are some new hooks, so I'm hoping that this is relatively easy to fix.
I remembered something I did read a little while ago about a new mechanism (vz, analog to hz): https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/RYEL5O2KSNWJQXTCMHLFSFF6F5YUVAMS/
Maybe worth it checking it out...
(Sorry for the delay, again)
The issue here was that ConTeXt combines the hpack_filter
and pre_linebreak_filter
callbacks, so to distinguish between being triggered by an \hbox
or by a paragraph, lua-widow-control checks to see if the first node is a “paragraph” node. However, ConTeXt LMTX uses the new “localboxes” mechanism to typeset the description title, but for whatever reason, localboxes are internally encoded as paragraph nodes, so lua-widow-control thought that it was given a paragraph and got confused.
The manual hints at this exact issue:
Local boxes are stored in an initial par node with an adequate subtype but users won't notice this (unless they mess around in Lua).
and the fix was pretty simple:
The other issue was that ConTeXt registered+froze some of the callbacks that lua-widow-control used, so when lua-widow-control tried hook into them, it was unable to, rendering the entire package non-functional. The fix for this was pretty short (73445ca0), but figuring out the correct details was a little tricky.
Anyways, everything should hopefully be fixed now. The builder that generates the .tds.zip
and CTAN files is currently broken, so if you want to test this, you'll need to manually copy both source/lua-widow-control.lua
and source/t-lua-widow-control.mkxl
to either the same folder as your .tex
document, or somewhere convenient in one of your texmf
trees.
Let me know if you find any other issues, and thanks for the bug report!
Issue
lua-widow-control cannot work properly with a ConTeXt document that contains description - https://wiki.contextgarden.net/Description.
Expected Behavior
Reproduction
Log File
Format
ConTeXt MKXL
Distribution
ConTeXt
Distribution Version
ConTeXt ver: 2023.09.26 18:19 LMTX fmt: 2023.12.18 int: english/english
Lua-widow-control Version
3.0.0
Other Relevant Packages and Versions
No response
Other
No response