From cab73095d7d9dd76c9973688474da279a9311d63 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Mon, 28 Aug 2017 17:34:42 +0900 Subject: [PATCH] fix #37467 (Is it safe to write a whatsit in math mode?) --- src/ltj-direction.lua | 4 ++-- src/luatexja-core.sty | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 9d650f2..f26d9c5 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -174,7 +174,7 @@ do local lv = tex_nest.ptr -- must be >= 1 if not v then v = get_dir_count() - if abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then + if abs(tex_nest[lv].mode) == ltjs.mmode and v == dir_tate then v = dir_utod end elseif v=='adj' then @@ -194,7 +194,7 @@ do local lv = tex_nest.ptr if not v then v,name = get_dir_count(), nil - if lv>=1 and abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then + if abs(tex_nest[lv].mode) == ltjs.mmode and v == dir_tate then v = dir_utod end elseif v=='adj' then diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 3ea21ca..6a4a230 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -604,6 +604,8 @@ } \PushPreHook{hbox}{\luafunction\ltj@@box@dirhook\aftergroup\ltj@@reset@badness} \PushPreHook{vbox}{\luafunction\ltj@@box@dirhook\aftergroup\ltj@@reset@badness} + \PushPreHook{math}{\luafunction\ltj@@box@dirhook} + \PushPreHook{display}{\luafunction\ltj@@box@dirhook} \else \let\ltj@@everyhbox=\everyhbox\let\ltj@@everyvbox=\everyvbox \newtoks\ltj@@i@everyhbox\newtoks\ltj@@i@everyvbox @@ -618,6 +620,20 @@ \aftergroup\ltj@@reset@badness\the\ltj@@i@everyhbox} \ltj@@everyvbox{\luafunction\ltj@@box@dirhook \aftergroup\ltj@@reset@badness\the\ltj@@i@everyvbox} + %% math + \ifltj@in@latex + \frozen@everymath{\luafunction\ltj@@box@dirhook\check@mathfonts\the\everymath} + \else + \let\ltj@@everymath=\everymath\newtoks\ltj@@i@everymath\let\everymath=\ltj@@i@everymath + \ltj@@everymath{\luafunction\ltj@@box@dirhook\the\ltj@@i@everymath} + \fi + %% display + \ifltj@in@latex + \frozen@everydisplay{\luafunction\ltj@@box@dirhook\check@mathfonts\the\everydisplay} + \else + \let\ltj@@everydisplay=\everydisplay\newtoks\ltj@@i@everydisplay\let\everydisplay=\ltj@@i@everydisplay + \ltj@@everydisplay{\luafunction\ltj@@box@dirhook\the\ltj@@i@everydisplay} + \fi \fi \newluafunction\ltj@@reset@badness@inner -- 2.11.0