[latex3-commits] [git/LaTeX3-latex3-latex3] main: Export colors in comma-sep format (closes #863) (13d52622e)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Mar 22 15:04:01 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/13d52622e5fb2dc22b3c8498b634e10bbb66fb75

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

commit 13d52622e5fb2dc22b3c8498b634e10bbb66fb75
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Mar 19 12:23:19 2021 +0000

    Export colors in comma-sep format (closes #863)


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

13d52622e5fb2dc22b3c8498b634e10bbb66fb75
 l3kernel/CHANGELOG.md                    |  1 +
 l3kernel/l3color.dtx                     | 30 ++++++++++++++++++++++++++++--
 l3kernel/testfiles/m3color003.luatex.tlg | 12 ++++++++++++
 l3kernel/testfiles/m3color003.lvt        |  9 ++++++++-
 l3kernel/testfiles/m3color003.ptex.tlg   | 12 ++++++++++++
 l3kernel/testfiles/m3color003.tlg        | 12 ++++++++++++
 l3kernel/testfiles/m3color003.uptex.tlg  | 12 ++++++++++++
 l3kernel/testfiles/m3color003.xetex.tlg  | 12 ++++++++++++
 8 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 28165bbce..4ab203fb7 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Added
 - `\tracingstacklevels`
+- Color export in comma-separated format
 
 ### Fixed
 - Evalutate integer constants only once (issue#861)
diff --git a/l3kernel/l3color.dtx b/l3kernel/l3color.dtx
index c28b7e2e6..52fac6138 100644
--- a/l3kernel/l3color.dtx
+++ b/l3kernel/l3color.dtx
@@ -342,6 +342,10 @@
 %      model, the second containing space-separated values appropriate
 %      for the model; this is the format required by backend functions
 %      of \pkg{expl3}
+%    \item \texttt{comma-sep-cmyk} Comma-separated cyan-magenta-yellow-black
+%      values
+%    \item \texttt{comma-sep-rgb} Comma-separated red-green-blue values
+%      suitable for use as a PDF annotation color
 %    \item \texttt{HTML} Uppercase two-digit hexadecimal values, expressing
 %      a red-green-blue color; the digits are \emph{not} separated
 %    \item \texttt{space-sep-cmyk} Space-separated cyan-magenta-yellow-black
@@ -1554,25 +1558,38 @@
 %
 % \begin{variable}
 %   {
+%     \c_@@_export_comma-sep-cmyk_tl ,
+%     \c_@@_export_comma-sep-rgb_tl  ,
 %     \c_@@_export_HTML_tl           ,
 %     \c_@@_export_space-sep-cmyk_tl ,
 %     \c_@@_export_space-sep-rgb_tl
 %   }
 %    \begin{macrocode}
+\tl_const:cn { c_@@_export_comma-sep-cmyk_tl } { cmyk }
+\tl_const:cn { c_@@_export_comma-sep-rgb_tl } { rgb }
 \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{macro}
+%   {\@@_export_format_comma-sep-cmyk:nnN, \@@_export_format_space-sep-cmyk:nnN}
+% \begin{macro}{\@@_export_space-sep-cmyk:Nw, \@@_export_comma-sep-cmyk:Nw}
 %    \begin{macrocode}
+\cs_new_protected:cpx { @@_export_format_comma-sep-cmyk:nnN } #1#2#3
+  {
+    \exp_not:N \@@_export:nnnNN { cmyk } {#1} {#2} #3
+      \exp_not:c { @@_export_comma-sep-cmyk:Nw }
+  }
 \cs_new_protected:cpx { @@_export_format_space-sep-cmyk:nnN } #1#2#3
   {
     \exp_not:N \@@_export:nnnNN { cmyk } {#1} {#2} #3
       \exp_not:c { @@_export_space-sep-cmyk:Nw }
   }
+\cs_new_protected:cpn { @@_export_comma-sep-cmyk:Nw }
+  #1#2 ~ #3 ~ #4 ~ #5 \s_@@_stop
+  { \tl_set:Nn #1 { #2 , #3 , #4 , #5 } }
 \cs_new_protected:cpn { @@_export_space-sep-cmyk:Nw } #1#2 \s_@@_stop
   { \tl_set:Nn #1 {#2} }
 %    \end{macrocode}
@@ -1581,11 +1598,13 @@
 %
 % \begin{macro}
 %   {
+%     \@@_export_format_comma-sep-rgb:nnN ,
 %     \@@_export_format_HTML:nnN          ,
 %     \@@_export_format_space-sep-rgb:nnN
 %   }
 % \begin{macro}
 %   {
+%     \@@_export_comma-sep-rgb:Nw ,
 %     \@@_export_HTML:Nw          ,
 %     \@@_export_space-sep-rgb:Nw
 %   }
@@ -1593,6 +1612,11 @@
 %   \textsc{html} values must be given in |rgb|: we force conversion if
 %   required, then do some simple maths.
 %    \begin{macrocode}
+\cs_new_protected:cpx { @@_export_format_comma-sep-rgb:nnN } #1#2#3
+  {
+    \exp_not:N \@@_export:nnnNN { rgb } {#1} {#2} #3
+      \exp_not:c { @@_export_comma-sep-rgb:Nw }
+  }
 \cs_new_protected:Npn \@@_export_format_HTML:nnN #1#2#3
   { \@@_export:nnnNN { rgb } {#1} {#2}#3 \@@_export_HTML:Nw }
 \cs_new_protected:cpx { @@_export_format_space-sep-rgb:nnN } #1#2#3
@@ -1600,6 +1624,8 @@
     \exp_not:N \@@_export:nnnNN { rgb } {#1} {#2} #3
       \exp_not:c { @@_export_space-sep-rgb:Nw }
   }
+\cs_new_protected:cpn { @@_export_comma-sep-rgb:Nw } #1#2 ~ #3 ~ #4 \s_@@_stop
+  { \tl_set:Nx #1 { #2 , #3 , #4 } }
 \cs_new_protected:Npn \@@_export_HTML:Nw #1#2 ~ #3 ~ #4 \s_@@_stop
   {
     \tl_set:Nx #1
diff --git a/l3kernel/testfiles/m3color003.luatex.tlg b/l3kernel/testfiles/m3color003.luatex.tlg
index dc11d4caa..005f2ddb4 100644
--- a/l3kernel/testfiles/m3color003.luatex.tlg
+++ b/l3kernel/testfiles/m3color003.luatex.tlg
@@ -139,6 +139,18 @@ l. ...  }
 > \l_tmpa_tl={cmyk}{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=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. ...  }
 > \l_tmpa_tl=4C4C4C.
 <recently read> }
 l. ...  }
diff --git a/l3kernel/testfiles/m3color003.lvt b/l3kernel/testfiles/m3color003.lvt
index e21d322a1..4380d4b63 100644
--- a/l3kernel/testfiles/m3color003.lvt
+++ b/l3kernel/testfiles/m3color003.lvt
@@ -111,7 +111,14 @@
       { 1 , 0 , 0 , 0 / 0.3 , 0.3 , 0.3 }
     \TIMO
     \clist_map_inline:nn
-      { backend , HTML , space-sep-cmyk , space-sep-rgb }
+      {
+        backend ,
+        comma-sep-cmyk ,
+        comma-sep-rgb  ,
+        HTML           ,
+        space-sep-cmyk ,
+        space-sep-rgb
+      }
       {
         \color_export:nnN { myA } {#1} \l_tmpa_tl
         \tl_show:N \l_tmpa_tl
diff --git a/l3kernel/testfiles/m3color003.ptex.tlg b/l3kernel/testfiles/m3color003.ptex.tlg
index 34e10a549..2a5b13b25 100644
--- a/l3kernel/testfiles/m3color003.ptex.tlg
+++ b/l3kernel/testfiles/m3color003.ptex.tlg
@@ -144,6 +144,18 @@ l. ...  }
 > \l_tmpa_tl={cmyk}{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=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. ...  }
 > \l_tmpa_tl=4C4C4C.
 <recently read> }
 l. ...  }
diff --git a/l3kernel/testfiles/m3color003.tlg b/l3kernel/testfiles/m3color003.tlg
index e04b15c35..83eee33c4 100644
--- a/l3kernel/testfiles/m3color003.tlg
+++ b/l3kernel/testfiles/m3color003.tlg
@@ -139,6 +139,18 @@ l. ...  }
 > \l_tmpa_tl={cmyk}{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=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. ...  }
 > \l_tmpa_tl=4C4C4C.
 <recently read> }
 l. ...  }
diff --git a/l3kernel/testfiles/m3color003.uptex.tlg b/l3kernel/testfiles/m3color003.uptex.tlg
index 34e10a549..2a5b13b25 100644
--- a/l3kernel/testfiles/m3color003.uptex.tlg
+++ b/l3kernel/testfiles/m3color003.uptex.tlg
@@ -144,6 +144,18 @@ l. ...  }
 > \l_tmpa_tl={cmyk}{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=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. ...  }
 > \l_tmpa_tl=4C4C4C.
 <recently read> }
 l. ...  }
diff --git a/l3kernel/testfiles/m3color003.xetex.tlg b/l3kernel/testfiles/m3color003.xetex.tlg
index 0febffaed..433d8c058 100644
--- a/l3kernel/testfiles/m3color003.xetex.tlg
+++ b/l3kernel/testfiles/m3color003.xetex.tlg
@@ -139,6 +139,18 @@ l. ...  }
 > \l_tmpa_tl={cmyk}{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=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. ...  }
 > \l_tmpa_tl=4C4C4C.
 <recently read> }
 l. ...  }





More information about the latex3-commits mailing list.