--
luatexbase.provides_module({
name = 'luatexja.ruby',
- date = '2017/05/05',
+ date = '2018/09/29',
description = 'Ruby annotation',
})
-module('luatexja.ruby', package.seeall)
-local err, warn, info, log = luatexbase.errwarinf(_NAME)
-
+luatexja.ruby = {}
luatexja.load_module('stack'); local ltjs = luatexja.stack
+luatexja.load_module('base'); local ltjb = luatexja.base
local to_node = node.direct.tonode
local to_direct = node.direct.todirect
luatexja.userid_table.RUBY_POST = luatexbase.newuserwhatsitid('ruby_post', 'luatexja')
local RUBY_PRE = luatexja.userid_table.RUBY_PRE
local RUBY_POST = luatexja.userid_table.RUBY_POST
+local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
----------------------------------------------------------------
-- TeX interface 0
----------------------------------------------------------------
do
local getbox = node.direct.getbox
- function cpbox() return node_copy(getbox(0)) end
+ function luatexja.ruby.cpbox() return node_copy(getbox(0)) end
end
----------------------------------------------------------------
-- 実行回数 + ルビ中身 から uniq_id を作る関数
-old_break_info = {} -- public, 前 run 時の分割情報
+luatexja.ruby.old_break_info = {} -- public, 前 run 時の分割情報
+local old_break_info = luatexja.ruby.old_break_info
local cache_handle
-function read_old_break_info()
+function luatexja.ruby.read_old_break_info()
if tex.jobname then
local fname = tex.jobname .. '.ltjruby'
local real_file = kpse.find_file(fname)
local concat
do
local node_prev = node.direct.getprev
+ local function get_attr_icflag(p)
+ return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
+ end
function concat(f, b)
if f then
if b then
if getid(nh)==id_whatsit and getsubtype(nh)==sid_user then
nh=node_next(nh); node_free(node_prev(nh))
end
+ set_attr(nh, attr_icflag,
+ get_attr_icflag(nh) + PROCESSED_BEGIN_FLAG)
setfield(node_tail(h), 'next', nh)
setfield(f, 'head', nil); node_free(f)
setfield(b, 'head', nil); node_free(b)
setfield(w, 'value', to_node(wv))
setfield(wv, 'type', 100)
setfield(wv, 'value', floor(#rtlr))
+ setfield(wv, 'user_id', RUBY_PRE) -- dummy
set_attr(wv, attr_ruby, rst.rubyzw)
set_attr(wv, attr_ruby_maxmargin, rst.maxmargin)
set_attr(wv, attr_ruby_maxprep, rst.pre)
end
-- rst: table
-function texiface(rst, rtlr, rtlp)
+function luatexja.ruby.texiface(rst, rtlr, rtlp)
if #rtlr ~= #rtlp then
for i=1, #rtlr do node_free(rtlr[i]) end
for i=1, #rtlp do node_free(rtlp[i]) end
- luatexja.base.package_error('luatexja-ruby',
+ ltjb.package_error('luatexja-ruby',
'Group count mismatch between the ruby and\n' ..
'the body (' .. #rtlr .. ' != ' .. #rtlp .. ').',
'')