Skip to content

Commit

Permalink
refactor: processing of hvline dash/text
Browse files Browse the repository at this point in the history
  • Loading branch information
muzimuzhi committed Nov 28, 2024
1 parent a9b5d5a commit 3cce25b
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions tabularray/tabularray.sty
Original file line number Diff line number Diff line change
Expand Up @@ -1138,14 +1138,14 @@
\tblr_set_hline:nnn {#1} {#2} {#3}
}

%% We need to check "text" quark first
%% We need to check "text" key first
%% If it does exist and has empty value, then do nothing
\cs_new_protected:Npn \tblr_set_hline:nnn #1 #2 #3
{
\group_begin:
\keys_set_groups:nnn { tblr/__hline } { text } {#3}
\tl_if_eq:NnF \l__tblr_hline_dash_tl
{ \exp_not:n { \q__tblr_text } }
% both tl and quark vars are short (no \long prefix)
\tl_if_eq:NNF \l__tblr_hline_dash_tl \q__tblr_text
{
\__tblr_set_hline_num:n {#1}
\tl_clear:N \l__tblr_hline_dash_tl
Expand Down Expand Up @@ -1221,12 +1221,8 @@

\keys_define:nn { tblr/__hline }
{
dash .code:n = \tl_set:Nn \l__tblr_hline_dash_tl { \exp_not:N \q__tblr_dash #1 },
text .code:n =
{
\tl_set:Nn \l__tblr_hline_dash_tl
{ \exp_not:n { \q__tblr_text #1 } }
} ,
dash .code:n = \tl_set:Nn \l__tblr_hline_dash_tl { \q__tblr_dash #1 },
text .code:n = \tl_set:Nn \l__tblr_hline_dash_tl { \q__tblr_text #1 },
text .groups:n = { text },
wd .code:n = \tl_set:Nn \l__tblr_hline_wd_tl { \dim_eval:n {#1} },
fg .code:n = \tl_set:Nn \l__tblr_hline_fg_tl {#1},
Expand All @@ -1245,7 +1241,7 @@
\cs_new_protected:Npn \__tblr_hline_unknown_key:n #1
{
\prop_if_in:NnTF \g__tblr_defined_hdash_styles_prop {#1}
{ \tl_set:Nn \l__tblr_hline_dash_tl { \exp_not:N \q__tblr_dash #1 } }
{ \tl_set:Nn \l__tblr_hline_dash_tl { \q__tblr_dash #1 } }
{
\regex_match:NnTF \c__tblr_is_color_key_regex {#1}
{ \tl_set:Nn \l__tblr_hline_fg_tl {#1} }
Expand All @@ -1262,7 +1258,8 @@
\__tblr_get_childs:ne {#1} { \int_use:N \c@colcount }
\clist_map_inline:Nn \l_tblr_childs_clist
{
\__tblr_set_hline_option:nnn { ##1 } { @dash } { \l__tblr_hline_dash_tl }
\__tblr_set_hline_option:nnn { ##1 } { @dash }
{ \exp_not:o \l__tblr_hline_dash_tl }
\tl_if_empty:NF \l__tblr_hline_wd_tl
{
\__tblr_set_hline_option:nnn { ##1 } { wd } { \l__tblr_hline_wd_tl }
Expand Down Expand Up @@ -1385,14 +1382,14 @@
\tblr_set_vline:nnn {#1} {#2} {#3}
}

%% We need to check "text" quark first
%% We need to check "text" key first
%% If it does exist and has empty value, then do nothing
\cs_new_protected:Npn \tblr_set_vline:nnn #1 #2 #3
{
\group_begin:
\keys_set_groups:nnn { tblr/__vline } { text } {#3}
\tl_if_eq:NnF \l__tblr_vline_dash_tl
{ \exp_not:n { \q__tblr_text } }
% both tl and quark vars are short (no \long prefix)
\tl_if_eq:NNF \l__tblr_vline_dash_tl \q__tblr_text
{
\__tblr_set_vline_num:n {#1}
\tl_clear:N \l__tblr_vline_dash_tl
Expand Down Expand Up @@ -1468,12 +1465,8 @@

\keys_define:nn { tblr/__vline }
{
dash .code:n = \tl_set:Nn \l__tblr_vline_dash_tl { \exp_not:N \q__tblr_dash #1 },
text .code:n =
{
\tl_set:Nn \l__tblr_vline_dash_tl
{ \exp_not:n { \q__tblr_text #1 } }
} ,
dash .code:n = \tl_set:Nn \l__tblr_vline_dash_tl { \q__tblr_dash #1 },
text .code:n = \tl_set:Nn \l__tblr_vline_dash_tl { \q__tblr_text #1 },
text .groups:n = { text },
wd .code:n = \tl_set:Nn \l__tblr_vline_wd_tl { \dim_eval:n {#1} },
fg .code:n = \tl_set:Nn \l__tblr_vline_fg_tl {#1},
Expand All @@ -1485,7 +1478,7 @@
\cs_new_protected:Npn \__tblr_vline_unknown_key:n #1
{
\prop_if_in:NnTF \g__tblr_defined_vdash_styles_prop {#1}
{ \tl_set:Nn \l__tblr_vline_dash_tl { \exp_not:N \q__tblr_dash #1 } }
{ \tl_set:Nn \l__tblr_vline_dash_tl { \q__tblr_dash #1 } }
{
\regex_match:NnTF \c__tblr_is_color_key_regex {#1}
{ \tl_set:Nn \l__tblr_vline_fg_tl {#1} }
Expand All @@ -1504,7 +1497,7 @@
{
\__tblr_spec_gput:nee { vline }
{ [##1][\int_use:N \c@colnum](\l__tblr_vline_num_tl) / @dash }
{ \l__tblr_vline_dash_tl }
{ \exp_not:o \l__tblr_vline_dash_tl }
\tl_if_empty:NF \l__tblr_vline_wd_tl
{
\__tblr_spec_gput:nee { vline }
Expand Down

0 comments on commit 3cce25b

Please sign in to comment.