[latex3-commits] [git/LaTeX3-latex3-latex2e] pre_shipout: Lua callback for shipout (17f3650c)
Marcel Fabian Krüger
tex at 2krueger.de
Thu Jan 7 12:36:56 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : pre_shipout
Link : https://github.com/latex3/latex2e/commit/17f3650cfc61f3ba4ecd6a275d4d99d325b019ec
>---------------------------------------------------------------
commit 17f3650cfc61f3ba4ecd6a275d4d99d325b019ec
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Wed Sep 30 17:40:51 2020 +0200
Lua callback for shipout
>---------------------------------------------------------------
17f3650cfc61f3ba4ecd6a275d4d99d325b019ec
base/ltshipout.dtx | 42 ++++++++++++++++++++++++++++++++++++
base/testfiles/tlb-callbacks-001.lvt | 2 ++
2 files changed, 44 insertions(+)
diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx
index fa5bfd00..862691f0 100644
--- a/base/ltshipout.dtx
+++ b/base/ltshipout.dtx
@@ -290,6 +290,20 @@
% names as given below.
%
%
+%
+% \subsection{Provided Lua\Tex\ callbacks}
+%
+% \begin{variable}{pre_shipout_filter}
+% Under Lua\TeX, additionally the \texttt{pre_shipout_filter} callback is
+% provided. The signature is
+% \begin{verbatim}
+% function(<node> head)
+% return true | false | <node> newhead
+% end
+% \end{verbatim}
+% This callback is invoked after all \TeX-level hooks described above.
+% \end{variable}
+%
% \subsection{Information counters}
%
%
@@ -593,6 +607,33 @@
%
%
%
+% \begin{macro}{\@@_finalize_box:}
+% For Lua\TeX{} invoke the \texttt{pre\_shipout\_filter} callback.
+% \begin{macrocode}
+\sys_if_engine_luatex:TF
+ {
+ \newluafunction \@@_finalize_box:
+ \exp_args:Nx \everyjob {
+ \exp_not:V \everyjob
+ \exp_not:N \lua_now:n {
+ 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~
+ setbox(\the \l_shipout_box, result~or~nil)
+ end~
+ end
+ }
+ }
+ \protected \luadef \@@_finalize_box: \the \@@_finalize_box:
+ } {
+ \cs_set_eq:NN \@@_finalize_box: \scan_stop:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{\@@_execute:}
% This is going to the be the code run by \cs{shipout}. The code
% follows closely the ideas from \pkg{atbegshi}, so not
@@ -786,6 +827,7 @@
}
\bool_gset_true:N \g_@@_lastpage_handled_bool
}
+ \@@_finalize_box:
% \end{macrocode}
% Finally we run the actual \TeX{} primitive for shipout. As that will
% expand delayed \cs{write} statements inside the page in which
diff --git a/base/testfiles/tlb-callbacks-001.lvt b/base/testfiles/tlb-callbacks-001.lvt
index f96e1a9b..d4fbf5a2 100644
--- a/base/testfiles/tlb-callbacks-001.lvt
+++ b/base/testfiles/tlb-callbacks-001.lvt
@@ -15,6 +15,8 @@
% current ltluatex user-callbacks
expected_user_callbacks['pre_mlist_to_hlist_filter']=1
expected_user_callbacks['post_mlist_to_hlist_filter']=1
+%
+ expected_user_callbacks['pre_shipout_filter']=1
% curent luaotfload user-callbacks
expected_user_callbacks['luaotfload.patch_font_unsafe']=1
expected_user_callbacks['luaotfload.resolve_font']=1
More information about the latex3-commits
mailing list.