[latex3-commits] [git/latex3] master: Allow \iow_newline: to correctly produce a new line in \iow_wrap:nnnN (d5afb23)

Bruno Le Floch bruno at le-floch.fr
Mon Dec 4 22:56:40 CET 2017


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/d5afb23e08f41359edd3ac216188c7cf5c980fd1

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

commit d5afb23e08f41359edd3ac216188c7cf5c980fd1
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Mon Dec 4 16:56:40 2017 -0500

    Allow \iow_newline: to correctly produce a new line in \iow_wrap:nnnN
    
    Turns out that so far only \\ worked: using \iow_newline: (or ^^J) would
    simply count as a normal character for \iow_wrap:nnnN, then would be
    turned to a newline much later by TeX.


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

d5afb23e08f41359edd3ac216188c7cf5c980fd1
 l3kernel/l3file.dtx |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index a4ae649..a68d602 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -532,7 +532,7 @@
 %
 % \subsection{Wrapping lines in output}
 %
-% \begin{function}[added = 2012-06-28, updated = 2017-07-17]{\iow_wrap:nnnN}
+% \begin{function}[added = 2012-06-28, updated = 2017-12-04]{\iow_wrap:nnnN}
 %   \begin{syntax}
 %     \cs{iow_wrap:nnnN} \Arg{text} \Arg{run-on text} \Arg{set up} \meta{function}
 %   \end{syntax}
@@ -546,7 +546,7 @@
 %   \meta{text} and \meta{run-on text} are exhaustively expanded by the
 %   function, with the following substitutions:
 %   \begin{itemize}
-%     \item |\\| may be used to force a new line,
+%     \item |\\| or \cs{iow_newline:} may be used to force a new line,
 %     \item \verb*|\ | may be used to represent a forced space
 %       (for example after a control sequence),
 %     \item |\#|, |\%|, |\{|, |\}|, |\~| may be used to represent
@@ -1923,7 +1923,7 @@
       \cs_set:Npx \% { \token_to_str:N \% }
       \cs_set:Npx \~ { \token_to_str:N \~ }
       \int_set:Nn \tex_escapechar:D { 92 }
-      \cs_set_eq:NN \\ \c_@@_wrap_newline_marker_tl
+      \cs_set_eq:NN \\ \iow_newline:
       \cs_set_eq:NN \  \c_catcode_other_space_tl
       \cs_set_eq:NN \iow_indent:n \@@_indent:n
       #3
@@ -1962,8 +1962,9 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_wrap_do:, \@@_wrap_start:w}
-%   Escape spaces.  Set up a few variables, in particular the initial
+% \begin{macro}{\@@_wrap_do:, \@@_wrap_fix_newline:w, \@@_wrap_start:w}
+%   Escape spaces and change newlines to \cs{c_@@_wrap_newline_marker_tl}.
+%   Set up a few variables, in particular the initial
 %   value of \cs{l_@@_wrap_tl}: the space stops the
 %   \texttt{f}-expansion of the main wrapping function and
 %   \cs{use_none:n} removes a newline marker inserted by later code.
@@ -1978,8 +1979,22 @@
         \exp_args:No \__str_to_other_fast:n \l_@@_wrap_tl
         \c_@@_wrap_end_marker_tl
       }
+    \tl_set:Nx \l_@@_wrap_tl
+      {
+        \exp_after:wN \@@_wrap_fix_newline:w \l_@@_wrap_tl
+          ^^J \q_nil ^^J \q_stop
+      }
     \exp_after:wN \@@_wrap_start:w \l_@@_wrap_tl
   }
+\cs_new:Npn \@@_wrap_fix_newline:w #1 ^^J #2 ^^J
+  {
+    #1
+    \if_meaning:w \q_nil #2
+      \use_i_delimit_by_q_stop:nw
+    \fi:
+    \c_@@_wrap_newline_marker_tl
+    \@@_wrap_fix_newline:w #2 ^^J
+  }
 \cs_new_protected:Npn \@@_wrap_start:w
   {
     \bool_set_false:N \l_@@_line_break_bool





More information about the latex3-commits mailing list