[latex3-commits] [git/LaTeX3-latex3-latex3] color-multi-model: Extend \color_export:nnN to cover multiple models (43520adfd)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Jun 24 12:02:45 CEST 2020


Repository : https://github.com/latex3/latex3
On branch  : color-multi-model
Link       : https://github.com/latex3/latex3/commit/43520adfd9401c59301f326d7f81ef22ff18f211

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

commit 43520adfd9401c59301f326d7f81ef22ff18f211
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Jun 24 10:30:58 2020 +0100

    Extend \color_export:nnN to cover multiple models


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

43520adfd9401c59301f326d7f81ef22ff18f211
 l3experimental/l3color/l3color.dtx                 | 56 ++++++++++++++++++----
 l3experimental/l3color/testfiles/m3color003.lvt    | 19 ++++++++
 .../l3color/testfiles/m3color003.ptex.tlg          | 30 +++++++++++-
 l3experimental/l3color/testfiles/m3color003.tlg    | 30 +++++++++++-
 .../l3color/testfiles/m3color003.uptex.tlg         | 30 +++++++++++-
 .../l3color/testfiles/m3color003.xetex.tlg         | 30 +++++++++++-
 6 files changed, 183 insertions(+), 12 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 2045a2712..c3a3275da 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -486,6 +486,7 @@
 % \begin{macro}{\@@_parse:nN}
 % \begin{macro}{\@@_parse_aux:nN}
 % \begin{macro}{\@@_parse_eq:Nn}
+% \begin{macro}{\@@_parse_eq:nNn}
 % \begin{macro}{\@@_parse:Nw}
 % \begin{macro}{\@@_parse_loop_init:Nnn}
 % \begin{macro}{\@@_parse_loop:w}
@@ -531,13 +532,33 @@
   }
 \cs_new_protected:Npn \@@_parse_set_eq:Nn #1#2
   {
-    \prop_get:cvN
-      { l_@@_named_ #2 _prop } { l_@@_named_ #2 _tl }
-      \l_@@_internal_tl
-    \tl_set:Nx #1
+    \tl_if_empty:NTF \l_color_fixed_model_tl
+       { \exp_args:Nv \@@_parse_set_eq:nNn { l_@@_named_ #2 _tl } }
+       { \exp_args:NV \@@_parse_set_eq:nNn \l_color_fixed_model_tl }
+         #1 {#2}
+  }
+%    \end{macrocode}
+%    Here, we have to allow for the case where there is a fixed model:
+%    that can't be swept up by generic conversion as we are dealing with a
+%    named color.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_parse_set_eq:nNn #1#2#3
+  {
+    \prop_get:cnNTF
+      { l_@@_named_ #3 _prop } {#1}
+      \l_@@_value_tl
+      { \tl_set:Nx #2 { {#1} { \l_@@_value_tl } } }
       {
-        { \tl_use:c { l_@@_named_ #2 _tl } }
-        { \l_@@_internal_tl }
+        \tl_set_eq:Nc \l_@@_model_tl { l_@@_named_ #3 _tl }
+        \prop_get:cVN { l_@@_named_ #3 _prop } \l_@@_model_tl
+          \l_@@_value_tl
+         \@@_convert:nnN
+           \l_@@_model_tl {#1} \l_@@_value_tl
+        \tl_set:Nx #2
+          {
+            {#1}
+            { \l_@@_value_tl }
+          }
       }
   }
 \cs_new_protected:Npn \@@_parse:Nw #1#2 ! #3 \s_@@_stop
@@ -704,6 +725,7 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}[EXP]
 %   {
@@ -1106,8 +1128,13 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \color_export:nnN #1#2#3
   {
-    \@@_parse:nN {#1} #3
-    \@@_export:nN {#2} #3
+    \group_begin:
+      \tl_if_exist:cT { c_@@_export_ #2 _tl }
+        { \tl_set_eq:Nc \l_color_fixed_model_tl { c_@@_export_ #2 _tl } }
+      \@@_parse:nN {#1} #3
+      \@@_export:nN {#2} #3
+    \exp_args:NNNV \group_end:
+    \tl_set:Nn #3 #3
   }
 \cs_new_protected:Npn \color_export:nnnN #1#2#3#4
   {
@@ -1156,6 +1183,19 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{variable}
+%   {
+%     \c_@@_export_HTML_tl           ,
+%     \c_@@_export_space-sep-cmyk_tl ,
+%     \c_@@_export_space-sep-rgb_tl
+%   }
+%    \begin{macrocode}
+\tl_const:Nn \c_@@_export_HTML_tl { rgb }
+\tl_const:cn { c_@@_export_space-sep-cmyk_tl } { cmyk }
+\tl_const:cn { c_@@_export_space-sep-rgb_tl } { rgb }
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}{\@@_export_format_space-sep-cmyk:nnN}
 % \begin{macro}{\@@_export_space-sep-cmyk:Nw}
 %    \begin{macrocode}
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index bf34f45a2..9c6273649 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -84,6 +84,25 @@
     \color_show:n { myexpr2 }
   }
 
+\TEST { Exporting~multiple~models }
+  {
+    \OMIT
+    \color_set:nnn { myA } { rgb / cmyk }
+      { 0.3 , 0.3 , 0.3 / 1 , 0 , 0 , 0 }
+    \color_set:nnn { myB } { cmyk / rgb }
+      { 1 , 0 , 0 , 0 / 0.3 , 0.3 , 0.3 }
+    \TIMO
+    \clist_map_inline:nn
+      { backend , HTML , space-sep-cmyk , space-sep-rgb }
+      {
+        \color_export:nnN { myA } {#1} \l_tmpa_tl
+        \tl_show:N \l_tmpa_tl
+        \color_export:nnN { myB } {#1} \l_tmpa_tl
+        \tl_show:N \l_tmpa_tl
+      }
+  }
+
+
 \TEST { Showing~multiple~models }
   {
     \color_set:nnn { foo1 } { cmyk / rgb }
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index da2dc6ebe..8ac01fe6c 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -113,7 +113,35 @@ The color myexpr2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: Showing multiple models
+TEST 4: Exporting multiple models
+============================================================
+> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={cmyk}{1.0 0.0 0.0 0.0}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 5: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index d18df2a3a..045f93432 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -108,7 +108,35 @@ The color myexpr2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: Showing multiple models
+TEST 4: Exporting multiple models
+============================================================
+> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={cmyk}{1.0 0.0 0.0 0.0}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 5: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index da2dc6ebe..8ac01fe6c 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -113,7 +113,35 @@ The color myexpr2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: Showing multiple models
+TEST 4: Exporting multiple models
+============================================================
+> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={cmyk}{1.0 0.0 0.0 0.0}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 5: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index 544b13758..47e130f05 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -108,7 +108,35 @@ The color myexpr2 has the properties:
 l. ...  }
 ============================================================
 ============================================================
-TEST 4: Showing multiple models
+TEST 4: Exporting multiple models
+============================================================
+> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl={cmyk}{1.0 0.0 0.0 0.0}.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=4C4C4C.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=1.0 0.0 0.0 0.0.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+> \l_tmpa_tl=0.3 0.3 0.3.
+<recently read> }
+l. ...  }
+============================================================
+============================================================
+TEST 5: Showing multiple models
 ============================================================
 The color foo1 has the properties:
 >  model  =>  cmyk





More information about the latex3-commits mailing list.