diff --git a/.github/tl_packages b/.github/tl_packages index 545df83ef..7ad52cafd 100644 --- a/.github/tl_packages +++ b/.github/tl_packages @@ -22,6 +22,7 @@ hyperref oberdiek lh tex-gyre +hypdoc # # special testing for firstaid bidi diff --git a/base/changes.txt b/base/changes.txt index bfdb5ac28..de6cc373c 100644 --- a/base/changes.txt +++ b/base/changes.txt @@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that are not part of the distribution. ================================================================================ +2021-11-17 Marcel Krüger + + * ltluatex.dtx: + Classify [hv]pack_quality callbacks as exclusive + Never pass true to the engine for LuaTeX list callbacks + 2021-11-15 Frank Mittelbach * build.lua (textfiles): diff --git a/base/doc/ltnews35.tex b/base/doc/ltnews35.tex index 731c5ee98..6b5d4816b 100644 --- a/base/doc/ltnews35.tex +++ b/base/doc/ltnews35.tex @@ -147,6 +147,19 @@ \subsection{???} \section{Code improvements} +\subsection{Lua\TeX\ callback improvements} + +The Lua\TeX\ callbacks \texttt{hpack\_quality} and \texttt{vpack\_quality} are +now \texttt{exclusive} and therefore only allow a single handler. +The previous type \texttt{list} resulted in incorrect parameters when multiple +handlers were set, therefore this only makes an existing restriction more +explicit. + +Additionally the return value \texttt{true} for \texttt{list} callbacks is now +handled internally and no longer passed on to the engine. This simplifies the +handling of these callbacks and makes it easier to provide consistent +interfaces for user defined \texttt{list} callbacks. + \subsection{???} % \githubissue{???} diff --git a/base/ltluatex.dtx b/base/ltluatex.dtx index 258ac4829..612e13542 100644 --- a/base/ltluatex.dtx +++ b/base/ltluatex.dtx @@ -28,7 +28,7 @@ \ProvidesFile{ltluatex.dtx} % %<*tex> -[2021/10/15 v1.1v +[2021/11/17 v1.1w % % LuaTeX support for plain TeX (core) %<*tex> @@ -1351,6 +1351,8 @@ local callbacktypes = callbacktypes or { % \changes{v1.1k}{2019/10/02}{mlist\_to\_hlist is \texttt{exclusive}} % \changes{v1.1l}{2020/02/02}{post\_linebreak\_filter is \texttt{reverselist}} % \changes{v1.1p}{2020/08/01}{new\_graf is \texttt{exclusive}} +% \changes{v1.1w}{2021/11/17}{hpack\_quality is \texttt{exclusive}} +% \changes{v1.1w}{2021/11/17}{vpack\_quality is \texttt{exclusive}} % \begin{macrocode} contribute_filter = simple, buildpage_filter = simple, @@ -1361,8 +1363,8 @@ local callbacktypes = callbacktypes or { post_linebreak_filter = reverselist, hpack_filter = list, vpack_filter = list, - hpack_quality = list, - vpack_quality = list, + hpack_quality = exclusive, + vpack_quality = exclusive, pre_output_filter = list, process_rule = exclusive, hyphenate = simple, @@ -1516,11 +1518,11 @@ end % Handler for |list| callbacks. % \changes{v1.0k}{2015/12/02}{resolve name and i.description (PHG)} % \changes{v1.1s}{2020/12/02}{Fix return value of list callbacks} +% \changes{v1.1w}{2021/11/17}{Never pass on \texttt{true} return values for list callbacks} % \begin{macrocode} local function list_handler(name) return function(head, ...) local ret - local alltrue = true for _,i in ipairs(callbacklist[name]) do ret = i.func(head, ...) if ret == false then @@ -1531,18 +1533,17 @@ local function list_handler(name) return false end if ret ~= true then - alltrue = false head = ret end end - return alltrue and true or head + return head end end % \end{macrocode} % Default for user-defined |list| and |reverselist| callbacks without explicit default. % \begin{macrocode} -local function list_handler_default() - return true +local function list_handler_default(head) +return head end % \end{macrocode} % Handler for |reverselist| callbacks. @@ -1551,7 +1552,6 @@ end local function reverselist_handler(name) return function(head, ...) local ret - local alltrue = true local callbacks = callbacklist[name] for i = #callbacks, 1, -1 do local cb = callbacks[i] @@ -1564,11 +1564,10 @@ local function reverselist_handler(name) return false end if ret ~= true then - alltrue = false head = ret end end - return alltrue and true or head + return head end end % \end{macrocode} @@ -1899,14 +1898,10 @@ callback_register("mlist_to_hlist", function(head, display_type, need_penalties) if current == false then flush_list(head) return nil - elseif current == true then - current = head end current = call_callback("mlist_to_hlist", current, display_type, need_penalties) local post = call_callback("post_mlist_to_hlist_filter", current, display_type, need_penalties) - if post == true then - return current - elseif post == false then + if post == false then flush_list(current) return nil end diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx index 7f6555d18..9e7bf4be8 100644 --- a/base/ltshipout.dtx +++ b/base/ltshipout.dtx @@ -741,8 +741,9 @@ luatexbase.create_callback('pre_shipout_filter', 'list') local~call, getbox, setbox = luatexbase.call_callback, tex.getbox, tex.setbox~ lua.get_functions_table()[\the \@@_finalize_box:] = function() - local~result = call('pre_shipout_filter', getbox(\the \l_shipout_box)) - if~not (result == true) then~ + local head = getbox(\the \l_shipout_box) + local~result = call('pre_shipout_filter', head) + if~not (result == head) then~ setbox(\the \l_shipout_box, result~or~nil) end~ end diff --git a/base/testfiles/tlb-ltluatex-001.luatex.tlg b/base/testfiles/tlb-ltluatex-001.luatex.tlg index 7f07f32d4..53c7483d1 100644 --- a/base/testfiles/tlb-ltluatex-001.luatex.tlg +++ b/base/testfiles/tlb-ltluatex-001.luatex.tlg @@ -7,7 +7,7 @@ stack traceback: ^^I[C]: in function 'error' ^^I./ltluatex.lua:110: in upvalue 'module_error' ^^I./ltluatex.lua:117: in upvalue 'luatexbase_error' -^^I./ltluatex.lua:432: in field 'create_callback' +^^I./ltluatex.lua:428: in field 'create_callback' ^^I[\directlua]:1: in main chunk. l. ...} The lua interpreter ran into a problem, so the