X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-ruby.lua;h=da638f5486d76856a46a1e8faaa362daf17f165e;hb=eb118f3e5ea0852407b5261817700401699528b9;hp=57686fead2f807360247812fe985d452d66ca512;hpb=9af4f04e3123548ad4a1f4bada4177e09abeb285;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-ruby.lua b/src/ltj-ruby.lua index 57686fe..da638f5 100644 --- a/src/ltj-ruby.lua +++ b/src/ltj-ruby.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.ruby', - date = '2015/01/14', + date = '2015/09/18', description = 'Ruby annotation', }) module('luatexja.ruby', package.seeall) @@ -12,7 +12,6 @@ local err, warn, info, log = luatexbase.errwarinf(_NAME) luatexja.load_module('stack'); local ltjs = luatexja.stack local Dnode = node.direct or node - local nullfunc = function(n) return n end local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc @@ -146,29 +145,37 @@ end -- concatenation of boxes: reusing nodes -- ルビ組版が行われている段落/hboxでの設定が使われる. -- ルビ文字を格納しているボックスでの設定ではない! -local function concat(f, b) - if f then - if b then - local h = getlist(f) - setfield(node_tail(h), 'next', getlist(b)) - setfield(f, 'head', nil); node_free(f) - setfield(b, 'head', nil); node_free(b) - return Dnode.hpack(luatexja.jfmglue.main(h,false)) +local concat +do + local node_prev = (Dnode ~= node) and Dnode.getprev or node.prev + function concat(f, b) + if f then + if b then + local h, nh = getlist(f), getlist(b) + if getid(nh)==id_whatsit and getsubtype(nh)==sid_user then + nh=node_next(nh); node_free(node_prev(nh)) + end + setfield(node_tail(h), 'next', nh) + setfield(f, 'head', nil); node_free(f) + setfield(b, 'head', nil); node_free(b) + local g = luatexja.jfmglue.main(h,false) + return Dnode.hpack(g) + else + return f + end + elseif b then + return b else - return f + local h = node_new(id_hlist) + setfield(h, 'subtype', 0) + setfield(h, 'width', 0) + setfield(h, 'height', 0) + setfield(h, 'depth', 0) + setfield(h, 'glue_set', 0) + setfield(h, 'glue_order', 0) + setfield(h, 'head', nil) + return h end - elseif b then - return b - else - local h = node_new(id_hlist) - setfield(h, 'subtype', 0) - setfield(h, 'width', 0) - setfield(h, 'height', 0) - setfield(h, 'depth', 0) - setfield(h, 'glue_set', 0) - setfield(h, 'glue_order', 0) - setfield(h, 'head', nil) - return h end end