Hi Hans,
I found a line-breaking problem in LuaMetaTeX (2026.10.25): a line break can
occur immediately after inline math, even when the following glue has the
noautobreak option set.
Here is a minimal ConTeXt example:
\starttext
\startframedtext[width=67mm]
Das digitale Geraet hat ein \math{3\frac{1}{2}}~stelliges Display und einen
Fehler.
\stopframedtext
\stoptext
The line can break between the fraction and "stelliges", although ~ should keep
them together.
I traced this to the two end_inline_math branches in texlinebreak.c. They can
introduce a math-related breakpoint without checking the noautobreak option of
the following glue.
I propose the following changes.
In the first branch, replace the glue check with:
halfword penalty = math_penalty(current);
halfword next = node_next(current);
if (next && node_type(next) == glue_node
&& (penalty <= -10000
|| !tex_has_glue_option(next, glue_option_no_auto_break))) {
/* existing code */
}
In the second branch, replace the existing tex_aux_valid_glue_break(current)
condition with:
halfword penalty = math_penalty(current);
halfword next = node_next(current);
if (tex_aux_valid_glue_break(current)
&& !(penalty > -10000 && next
&& node_type(next) == glue_node
&& tex_has_glue_option(next, glue_option_no_auto_break))) {
/* existing code */
}
The important distinction is that noautobreak should suppress automatic
breakpoints, but not an explicitly forced math break (penalty -10000).
For example, this must still allow the forced break:
\postinlinepenalty=-10000
\math{12345}~stelliges
I initially overlooked this interaction, but caught it through further testing
and adjusted the fix accordingly.
I have now run extensive regression tests covering different glue options, math
penalties, short and regular inline math, mathsurround, and directly
constructed glue nodes. All tests pass with the revised fix, while ordinary
breakpoints retain their previous behavior.
I can provide the complete patch and test suite if you are interested.
Best regards,
Bernd
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
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
___________________________________________________________________________________