[latex3-commits] [git/LaTeX3-latex3-latex3] master: Ensure color values are well-formed (d2cb4da)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue May 14 23:12:41 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/d2cb4dad2b8250672575d1af294d12de2b3cc82b

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

commit d2cb4dad2b8250672575d1af294d12de2b3cc82b
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue May 14 13:31:01 2019 +0100

    Ensure color values are well-formed
    
    Leading zeros should be present.


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

d2cb4dad2b8250672575d1af294d12de2b3cc82b
 l3experimental/l3color/l3color.dtx |   39 +++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/l3experimental/l3color/l3color.dtx b/l3experimental/l3color/l3color.dtx
index 92ca583..32ba1a1 100644
--- a/l3experimental/l3color/l3color.dtx
+++ b/l3experimental/l3color/l3color.dtx
@@ -633,21 +633,42 @@
 % \end{macro}
 %
 % \begin{macro}[EXP]
-%   {\@@_parse_gray:w, \@@_parse_rgb:w, \@@_parse_cmyk:w, \@@_parse_spot:w}
+%   {
+%     \@@_parse_model_gray:w, \@@_parse_model_rgb:w,
+%     \@@_parse_model_cmyk:w, \@@_parse_model_spot:w
+%   }
+% \begin{macro}[EXP]{\@@_parse_number:n}
+% \begin{macro}[EXP]{\@@_parse_number:w}
 % \begin{macro}[EXP]{\@@_parse_spot_aux:w}
-%   Turn the input into internal form.
+%   Turn the input into internal form, also tidying up the number quickly.
 %    \begin{macrocode}
-\cs_new:Npn \@@_parse_gray:w #1 , #2 \q_stop {#1}
-\cs_new:Npn \@@_parse_rgb:w #1 , #2 , #3 , #4 \q_stop { #1 ~ #2 ~ #3 }
-\cs_new:Npn \@@_parse_cmyk:w #1 , #2 , #3 , #4 , #5 \q_stop
-  { #1 ~ #2 ~ #3 ~ #4 }
-\cs_new:Npn \@@_parse_spot:w #1 , #2 \q_stop
+\cs_new:Npn \@@_parse_model_gray:w #1 , #2 \q_stop { \@@_parse_number:n {#1} }
+\cs_new:Npn \@@_parse_model_rgb:w #1 , #2 , #3 , #4 \q_stop
+  {
+    \@@_parse_number:n {#1} ~ 
+    \@@_parse_number:n {#2} ~
+    \@@_parse_number:n {#3}
+  }
+\cs_new:Npn \@@_parse_model_cmyk:w #1 , #2 , #3 , #4 , #5 \q_stop
+  {
+    \@@_parse_number:n {#1} ~ 
+    \@@_parse_number:n {#2} ~
+    \@@_parse_number:n {#3} ~
+    \@@_parse_number:n {#4}
+  }
+\cs_new:Npn \@@_parse_model_spot:w #1 , #2 \q_stop
   { \@@_parse_spot_aux:w #1 ! 100 ! \q_stop }
 \cs_new:Npn \@@_parse_spot_aux:w #1 ! #2 ! #3 \q_stop
   { #1 ~ \fp_eval:n { #2 / 100 } }
+\cs_new:Npn \@@_parse_number:n #1
+  {  \@@_parse_number:w #1 . 0 . \q_stop }
+\cs_new:Npn \@@_parse_number:w #1 . #2 . #3 \q_stop
+  { \tl_if_blank:nTF {#1} { 0 } {#1} . #2 }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \subsection{Selecting colors (and color models)}
 %
@@ -725,10 +746,10 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_direct:nnN #1#2#3
   {
-    \cs_if_exist:cTF { @@_parse_ #1 :w }
+    \cs_if_exist:cTF { @@_parse_model_ #1 :w }
       {
         \tl_set:Nx #3
-          { #1 ~ \use:c {  @@_parse_ #1 :w } #2 , 0 , 0 , 0 , 0 \q_stop }
+          { #1 ~ \use:c {  @@_parse_model_ #1 :w } #2 , 0 , 0 , 0 , 0 \q_stop }
         \@@_check_model:N #3
       }
       {





More information about the latex3-commits mailing list