[latex3-commits] [latex3/latex2e] tagging36+tagging641: make sure we get a \@noitemerr early if there is material before the first item (3f67c691)

github at latex-project.org github at latex-project.org
Mon Sep 2 23:01:43 CEST 2024


Repository : https://github.com/latex3/latex2e
On branch  : tagging36+tagging641
Link       : https://github.com/latex3/latex2e/commit/3f67c6911284d6f839dc50f0583b1055f7b85858

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

commit 3f67c6911284d6f839dc50f0583b1055f7b85858
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Mon Sep 2 23:01:43 2024 +0200

    make sure we get a \@noitemerr early if there is material before the first item


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

3f67c6911284d6f839dc50f0583b1055f7b85858
 required/latex-lab/changes.txt                     |  3 ++
 required/latex-lab/latex-lab-block.dtx             | 37 ++++++++++++++++++----
 .../testfiles-block/blocks-item-02.luatex.tlg      | 18 +++++++++--
 .../latex-lab/testfiles-block/blocks-item-02.lvt   | 10 +++---
 .../latex-lab/testfiles-block/blocks-item-02.tlg   | 18 +++++++++--
 5 files changed, 72 insertions(+), 14 deletions(-)

diff --git a/required/latex-lab/changes.txt b/required/latex-lab/changes.txt
index 72430452..17210bf3 100644
--- a/required/latex-lab/changes.txt
+++ b/required/latex-lab/changes.txt
@@ -7,6 +7,9 @@
 	(subsubsection{Implementation of \cs{item} template(s)}):
 	Set @newlist to false after the first \item (issue tagging/36)
 
+	Call \@noitemerr in para/begin hook if hmode is started before
+	the first item
+
 	(subsubsection{Implementation of block templates \ldots}):
 	Drop \@noitemerr from \addvspace and \addpenalty
 
diff --git a/required/latex-lab/latex-lab-block.dtx b/required/latex-lab/latex-lab-block.dtx
index 4d503a2e..5a4a30bc 100644
--- a/required/latex-lab/latex-lab-block.dtx
+++ b/required/latex-lab/latex-lab-block.dtx
@@ -2271,12 +2271,26 @@
       \tl_set_eq:NN \@itemlabel \l_@@_item_label_tl
     }
 %    \end{macrocode}
