[latex3-commits] [git/LaTeX3-latex3-latex2e] callbacks: Add pre/post_mlist_to_hlist callbacks (f2dca931)

Marcel Fabian Krüger tex at 2krueger.de
Fri Jan 10 15:02:45 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : callbacks
Link       : https://github.com/latex3/latex2e/commit/f2dca9313bd97dd380014a830fed38322f59a8a5

>---------------------------------------------------------------

commit f2dca9313bd97dd380014a830fed38322f59a8a5
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Fri Jan 10 14:46:11 2020 +0100

    Add pre/post_mlist_to_hlist callbacks


>---------------------------------------------------------------

f2dca9313bd97dd380014a830fed38322f59a8a5
 base/ltluatex.dtx                          | 33 +++++++++++++++++++++++++++++-
 base/testfiles/tlb-callbacks-001.lvt       |  3 +++
 base/testfiles/tlb-ltluatex-001.luatex.tlg |  2 +-
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/base/ltluatex.dtx b/base/ltluatex.dtx
index 0f7dcc4e..989006f3 100644
--- a/base/ltluatex.dtx
+++ b/base/ltluatex.dtx
@@ -1338,7 +1338,9 @@ local callbacktypes = callbacktypes or {
   ligaturing             = simple,
   kerning                = simple,
   insert_local_par       = simple,
+  pre_mlist_to_hlist_filter = list,
   mlist_to_hlist         = exclusive,
+  post_mlist_to_hlist_filter = reverselist,
   new_graf               = simple,
 %    \end{macrocode}
 % Section 8.5: information reporting callbacks.
@@ -1575,7 +1577,11 @@ local defaults = {
 % If a default function is not required, it may be declared as |false|.
 % First we need a list of user callbacks.
 %    \begin{macrocode}
-local user_callbacks_defaults = { }
+local user_callbacks_defaults = {
+  pre_mlist_to_hlist_filter = list_handler_default,
+  mlist_to_hlist = node.mlist_to_hlist,
+  post_mlist_to_hlist_filter = list_handler_default,
+}
 %    \end{macrocode}
 %
 % \begin{macro}{create_callback}
@@ -1844,6 +1850,31 @@ end
 luatexbase.uninstall = uninstall
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{mlist_to_hlist}
+% \changes{v1.1l}{2020/02/02}{|pre/post_mlist_to_hlist| added}
+%   To emulate these callbacks, the ``real'' |mlist_to_hlist| is replaced by a
+%   wrapper calling the wrappers before and after.
+%    \begin{macrocode}
+callback_register("mlist_to_hlist", function(head, display_type, need_penalties)
+  local current = call_callback("pre_mlist_to_hlist_filter", 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
+    flush_list(current)
+    return nil
+  end
+  return post
+end)
+%    \end{macrocode}
+% \end{macro}
 % \endgroup
 %
 %    \begin{macrocode}
diff --git a/base/testfiles/tlb-callbacks-001.lvt b/base/testfiles/tlb-callbacks-001.lvt
index 881e44eb..223edf25 100644
--- a/base/testfiles/tlb-callbacks-001.lvt
+++ b/base/testfiles/tlb-callbacks-001.lvt
@@ -12,6 +12,9 @@
 %
  local expected_user_callbacks={}
 %
+% current ltluatex user-callbacks
+ expected_user_callbacks['pre_mlist_to_hlist_filter']=1
+ expected_user_callbacks['post_mlist_to_hlist_filter']=1
 % curent luaotfload user-callbacks
  expected_user_callbacks['luaotfload.patch_font_unsafe']=1
  expected_user_callbacks['luaotfload.resolve_font']=1
diff --git a/base/testfiles/tlb-ltluatex-001.luatex.tlg b/base/testfiles/tlb-ltluatex-001.luatex.tlg
index 659f3a34..8fccccdf 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:109: in upvalue 'module_error'
 ^^I./ltluatex.lua:116: in upvalue 'luatexbase_error'
-^^I./ltluatex.lua:423: in field 'create_callback'
+^^I./ltluatex.lua:429: in field 'create_callback'
 ^^I[\directlua]:1: in main chunk.
 l. ...}
 The lua interpreter ran into a problem, so the





More information about the latex3-commits mailing list