Currently LuaTeX ignores "null paragraphs" (see the manual at the end
of section 3.3.2 "How it works"), but it is actually doing so only for
paragraphs created with end_graf. enter_display_math ignores
paragraphs if they only contain local_par nodes, but not if they also
contain dir nodes. This is somewhat inconsistent, so it would be nice
if enter_display_math would discard paragraphs like end_graf.
I attached a patch. It is almost identical to the change in
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/commit/908e51adaad4b4048fed17d33aeb3cc7342e6fef?page=24#9b95deb9f9de4a293c6aecb24414a21f25c8a9e3_1883_1961
but it is even smaller, since enter_display_math already discard
paragraphs containing only local_par nodes.
Even though this change is less disruptive, there might be more
concerns about backwards compatibility today than three years ago, if
this is the case a new value to \matheqdirmode can be added.
Udi
diff --git a/source/texk/web2c/luatexdir/tex/texmath.c b/source/texk/web2c/luatexdir/tex/texmath.c
index 4b34c1723..48cd7993c 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.c
+++ b/source/texk/web2c/luatexdir/tex/texmath.c
@@ -1084,6 +1084,18 @@ static boolean math_and_text_reversed_p(void)
*/
+static int only_dirs(halfword n)
+{
+ while (n) {
+ if (type(n) == local_par_node || type(n) == dir_node) {
+ n = vlink(n);
+ } else {
+ return 0;
+ }
+ }
+ return 1;
+}
+
void enter_display_math(void)
{
/*tex new or partial |pre_display_size| */
@@ -1101,19 +1113,18 @@ void enter_display_math(void)
\.{\$\${ }\$\$}
*/
- if (head == tail ||
- (vlink(head) == tail &&
- type(tail) == local_par_node && vlink(tail) == null)) {
- if (vlink(head) == tail) {
- /*tex
-
- |resume_after_display| inserts a |local_par_node|, but if there
- is another display immediately following, we have to get rid of
- that node.
-
- */
- flush_node(tail);
- }
+ if (head == tail) {
+ pop_nest();
+ w = -max_dimen;
+ } else if (only_dirs(vlink(head))) {
+ /*tex
+
+ We ignore |null| paragraphs, that is those that only have a local par node,
+ for example because |resume_after_display| inserts a |local_par_node|,
+ and possibly a few dir nodes injected automatically.
+
+ */
+ flush_node(tail);
pop_nest();
w = -max_dimen;
} else {
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]