--
--- luatexja/ltj-math.lua
+-- ltj-math.lua
--
luatexja.load_module('base'); local ltjb = luatexja.base
local is_math_letters = {}
local list_dir
+-- vcenter noad は軸に揃えるため,欧文ベースライン補正がかかる
local function conv_vcenter(sb)
local h = getfield(sb, 'head');local hd = getlist(h)
if getid(hd)==id_whatsit and
local d = node_next(hd)
if getid(d)==id_vlist and has_attr(d, attr_dir)>=dir_node_auto then
node_free(hd); setfield(h, 'head', nil); node_free(h)
- setfield(sb, 'head', d); h = d
+ setfield(sb, 'head', d); set_attr(d, attr_icflag, 0)
end
end
- set_attr(h, attr_icflag, PROCESSED)
return sb
end
return p
end
-luatexbase.add_to_callback('mlist_to_hlist',
- function (n, display_type, penalties)
- n = to_direct(n); list_dir = ltjd_get_dir_count()
- if getid(n)==id_whatsit and getsubtype(n)==sid_user and
- getfield(n, 'user_id') == DIR then
- local old_n = n; n = node_remove(n, n)
- node_free(old_n)
- end
- return node.mlist_to_hlist(
- to_node(conv_jchar_to_hbox(n, 0)),
- display_type, penalties)
- end,'ltj.mlist_to_hlist', 1)
+do
+ local function mlist_callback_ltja(n)
+ local n = to_direct(n); list_dir = ltjd_get_dir_count()
+ if getid(n)==id_whatsit and getsubtype(n)==sid_user and
+ getfield(n, 'user_id') == DIR then
+ local old_n = n; n = node_remove(n, n)
+ node_free(old_n); if not n then return nil end
+ end
+ return to_node(conv_jchar_to_hbox(n, 0))
+ end
+ -- LaTeX 2020-02-02 seems to have pre_mlist_to_hlist_filter callback
+ if luatexbase.callbacktypes['pre_mlist_to_hlist_filter'] then
+ luatexbase.add_to_callback('pre_mlist_to_hlist_filter',
+ mlist_callback_ltja, 'ltj.mlist_to_hlist_pre', 1)
+ else
+ local mlist_to_hlist = node.mlist_to_hlist
+ luatexbase.add_to_callback('mlist_to_hlist',
+ function (n, display_type, penalties)
+ return mlist_to_hlist(mlist_callback_ltja(n),display_type, penalties)
+ end,'ltj.mlist_to_hlist', 1)
+ end
+end
luatexja.math = { is_math_letters = is_math_letters }