callback.register('pre_linebreak_filter',
function(t,groupcode,glyphes)
local node_id_glyph=node.id("glyph")
local node_id_glue=node.id("glue")
head = t
for t in node.traverse(head) do
if (node.has_attribute(t,kinsoku)) then
if (t.next and t.next.next and t.id == node_id_glyph and t.next.id == node_id_glue and t.next.next.id == node_id_glyph and is_CJK(t.char) and is_CJK(t.next.next.char))
then l = t.next.next
node.free(t.next)
t.next = l
end
if (t.next and t.id == node_id_glyph and t.next.id == node_id_glyph) then
if (is_CJK(t.next.char)) then
if (is_CJK_le(t.char)) then insert_small_glue(head,t); insert_penalty(head,t);
elseif (is_CJK_re(t.char)) then
if (is_CJK_karenb(t.next.char)) then insert_half_glue(head,t);
else insert_double_half(head,t); end
elseif (is_CJK_ll(t.char)) then
if (is_CJK_karenb(t.next.char)) then insert_small_glue(head,t); insert_penalty(head,t);
else insert_half_glue(head,t); insert_penalty(head,t); end
else
if (is_CJK_ka(t.next.char)) then insert_small_glue(head,t);
elseif (is_CJK_le(t.next.char)) then insert_half_glue(head,t);
else insert_small_glue(head,t); insert_penalty(head,t); end
end
elseif (is_CJK(t.char)) then
if (is_CJK_re(t.char)) then
if (is_CJK_rl(t.next.char)) then insert_half_glue(head,t); insert_penalty(head,t);
else insert_half_glue(head,t); end
elseif (is_CJK_le(t.char) or is_CJK_rl(t.next.char)) then insert_small_glue(head,t); insert_penalty(head,t);
else insert_small_glue(head,t); end
end
end
end
end
return true
end )