summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/cellprops/cellprops.pdfbin507792 -> 518401 bytes
-rw-r--r--Master/texmf-dist/source/latex/cellprops/cellprops.dtx177
-rw-r--r--Master/texmf-dist/tex/latex/cellprops/cellprops.sty116
3 files changed, 227 insertions, 66 deletions
diff --git a/Master/texmf-dist/doc/latex/cellprops/cellprops.pdf b/Master/texmf-dist/doc/latex/cellprops/cellprops.pdf
index 66e7a6ed74e..dbc70fafdaf 100644
--- a/Master/texmf-dist/doc/latex/cellprops/cellprops.pdf
+++ b/Master/texmf-dist/doc/latex/cellprops/cellprops.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cellprops/cellprops.dtx b/Master/texmf-dist/source/latex/cellprops/cellprops.dtx
index 6786f616db4..2ec12963014 100644
--- a/Master/texmf-dist/source/latex/cellprops/cellprops.dtx
+++ b/Master/texmf-dist/source/latex/cellprops/cellprops.dtx
@@ -14,8 +14,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}
%</driver|package>
%<*driver>
\documentclass[full]{l3doc}
@@ -186,18 +186,23 @@
% columns actually increase the child count by the number of column they
% span, so that nth-child can still be used to select columns.
% This is not consistent with the CSS specification.
-% \item Currently, only "2n", "2n+1", "3n", "3n+1" and "3n+2" are supported,
-% without any space, as arguments of "nth-child()" other than a single
-% number, "odd" or "even" without any space. Supporting others is trivial,
-% but increase the running time. In a near-future release, I intend to
-% detect which multiples are actually used and automatically support
-% those.
+% \item Any ":nth-child("$A$"n+"$B$")" or ":nth-child("$A$"n)"
+% or ":nth-child("$B$")" is supported, with arbitrary $A$~and~$B$. The
+% performance will slowly degrade the more different~$A$ are active
+% (but if in a \TeX\ group, they will become inactive again when leaving
+% the group). \emph{A big difference} with the CSS specification is that
+% currently $n$ is not enforced non-negative. In particular
+% ":nth-child(2n+8)" \emph{will} match for the second element. This also
+% prevents tricks like ":nth-child(-n+3)". I am investigating how to
+% handle those without slowing down the general case.
% \end{itemize}
%
% \subsection{TODO}
%
-% Add "border" properties. Add automatic support of ":nth-child(an+b)" for
-% $"a"\ge 4$.
+% Add "border" properties. Test with different table-oriented packages. Improve
+% the documentation, and test more \LaTeX\ table constructs and preamble column
+% types. Enforce $n\ge0$ in ":nth-child" selectors to match the CSS
+% specification.
%
% \end{documentation}
%
@@ -298,10 +303,8 @@
% \end{macro}
%
% \begin{macrocode}
-\cs_set_protected:Nn \@@_parse_properties:nn {
- \tl_if_exist:cF { l_@@_property_group_#1_tl } {
- \tl_clear:c { l_@@_property_group_#1_tl }
- }
+\cs_set_protected:Nn \@@_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} {
@@ -311,7 +314,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 { _@@_property_type_\l_tmpa_str :nn } {
- \tl_put_right:cx { l_@@_property_group_#1_tl } {
+ \tl_put_right:Nx #1 {
\exp_args:Nc \exp_args:NVV
{ _@@_property_type_\l_tmpa_str :nn }
\l_tmpa_str \l_tmpa_tl
@@ -418,8 +421,6 @@
background-color,
}
-
-% TODO: properties for array
\NewDocumentCommand \cellprops { m } {
\@@_parse_css:n {#1}
}
@@ -427,15 +428,118 @@
\cs_new_protected:Nn \@@_parse_css:n {
\@@_parse_css:w #1 \q_mark {\q_nil} \q_stop
}
+
+\tl_new:N \l_@@_parse_tmp_tl
\NewDocumentCommand \@@_parse_css:w { lmu{\q_stop} } {
\quark_if_nil:nF {#2} {
+ \@@_parse_properties:Nn \l_@@_parse_tmp_tl {#2}
\clist_map_inline:nn {#1} {
- \@@_parse_properties:nn {##1} {#2}
+ \@@_parse_css_addprops:nV {##1} \l_@@_parse_tmp_tl
}
\@@_parse_css:w #3 \q_stop
}
}
+
+\seq_new:N \l_@@_parse_selector_seq
+\tl_new:N \l_@@_parse_desc_tl
+
+\str_const:Nn \c_@@_parse_nthchild_str { :nth-child( }
+\prop_new:N \c_@@_parse_replace_prop
+\prop_put:Nnn \c_@@_parse_replace_prop { :first-child } { :nth-child(1) }
+
+\cs_new_protected:Nn \@@_parse_selector:Nn {
+ \str_set:Nx \l_tmpa_str {#2}
+% \end{macrocode}
+% Replace some aliases with their meaning:
+% \begin{macrocode}
+ \prop_map_inline:Nn \c_@@_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 } }
+ }
+ }
+% \end{macrocode}
+% Replace all spaces by \cs{q_stop} to defeat the space removal feature of
+% \cs{seq_set_split:Nnn}.
+% \begin{macrocode}
+ \tl_replace_all:Nnn \l_tmpa_str {~} {\q_stop}
+ \exp_args:NNVV
+ \seq_set_split:Nnn \l_tmpa_seq \c_@@_parse_nthchild_str \l_tmpa_str
+ \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl
+% \end{macrocode}
+% And replace them back.
+% \begin{macrocode}
+ \tl_replace_all:Nnn \l_tmpa_tl {\q_stop} {~}
+ \seq_clear:N \l_@@_parse_selector_seq
+ \seq_put_right:NV \l_@@_parse_selector_seq \l_tmpa_tl
+ \seq_map_inline:Nn \l_tmpa_seq {
+ \tl_set:Nn \l_tmpa_tl { ##1 }
+% \end{macrocode}
+% And replace them back again.
+% \begin{macrocode}
+ \tl_replace_all:Nnn \l_tmpa_tl {\q_stop} {~}
+% \end{macrocode}
+% Now replace the first closing parenthesis by \cs{q_stop}\cs{prg_do_nothing:}
+% to use \cs{q_stop} as a delimiter for \cs{seq_set_split:Nnn} and thus split
+% at most once. Note that here the space trimming feature is desired for the
+% left part, but not just at the right of the parenthesis, so
+% \cs{prg_do_nothing:} will act as a guard and will be removed afterwards.
+% \begin{macrocode}
+ \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_@@_parse_desc_tl
+ \tl_replace_once:Nnn \l_@@_parse_desc_tl { \prg_do_nothing: } {}
+ \seq_get_left:NNT \l_tmpa_seq \l_tmpa_tl {
+ \exp_args:NNV \@@_parse_nth:Nn \l_tmpa_tl \l_tmpa_tl
+ \tl_put_left:Nn \l_@@_parse_desc_tl { ) }
+ \tl_put_left:NV \l_@@_parse_desc_tl \l_tmpa_tl
+ }
+ \seq_put_right:NV \l_@@_parse_selector_seq \l_@@_parse_desc_tl
+ }
+ \tl_set:Nx #1 {
+ \exp_args:NNV \seq_use:Nn
+ \l_@@_parse_selector_seq \c_@@_parse_nthchild_str
+ }
+}
+
+\str_const:Nn \c_@@_parse_n_str {n}
+\seq_new:N \l_@@_used_nth_factors_seq
+\cs_new_protected:Nn \@@_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_@@_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_@@_parse_n_str
+ + \int_use:N \l_tmpb_int }
+ \seq_put_right:Nx
+ \l_@@_used_nth_factors_seq { \int_use:N \l_tmpa_int }
+ }
+}
+
+\cs_new_protected:Npn \@@_parse_css_addprops:nV #1 #2 {
+ \@@_parse_selector:Nn \l_tmpa_tl {#1}
+ \tl_set:Nx \l_tmpa_tl { l_@@_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 \@@_recall_properties:n {
\tl_if_exist:cT { l_@@_property_group_#1_tl } {
\tl_use:c { l_@@_property_group_#1_tl }
@@ -516,15 +620,15 @@
\tab@initread
\tl_put_left:Nn \tab@tabtext {\int_gincr:N \g_@@_col_int}
}
-% \end{macrocode}
+% \end{macrocode}
% Zero \cs{col@sep} but remember its value for the default padding.
-% \begin{macrocode}
+% \begin{macrocode}
\dim_set_eq:NN \l_@@_colsep_dim \col@sep
\dim_zero:N \col@sep
-% \end{macrocode}
+% \end{macrocode}
% Also ignore \cs{*extrasep} dimensions that are not part of cellprop
% interface and should be replaced by CSS equivalents.
-% \begin{macrocode}
+% \begin{macrocode}
\dim_zero:N \tab@extrasep
\group_begin:
\@@_recall_properties:n {table}
@@ -542,15 +646,13 @@
\@@_orig_array:[{#1}]{#2}
\hlx{s[\l_@@_tablepadding_top_dim]}
}
-
-% \end{macrocode}
+% \end{macrocode}
% The color inheritance is handled with \cs{l_@@_inherit_color_tl},
% \cs{l_@@_color_tl} and \cs{l_@@_bgcolor_tl}. The role of
% \cs{@@_update_color:Nn} is to set the inherit fallback to the already
% existing value of \verb|#1| then set \verb|#1| to the CSS value, which can be
% the inherit variable.
-% \begin{macrocode}
-
+% \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_update_color:Nn {
\@@_get_property:nN {#2} \l_tmpc_tl
\exp_args:NV \tl_if_eq:NNF \l_tmpc_tl \c_@@_inherit_color_tl {
@@ -680,26 +782,17 @@
\colpop
-
-% \end{macrocode}
+% \end{macrocode}
+%
% Handle various \verb|:nth-child()| forms.
-% \begin{macrocode}
-
-\cs_new_protected_nopar:Nn \@@_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 }
-}
-
+% \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_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_@@_used_nth_factors_seq {
+ \seq_put_right:Nx #1 {
+ ##1 n + \int_eval:n{\int_mod:nn{#2}{##1}}
+ }
}
- \@@_nthchild_anb:Nnn #1 {#2} {2}
- \@@_nthchild_anb:Nnn #1 {#2} {3}
\seq_put_right:Nx #1 { \int_eval:n{#2} }
}
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} }
}