[latex3-commits] [l3svn] 04/04: Make all boxes 'colour safe'

noreply at latex-project.org noreply at latex-project.org
Wed Apr 5 21:43:24 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit d7269ead0c45450c38930c3eb5aa705a815f5058
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Apr 5 20:42:40 2017 +0100

    Make all boxes 'colour safe'
    
    This is the 'easy' part of handling colour: add a group to all
    box constructs such that any colour applied internal cannot escape.
---
 l3kernel/l3box.dtx     |  113 +++++++++++++++++++++++++++++++-----------------
 l3kernel/l3coffins.dtx |    9 ++--
 2 files changed, 77 insertions(+), 45 deletions(-)

diff --git a/l3kernel/l3box.dtx b/l3kernel/l3box.dtx
index edbf6b7..3ecd58d 100644
--- a/l3kernel/l3box.dtx
+++ b/l3kernel/l3box.dtx
@@ -335,9 +335,14 @@
 %   group levels.
 % \end{function}
 %
+% \section{Boxes and color}
+%
+% All \LaTeX{}3 boxes are \enquote{color safe}: a color set inside the box
+% will not apply after the end of the box has occurred.
+%
 % \section{Horizontal mode boxes}
 %
-% \begin{function}{\hbox:n}
+% \begin{function}[updated = 2017-04-05]{\hbox:n}
 %   \begin{syntax}
 %     \cs{hbox:n} \Arg{contents}
 %   \end{syntax}
@@ -345,7 +350,7 @@
 %   width and then includes this box in the current list for typesetting.
 % \end{function}
 %
-% \begin{function}{\hbox_to_wd:nn}
+% \begin{function}[updated = 2017-04-05]{\hbox_to_wd:nn}
 %   \begin{syntax}
 %     \cs{hbox_to_wd:nn} \Arg{dimexpr} \Arg{contents}
 %   \end{syntax}
@@ -354,7 +359,7 @@
 %   typesetting.
 % \end{function}
 %
-% \begin{function}{\hbox_to_zero:n}
+% \begin{function}[updated = 2017-04-05]{\hbox_to_zero:n}
 %   \begin{syntax}
 %     \cs{hbox_to_zero:n} \Arg{contents}
 %   \end{syntax}
@@ -362,7 +367,8 @@
 %   and then includes this box in the current list for typesetting.
 % \end{function}
 %
-% \begin{function}{\hbox_set:Nn, \hbox_set:cn, \hbox_gset:Nn, \hbox_gset:cn}
+% \begin{function}[updated = 2017-04-05]
+%   {\hbox_set:Nn, \hbox_set:cn, \hbox_gset:Nn, \hbox_gset:cn}
 %   \begin{syntax}
 %     \cs{hbox_set:Nn} \meta{box} \Arg{contents}
 %   \end{syntax}
@@ -370,7 +376,7 @@
 %   result inside the \meta{box}.
 % \end{function}
 %
