You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to be able to use this package together with the OpTeX format. If you will be willing to do so, i'll request the developer of the format to add the pre_append_to_vlist_filter call back so it would be easier to do so.
Just for a proof of concept:, the following diff works:
diff --git a/lua-ul.dtx b/lua-ul.dtx
index d389573..4cf09ed 100644
--- a/lua-ul.dtx+++ b/lua-ul.dtx@@ -455,6 +455,21 @@ local underline_types = {}
local underline_strict_flag = {}
local underline_over_flag = {}
+local format = tex.formatname+local latex, optex++if format:find("latex") then + latex = true+elseif format:find("optex") then+ optex = true+ function luatexbase.new_luafunction(name)+ return #functions + 1+ end+else+ texerror("Unsupported format", {"Please use LaTeX or OpTeX."})+end++
local vmode do
for k, v in pairs(tex.getmodevalues()) do
if v == "vertical" then
@@ -610,16 +625,16 @@ local function reset_underline()
tex.attribute[j] = -0x7FFFFFFF
end
local new_underline_type_func =
- luatexbase.new_luafunction"luaul.new_underline_type"-local set_underline_func =- luatexbase.new_luafunction"luaul.set_underline_func"-local reset_underline_func =- luatexbase.new_luafunction"luaul.reset_underline_func"+ luatexbase.new_luafunction"luaul.new_underline_type"
set_lua("LuaULNewUnderlineType", new_underline_type_func)
-set_lua("LuaULSetUnderline", set_underline_func, "protected")-set_lua("LuaULResetUnderline", reset_underline_func, "protected")
functions[new_underline_type_func] = new_underline_type
+local set_underline_func =+ luatexbase.new_luafunction"luaul.set_underline_func"+set_lua("LuaULSetUnderline", set_underline_func, "protected")
functions[set_underline_func] = set_underline
+local reset_underline_func =+ luatexbase.new_luafunction"luaul.reset_underline_func"+set_lua("LuaULResetUnderline", reset_underline_func, "protected")
functions[reset_underline_func] = reset_underline
% \end{macrocode}
@@ -846,8 +861,37 @@ function add_underline_hbox(head, attr, outervalue, set_height_depth)
end
set_attribute(head, attr, outervalue and -outervalue or 0)
end
-require'pre_append_to_vlist_filter'-luatexbase.add_to_callback('pre_append_to_vlist_filter',+local filter_callback+local filter_callback_return+if optex then + filter_callback = 'append_to_vlist_filter'+ function filter_callback_return(b, prev, mirror)+ local new_b = tonode(b)+ local new_prev = mirror and new_b.height or new_b.depth+ if prev > -65536000 then+ local lineglue = tex.baselineskip.width - prev - (mirror and new_b.depth or new_b.height)+ local skip+ if lineglue < tex.lineskiplimit then+ skip = node.new('glue', 1)+ node.setglue(skip, node.getglue(tex.lineskip))+ else+ skip = node.new('glue', 2)+ node.setglue(skip, node.getglue(tex.baselineskip))+ skip.width = lineglue+ end+ skip.next = new_b+ new_b = skip+ end+ return new_b, new_prev+ end+else+ filter_callback = 'pre_append_to_vlist_filter'+ function filter_callback_return(b, prev, mirror)+ return tonode(b)+ end+ require'pre_append_to_vlist_filter'+end+luatexbase.add_to_callback(filter_callback,
function(b, loc, prev, mirror)
local props = properties[todirect(texnest.top.head)]
props = props and props.luaul_attributes
@@ -875,7 +919,7 @@ luatexbase.add_to_callback('pre_append_to_vlist_filter',
end
end
end
- return tonode(b)+ return filter_callback_return(b, prev, mirror)
end, 'add underlines to list')
luatexbase.add_to_callback('hpack_filter',
function(head, group, size, pack, dir, attr)
A few notes... if OpTeX will add the pre_append_to_vlist_filter call back, the patch would be much smaller. The only problem is that OpTeX does not use luatexbase, and so it does not define luatexbase.new_luafunction. It only define a small subset of luatexbase functions (or aliases of them) for compatibility with luaotfload.
The text was updated successfully, but these errors were encountered:
@zauguin Are you planing to do that eventually or it is not in your interest?
If it is the latter, will you mind if I'll public an adaption of luaul for OpTeX?
It would be nice to be able to use this package together with the OpTeX format. If you will be willing to do so, i'll request the developer of the format to add the
pre_append_to_vlist_filter
call back so it would be easier to do so.Just for a proof of concept:, the following diff works:
Test file
A few notes... if OpTeX will add the
pre_append_to_vlist_filter
call back, the patch would be much smaller. The only problem is that OpTeX does not use luatexbase, and so it does not defineluatexbase.new_luafunction
. It only define a small subset of luatexbase functions (or aliases of them) for compatibility withluaotfload
.The text was updated successfully, but these errors were encountered: