[latex3-commits] [latex3/latex2e] ltcmd-verb: Collect \endlinechar as \par in ltcmd +v-type (a3cb7a60)

github at latex-project.org github at latex-project.org
Wed Jun 14 09:43:21 CEST 2023


Repository : https://github.com/latex3/latex2e
On branch  : ltcmd-verb
Link       : https://github.com/latex3/latex2e/commit/a3cb7a60b5eb6b316d9b4cf8aae349fa90b55503

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

commit a3cb7a60b5eb6b316d9b4cf8aae349fa90b55503
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Jun 14 07:49:22 2023 +0100

    Collect \endlinechar as \par in ltcmd +v-type


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

a3cb7a60b5eb6b316d9b4cf8aae349fa90b55503
 base/changes.txt                     |  1 +
 base/doc/ltnews38.tex                | 14 ++++++++++++++
 base/ltcmd.dtx                       | 22 +++++++++++++++++++++-
 base/testfiles-ltcmd/github-0876.tlg |  8 ++++----
 4 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 698d1bbe..77c9a67b 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -12,6 +12,7 @@ are not part of the distribution.
 	Support (visible) tabs in verbatim material
 	* ltcmd.dtx
 	Collect spaces and tabs as active chars
+	Collect \endlinechar as \par
 
 2023-06-09  Joseph Wright  <Joseph.Wright at latex-project.org>
 
diff --git a/base/doc/ltnews38.tex b/base/doc/ltnews38.tex
index 78c8d03e..8b13cf81 100644
--- a/base/doc/ltnews38.tex
+++ b/base/doc/ltnews38.tex
@@ -172,6 +172,20 @@ to easily print visible spaces. We have adjusted the implementation of the
 space has been modified. However, the team believe that overall the benefit of
 better consistency makes this a necessary change.
 
+\subsection{Handling of end-of-lines in \cs{NewDocumentCommand} \texttt{+v}
+arguments}
+
+The \texttt{+v} argument type provided by \cs{NewDocumentCommand}, etc., allows
+grabbing of multiple lines of text in a verbatim-like argument. Almost always,
+the result of this grabbing will be used in a typesetting context. Previously,
+the end-of-line characters were stored literally as category code~12
+(\enquote{other}) \verb|^^M| tokens. However, these are difficult to work with
+in general. We have now revised this behavior, such that end-of-line characters
+are converted to the \cs{par} command when parsed by \texttt{+v}-type
+arguments. As with the previous change, this may require adjustment in the
+source of some documents, but the enhanced ability of users and programmers to
+exploit the \texttt{+v}-type argument means we believe it is necessary.
+
 \section{Bug fixes}
 
 \section{Changes to packages in the \pkg{amsmath} category}
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 7e87bcdc..ecb25939 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -3548,18 +3548,38 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_grab_v_aux_put:N}
+% \changes{v1.1f}{2023/06/14}{Collect \cs{endlinechar} as \cs{par} token}
 %   Storing one token in the collected argument. Most tokens are
 %   converted to category code $12$, with the exception of active
 %   characters.
 %    \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2023/11/01}{\@@_grab_v_aux_put:N}%
+%<latexrelease>  {Endlines~as~\par}
 \cs_new_protected:Npn \@@_grab_v_aux_put:N #1
   {
     \tl_put_right:Nx \l_@@_v_arg_tl
       {
         \token_if_active:NTF #1
-          { \exp_not:N #1 } { \token_to_str:N #1 }
+          { \exp_not:N #1 }
+          {
+            \int_compare:nNnTF {`#1} = \tex_endlinechar:D
+              { \exp_not:N \par }
+              { \token_to_str:N #1 }
+          }
       }
   }
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_grab_v_aux_put:N}%
+%<latexrelease>  {Endlines~as~\par}
+%<latexrelease>\cs_new_protected:Npn \@@_grab_v_aux_put:N #1
+%<latexrelease>  {
+%<latexrelease>    \tl_put_right:Nx \l_@@_v_arg_tl
+%<latexrelease>      {
+%<latexrelease>        \token_if_active:NTF #1
+%<latexrelease>          { \exp_not:N #1 } { \token_to_str:N #1 }
+%<latexrelease>      }
+%<latexrelease>  }
+%<latexrelease>\EndIncludeInRelease
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/base/testfiles-ltcmd/github-0876.tlg b/base/testfiles-ltcmd/github-0876.tlg
index e06c7c0f..7fde532d 100644
--- a/base/testfiles-ltcmd/github-0876.tlg
+++ b/base/testfiles-ltcmd/github-0876.tlg
@@ -16,7 +16,7 @@ The token list contains the tokens:
 >  b (the character b)
 >  a (the character a)
 >  r (the character r)
->  ^^M (the character ^^M)
+>  \par (control sequence=\protected\long macro:->\scan_stop: \mode_if_h\ETC.)
 >  b (the character b)
 >  a (the character a)
 >  r (the character r).
@@ -27,7 +27,7 @@ The token list contains the tokens:
 >  b (the character b)
 >  a (the character a)
 >  r (the character r)
->  ^^M (the character ^^M)
+>  \par (control sequence=\protected\long macro:->\scan_stop: \mode_if_h\ETC.)
 >  b (the character b)
 >  a (the character a)
 >  r (the character r).
@@ -35,11 +35,11 @@ The token list contains the tokens:
 l. ...bar+
          ^^M
 The token list contains the tokens:
->  ^^M (the character ^^M)
+>  \par (control sequence=\protected\long macro:->\scan_stop: \mode_if_h\ETC.)
 >  b (the character b)
 >  a (the character a)
 >  r (the character r)
->  ^^M (the character ^^M)
+>  \par (control sequence=\protected\long macro:->\scan_stop: \mode_if_h\ETC.)
 >  b (the character b)
 >  a (the character a)
 >  r (the character r).





More information about the latex3-commits mailing list.