Skip to content

Commit

Permalink
Add \color_if_exist:n(TF)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Aug 12, 2022
1 parent 6b03372 commit db2b264
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions l3kernel/CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]

### Added
- `\color_if_exist:n(TF)`
- Support for case changing Vietnamese characters with 8-bit engines

## [2022-08-05]
Expand Down
23 changes: 16 additions & 7 deletions l3kernel/l3color.dtx
Expand Up @@ -235,6 +235,15 @@
% it to be saved to a name.
% \end{function}
%
% \begin{function}[EXP, pTF, added = 2022-08-12]{\color_if_exist:n}
% \begin{syntax}
% \cs{color_if_exist:n} \Arg{name}
% \cs{color_if_exist:n} \Arg{name} \Arg{true code} \Arg{false code}
% \end{syntax}
% Tests whether \meta{name} is currently defined to provide a color
% specification.
% \end{function}
%
% \begin{function}[added = 2021-05-11]{\color_show:n, \color_log:n}
% \begin{syntax}
% \cs{color_show:n} \Arg{name}
Expand Down Expand Up @@ -625,12 +634,12 @@
%
% \subsection{Utility functions}
%
% \begin{macro}[TF, EXP]{\@@_if_defined:n}
% \begin{macro}[pTF, EXP]{\color_if_exist:n}
% A simple wrapper to avoid needing to have the lookup repeated in too many
% places.To guard against a color created in a group, we need to test for
% entries in the |prop|.
% \begin{macrocode}
\prg_new_conditional:Npnn \@@_if_defined:n #1 { T, F, TF }
\prg_new_conditional:Npnn \color_if_exist:n #1 { p , T, F, TF }
{
\prop_if_exist:cTF { l_@@_named_ #1 _prop }
{
Expand Down Expand Up @@ -827,7 +836,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_parse_aux:nN #1#2
{
\@@_if_defined:nTF {#1}
\color_if_exist:nTF {#1}
{ \@@_parse_set_eq:Nn #2 {#1} }
{ \@@_parse:Nw #2#1 ! \s_@@_stop }
\@@_check_model:N #2
Expand Down Expand Up @@ -865,7 +874,7 @@
}
\cs_new_protected:Npn \@@_parse:Nw #1#2 ! #3 \s_@@_stop
{
\@@_if_defined:nTF {#2}
\color_if_exist:nTF {#2}
{
\tl_if_blank:nTF {#3}
{ \@@_parse_set_eq:Nn #1 {#2} }
Expand Down Expand Up @@ -938,7 +947,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_parse_loop:nn #1#2
{
\@@_if_defined:nTF {#2}
\color_if_exist:nTF {#2}
{
\@@_extract:nNN {#2} \l_@@_next_model_tl \l_@@_next_value_tl
\tl_if_eq:NNF \l_@@_model_tl \l_@@_next_model_tl
Expand Down Expand Up @@ -1738,7 +1747,7 @@
}
\cs_new_protected:Npn \color_set_eq:nn #1#2
{
\@@_if_defined:nTF {#2}
\color_if_exist:nTF {#2}
{
\tl_clear_new:c { l_@@_named_ #1 _tl }
\prop_clear_new:c { l_@@_named_ #1 _prop }
Expand Down Expand Up @@ -2932,7 +2941,7 @@
#1 { color } { show }
{#2}
{
\@@_if_defined:nT {#2}
\color_if_exist:nT {#2}
{
\exp_args:Nv \@@_show:n { l_@@_named_ #2 _tl }
\prop_map_function:cN
Expand Down

0 comments on commit db2b264

Please sign in to comment.