-function whatsit_callback(Np, lp, Nq, bsl)
- if Np.nuc then return Np
- elseif lp.user_id == uid_ruby_pre then
- Np.first = lp; Np.nuc = lp; Np.last = lp
- local x = lp.value.next.next
- Np.last_char = luatexja.jfmglue.check_box_high(Np, x.head, nil)
- if Nq.id ~=id_pbox_w and Nq.char then
- if has_attr(lp.value, attr_ruby_maxprep) < 0 then -- auto
- local p = round(ltjs_get_penalty_table('ripre', Nq.char, 0, bsl)
- *has_attr(lp.value, attr_ruby))
- if has_attr(lp.value, attr_ruby_mode)%2 == 0 then -- intrusion 無効
- p = 0
- end
- set_attr(lp.value, attr_ruby_maxprep, p)
- end
- if Nq.prev_ruby then
- set_attr(lp, attr_ruby, 1)
- end
+do
+ local RIPRE = luatexja.stack_table_index.RIPRE
+ local function whatsit_callback(Np, lp, Nq)
+ if Np.nuc then return Np
+ elseif getfield(lp, 'user_id') == RUBY_PRE then
+ Np.first, Np.nuc, Np.last = lp, lp, lp
+ local lpv = getfield(lp, 'value')
+ local x = node_next(node_next(lpv))
+ Np.last_char = luatexja.jfmglue.check_box_high(Np, getlist(x), nil)
+ if Nq.id ~=id_pbox_w then
+ if type(Nq.char)=='number' then
+ -- Nq is a JAchar
+ if has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ local p = round((ltjs.table_current_stack[RIPRE + Nq.char] or 0)
+ *has_attr(lpv, attr_ruby))
+ if has_attr(lpv, attr_ruby_mode)%2 == 0 then -- intrusion 無効
+ p = 0
+ end
+ set_attr(lpv, attr_ruby_maxprep, -p)
+ end
+ if Nq.prev_ruby then
+ set_attr(lp, attr_ruby, Nq.prev_ruby)
+ end
+ elseif has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ if Nq.char == 'parbdd' then
+ local p = round((ltjs.table_current_stack[RIPRE-1] or 0)
+ *has_attr(lpv, attr_ruby))
+ p = min(p, Nq.width)
+ if has_attr(lpv, attr_ruby_mode)%2 == 0 then -- intrusion 無効
+ p = 0
+ end
+ set_attr(lpv, attr_ruby_maxprep, p)
+ else
+ set_attr(lpv, attr_ruby_maxprep, 0)
+ end
+ end
+ elseif has_attr(lpv, attr_ruby_maxprep) < 0 then -- auto
+ set_attr(lpv, attr_ruby_maxprep, 0)
+ end
+ return Np