summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3color.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3color.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3color.dtx65
1 files changed, 50 insertions, 15 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3color.dtx b/Master/texmf-dist/source/latex/l3kernel/l3color.dtx
index 218f560acbd..017cad63c5c 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3color.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3color.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2023-02-22}
+% \date{Released 2023-03-30}
%
% \maketitle
%
@@ -155,13 +155,13 @@
% In addition to allowing specification of color by model and values,
% \pkg{l3color} also supports color expressions. These are created
% by combining one or more color names, with the amount of each specified
-% as a percentage. The latter is given between |!| symbols in the expression.
-% Thus for example
+% as a value in the range $0$--$100$. The value should be given between
+% |!| symbols in the expression. Thus for example
% \begin{verbatim}
% red!50!green
% \end{verbatim}
-% is a mixture of $50\,\%$ red and $50\,\%$ green. A trailing percentage is
-% interpreted as implicitly followed by |white|, and so
+% is a mixture of $50\,\%$ red and $50\,\%$ green. A trailing value is
+% interpreted as implicitly followed by |!white|, and so
% \begin{verbatim}
% red!25
% \end{verbatim}
@@ -643,6 +643,14 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}{\l_@@_ignore_error_bool}
+% Used to avoid issuing multiple errors if there is a change-of-model with
+% input container an error.
+% \begin{macrocode}
+\bool_new:N \l_@@_ignore_error_bool
+% \end{macrocode}
+% \end{variable}
+%
% \subsection{Utility functions}
%
% \begin{macro}[pTF, EXP]{\color_if_exist:n}
@@ -825,6 +833,7 @@
% \begin{macro}{\@@_parse:Nw}
% \begin{macro}{\@@_parse_loop_init:Nnn}
% \begin{macro}{\@@_parse_loop:w}
+% \begin{macro}{\@@_parse_loop_check:nn}
% \begin{macro}{\@@_parse_loop:nn}
% \begin{macro}{\@@_parse_gray:n, \@@_parse_std:n}
% \begin{macro}{\@@_parse_break:w}
@@ -936,17 +945,11 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_parse_loop:w #1 ! #2 ! #3 ! #4 ! #5 \s_@@_stop
{
- \bool_lazy_or:nnF
- { \tl_if_blank_p:n {#1} }
- { \int_compare_p:nNn {#1} = { 100 } }
+ \tl_if_blank:nF {#1}
{
- \int_compare:nNnTF {#1} = { 0 }
- {
- \tl_if_blank:nTF {#2}
- { \@@_extract:nNN { white } }
- { \@@_extract:nNN {#2} }
- \l_@@_model_tl \l_@@_value_tl
- }
+ \bool_lazy_and:nnTF
+ { \fp_compare_p:nNn {#1} > { 0 } }
+ { \fp_compare_p:nNn {#1} < { 100 } }
{
\use:x
{
@@ -954,12 +957,35 @@
{ \tl_if_blank:nTF {#2} { white } {#2} }
}
}
+ { \@@_parse_loop_check:nn {#1} {#2} }
}
\tl_if_blank:nF {#3}
{ \@@_parse_loop:w #3 ! #4 ! #5 \s_@@_stop }
\@@_parse_end:
}
% \end{macrocode}
+% As these are unusual cases, we accept slower performance here for clearer
+% code: check for the error conditions, handle the boundary cases after
+% that.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_parse_loop_check:nn #1#2
+ {
+ \bool_if:NF \l_@@_ignore_error_bool
+ {
+ \bool_lazy_or:nnT
+ { \fp_compare_p:nNn {#1} < { 0 } }
+ { \fp_compare_p:nNn {#1} > { 100 } }
+ { \msg_error:nnnnn { color } { out-of-range } {#1} { 0 } { 100 } }
+ }
+ \fp_compare:nNnF {#1} > \c_zero_fp
+ {
+ \tl_if_blank:nTF {#2}
+ { \@@_extract:nNN { white } }
+ { \@@_extract:nNN {#2} }
+ \l_@@_model_tl \l_@@_value_tl
+ }
+ }
+% \end{macrocode}
% The \enquote{payload} of calculation in the loop first. If the model for
% the upcoming color is different from that of the existing (partial) color,
% convert the model. For |gray| the two are flipped round so that the outcome
@@ -1065,6 +1091,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}[EXP]
% {
@@ -1779,6 +1806,7 @@
\prop_if_in:cnF { l_@@_named_ #1 _prop } {##1}
{
\group_begin:
+ \bool_set_true:N \l_@@_ignore_error_bool
\tl_set:cn { l_@@_named_ #3 _tl } {##1}
\@@_parse:nN {#2} \l_@@_internal_tl
\exp_args:NNNV \group_end:
@@ -3116,6 +3144,13 @@
LaTeX~was~asked~to~define~a~new~color~model~called~'#1',~but~
this~color~model~already~exists.
}
+\msg_new:nnnn { color } { out-of-range }
+ { Input~value~#1~out~of~range~[#2,~#3]. }
+ {
+ LaTeX~was~expecting~a~value~in~the~range~[#2,~#3]~as~part~of~a~color,~
+ but~you~gave~#1.~LaTeX~will~assume~you~meant~the~limit~of~the~range~
+ and~continue.
+ }
\msg_new:nnnn { color } { separation-alternative-model }
{ Separation~color~space~'#1'~require~an~alternative~model. }
{