--
--- luatexja/jfmglue.lua
+-- luatexja/ltj-jfmglue.lua
--
luatexbase.provides_module({
name = 'luatexja.jfmglue',
- date = '2012/07/19',
- version = '0.5',
+ date = '2013/04/27',
description = 'Insertion process of JFM glues and kanjiskip',
})
module('luatexja.jfmglue', package.seeall)
local function slow_find_char_class(c, m, oc)
local xc = c or oc
local cls = ltjf_find_char_class(oc, m)
- if xc ~= oc and cls==0 then cls, xc = ltjf_find_char_class(-xc, m) end
+ if xc ~= oc and cls==0 then cls = ltjf_find_char_class(-xc, m) end
return cls, xc
end
local function check_box(box_ptr, box_end)
local p = box_ptr; local found_visible_node = false
if not p then
- find_first_char = false; first_char = nil; last_char = nil
+ find_first_char = false; last_char = nil
return true
end
while p and p~=box_end do
end,
[id_whatsit] = function(lp)
if lp.subtype==sid_user then
- if lp.user_id==30111 then
+ if lp.user_id==luatexja.userid_table.IHB then
local lq = node_next(lp);
head = node.remove(head, lp); node.free(lp); ihb_flag = true
return false, lq;
local lpa = has_attr(lp, attr_icflag) or 0
-- unbox 由来ノードの検出
if lpa>=PACKED then
- if lpa == BOXBDD then
+ if lpa%PROCESSED_BEGIN_FLAG == BOXBDD then
local lq = node_next(lp)
head = node.remove(head, lp); node.free(lp); lp = lq
else return calc_np_pbox(lp, last)
if not ihb_flag then
local pm = Np.met
return new_jfm_glue(pm,
- fast_find_char_class(((Nq.id == id_math and -1) or 'jcharbdd'), pm), Np.class)
+ fast_find_char_class(((Nq.id == id_math and -1) or (type(Nq.char)=='string' and Nq.char or 'jcharbdd')), pm), Np.class)
else return nil
end
end
local g = get_OA_skip() or get_kanjiskip() -- O_A->K
handle_penalty_normal(0, Np.pre, g); real_insert(g)
elseif Nq.pre then
- local g = get_OA_skip() or get_xkanjiskip(Np) -- O_A->X
+ local g = get_OA_skip() or get_xkanjiskip(Np) -- O_A->X
handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g); real_insert(g)
else
local g = get_OA_skip() -- O_A
return cleanup(mode, last)
end
--- \inhibitglue
-
-function create_inhibitglue_node()
- local tn = node_new(id_whatsit, sid_user)
- tn.user_id=30111; tn.type=100; tn.value=1
- node.write(tn)
-end
-
--- Node for indicating beginning of a paragraph
--- (for ltjsclasses)
-function create_beginpar_node()
- local tn = node_new(id_whatsit, sid_user)
- tn.user_id=30114; tn.type=100; tn.value=1
- node.write(tn)
-end
-
do
+ local IHB = luatexja.userid_table.IHB
+ local BPAR = luatexja.userid_table.BPAR
+
+ -- \inhibitglue
+ function create_inhibitglue_node()
+ local tn = node_new(id_whatsit, sid_user)
+ tn.user_id=IHB; tn.type=100; tn.value=1
+ node.write(tn)
+ end
-local function whatsit_callback(Np, lp, Nq)
- if Np and Np.nuc then return Np
- elseif Np and lp.user_id == 30114 then
- Np.first = lp; Np.nuc = lp; Np.last = lp
- Np.char = 'parbdd'
- Np.met = nil
- Np.pre = 0; Np.post = 0
- Np.xspc = 0
- Np.auto_xspc = false
- return Np
+ -- Node for indicating beginning of a paragraph
+ -- (for ltjsclasses)
+ function create_beginpar_node()
+ local tn = node_new(id_whatsit, sid_user)
+ tn.user_id=BPAR; tn.type=100; tn.value=1
+ node.write(tn)
end
-end
+ local function whatsit_callback(Np, lp, Nq)
+ if Np and Np.nuc then return Np
+ elseif Np and lp.user_id == BPAR then
+ Np.first = lp; Np.nuc = lp; Np.last = lp
+ Np.char = 'parbdd'
+ Np.met = nil
+ Np.pre = 0; Np.post = 0
+ Np.xspc = 0
+ Np.auto_xspc = false
+ return Np
+ end
+ end
-local function whatsit_after_callback(s, Nq, Np)
- if not s and Nq.nuc.user_id == 30114 then
- local x, y = node.prev(Nq.nuc), Nq.nuc
- Nq.first, Nq.nuc, Nq.last = x, x, x
- head = node.remove(head, y)
+ local function whatsit_after_callback(s, Nq, Np)
+ if not s and Nq.nuc.user_id == BPAR then
+ local x, y = node.prev(Nq.nuc), Nq.nuc
+ Nq.first, Nq.nuc, Nq.last = x, x, x
+ head = node.remove(head, y)
+ end
+ return s
end
- return s
-end
-luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback,
- "luatexja.beginpar.np_info", 1)
-luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
- "luatexja.beginpar.np_info_after", 1)
+ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback,
+ "luatexja.beginpar.np_info", 1)
+ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback,
+ "luatexja.beginpar.np_info_after", 1)
end