[latex3-commits] [git/LaTeX3-latex3-latex2e] parhook-skip: adjust glue guard at end of paragraph (cb5a8c0c)

David Carlisle d.p.carlisle at gmail.com
Sat Sep 18 14:09:01 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : parhook-skip
Link       : https://github.com/latex3/latex2e/commit/cb5a8c0c87fed6dd998aba72a88a33977509be74

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

commit cb5a8c0c87fed6dd998aba72a88a33977509be74
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Sat Sep 18 13:09:01 2021 +0100

    adjust glue guard at end of paragraph


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

cb5a8c0c87fed6dd998aba72a88a33977509be74
 base/changes.txt |  6 ++++++
 base/ltpara.dtx  | 23 +++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 700f7462..50f916b2 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-09-18  David Carlisle  <David.Carlisle at latex-project.org>
+
+	* ltpara.dtx: use a \hskip rather than \kern as the guard to
+	prevent more than one glue item being removed when the primitive
+	par is called twice to process the end of paragraph hooks.
+
 2021-09-12  David Carlisle  <David.Carlisle at latex-project.org>
 
 	* ltfntcmd.dtx: guard definition in \text at command with \unexpanded (gh/665)
diff --git a/base/ltpara.dtx b/base/ltpara.dtx
index 22edac2f..0b646de0 100644
--- a/base/ltpara.dtx
+++ b/base/ltpara.dtx
@@ -14,8 +14,8 @@
 %%% From File: ltpara.dtx
 %
 %    \begin{macrocode}
-\def\ltparaversion{v1.0i}
-\def\ltparadate{2021/08/27}
+\def\ltparaversion{v1.0j}
+\def\ltparadate{2021/09/18}
 %    \end{macrocode}
 %<*driver>
 \documentclass{l3doc}
@@ -1032,12 +1032,13 @@
          \mode_if_horizontal:TF {
 %    \end{macrocode}
 %    The final action (before getting to the point where
-%    \cs{tex_par:D} is called) is to add a kern item so that the
+%    \cs{tex_par:D} is called) is to add a glue item so that the
 %    primitive is prevented from removing glue (if there was some). If
 %      we don't do this and the
 %    horizontal list ended in several glue items we would end up  with
 %    removing two instead of just the last one, which would be wrong.
-%    We use a kern as that is minimally faster.
+%    We use glue (rather than a kern) as that will be removed by the primitive
+%    par.
 %
 %    There is however one other \TeX{} optimization that hurts: in a
 %    sequence like this \verb=$$ ... $$ \par=  \TeX{} will be in
@@ -1047,17 +1048,19 @@
 %    away. The space between \verb=$$= and \cs{par} got already
 %    dropped during the display processing so the \cs{par} is not
 %    removing any space and appending \cs{parfillskip}, instead it
-%    simply goes silently to vmode. Now if we would had added something (to
+%    simply goes silently to vmode. Now if we would have added something (to
 %    prevent glue removal) that would look to \TeX{} like material
 %    after the display and so we would end up with an empty paragraph
 %    just containing \cs{parfillskip}.
 %
-%    We therefore check if the current hlist is empty
-%    (\cs{tex_lastnodetype:D} has the value \texttt{-1} and
-%    only if not we add our kern.
+%    We therefore check if the current hlist does end in glue
+%    (\cs{tex_lastnodetype:D} has the value \texttt{11} and
+%    only if not we add our skip, the guard skip will be removed by the
+%    following \cs{tex_par:D}.
+% \changes{v1.0i}{2021/09/18}{Use skip rather than kern as guard.}
 %    \begin{macrocode}
-           \if_int_compare:w 0 < \tex_lastnodetype:D
-             \tex_kern:D \c_zero_dim
+           \if_int_compare:w 11 = \tex_lastnodetype:D
+             \tex_hskip:D \c_zero_dim
            \fi:
 %    \end{macrocode}
 %    To run the \hook{para/after} hook we first end the





More information about the latex3-commits mailing list.