-%    finally, we signal that we are at the start of a new list (which
+%    Finally, we signal that we are at the start of a new list (which
 %    effects how the first \cs{item} is handled and how \cs{par}
 %    commands are interpreted.
 %    \begin{macrocode}
     \legacy_if_gset_true:n { @newlist }
 %    \end{macrocode}
+%    If we encounter horizontal material before the first \cs{item} we
+%    do want a \cs{@noitemerr} straight away, because afterwards we
+%    end up with tagging structure faults  and the cause is the
+%    missing \cs{item}. So we setup up \cs{@@_item_everypar:} to test
+%    for this. When the first \cs{item} is encountered this is then
+%    reset. This is only relevant for vertical lists, if we have
+%    inline lists one would need to test for somethingg else to
+%    identify that there is horizontal material between list start and
+%    the first \cs{item}, maybe some \cs{spacefactor} trick could be
+%    used then.\fmi{Think about a better implementation at some point.}
+%  \changes{v0.8q}{2024/09/02}{}
+%    \begin{macrocode}
+    \cs_set_eq:NN \@@_item_everypar: \@@_item_everypar_first:
+%    \end{macrocode}
 %    
 %    \begin{macrocode}
   \@@_debug_typeout:n{template:list:std~end}
@@ -2367,6 +2381,7 @@
     \tl_set_eq:NN \l_@@_label_given_tl \c_novalue_tl
     \tl_if_empty:nF{#1}{ \SetTemplateKeys{item}{std}{#1} }
 %    \end{macrocode}
+%    
 %    If no optional argument was given then \cs{l_@@_label_given_tl}
 %    is still equal to \cs{c_novalue_tl} and so we can distinuish
 %    that from \verb=\item[]=.
@@ -2518,16 +2533,16 @@
 %
 %
 %
-% \begin{macro}{\@@_item_everypar:, \@@_item_everypar_std:}
+% \begin{macro}{\@@_item_everypar:, \@@_item_everypar_std:, \@@_item_everypar_first:}
 %    The \cs{@@_item_everypar:} command is executed as part of \hook{para/begin}
 %    but most of the time does nothing, i.e., it has the following
-%    default definition.
+%    default definition outside of lists and most of the time within lists.
 %    \begin{macrocode}
 \cs_new_eq:NN \@@_item_everypar: \prg_do_nothing:
 %    \end{macrocode}
 %    
 %    \begin{macrocode}
-\AddToHook{para/begin}[lists]{\@@_item_everypar:}
+\AddToHook{para/begin}[items]{\@@_item_everypar:}
 %    \end{macrocode}
 %
 %    Note that we have to make sure that the above code is executed
@@ -2535,9 +2550,9 @@
 %    \texttt{@inlabel} to make a decision.
 %
 %    By the end of the day both should probably move into the kernel
-%    hook instead!
+%    hook instead or into sockets really.
 %    \begin{macrocode}
-\DeclareHookRule{para/begin}{lists}{after}{tagpdf}
+\DeclareHookRule{para/begin}{items}{after}{tagpdf}
 %    \end{macrocode}
 %
 %
@@ -2589,6 +2604,16 @@
 }
 %    \end{macrocode}
 %
+%    This is the setting for \cs{@@_item_everypar:} before the first
+%    \cs{item} is encountered.
+%  \changes{v0.8q}{2024/09/02}{Call \cs{@noitemerr} if hmode is
+%    started before the first item}
+%    \begin{macrocode}
+\cs_new:Npn \@@_item_everypar_first: {
+  \legacy_if:nT { @newlist }  { \@noitemerr }
+}
+%    \end{macrocode}
+%
 % \end{macro}
 %
 %
diff --git a/required/latex-lab/testfiles-block/blocks-item-02.luatex.tlg b/required/latex-lab/testfiles-block/blocks-item-02.luatex.tlg
index 0addc94b..e4b0a4c8 100644
--- a/required/latex-lab/testfiles-block/blocks-item-02.luatex.tlg
+++ b/required/latex-lab/testfiles-block/blocks-item-02.luatex.tlg
@@ -1,5 +1,6 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
+========= Empty list should only generate a no-item error (but not two)
 ==> enumerate-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -25,6 +26,7 @@ Package tagpdf Info: closing structure 4 tagged /enumerate
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 3 tagged /text-unit
+========= And this should also generate a no-item error
 ==> itemize-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -64,14 +66,15 @@ Package tagpdf Warning: Parent-Child 'L/' --> 'text/user'.
 Package tagpdf Info: Parent-Child 'P' --> 'MC'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'P' --> 'MC' on line ...
-==> blockenv common ending on input line ...
 ! LaTeX Error: Something's wrong--perhaps a missing \item.
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H <return>  for immediate help.
  ...                                              
-l. ...  \begin{center} X \end{center}
+l. ...  \begin{center} X
+                      \end{center}
 Try typing  <return>  to proceed.
 If that doesn't work, type  X <return>  to quit.
+==> blockenv common ending on input line ...
 ==> run (another) @doendpe at group level 2
 Package tagpdf Info: Parent-Child 'P' --> 'LI'.
 (tagpdf)             Relation is -1 (='∅')
@@ -101,6 +104,7 @@ Package tagpdf Info: closing structure 6 tagged /itemize
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 5 tagged /text-unit
+========= And this should also generate a no-item error
 ==> description-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -128,6 +132,14 @@ Package tagpdf Warning: Parent-Child 'L/' --> 'text/user'.
 Package tagpdf Info: Parent-Child 'P' --> 'MC'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'P' --> 'MC' on line ...
+! LaTeX Error: Something's wrong--perhaps a missing \item.
+See the LaTeX manual or LaTeX Companion for explanation.
+Type  H <return>  for immediate help.
+ ...                                              
+l. ...  m
+      issing item
+Try typing  <return>  to proceed.
+If that doesn't work, type  X <return>  to quit.
 Package tagpdf Info: Parent-Child 'P' --> 'LI'.
 (tagpdf)             Relation is -1 (='∅')
 (tagpdf)             Rolemapped from: 'P' --> 'LI' on line ...
@@ -135,6 +147,7 @@ Package tagpdf Warning: Parent-Child 'P/' --> 'LI/pdf2'.
 (tagpdf)                Relation is not allowed (struct 15, /text --> struct
 (tagpdf)                16) on line ...
 ==> template:item:std
+==> item with optional
 Package tagpdf Info: Parent-Child 'LI' --> 'Lbl'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'LI' --> 'Lbl' on line ...
@@ -155,6 +168,7 @@ Package tagpdf Info: closing structure 13 tagged /description
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 12 tagged /text-unit
+========= Empty biblio should generate only warning
 Package tagpdf Info: Parent-Child 'Document' --> 'Part'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'Document' --> 'text-unit' on line ...
diff --git a/required/latex-lab/testfiles-block/blocks-item-02.lvt b/required/latex-lab/testfiles-block/blocks-item-02.lvt
index 147eb847..30328d54 100644
--- a/required/latex-lab/testfiles-block/blocks-item-02.lvt
+++ b/required/latex-lab/testfiles-block/blocks-item-02.lvt
@@ -20,13 +20,13 @@
 
 \START
 
-% empty list should only generate a no-item error (but not two)
+\typeout{========= Empty list should only generate a no-item error (but not two)}
 
 \begin{enumerate}
 % missing an item
 \end{enumerate}
 
-% And this should also generate a no-item error
+\typeout{========= And this should also generate a no-item error}
 
 \begin{itemize}
   \begin{center} X \end{center}
@@ -34,13 +34,15 @@
   foo
 \end{itemize}
 
+\typeout{========= And this should also generate a no-item error}
+
 \begin{description}
   missing item
-\item
+\item[foo]
   foo
 \end{description}
 
-% empty biblio should generate only warning
+\typeout{========= Empty biblio should generate only warning}
 
 \begin{thebibliography}{9}
 \end{thebibliography}
diff --git a/required/latex-lab/testfiles-block/blocks-item-02.tlg b/required/latex-lab/testfiles-block/blocks-item-02.tlg
index 8082474a..fd6d887a 100644
--- a/required/latex-lab/testfiles-block/blocks-item-02.tlg
+++ b/required/latex-lab/testfiles-block/blocks-item-02.tlg
@@ -1,5 +1,6 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
+========= Empty list should only generate a no-item error (but not two)
 ==> enumerate-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -25,6 +26,7 @@ Package tagpdf Info: closing structure 4 tagged /enumerate
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 3 tagged /text-unit
+========= And this should also generate a no-item error
 ==> itemize-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -64,14 +66,15 @@ Package tagpdf Warning: Parent-Child 'L/' --> 'text/user'.
 Package tagpdf Info: Parent-Child 'P' --> 'MC'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'P' --> 'MC' on line ...
-==> blockenv common ending on input line ...
 ! LaTeX Error: Something's wrong--perhaps a missing \item.
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H <return>  for immediate help.
  ...                                              
-l. ...  \begin{center} X \end{center}
+l. ...  \begin{center} X
+                        \end{center}
 Try typing  <return>  to proceed.
 If that doesn't work, type  X <return>  to quit.
+==> blockenv common ending on input line ...
 ==> run (another) @doendpe at group level 2
 Package tagpdf Info: Parent-Child 'P' --> 'LI'.
 (tagpdf)             Relation is -1 (='^^e2^^88^^85')
@@ -103,6 +106,7 @@ Package tagpdf Info: closing structure 6 tagged /itemize
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 5 tagged /text-unit
+========= And this should also generate a no-item error
 ==> description-env-start
 ==> use instance: list-1
 ==> @endpe=false on input line ...
@@ -130,6 +134,14 @@ Package tagpdf Warning: Parent-Child 'L/' --> 'text/user'.
 Package tagpdf Info: Parent-Child 'P' --> 'MC'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'P' --> 'MC' on line ...
+! LaTeX Error: Something's wrong--perhaps a missing \item.
+See the LaTeX manual or LaTeX Companion for explanation.
+Type  H <return>  for immediate help.
+ ...                                              
+l. ...  m
+        issing item
+Try typing  <return>  to proceed.
+If that doesn't work, type  X <return>  to quit.
 Package tagpdf Info: Parent-Child 'P' --> 'LI'.
 (tagpdf)             Relation is -1 (='^^e2^^88^^85')
 (tagpdf)             Rolemapped from: 'P' --> 'LI' on line ...
@@ -137,6 +149,7 @@ Package tagpdf Warning: Parent-Child 'P/' --> 'LI/pdf2'.
 (tagpdf)                Relation is not allowed (struct 15, /text --> struct
 (tagpdf)                16) on line ...
 ==> template:item:std
+==> item with optional
 Package tagpdf Info: Parent-Child 'LI' --> 'Lbl'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'LI' --> 'Lbl' on line ...
@@ -159,6 +172,7 @@ Package tagpdf Info: closing structure 13 tagged /description
 ==> flattened=false on input line ...
 ==> Structure-end text-unit after displayblock on input line ...
 Package tagpdf Info: closing structure 12 tagged /text-unit
+========= Empty biblio should generate only warning
 Package tagpdf Info: Parent-Child 'Document' --> 'Part'.
 (tagpdf)             Relation is 1 (='0..n')
 (tagpdf)             Rolemapped from: 'Document' --> 'text-unit' on line ...





More information about the latex3-commits mailing list.