-% \begin{function}
+% \begin{function}[updated = 2017-04-05]
 %   {
 %     \hbox_set_to_wd:Nnn,  \hbox_set_to_wd:cnn,
 %     \hbox_gset_to_wd:Nnn, \hbox_gset_to_wd:cnn
@@ -382,7 +388,7 @@
 %   and then stores the result inside the \meta{box}.
 % \end{function}
 %
-% \begin{function}{\hbox_overlap_right:n}
+% \begin{function}[updated = 2017-04-05]{\hbox_overlap_right:n}
 %   \begin{syntax}
 %     \cs{hbox_overlap_right:n} \Arg{contents}
 %   \end{syntax}
@@ -391,7 +397,7 @@
 %   point.
 % \end{function}
 %
-% \begin{function}{\hbox_overlap_left:n}
+% \begin{function}[updated = 2017-04-05]{\hbox_overlap_left:n}
 %   \begin{syntax}
 %     \cs{hbox_overlap_left:n} \Arg{contents}
 %   \end{syntax}
@@ -400,7 +406,7 @@
 %   point.
 % \end{function}
 %
-% \begin{function}
+% \begin{function}[updated = 2017-04-05]
 %   {
 %     \hbox_set:Nw, \hbox_set:cw,
 %     \hbox_set_end:,
@@ -451,18 +457,15 @@
 % is that of the first item added. These tend to have a large depth and
 % small height, although the latter will typically be non-zero.
 %
-% \begin{function}[updated = 2011-12-18]{\vbox:n}
+% \begin{function}[updated = 2017-04-05]{\vbox:n}
 %   \begin{syntax}
 %     \cs{vbox:n} \Arg{contents}
 %   \end{syntax}
 %   Typesets the \meta{contents} into a vertical box of natural height
 %   and includes this box in the current list for typesetting.
-%   \begin{texnote}
-%     This is the \TeX{} primitive \tn{vbox}.
-%   \end{texnote}
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]{\vbox_top:n}
+% \begin{function}[updated = 2017-04-05]{\vbox_top:n}
 %   \begin{syntax}
 %     \cs{vbox_top:n} \Arg{contents}
 %   \end{syntax}
@@ -470,12 +473,9 @@
 %   and includes this box in the current list for typesetting. The
 %   baseline of the box will be equal to that of the \emph{first}
 %   item added to the box.
-%   \begin{texnote}
-%     This is the \TeX{} primitive \tn{vtop}.
-%   \end{texnote}
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]{\vbox_to_ht:nn}
+% \begin{function}[updated = 2017-04-05]{\vbox_to_ht:nn}
 %   \begin{syntax}
 %     \cs{vbox_to_ht:nn} \Arg{dimexpr} \Arg{contents}
 %   \end{syntax}
@@ -484,7 +484,7 @@
 %   typesetting.
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]{\vbox_to_zero:n}
+% \begin{function}[updated = 2017-04-05]{\vbox_to_zero:n}
 %   \begin{syntax}
 %     \cs{vbox_to_zero:n} \Arg{contents}
 %   \end{syntax}
@@ -492,7 +492,7 @@
 %   and then includes this box in the current list for typesetting.
 % \end{function}
 %
-%  \begin{function}[updated = 2011-12-18]
+%  \begin{function}[updated = 2017-04-05]
 %    {\vbox_set:Nn, \vbox_set:cn, \vbox_gset:Nn, \vbox_gset:cn}
 %   \begin{syntax}
 %     \cs{vbox_set:Nn} \meta{box} \Arg{contents}
@@ -501,7 +501,7 @@
 %   result inside the \meta{box}.
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]
+% \begin{function}[updated = 2017-04-05]
 %   {\vbox_set_top:Nn, \vbox_set_top:cn, \vbox_gset_top:Nn, \vbox_gset_top:cn}
 %   \begin{syntax}
 %     \cs{vbox_set_top:Nn} \meta{box} \Arg{contents}
