diff options
Diffstat (limited to 'macros/latex-dev/base/ltpara.dtx')
-rw-r--r-- | macros/latex-dev/base/ltpara.dtx | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/macros/latex-dev/base/ltpara.dtx b/macros/latex-dev/base/ltpara.dtx index 5ab52a5e9b..bc51e4688f 100644 --- a/macros/latex-dev/base/ltpara.dtx +++ b/macros/latex-dev/base/ltpara.dtx @@ -14,8 +14,8 @@ %%% From File: ltpara.dtx % % \begin{macrocode} -\def\ltparaversion{v1.0g} -\def\ltparadate{2021/05/27} +\def\ltparaversion{v1.0j} +\def\ltparadate{2021/09/18} % \end{macrocode} %<*driver> \documentclass{l3doc} @@ -468,7 +468,7 @@ % % The commands \cs{RawIndent} and \cs{RawNoindent} are not meant % for normal paragraph building (where the result is a textual -% paragraph in the the traditional meaning of the word), but for +% paragraph in the traditional meaning of the word), but for % special cases where \TeX{}'s low-level algorithm is used to % achieve special effects, but where the result is not a % \enquote{paragraph}. @@ -972,6 +972,30 @@ % above construct but two conditionals instead. Using low-level % \cs{if_mode...} conditions would be even faster but has the % danger to conflict with conditionals in the user hooks. +% +% If \cs{para_end:} is executed while \TeX{} is currently doing a +% low-level assignment the test for horizontal mode may get +% executed as part of the assignment. That is normally not an issue +% but we just found one case where it is: +%\begin{verbatim} +% \afterassignment\lst@vskip\@tempskipa \z@ \par +%\end{verbatim} +% If \TeX{} is in hmode while that assignment happens then the +% \cs{par} is seen in hmode (because in the above case the +% assignment isn't finished (one should have used \cs{z@skip} and +% the \cs{lst@vskip} will get inserted into the middle of the +% conditional. The \cs{lst@vskip} then changes to vmode and you get +% a surprising error about the \texttt{para/end} hook having +% changed modes even if you don't have any hook code because it is +% the instered \cs{lst@vskip} that is causing it. That happened +% when the output routines got started while a \texttt{lstlisting} +% environment (that redefines \cs{vskip} in this way) was +% active. This is really faulty coding, but we try to be proactive +% and guard the conditional so thatany scanning is stopped before it: +% \begin{macrocode} + \scan_stop: +% \end{macrocode} +% % \begin{macrocode} \mode_if_horizontal:TF { \mode_if_inner:F { @@ -1008,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 @@ -1023,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 +% if so we add a zero-length guard skip which 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 @@ -1054,7 +1081,7 @@ % Finally close out the nested conditionals. % \begin{macrocode} } - } + } % \end{macrocode} % % \begin{macrocode} @@ -1090,7 +1117,7 @@ \@@_handle_indent: \the\everypar } } - { \msg_error:nn { kernel }{ raw-para } } + { \msg_error:nn { latex2e }{ raw-para } } \tex_indent:D } % \end{macrocode} @@ -1103,7 +1130,7 @@ \tex_everypar:D { \g_@@_standard_everypar_tl } \the\everypar } } - { \msg_error:nn { kernel }{ raw-para } } + { \msg_error:nn { latex2e }{ raw-para } } \tex_noindent:D } % \end{macrocode} @@ -1161,7 +1188,7 @@ % The first argument is the hook name second the mode % it should have stayed in but didn't. % -% \begin{macrocode} +% \begin{macrocode} \msg_new:nnnn { hooks } { para-mode } { Illegal~mode~ change~ in~ hook~ 'para/#1'.\\ @@ -1175,10 +1202,11 @@ } % \end{macrocode} % +% \changes{v1.0i}{2021/08/27}{Internal message name changes} % And here is one used in the \enquote{raw} commands when they are -% used outside of vertical mode. +% used outside of vertical mode. % \begin{macrocode} -\msg_new:nnnn { kernel } { raw-para } +\msg_new:nnnn { latex2e } { raw-para } { Not~ in~ vertical~ mode. } @@ -1206,7 +1234,7 @@ %<latexrelease>\cs_set_eq:NN \par \tex_par:D %<latexrelease>\cs_set_eq:NN \@@par \tex_par:D %<latexrelease>\cs_set_eq:NN \endgraf \tex_par:D -%<latexrelease> +%<latexrelease> %<latexrelease>\EndModuleRelease \ExplSyntaxOff %</2ekernel|latexrelease> @@ -1220,4 +1248,3 @@ \endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - |