[latex3-commits] [git/LaTeX3-latex3-latex3] master: Handle xcolor "model1:model2" input (a569e3a1f)
Joseph Wright
joseph.wright at morningstar2.co.uk
Mon Aug 10 14:12:54 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/a569e3a1fbd5e1748dd731ca194100cf2725534f
>---------------------------------------------------------------
commit a569e3a1fbd5e1748dd731ca194100cf2725534f
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Mon Aug 10 13:10:58 2020 +0100
Handle xcolor "model1:model2" input
This is done by dropping "model1" entirely, so it
does not have quite the same effect as in xcolor.
>---------------------------------------------------------------
a569e3a1fbd5e1748dd731ca194100cf2725534f
l3experimental/l3color/l3color.dtx | 25 ++++++++++++++++---
l3experimental/l3color/testfiles/m3color003.lvt | 9 +++++--
.../l3color/testfiles/m3color003.ptex.tlg | 29 +++++++++++++++-------
l3experimental/l3color/testfiles/m3color003.tlg | 29 +++++++++++++++-------
.../l3color/testfiles/m3color003.uptex.tlg | 29 +++++++++++++++-------
.../l3color/testfiles/m3color003.xetex.tlg | 29 +++++++++++++++-------
6 files changed, 109 insertions(+), 41 deletions(-)
diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 80fd54d41..9004dd38a 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -92,6 +92,10 @@
% \end{itemize}
% All interface models are internally stored as |rgb|.
%
+% To allow parsing of data from \pkg{xcolor}, any leading model up the first
+% \texttt{:} will be discarded; the approach of selecting an internal form
+% for data is \emph{not} used in \pkg{l3color}.
+%
% Additional models may be created to allow mixing of separation colors
% with each other or with those from other models. See
% Section~\ref{l3color:sec:new-models} for more detail of color support
@@ -1119,6 +1123,7 @@
% \begin{macro}{\@@_set:nn}
% \begin{macro}{\@@_set:nnw}
% \begin{macro}{\color_set:nnn}
+% \begin{macro}{\@@_set_colon:nnw}
% \begin{macro}{\@@_set_loop:nw}
% \begin{macro}{\color_set_eq:nn}
% Defining named colors means working through the model list and saving
@@ -1181,15 +1186,28 @@
}
}
}
-\cs_new_protected:Npn \color_set:nnn #1#2#3
+\cs_new_protected:Npx \color_set:nnn #1#2#3
{
- \str_if_eq:nnF {#1} { . }
+ \exp_not:N \str_if_eq:nnF {#1} { . }
{
\tl_clear_new:c { l_@@_named_ #1 _tl }
\prop_clear_new:c { l_@@_named_ #1 _prop }
- \@@_set_loop:nw {#1} #2 / / \s_@@_mark #3 / / \s_@@_stop
+ \exp_not:N \@@_set_colon:nnw {#1} {#3}
+ #2 \c_colon_str \c_colon_str \exp_not:N \s_@@_stop
}
}
+\use:x
+ {
+ \cs_new_protected:Npn \exp_not:N \@@_set_colon:nnw
+ ##1##2 ##3 \c_colon_str ##4 \c_colon_str
+ ##5 \exp_not:N \s_@@_stop
+ }
+ {
+ \tl_if_blank:nTF {#4}
+ { \@@_set_loop:nw {#1} #3 }
+ { \@@_set_loop:nw {#1} #4 }
+ / / \s_@@_mark #2 / / \s_@@_stop
+ }
\cs_new_protected:Npn \@@_set_loop:nw
#1#2 / #3 \s_@@_mark #4 / #5 \s_@@_stop
{
@@ -1234,6 +1252,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% A small set of colors are always defined.
% \begin{macrocode}
diff --git a/l3experimental/l3color/testfiles/m3color003.lvt b/l3experimental/l3color/testfiles/m3color003.lvt
index f9222b84d..8fd8da6e8 100644
--- a/l3experimental/l3color/testfiles/m3color003.lvt
+++ b/l3experimental/l3color/testfiles/m3color003.lvt
@@ -72,6 +72,13 @@
\color_show:n { test }
}
+\TEST { Multiple~models:~xcolor~data }
+ {
+ \exp_args:Nnx \color_set:nnn { foo2 } { hsb \c_colon_str rgb }
+ { 0.1 , 0.1 , 0.2 }
+ \color_show:n { foo2 }
+ }
+
\TEST { Mixing~multiple~models }
{
\OMIT
@@ -114,7 +121,6 @@
}
}
-
\TEST { Showing~multiple~models }
{
\color_set:nnn { foo1 } { cmyk / rgb }
@@ -140,7 +146,6 @@
\color_show:n { mixA }
}
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\TEST { Creating~new~models }
diff --git a/l3experimental/l3color/testfiles/m3color003.ptex.tlg b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
index 45a89adc8..84829e517 100644
--- a/l3experimental/l3color/testfiles/m3color003.ptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.ptex.tlg
@@ -94,7 +94,18 @@ The color test has the properties:
l. ... }
============================================================
============================================================
-TEST 3: Mixing multiple models
+TEST 3: Multiple models: xcolor data
+============================================================
+Defining \l__color_named_foo2_tl on line ...
+Defining \l__color_named_foo2_prop on line ...
+The color foo2 has the properties:
+> model => rgb
+> rgb => 0.1 0.1 0.2.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: Mixing multiple models
============================================================
Defining \l__color_named_myexpr1_tl on line ...
Defining \l__color_named_myexpr1_prop on line ...
@@ -130,7 +141,7 @@ The color myD has the properties:
l. ... }
============================================================
============================================================
-TEST 4: Exporting multiple models
+TEST 5: Exporting multiple models
============================================================
> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
<recently read> }
@@ -158,7 +169,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 5: Showing multiple models
+TEST 6: Showing multiple models
============================================================
The color foo1 has the properties:
> model => cmyk
@@ -168,7 +179,7 @@ The color foo1 has the properties:
l. ... }
============================================================
============================================================
-TEST 6: Multiple models with model fixed
+TEST 7: Multiple models with model fixed
============================================================
Defining \l__color_named_mixA_tl on line ...
Defining \l__color_named_mixA_prop on line ...
@@ -192,7 +203,7 @@ The color mixA has the properties:
l. ... }
============================================================
============================================================
-TEST 7: Creating new models
+TEST 8: Creating new models
============================================================
Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
@@ -261,7 +272,7 @@ The color BarToneCIELAB is undefined.
l. ... }
============================================================
============================================================
-TEST 8: Creating new models: errors
+TEST 9: Creating new models: errors
============================================================
! LaTeX3 Error: Color model 'BarToneCMYK' already defined.
For immediate help type H <return>.
@@ -330,7 +341,7 @@ LaTeX has been asked to create a separation color space, but no
key was given with the correct information.
============================================================
============================================================
-TEST 9: Converting new models
+TEST 10: Converting new models
============================================================
> \l_tmpa_tl=BFB2A6.
<recently read> }
@@ -343,7 +354,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 10: Mixing separations
+TEST 11: Mixing separations
============================================================
Defining \l__color_named_foo_tl on line ...
Defining \l__color_named_foo_prop on line ...
@@ -369,7 +380,7 @@ The color foo has the properties:
l. ... }
============================================================
============================================================
-TEST 11: Mixing separation: failures
+TEST 12: Mixing separation: failures
============================================================
The color foo has the properties:
> model => BarToneCMYK
diff --git a/l3experimental/l3color/testfiles/m3color003.tlg b/l3experimental/l3color/testfiles/m3color003.tlg
index b0bc6a7cd..68e45ff75 100644
--- a/l3experimental/l3color/testfiles/m3color003.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.tlg
@@ -84,7 +84,18 @@ The color test has the properties:
l. ... }
============================================================
============================================================
-TEST 3: Mixing multiple models
+TEST 3: Multiple models: xcolor data
+============================================================
+Defining \l__color_named_foo2_tl on line ...
+Defining \l__color_named_foo2_prop on line ...
+The color foo2 has the properties:
+> model => rgb
+> rgb => 0.1 0.1 0.2.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: Mixing multiple models
============================================================
Defining \l__color_named_myexpr1_tl on line ...
Defining \l__color_named_myexpr1_prop on line ...
@@ -120,7 +131,7 @@ The color myD has the properties:
l. ... }
============================================================
============================================================
-TEST 4: Exporting multiple models
+TEST 5: Exporting multiple models
============================================================
> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
<recently read> }
@@ -148,7 +159,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 5: Showing multiple models
+TEST 6: Showing multiple models
============================================================
The color foo1 has the properties:
> model => cmyk
@@ -158,7 +169,7 @@ The color foo1 has the properties:
l. ... }
============================================================
============================================================
-TEST 6: Multiple models with model fixed
+TEST 7: Multiple models with model fixed
============================================================
Defining \l__color_named_mixA_tl on line ...
Defining \l__color_named_mixA_prop on line ...
@@ -182,7 +193,7 @@ The color mixA has the properties:
l. ... }
============================================================
============================================================
-TEST 7: Creating new models
+TEST 8: Creating new models
============================================================
Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
@@ -251,7 +262,7 @@ The color BarToneCIELAB is undefined.
l. ... }
============================================================
============================================================
-TEST 8: Creating new models: errors
+TEST 9: Creating new models: errors
============================================================
! LaTeX3 Error: Color model 'BarToneCMYK' already defined.
For immediate help type H <return>.
@@ -320,7 +331,7 @@ LaTeX has been asked to create a separation color space, but no
key was given with the correct information.
============================================================
============================================================
-TEST 9: Converting new models
+TEST 10: Converting new models
============================================================
> \l_tmpa_tl=BFB2A6.
<recently read> }
@@ -333,7 +344,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 10: Mixing separations
+TEST 11: Mixing separations
============================================================
Defining \l__color_named_foo_tl on line ...
Defining \l__color_named_foo_prop on line ...
@@ -359,7 +370,7 @@ The color foo has the properties:
l. ... }
============================================================
============================================================
-TEST 11: Mixing separation: failures
+TEST 12: Mixing separation: failures
============================================================
The color foo has the properties:
> model => BarToneCMYK
diff --git a/l3experimental/l3color/testfiles/m3color003.uptex.tlg b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
index 45a89adc8..84829e517 100644
--- a/l3experimental/l3color/testfiles/m3color003.uptex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.uptex.tlg
@@ -94,7 +94,18 @@ The color test has the properties:
l. ... }
============================================================
============================================================
-TEST 3: Mixing multiple models
+TEST 3: Multiple models: xcolor data
+============================================================
+Defining \l__color_named_foo2_tl on line ...
+Defining \l__color_named_foo2_prop on line ...
+The color foo2 has the properties:
+> model => rgb
+> rgb => 0.1 0.1 0.2.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: Mixing multiple models
============================================================
Defining \l__color_named_myexpr1_tl on line ...
Defining \l__color_named_myexpr1_prop on line ...
@@ -130,7 +141,7 @@ The color myD has the properties:
l. ... }
============================================================
============================================================
-TEST 4: Exporting multiple models
+TEST 5: Exporting multiple models
============================================================
> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
<recently read> }
@@ -158,7 +169,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 5: Showing multiple models
+TEST 6: Showing multiple models
============================================================
The color foo1 has the properties:
> model => cmyk
@@ -168,7 +179,7 @@ The color foo1 has the properties:
l. ... }
============================================================
============================================================
-TEST 6: Multiple models with model fixed
+TEST 7: Multiple models with model fixed
============================================================
Defining \l__color_named_mixA_tl on line ...
Defining \l__color_named_mixA_prop on line ...
@@ -192,7 +203,7 @@ The color mixA has the properties:
l. ... }
============================================================
============================================================
-TEST 7: Creating new models
+TEST 8: Creating new models
============================================================
Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
@@ -261,7 +272,7 @@ The color BarToneCIELAB is undefined.
l. ... }
============================================================
============================================================
-TEST 8: Creating new models: errors
+TEST 9: Creating new models: errors
============================================================
! LaTeX3 Error: Color model 'BarToneCMYK' already defined.
For immediate help type H <return>.
@@ -330,7 +341,7 @@ LaTeX has been asked to create a separation color space, but no
key was given with the correct information.
============================================================
============================================================
-TEST 9: Converting new models
+TEST 10: Converting new models
============================================================
> \l_tmpa_tl=BFB2A6.
<recently read> }
@@ -343,7 +354,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 10: Mixing separations
+TEST 11: Mixing separations
============================================================
Defining \l__color_named_foo_tl on line ...
Defining \l__color_named_foo_prop on line ...
@@ -369,7 +380,7 @@ The color foo has the properties:
l. ... }
============================================================
============================================================
-TEST 11: Mixing separation: failures
+TEST 12: Mixing separation: failures
============================================================
The color foo has the properties:
> model => BarToneCMYK
diff --git a/l3experimental/l3color/testfiles/m3color003.xetex.tlg b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
index e83cdfa8a..3c997c497 100644
--- a/l3experimental/l3color/testfiles/m3color003.xetex.tlg
+++ b/l3experimental/l3color/testfiles/m3color003.xetex.tlg
@@ -84,7 +84,18 @@ The color test has the properties:
l. ... }
============================================================
============================================================
-TEST 3: Mixing multiple models
+TEST 3: Multiple models: xcolor data
+============================================================
+Defining \l__color_named_foo2_tl on line ...
+Defining \l__color_named_foo2_prop on line ...
+The color foo2 has the properties:
+> model => rgb
+> rgb => 0.1 0.1 0.2.
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 4: Mixing multiple models
============================================================
Defining \l__color_named_myexpr1_tl on line ...
Defining \l__color_named_myexpr1_prop on line ...
@@ -120,7 +131,7 @@ The color myD has the properties:
l. ... }
============================================================
============================================================
-TEST 4: Exporting multiple models
+TEST 5: Exporting multiple models
============================================================
> \l_tmpa_tl={rgb}{0.3 0.3 0.3}.
<recently read> }
@@ -148,7 +159,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 5: Showing multiple models
+TEST 6: Showing multiple models
============================================================
The color foo1 has the properties:
> model => cmyk
@@ -158,7 +169,7 @@ The color foo1 has the properties:
l. ... }
============================================================
============================================================
-TEST 6: Multiple models with model fixed
+TEST 7: Multiple models with model fixed
============================================================
Defining \l__color_named_mixA_tl on line ...
Defining \l__color_named_mixA_prop on line ...
@@ -182,7 +193,7 @@ The color mixA has the properties:
l. ... }
============================================================
============================================================
-TEST 7: Creating new models
+TEST 8: Creating new models
============================================================
Defining \c__color_fallback_BarToneCMYK_tl on line ...
Defining \__color_parse_mix_BarToneCMYK:nw on line ...
@@ -251,7 +262,7 @@ The color BarToneCIELAB is undefined.
l. ... }
============================================================
============================================================
-TEST 8: Creating new models: errors
+TEST 9: Creating new models: errors
============================================================
! LaTeX3 Error: Color model 'BarToneCMYK' already defined.
For immediate help type H <return>.
@@ -320,7 +331,7 @@ LaTeX has been asked to create a separation color space, but no
key was given with the correct information.
============================================================
============================================================
-TEST 9: Converting new models
+TEST 10: Converting new models
============================================================
> \l_tmpa_tl=BFB2A6.
<recently read> }
@@ -333,7 +344,7 @@ l. ... }
l. ... }
============================================================
============================================================
-TEST 10: Mixing separations
+TEST 11: Mixing separations
============================================================
Defining \l__color_named_foo_tl on line ...
Defining \l__color_named_foo_prop on line ...
@@ -359,7 +370,7 @@ The color foo has the properties:
l. ... }
============================================================
============================================================
-TEST 11: Mixing separation: failures
+TEST 12: Mixing separation: failures
============================================================
The color foo has the properties:
> model => BarToneCMYK
More information about the latex3-commits
mailing list.