@@ -511,7 +511,7 @@
 %   to that of the \emph{first} item added to the box.
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]
+% \begin{function}[updated = 2017-04-05]
 %   {
 %     \vbox_set_to_ht:Nnn,  \vbox_set_to_ht:cnn,
 %     \vbox_gset_to_ht:Nnn, \vbox_gset_to_ht:cnn
@@ -523,7 +523,7 @@
 %   \meta{dimexpr} and then stores the result inside the \meta{box}.
 % \end{function}
 %
-% \begin{function}[updated = 2011-12-18]
+% \begin{function}[updated = 2017-04-058]
 %  {
 %    \vbox_set:Nw, \vbox_set:cw,
 %    \vbox_set_end:,
@@ -976,7 +976,8 @@
 % \testfile{m3box002.lvt}
 %   Put a horizontal box directly into the input stream.
 %    \begin{macrocode}
-\cs_new_protected:Npn \hbox:n #1 { \tex_hbox:D \scan_stop: {#1} }
+\cs_new_protected:Npn \hbox:n #1
+  { \tex_hbox:D \scan_stop: { \group_begin: #1 \group_end: } }
 %    \end{macrocode}
 %  \end{macro}
 %
@@ -985,7 +986,7 @@
 % \testfile*
 %    \begin{macrocode}
 \cs_new_protected:Npn \hbox_set:Nn #1#2
-  { \tex_setbox:D #1 \tex_hbox:D {#2} }
+  { \tex_setbox:D #1 \tex_hbox:D { \group_begin: #2 \group_end: } }
 \cs_new_protected:Npn \hbox_gset:Nn { \tex_global:D \hbox_set:Nn }
 \cs_generate_variant:Nn \hbox_set:Nn { c }
 \cs_generate_variant:Nn \hbox_gset:Nn { c }
@@ -999,7 +1000,10 @@
 %   Storing material in a horizontal box with a specified width.
 %    \begin{macrocode}
 \cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3
-  { \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end: {#3} }
+  {
+    \tex_setbox:D #1 \tex_hbox:D to \__dim_eval:w #2 \__dim_eval_end:
+      { \group_begin: #3 \group_end: }
+  }
 \cs_new_protected:Npn \hbox_gset_to_wd:Nnn
   { \tex_global:D \hbox_set_to_wd:Nnn }
 \cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c }
@@ -1016,13 +1020,21 @@
 %    environment definitions.
 %    \begin{macrocode}
 \cs_new_protected:Npn \hbox_set:Nw  #1
-  { \tex_setbox:D #1 \tex_hbox:D \c_group_begin_token }
+  {
+    \tex_setbox:D #1 \tex_hbox:D
+      \c_group_begin_token
+        \group_begin:
+  }
 \cs_new_protected:Npn \hbox_gset:Nw
   { \tex_global:D \hbox_set:Nw }
 \cs_generate_variant:Nn \hbox_set:Nw  { c }
 \cs_generate_variant:Nn \hbox_gset:Nw { c }
-\cs_new_eq:NN \hbox_set_end:  \c_group_end_token
-\cs_new_eq:NN \hbox_gset_end: \c_group_end_token
+\cs_new_protected:Npn \hbox_set_end:
+  {
+      \group_end:
+    \c_group_end_token
+  }
+\cs_new_eq:NN \hbox_gset_end: \hbox_set_end:
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1034,8 +1046,12 @@
 %   Put a horizontal box directly into the input stream.
 %    \begin{macrocode}
 \cs_new_protected:Npn \hbox_to_wd:nn #1#2
-   { \tex_hbox:D to \__dim_eval:w #1 \__dim_eval_end: {#2} }
-\cs_new_protected:Npn \hbox_to_zero:n #1 { \tex_hbox:D to \c_zero_dim {#1} }
+   {
+     \tex_hbox:D to \__dim_eval:w #1 \__dim_eval_end:
+       { \group_begin: #2 \group_end: }
+   }
+\cs_new_protected:Npn \hbox_to_zero:n #1
+  { \tex_hbox:D to \c_zero_dim { \group_begin: #1 \group_end: } }
 %    \end{macrocode}
 %  \end{macro}
 %  \end{macro}
@@ -1076,8 +1092,10 @@
 % \TestFiles{m3box003.lvt}
 %   Put a vertical box directly into the input stream.
 %    \begin{macrocode}
-\cs_new_protected:Npn \vbox:n #1     { \tex_vbox:D { #1 \par } }
-\cs_new_protected:Npn \vbox_top:n #1 { \tex_vtop:D { #1 \par } }
+\cs_new_protected:Npn \vbox:n #1
+  { \tex_vbox:D { \group_begin: #1 \par \group_end: } }
+\cs_new_protected:Npn \vbox_top:n #1
+  { \tex_vtop:D { \group_begin: #1 \par \group_end: } }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1088,9 +1106,15 @@
 %   Put a vertical box directly into the input stream.
 %    \begin{macrocode}
 \cs_new_protected:Npn \vbox_to_ht:nn #1#2
-  { \tex_vbox:D to \__dim_eval:w #1 \__dim_eval_end: { #2 \par } }
+  {
+    \tex_vbox:D to \__dim_eval:w #1 \__dim_eval_end:
+      { \group_begin: #2 \par \group_end: }
+  }
 \cs_new_protected:Npn \vbox_to_zero:n #1
-  { \tex_vbox:D to \c_zero_dim { #1 \par } }
+  {
+    \tex_vbox:D to \c_zero_dim
+      { \group_begin: #1 \par \group_end: }
+  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -1101,7 +1125,10 @@
 %   Storing material in a vertical box with a natural height.
 %    \begin{macrocode}
 \cs_new_protected:Npn \vbox_set:Nn #1#2
-  { \tex_setbox:D #1 \tex_vbox:D { #2 \par } }
+  {
+    \tex_setbox:D #1 \tex_vbox:D
+      { \group_begin: #2 \par \group_end: }
+  }
 \cs_new_protected:Npn \vbox_gset:Nn  { \tex_global:D \vbox_set:Nn }
 \cs_generate_variant:Nn \vbox_set:Nn  { c }
 \cs_generate_variant:Nn \vbox_gset:Nn { c }
@@ -1116,7 +1143,10 @@
 %   point at the baseline of the first object in the box.
 %    \begin{macrocode}
 \cs_new_protected:Npn \vbox_set_top:Nn #1#2
-  { \tex_setbox:D #1 \tex_vtop:D { #2 \par } }
+  {
+    \tex_setbox:D #1 \tex_vtop:D
+      { \group_begin: #2 \par \group_end: }
+  }
 \cs_new_protected:Npn \vbox_gset_top:Nn
   { \tex_global:D \vbox_set_top:Nn }
 \cs_generate_variant:Nn \vbox_set_top:Nn { c }
@@ -1133,7 +1163,7 @@
 \cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3
   {
     \tex_setbox:D #1 \tex_vbox:D to \__dim_eval:w #2 \__dim_eval_end:
-      { #3 \par }
+      { \group_begin: #3 \par \group_end: }
   }
 \cs_new_protected:Npn \vbox_gset_to_ht:Nnn
   { \tex_global:D \vbox_set_to_ht:Nnn }
@@ -1151,14 +1181,19 @@
 %   environment definitions.
 %    \begin{macrocode}
 \cs_new_protected:Npn \vbox_set:Nw #1
-  { \tex_setbox:D #1 \tex_vbox:D \c_group_begin_token }
+  {
+    \tex_setbox:D #1 \tex_vbox:D
+      \c_group_begin_token
+        \group_begin:
+  }
 \cs_new_protected:Npn \vbox_gset:Nw
   { \tex_global:D \vbox_set:Nw }
 \cs_generate_variant:Nn \vbox_set:Nw  { c }
 \cs_generate_variant:Nn \vbox_gset:Nw { c }
 \cs_new_protected:Npn \vbox_set_end:
   {
-    \par
+        \par
+      \group_end:
     \c_group_end_token
   }
 \cs_new_eq:NN \vbox_gset_end: \vbox_set_end:
diff --git a/l3kernel/l3coffins.dtx b/l3kernel/l3coffins.dtx
index 0a7f4a3..88d32dc 100644
--- a/l3kernel/l3coffins.dtx
+++ b/l3kernel/l3coffins.dtx
@@ -535,10 +535,8 @@
       {
         \hbox_set:Nn #1
           {
-            \color_group_begin:
-              \color_ensure_current:
-              #2
-            \color_group_end:
+            \color_ensure_current:
+            #2
           }
         \@@_reset_structure:N #1
         \@@_update_poles:N #1
@@ -603,10 +601,9 @@
   {
     \@@_if_exist:NT #1
       {
-        \hbox_set:Nw #1 \color_group_begin: \color_ensure_current:
+        \hbox_set:Nw #1 \color_ensure_current:
           \cs_set_protected:Npn \hcoffin_set_end:
             {
-                \color_group_end:
               \hbox_set_end:
               \@@_reset_structure:N #1
               \@@_update_poles:N #1

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list