diff options
author | Karl Berry <karl@freefriends.org> | 2020-06-08 21:18:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-06-08 21:18:51 +0000 |
commit | 2453da40125221dbdd1b69cbcca473fab6f1f70d (patch) | |
tree | e0c0e5728eee75362ff6bc473123259a5d16f847 /Master/texmf-dist/tex/latex/cellprops | |
parent | 520fec3063ffc0dc67fa9bc435e18770dc071729 (diff) |
cellprops (8jun20)
git-svn-id: svn://tug.org/texlive/trunk@55483 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cellprops')
-rw-r--r-- | Master/texmf-dist/tex/latex/cellprops/cellprops.sty | 328 |
1 files changed, 179 insertions, 149 deletions
diff --git a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty index dd455c340d6..6126921c594 100644 --- a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty +++ b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty @@ -6,7 +6,7 @@ %% %% cellprops.dtx (with options: `package') %% -%% File: cellprops.dtx (C) Copyright 2016-2019 RIVAUD Julien +%% File: cellprops.dtx (C) Copyright 2016-2020 RIVAUD Julien %% %% It may be distributed and/or modified under the conditions of the %% General Public License (GPL), either version 3 of this @@ -15,8 +15,8 @@ \RequirePackage{expl3}[2018/06/19] \def\ExplFileName{cellprops} \def\ExplFileDescription{CSS-like cell and table properties} -\def\ExplFileDate{2019/09/29} -\def\ExplFileVersion{1.6} +\def\ExplFileDate{2020/06/07} +\def\ExplFileVersion{1.7a} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -79,7 +79,6 @@ } } } - \cs_new:Nn \__cellprops_fourval_setter:nnnnnn { \__cellprops_fourval_setter_aux:w {#1}{#2}{#3}{#4}#6~{\q_no_value}~{\q_no_value}~{\q_no_value}~\q_stop @@ -112,7 +111,6 @@ #2 } } - \tl_const:Nn \c__cellprops_inherit_color_tl { \q_nil } \cs_new_nopar:Nn \__cellprops_color_setter:nn { @@ -142,7 +140,6 @@ \__cellprops_color_setter:nn {#1} {#2} } } - \cs_new_nopar:Nn \__cellprops_linewidth_setter:nn { \str_case:nnF {#2} { {thin} { \__cellprops_generic_setter:nnn \exp_not:n {#1} { \fboxrule} } @@ -152,7 +149,6 @@ \__cellprops_generic_setter:nnn \exp_not:n {#1} {#2} } } - \cs_new_nopar:Nn \__cellprops_border_setter:nn { \__cellprops_border_setter_aux:nw {#1}#2~{\q_no_value}~{\q_no_value}~\q_stop @@ -188,13 +184,13 @@ \__cellprops_delegate_setter:nn {#1-color} {#4} } } + \cs_new:Npn \__cellprops_border_setter_isstyle:nTF #1 { \str_case:nnTF {#1} { {none}{} {hidden}{} {dotted}{} {dashed}{} {solid}{} {double}{} {groove}{} {ridge}{} {inset}{} {outset}{} } } - \__cellprops_define_properties:nn { \__cellprops_generic_setter:nnn \exp_not:n }{ @@ -202,19 +198,16 @@ min-depth, min-width, } - \__cellprops_define_fourval_properties:nnnnnn { \__cellprops_generic_setter:nnn \exp_not:n } {padding} {padding-top}{padding-right}{padding-bottom}{padding-left} - \__cellprops_define_properties:nn { \__cellprops_generic_setter:nnn \tl_to_str:n }{ text-align, math-mode, } - \__cellprops_define_properties:nn { \__cellprops_color_setter:nn }{ @@ -226,31 +219,26 @@ }{ background-color, } - \__cellprops_define_fourval_properties:nnnnnn { \__cellprops_linewidth_setter:nn } {border-width} {border-top-width}{border-right-width} {border-bottom-width}{border-left-width} - \__cellprops_define_fourval_properties:nnnnnn { \__cellprops_generic_setter:nnn \tl_to_str:n } {border-style} {border-top-style}{border-right-style} {border-bottom-style}{border-left-style} - \__cellprops_define_fourval_properties:nnnnnn { \__cellprops_color_setter:nn } {border-color} {border-top-color}{border-right-color} {border-bottom-color}{border-left-color} - \__cellprops_define_properties:nn { \__cellprops_border_setter:nn }{ border, border-top, border-right, border-bottom, border-left } - \NewDocumentCommand \cellprops { m } { \__cellprops_parse_css:n {#1} } @@ -258,104 +246,172 @@ \cs_new_protected:Nn \__cellprops_parse_css:n { \__cellprops_parse_css:w #1 \q_mark {\q_nil} \q_stop } - -\tl_new:N \l__cellprops_parse_tmp_tl +\tl_new:N \l__cellprops_parse_properties_tl \NewDocumentCommand \__cellprops_parse_css:w { lmu{\q_stop} } { \quark_if_nil:nF {#2} { - \__cellprops_parse_properties:Nn \l__cellprops_parse_tmp_tl {#2} + \__cellprops_parse_properties:Nn \l__cellprops_parse_properties_tl {#2} \clist_map_inline:nn {#1} { - \__cellprops_parse_css_addprops:nV {##1} \l__cellprops_parse_tmp_tl + \__cellprops_parse_css_addprops:n {##1} } \__cellprops_parse_css:w #3 \q_stop } } - -\seq_new:N \l__cellprops_parse_selector_seq -\tl_new:N \l__cellprops_parse_desc_tl - -\str_const:Nn \c__cellprops_parse_nthchild_str { :nth-child( } -\prop_new:N \c__cellprops_parse_replace_prop -\prop_put:Nnn \c__cellprops_parse_replace_prop { :first-child } { :nth-child(1) } - -\cs_new_protected:Nn \__cellprops_parse_selector:Nn { - \str_set:Nx \l_tmpa_str {#2} - \prop_map_inline:Nn \c__cellprops_parse_replace_prop { - \use:x { - \exp_not:n { \tl_replace_all:Nnn \l_tmpa_str } - { \tl_to_str:n { ##1 } } { \tl_to_str:n { ##2 } } +\tl_new:N \l__cellprops_current_selector_tl +\tl_new:N \l__cellprops_current_selector_check_tl +\cs_new_protected:Nn \__cellprops_parse_css_addprops:n { + \__cellprops_parse_selector:n {#1} + \tl_set:Nx \l_tmpa_tl { l__cellprops_property_group_\l__cellprops_current_selector_tl _tl } + \tl_if_exist:cF { \l_tmpa_tl } { \tl_clear:c { \l_tmpa_tl } } + \tl_if_empty:NTF \l__cellprops_current_selector_check_tl { + \tl_put_right:cV { \l_tmpa_tl } \l__cellprops_parse_properties_tl + }{ + \tl_put_right:cx { \l_tmpa_tl } { + \exp_not:N \bool_if:nT { + \exp_not:V \l__cellprops_current_selector_check_tl + }{ + \exp_not:V \l__cellprops_parse_properties_tl + } } } - \tl_replace_all:Nnn \l_tmpa_str {~} {\q_stop} - \exp_args:NNVV - \seq_set_split:Nnn \l_tmpa_seq \c__cellprops_parse_nthchild_str \l_tmpa_str - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl - \tl_replace_all:Nnn \l_tmpa_tl {\q_stop} {~} - \seq_clear:N \l__cellprops_parse_selector_seq - \seq_put_right:NV \l__cellprops_parse_selector_seq \l_tmpa_tl - \seq_map_inline:Nn \l_tmpa_seq { - \tl_set:Nn \l_tmpa_tl { ##1 } - \tl_replace_all:Nnn \l_tmpa_tl {\q_stop} {~} - \tl_replace_once:Nnn \l_tmpa_tl { ) } { \q_stop\prg_do_nothing: } - \seq_set_split:NnV \l_tmpa_seq { \q_stop } \l_tmpa_tl - \seq_pop_right:NN \l_tmpa_seq \l__cellprops_parse_desc_tl - \tl_replace_once:Nnn \l__cellprops_parse_desc_tl { \prg_do_nothing: } {} - \seq_get_left:NNT \l_tmpa_seq \l_tmpa_tl { - \exp_args:NNV \__cellprops_parse_nth:Nn \l_tmpa_tl \l_tmpa_tl - \tl_put_left:Nn \l__cellprops_parse_desc_tl { ) } - \tl_put_left:NV \l__cellprops_parse_desc_tl \l_tmpa_tl +} +\cs_new_protected:Nn \__cellprops_parse_selector_sanitize:n { + \exp_args:Nx \__cellprops_parse_selector_sanitize_aux:n + { \tl_to_str:n{#1} } +} +\cs_new_protected:Nn \__cellprops_parse_selector_sanitize_aux:n { + \cs_set:Npn \__cellprops_parse_selector_sanitize:w ##1:#1(##2)##3\q_stop + { + \quark_if_nil:nTF {##3} { + ##1 + }{ + ##1:#1{##2}\__cellprops_parse_selector_sanitize:w ##3\q_stop } - \seq_put_right:NV \l__cellprops_parse_selector_seq \l__cellprops_parse_desc_tl } - \tl_set:Nx #1 { - \exp_args:NNV \seq_use:Nn - \l__cellprops_parse_selector_seq \c__cellprops_parse_nthchild_str + \tl_set:Nx \l__cellprops_current_selector_tl { + \exp_last_unbraced:NV + \__cellprops_parse_selector_sanitize:w + \l__cellprops_current_selector_tl + :#1()\q_nil\q_stop + } +} +\seq_new:N \l__cellprops_current_selector_seq +\seq_new:N \l__cellprops_pseudoclasses_seq +\tl_new:N \l__cellprops_current_element_tl +\cs_new_protected:Nn \__cellprops_parse_selector:n { + \tl_set:Nx \l__cellprops_current_selector_tl { \tl_to_str:n {#1} } + \exp_args:NNV \tl_replace_all:Nnn + \l__cellprops_current_selector_tl \c_colon_str {:} + \__cellprops_parse_selector_sanitize:n {nth-child} + \seq_set_split:NnV \l__cellprops_current_selector_seq {~} \l__cellprops_current_selector_tl + \tl_clear:N \l__cellprops_current_selector_tl + \tl_clear:N \l__cellprops_current_selector_check_tl + \seq_map_inline:Nn \l__cellprops_current_selector_seq { + \seq_set_split:Nnn \l__cellprops_pseudoclasses_seq {:} {##1} + \seq_pop_left:NN \l__cellprops_pseudoclasses_seq \l__cellprops_current_element_tl + \tl_put_right:Nn \l__cellprops_current_selector_tl {~} + \tl_put_right:NV \l__cellprops_current_selector_tl \l__cellprops_current_element_tl + \seq_map_inline:Nn \l__cellprops_pseudoclasses_seq { + \__cellprops_parse_pseudoclass:w ####1{}\q_stop + } + } +} +\NewDocumentCommand \__cellprops_parse_pseudoclass:w { lmu{\q_stop} } { + \exp_args:Nx \str_case:nn { #1 } { + {first-child} { \__cellprops_parse_selector_nth:n {1} } + {nth-child} { \__cellprops_parse_selector_nth:n {#2} } } } \str_const:Nn \c__cellprops_parse_n_str {n} -\seq_new:N \l__cellprops_used_nth_factors_seq -\cs_new_protected:Nn \__cellprops_parse_nth:Nn { - \str_case:nnF {#2} { +\int_new:N \l__cellprops_nth_coeff_int +\int_new:N \l__cellprops_nth_offset_int +\cs_new_protected:Nn \__cellprops_parse_selector_nth:n { + \tl_put_right:Nn \l__cellprops_current_selector_tl { :nth-child } + \str_case:nnF {#1} { {even} { \str_set:Nn \l_tmpa_str {2n} } {odd} { \str_set:Nn \l_tmpa_str {2n+1} } }{ - \str_set:Nn \l_tmpa_str {#2} + \str_set:Nn \l_tmpa_str {#1} } - \exp_args:NNVV - \seq_set_split:Nnn \l_tmpa_seq \c__cellprops_parse_n_str \l_tmpa_str + \exp_args:NNV + \seq_set_split:NnV \l_tmpa_seq \c__cellprops_parse_n_str \l_tmpa_str \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl - \int_set:Nn \l_tmpb_int { 0\l_tmpa_tl } - \seq_get_left:NNTF \l_tmpa_seq \l_tmpa_tl { - \int_set:Nn \l_tmpa_int { 0\l_tmpa_tl } + \tl_if_empty:NTF \l_tmpa_tl { + \int_zero:N \l__cellprops_nth_offset_int }{ - \int_zero:N \l_tmpa_int + \int_set:Nn \l__cellprops_nth_offset_int { \l_tmpa_tl } } - \int_compare:nNnTF \l_tmpa_int = { 0 } { - \tl_set:Nx #1 { \int_use:N \l_tmpb_int } + \seq_get_left:NNTF \l_tmpa_seq \l_tmpa_tl { + \tl_if_empty:NTF \l_tmpa_tl { + \int_set:Nn \l__cellprops_nth_coeff_int {1} + }{ + \exp_args:NV \tl_if_eq:nnTF \l_tmpa_tl {-} { + \int_set:Nn \l__cellprops_nth_coeff_int {-1} + }{ + \int_set:Nn \l__cellprops_nth_coeff_int { \l_tmpa_tl } + } + } }{ - \int_set:Nn \l_tmpb_int { \int_mod:nn {\l_tmpb_int} {\l_tmpa_int} } - \tl_set:Nx #1 { - \int_use:N \l_tmpa_int \exp_not:V \c__cellprops_parse_n_str - + \int_use:N \l_tmpb_int } - \seq_put_right:Nx - \l__cellprops_used_nth_factors_seq { \int_use:N \l_tmpa_int } + \int_zero:N \l__cellprops_nth_coeff_int + } + \exp_args:NV \str_case:nn \l__cellprops_current_element_tl { + {tr} { \__cellprops_generate_check_nth:n {\g__cellprops_row_int} } + {td} { \__cellprops_generate_check_nth:n {\g__cellprops_col_int} } } } -\cs_new_protected:Npn \__cellprops_parse_css_addprops:nV #1 #2 { - \__cellprops_parse_selector:Nn \l_tmpa_tl {#1} - \tl_set:Nx \l_tmpa_tl { l__cellprops_property_group_\l_tmpa_tl _tl } - \tl_if_exist:cF { \l_tmpa_tl } { \tl_clear:c { \l_tmpa_tl } } - \tl_put_right:cV { \l_tmpa_tl } #2 +\cs_new_protected_nopar:Nn \__cellprops_generate_check_nth:n { + \int_compare:nNnTF \l__cellprops_nth_coeff_int = { 0 } { + \tl_set:Nx \l_tmpa_tl { + \exp_not:n { \int_compare_p:nNn #1 = } + \exp_not:V \l__cellprops_nth_offset_int + } + }{ + \tl_set:Nx \l_tmpb_tl { + { + \exp_not:n { #1 - } + \exp_not:V \l__cellprops_nth_offset_int + }{ + \exp_not:V \l__cellprops_nth_coeff_int + } + } + \tl_set:Nx \l_tmpa_tl { + \exp_not:N \bool_lazy_and_p:nn { + \exp_not:n { \int_compare_p:nNn 0 = } + { + \exp_not:N \int_mod:nn + \exp_not:V \l_tmpb_tl + } + }{ + \exp_not:n { \int_compare_p:nNn 0 < } + { + \exp_not:N \int_div_truncate:nn + \exp_not:V \l_tmpb_tl + \exp_not:n { + 1 } + } + } + } + } + \tl_if_empty:NTF \l__cellprops_current_selector_check_tl { + \tl_set_eq:NN \l__cellprops_current_selector_check_tl \l_tmpa_tl + }{ + \tl_set:Nx \l__cellprops_current_selector_check_tl { + \exp_not:N \bool_lazy_and_p:nn { + \exp_not:V \l__cellprops_current_selector_check_tl + }{ + \exp_not:V \l_tmpa_tl + } + } + } } \cs_set_protected:Nn \__cellprops_recall_properties:n { - \tl_if_exist:cT { l__cellprops_property_group_#1_tl } { - \tl_use:c { l__cellprops_property_group_#1_tl } + \tl_if_exist:cT { l__cellprops_property_group_~#1_tl } { + \tl_use:c { l__cellprops_property_group_~#1_tl } } \clist_map_inline:nn { \@currenvir } { - \tl_if_exist:cT { l__cellprops_property_group_##1~#1_tl } { - \tl_use:c { l__cellprops_property_group_##1~#1_tl } + \tl_if_exist:cT { l__cellprops_property_group_~##1~#1_tl } { + \tl_use:c { l__cellprops_property_group_~##1~#1_tl } } } } @@ -456,13 +512,34 @@ \hlx{s[\l__cellprops_tablepadding_top_dim]} } +\cs_new_protected_nopar:Nn \__cellprops_maybe_startrow: { + \bool_if:NF \g__cellprops_inrow_bool { + \bool_gset_true:N \g__cellprops_inrow_bool + \int_gincr:N \g__cellprops_row_int + \int_gset_eq:NN \g__cellprops_col_int \c_one_int + \dim_gzero:N \g__cellprops_ht_dim + \dim_gzero:N \g__cellprops_dp_dim + } +} + +\cs_new_protected_nopar:Nn \__cellprops_maybe_endrow: { + \bool_if:NT \g__cellprops_inrow_bool { + \__cellprops_every_cell_end: + \bool_gset_false:N \g__cellprops_inrow_bool + } +} + +\cs_new_protected_nopar:Nn \__cellprops_every_cell_end: { + \int_gincr:N \g__cellprops_col_int +} + \cs_set_protected_nopar:Nn \__cellprops_readpreamble:n { \cs_set_eq:NN \tab@readpreamble \__cellprops_orig_tab@readpreamble:n - \tl_put_left:Nn \tab@multicol {\__cellprops_startrow:} - \tl_put_left:Nn \tab@tabtext {\int_gincr:N \g__cellprops_col_int} + \tl_put_left:Nn \tab@multicol {\__cellprops_maybe_startrow:} + \tl_put_left:Nn \tab@tabtext {\__cellprops_every_cell_end:} \tab@readpreamble{#1} \exp_args:Nx \tab@preamble - { \exp_not:N\__cellprops_startrow: \the\tab@preamble \exp_not:N\__cellprops_endrow: } + { \the\tab@preamble \exp_not:N\__cellprops_maybe_endrow: } } \cs_new_protected_nopar:Nn \__cellprops_update_color:Nn { \__cellprops_get_property:nN {#2} \l_tmpa_tl @@ -517,24 +594,8 @@ \__cellprops_end_array:n { \__cellprops_orig_endLT: } } -\cs_new_protected_nopar:Nn \__cellprops_startrow: { - \bool_if:NF \g__cellprops_inrow_bool { - \bool_gset_true:N \g__cellprops_inrow_bool - \int_gincr:N \g__cellprops_row_int - \int_gset_eq:NN \g__cellprops_col_int \c_one_int - \dim_gzero:N \g__cellprops_ht_dim - \dim_gzero:N \g__cellprops_dp_dim - } -} - -\cs_new_protected_nopar:Nn \__cellprops_endrow: { - \bool_if:NT \g__cellprops_inrow_bool { - \bool_gset_false:N \g__cellprops_inrow_bool - } -} - \cs_new_protected_nopar:Nn \__cellprops_cr:n { - \__cellprops_endrow: + \__cellprops_maybe_endrow: \tl_if_empty:NF \g__cellprops_borders_tl { \cr \noalign{\nobreak} @@ -557,10 +618,12 @@ \cs_set_eq:NN \__cellprops_orig_multicolumn:w \multicolumn \cs_set:Npn \multicolumn#1#2#3 { - \__cellprops_orig_multicolumn:w {#1}{#2}{ - #3 - \int_gadd:Nn \g__cellprops_col_int {#1} + \__cellprops_orig_multicolumn:w {#1}{#2}{#3} + \int_gadd:Nn \g__cellprops_col_int {#1} + \tl_gput_right:Nx \g__cellprops_borders_tl { + \prg_replicate:nn {#1 - 1} {\span\omit} } + \ignorespaces } } @@ -643,15 +706,6 @@ }} \colpop -\cs_new_protected_nopar:Nn \__cellprops_seq_nthchild:Nn { - \seq_clear:N #1 - \seq_map_inline:Nn \l__cellprops_used_nth_factors_seq { - \seq_put_right:Nx #1 { - ##1 n + \int_eval:n{\int_mod:nn{#2}{##1}} - } - } - \seq_put_right:Nx #1 { \int_eval:n{#2} } -} \cs_new_protected_nopar:Nn \__cellprops_begincell:n { \__cellprops_begin_raw_cell:n { @@ -690,25 +744,13 @@ \global\@minipagefalse \everypar{} } - \__cellprops_seq_nthchild:Nn \l_tmpa_seq { \g__cellprops_row_int } - \__cellprops_seq_nthchild:Nn \l_tmpb_seq { \g__cellprops_col_int } \__cellprops_recall_properties:n {td~p} - \seq_map_inline:Nn \l_tmpa_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)~p} - } - \seq_map_inline:Nn \l_tmpb_seq { - \__cellprops_recall_properties:n {td:nth-child(##1)~p} - } \__cellprops_recall_properties:n {tr~td~p} - \seq_map_inline:Nn \l_tmpa_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)~td~p} - } - \seq_map_inline:Nn \l_tmpa_seq { - \seq_map_inline:Nn \l_tmpb_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)~ - td:nth-child(####1)~p} - } - } + \__cellprops_recall_properties:n {tr:nth-child~p} + \__cellprops_recall_properties:n {td:nth-child~p} + \__cellprops_recall_properties:n {tr:nth-child~td~p} + \__cellprops_recall_properties:n {tr~td:nth-child~p} + \__cellprops_recall_properties:n {tr:nth-child~td:nth-child~p} } } \cs_new_protected_nopar:Nn \__cellprops_end_par_cell:n { @@ -723,26 +765,14 @@ \cs_new_protected_nopar:Nn \__cellprops_begin_raw_cell:n { \group_begin: - \__cellprops_seq_nthchild:Nn \l_tmpa_seq { \g__cellprops_row_int } - \__cellprops_seq_nthchild:Nn \l_tmpb_seq { \g__cellprops_col_int } - \seq_map_inline:Nn \l_tmpa_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)} - } + \__cellprops_recall_properties:n {tr:nth-child} \__cellprops_update_colors: \__cellprops_recall_properties:n {td} \__cellprops_recall_properties:n {tr~td} - \seq_map_inline:Nn \l_tmpb_seq { - \__cellprops_recall_properties:n {td:nth-child(##1)} - } - \seq_map_inline:Nn \l_tmpa_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)~td} - } - \seq_map_inline:Nn \l_tmpa_seq { - \seq_map_inline:Nn \l_tmpb_seq { - \__cellprops_recall_properties:n {tr:nth-child(##1)~ - td:nth-child(####1)} - } - } + \__cellprops_recall_properties:n {td:nth-child} + \__cellprops_recall_properties:n {tr:nth-child~td} + \__cellprops_recall_properties:n {tr~td:nth-child} + \__cellprops_recall_properties:n {tr:nth-child~td:nth-child} \__cellprops_update_colors: % Additional init code #1 |