summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cellprops
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-06-12 21:49:45 +0000
committerKarl Berry <karl@freefriends.org>2018-06-12 21:49:45 +0000
commitab45a81a1b19ca667d1b45f06687cf639a6d0901 (patch)
tree4fa90bacdb573218a4c6825b7f2cf27e320659a6 /Master/texmf-dist/tex/latex/cellprops
parentbbfba2e99d6a1f7490fe73fde3e3bca4474adb4c (diff)
cellprops (12jun18)
git-svn-id: svn://tug.org/texlive/trunk@47996 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cellprops')
-rw-r--r--Master/texmf-dist/tex/latex/cellprops/cellprops.sty116
1 files changed, 92 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty
index 78777063c4d..2f63c5f4419 100644
--- a/Master/texmf-dist/tex/latex/cellprops/cellprops.sty
+++ b/Master/texmf-dist/tex/latex/cellprops/cellprops.sty
@@ -15,8 +15,8 @@
\RequirePackage{expl3}[2016/01/19]
\def\ExplFileName{cellprops}
\def\ExplFileDescription{CSS-like cell and table properties}
-\def\ExplFileDate{2016/04/05}
-\def\ExplFileVersion{1.0}
+\def\ExplFileDate{2018/06/12}
+\def\ExplFileVersion{1.1a}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -48,10 +48,8 @@
\use:c {__cellprops_property_type_#1:nn} {#1} {#2}
}
}
-\cs_set_protected:Nn \__cellprops_parse_properties:nn {
- \tl_if_exist:cF { l__cellprops_property_group_#1_tl } {
- \tl_clear:c { l__cellprops_property_group_#1_tl }
- }
+\cs_set_protected:Nn \__cellprops_parse_properties:Nn {
+ \tl_clear:N #1
\seq_set_split:Nnn \l_tmpa_seq {;} {#2}
\seq_map_inline:Nn \l_tmpa_seq {
\tl_if_empty:nF {##1} {
@@ -61,7 +59,7 @@
\exp_args:NNV \str_set:Nn \l_tmpa_str \l_tmpa_tl
\seq_get_right:NN \l_tmpb_seq \l_tmpa_tl
\cs_if_exist:cTF { __cellprops_property_type_\l_tmpa_str :nn } {
- \tl_put_right:cx { l__cellprops_property_group_#1_tl } {
+ \tl_put_right:Nx #1 {
\exp_args:Nc \exp_args:NVV
{ __cellprops_property_type_\l_tmpa_str :nn }
\l_tmpa_str \l_tmpa_tl
@@ -174,15 +172,97 @@
\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
\NewDocumentCommand \__cellprops_parse_css:w { lmu{\q_stop} } {
\quark_if_nil:nF {#2} {
+ \__cellprops_parse_properties:Nn \l__cellprops_parse_tmp_tl {#2}
\clist_map_inline:nn {#1} {
- \__cellprops_parse_properties:nn {##1} {#2}
+ \__cellprops_parse_css_addprops:nV {##1} \l__cellprops_parse_tmp_tl
}
\__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_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
+ }
+ \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
+ }
+}
+
+\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} {
+ {even} { \str_set:Nn \l_tmpa_str {2n} }
+ {odd} { \str_set:Nn \l_tmpa_str {2n+1} }
+ }{
+ \str_set:Nn \l_tmpa_str {#2}
+ }
+ \exp_args:NNVV
+ \seq_set_split:Nnn \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 }
+ }{
+ \int_zero:N \l_tmpa_int
+ }
+ \int_compare:nNnTF \l_tmpa_int = { 0 } {
+ \tl_set:Nx #1 { \int_use:N \l_tmpb_int }
+ }{
+ \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 }
+ }
+}
+
+\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_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 }
@@ -281,8 +361,6 @@
\__cellprops_orig_array:[{#1}]{#2}
\hlx{s[\l__cellprops_tablepadding_top_dim]}
}
-
-
\cs_new_protected_nopar:Nn \__cellprops_update_color:Nn {
\__cellprops_get_property:nN {#2} \l_tmpc_tl
\exp_args:NV \tl_if_eq:NNF \l_tmpc_tl \c__cellprops_inherit_color_tl {
@@ -408,23 +486,13 @@
}}
\colpop
-
-
-\cs_new_protected_nopar:Nn \__cellprops_nthchild_anb:Nnn {
- \tl_set:Nx \l_tmpa_tl { +\int_eval:n{\int_mod:nn{#2}{#3}} }
- \exp_args:NV \tl_if_eq:nnT \l_tmpa_tl { +0 } {
- \tl_clear:N \l_tmpa_tl
- }
- \seq_put_right:Nx #1 { #3n\l_tmpa_tl }
-}
-
\cs_new_protected_nopar:Nn \__cellprops_seq_nthchild:Nn {
\seq_clear:N #1
- \seq_put_right:Nx #1 {
- \int_compare:nNnTF{\int_mod:nn{#2}{2}}={0}{even}{odd}
+ \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}}
+ }
}
- \__cellprops_nthchild_anb:Nnn #1 {#2} {2}
- \__cellprops_nthchild_anb:Nnn #1 {#2} {3}
\seq_put_right:Nx #1 { \int_eval:n{#2} }
}