diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-17 20:56:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-17 20:56:22 +0000 |
commit | 039ad675536b0349e4805af936ccca3763b0f851 (patch) | |
tree | 88d7f7604b86b7cc879d3e8ead8a3132029c65f8 /Master/texmf-dist/tex/latex | |
parent | 4a2d30578b6611081fd6dc4866f82f7d43b3e70a (diff) |
dbshow (17jan22)
git-svn-id: svn://tug.org/texlive/trunk@61634 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/dbshow/dbshow.sty | 289 |
1 files changed, 207 insertions, 82 deletions
diff --git a/Master/texmf-dist/tex/latex/dbshow/dbshow.sty b/Master/texmf-dist/tex/latex/dbshow/dbshow.sty index 5543a6a09eb..ee3dc831c94 100644 --- a/Master/texmf-dist/tex/latex/dbshow/dbshow.sty +++ b/Master/texmf-dist/tex/latex/dbshow/dbshow.sty @@ -31,15 +31,16 @@ %% -------------------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} -\GetIdInfo$Id: dbshow.dtx 461d9bb 2022-01-14 02:50:24 +0800 Changkai Li <lichangkai225@qq.com> $ +\GetIdInfo$Id: dbshow.dtx 1a507c4 2022-01-17 22:53:24 +0800 Changkai Li <lichangkai225@qq.com> $ {Database to store and display data} \ProvidesExplPackage{\ExplFileName} - {\ExplFileDate}{1.4}{\ExplFileDescription} + {\ExplFileDate}{1.5}{\ExplFileDescription} \__kernel_dependency_version_check:nn { 2021-11-07 } { l3prop } \__kernel_dependency_version_check:nn { 2021-05-17 } { l3str } \__kernel_dependency_version_check:nn { 2021-05-10 } { l3clist } \cs_generate_variant:Nn \msg_warning:nnnn { nnnx } \cs_generate_variant:Nn \keys_set:nn { nv } +\cs_generate_variant:Nn \tl_put_right:Nn { Nv } \cs_generate_variant:Nn \clist_use:nn { xx } \cs_generate_variant:Nn \clist_use:nnnn { xxxx } \cs_generate_variant:Nn \clist_map_inline:nn { Vn } @@ -65,14 +66,14 @@ Database~'#1'~does~not~exist~\msg_line_context:. } \cs_new:Nn \__dbshow_check_database:n { - \prop_if_exist:cF { g__dbshow_attr_type_prop_#1 } + \prop_if_exist:cF { g__dbshow_attr_type_prop_\tl_to_str:n {#1} } { \msg_fatal:nnn { dbshow } { non-existent-database } {#1} } } \msg_new:nnn { dbshow } { non-existent-attr } { Attribute~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:. } \cs_new:Nn \__dbshow_check_attr:nn { - \prop_if_in:cnF { g__dbshow_attr_type_prop_#1 } {#2} + \prop_if_in:cnF { g__dbshow_attr_type_prop_\tl_to_str:n {#1} } {#2} { \msg_fatal:nnnn { dbshow } { non-existent-attr } {#1} {#2} } } \cs_generate_variant:Nn \__dbshow_check_attr:nn { nV } @@ -80,21 +81,22 @@ Style~'#1'~of~database~'#2'~does~not~exist~\msg_line_context:. } \cs_new:Nn \__dbshow_check_style:nn { - \tl_if_exist:cF { g__dbshow_style_opts_tl_#1_#2 } - { \msg_warning:nnnn { dbshow } { non-existent-style } {#1} {#2} } + \tl_if_exist:cF { g__dbshow_style_opts_tl_\tl_to_str:n {#1}_\tl_to_str:n {#2} } + { \msg_fatal:nnnn { dbshow } { non-existent-style } {#1} {#2} } } \msg_new:nnn { dbshow } { non-existent-cond } { Conditional~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:. } \cs_new:Nn \__dbshow_check_cond:nnn { - \tl_if_exist:cF { g__dbshow_filter_attr_#1_#2 } + \tl_if_exist:cF { g__dbshow_filter_attr_\tl_to_str:n {#1}_\tl_to_str:n {#2} } { \msg_fatal:nnnn { dbshow } { non-existent-cond } {#1} {#2} } } \msg_new:nnn { dbshow } { non-existent-filter } { Filter~'#2'~of~database~'#1'~does~not~exist~and~is~ignored~\msg_line_context:. } \cs_new:Nn \__dbshow_check_filter:nn { - \seq_if_exist:cF { g__dbshow_filter_run_seq_#1_#2 } { + \seq_if_exist:cF + { g__dbshow_filter_run_seq_\tl_to_str:n {#1}_\tl_to_str:n {#2} } { \str_if_eq:eeF {#2} { -none- } { \msg_warning:nnnx { dbshow } { non-existent-filter } {#1} {#2} } @@ -113,10 +115,10 @@ option~'sep'~should~contain~#1~items~but~only~#2~items~was~given,~ sep~=~\{#3\}~\msg_line_context:. } -\cs_new:Nn \__dbshow_sep_error:nnn { - \msg_error:nnnnn { dbshow } { wrong-seperator } {#1} {#2} {#3} +\cs_new:Nn \__dbshow_sep_fatal:nnn { + \msg_fatal:nnnnn { dbshow } { wrong-seperator } {#1} {#2} {#3} } -\cs_generate_variant:Nn \__dbshow_sep_error:nnn { xxx } +\cs_generate_variant:Nn \__dbshow_sep_fatal:nnn { xxx } \msg_new:nnn { dbshow } { unsupported-sort-type } { unsupported~sort~type:~'#1'~\msg_line_context:.~The~type~should~be~one~of~ \{str,~date,~int,~fp\}. @@ -125,7 +127,7 @@ #1\__dbshow_sep#2\__dbshow_sep#3|#4\__dbshow_stop { \__dbshow_check_type:n {#3} \prop_gput:cxx { g__dbshow_attr_type_prop_#1 } {#2} {#3} - \prop_gput:cxx { g__dbshow_default_map_#1 } {#2} {#4} + \prop_gput:cno { g__dbshow_default_map_#1 } {#2} {#4} } \cs_new_protected:Nn \__dbshow_process_attr_type_prop:n { \prop_gclear_new:c { g__dbshow_default_map_#1 } @@ -266,7 +268,7 @@ \regex_match:VVTF #2 #3 {#4} {#5} } \cs_generate_variant:Nn \__dbshow_filter_str:NNNnn { cccnn } -\cs_set_eq:NN \__dbshow_filter_tl:NNNnn \__dbshow_filter_str:NNNnn +\cs_gset_eq:NN \__dbshow_filter_tl:NNNnn \__dbshow_filter_str:NNNnn \cs_generate_variant:Nn \__dbshow_filter_tl:NNNnn { cccnn } \cs_new_protected:Npn \__dbshow_parse_date_cond:NNw #1#2#3|#4\__dbshow_stop { \clist_set_eq:Nc #1 { g__review_points_#3 } @@ -282,8 +284,11 @@ \__dbdate_set:xx { tmp_day1 } { \l__dbshow_filter_tmp_tl } \__dbdate_set:xx { tmp_day2 } {#3} \__dbdate_sub:nnN { tmp_day1 } { tmp_day2 } \l__dbshow_filter_diff_int - \clist_if_in:NxTF \l__dbshow_filter_tmp_clist - { \int_use:N \l__dbshow_filter_diff_int } {#4} {#5} + #5 + \clist_map_inline:Nn \l__dbshow_filter_tmp_clist { + \int_compare:nNnT { \l__dbshow_filter_diff_int } = {##1} + { #4 \clist_map_break: } + } } { \int_zero_new:N \l__dbshow_filter_tmpa_int \int_zero_new:N \l__dbshow_filter_tmpb_int @@ -313,11 +318,12 @@ } } \cs_generate_variant:Nn \__dbshow_filter_date:NNNnn { cccnn } -\cs_set:Nn \__dbshow_filter:nnn { +\cs_new_protected:Nn \__dbshow_filter:nnn { \tl_set_eq:Nc \l__dbshow_attr_tl { g__dbshow_filter_attr_tl_#1_#2 } \cs_set_eq:Nc \dbval { g__dbshow_data_#1_\l__dbshow_attr_tl _#3 } + \tl_set:Nx \l__dbshow_type_tl { \__dbshow_get_type:nV {#1} \l__dbshow_attr_tl } \use:c - { __dbshow_filter_\__dbshow_get_type:nV {#1} \l__dbshow_attr_tl :cccnn } + { __dbshow_filter_\l__dbshow_type_tl :cccnn } { g__dbshow_cond_star_bool_#1_#2 } { g__dbshow_filter_expr_tl_#1_#2 } { dbval } @@ -325,6 +331,8 @@ { \bool_gset_false:c { g__dbshow_filter_bool_#1_#2 } } } \cs_new_protected:Nn \__dbshow_new_conditional:nnnnn { + \__dbshow_check_database:n {#1} + \__dbshow_check_attr:nn {#1} {#3} \tl_gset:cn { g__dbshow_filter_attr_tl_#1_#2 } {#3} \tl_gset:cn { g__dbshow_filter_expr_tl_#1_#2 } {#4} \bool_if_exist:cF { g__dbshow_filter_bool_#1_#2 } @@ -337,49 +345,68 @@ \cs_gset:cn { g__dbshow_filter_hook_#1_#2:n } { \__dbshow_filter:nnn {#1} {#2} {##1} } - \seq_gput_right:cn { g__dbshow_cond_seq_#1 } {#2} + \bool_if_exist:cF { g__dbshow_cond_exist_bool_#1_#2 } + { \bool_set_false:c { g__dbshow_cond_exist_bool_#1_#2 } } + \bool_if:cF { g__dbshow_cond_exist_bool_#1_#2 } + { \seq_gput_right:cn { g__dbshow_cond_seq_#1 } {#2} } } \cs_new_protected:Nn \__dbshow_combine_conditional:nnn { \tl_gset_eq:cN { g__dbshow_filter_bool_tl_#1_#2 } \c_true_bool \seq_gclear_new:c { g__dbshow_filter_run_seq_#1_#2 } - \regex_extract_all:nnN { \w+ } {#3} \l__dbshow_cond_seq + \regex_extract_all:nnN { [^!=&<>()\ ]+ } {#3} \l__dbshow_cond_seq \seq_map_inline:Nn \l__dbshow_cond_seq { \seq_if_in:cnT { g__dbshow_cond_seq_#1 } {##1} { - \seq_gput_right:cn { g__dbshow_filter_run_seq_#1_#2 } + \seq_if_in:cnF { g__dbshow_filter_run_seq_#1_#2 } { g__dbshow_filter_hook_#1_##1:n } + { + \seq_gput_right:cn { g__dbshow_filter_run_seq_#1_#2 } + { g__dbshow_filter_hook_#1_##1:n } + } } } \tl_set:Nn \l__dbshow_cond_expr_tl {#3} \regex_replace_all:nnN - { \w+ } { \c{ g__dbshow_filter_bool_#1_\0 } } + { (\w|-|\d|\_)+ } + { \c{ g__dbshow_filter_bool_#1_\0 } } \l__dbshow_cond_expr_tl \tl_gset_eq:cN { g__dbshow_filter_bool_tl_#1_#2 } \l__dbshow_cond_expr_tl } \cs_generate_variant:Nn \__dbshow_combine_conditional:nnn { nVn } -\NewDocumentEnvironment { dbFilters } { m } { - \seq_gclear_new:c { g__dbshow_cond_seq_#1 } - \DeclareDocumentCommand { \dbNewConditional } { s m m m } { - \__dbshow_new_conditional:nnnnn - {#1} {##2} {##3} {##4} {##1} +\NewDocumentEnvironment { dbFilters } { s m } { + \seq_if_exist:cF { g__dbshow_cond_seq_#2 } + { \seq_new:c { g__dbshow_cond_seq_#2 } } + \DeclareDocumentCommand { \dbNewConditional } { s m m m O{} } { + \__dbshow_new_conditional:nnnnn {#2} {##2} {##3} {##4} {##1} + \IfValueT {#1} { + \dbCombCond{##2}{##2}[##5] + } } \DeclareDocumentCommand { \dbCombineConditionals } { m m O{} } { - \tl_gset:cn { g__dbshow_filter_info_tl_#1_##1 } {##3} - \__dbshow_combine_conditional:nnn {#1} {##1} {##2} + \tl_gset:cn { g__dbshow_filter_info_tl_#2_##1 } {##3} + \__dbshow_combine_conditional:nnn {#2} {##1} {##2} } + \cs_set_eq:NN \dbNewCond \dbNewConditional + \cs_set_eq:NN \dbCombCond \dbCombineConditionals } {} +\DeclareDocumentCommand { \dbNewRawFilter } { s m m m m O{} } { + \seq_if_exist:cF { g__dbshow_cond_seq_#3 } + { \seq_new:c { g__dbshow_cond_seq_#3 } } + \__dbshow_new_conditional:nnnnn {#3} {#2} {#4} {#5} {#1} + \tl_gset:cn { g__dbshow_filter_info_tl_#3_#2 } {#6} + \__dbshow_combine_conditional:nnn {#3} {#2} {#2} +} \NewDocumentCommand { \dbNewReviewPoints } { m m } { \clist_set:cn { g__review_points_#1 } {#2} } -\cs_set_eq:NN \dbIntAbs \int_abs:n -\cs_set_eq:NN \dbIntSign \int_sign:n -\cs_set_eq:NN \dbIntDivRound \int_div_round:nn -\cs_set_eq:NN \dbIntDivTruncate \int_div_truncate:nn -\cs_set_eq:NN \dbIntMax \int_max:nn -\cs_set_eq:NN \dbIntMin \int_min:nn -\cs_set_eq:NN \dbIntMod \int_mod:nn -\cs_set_eq:NN \dbFpSign \fp_sign:n -\cs_new:Nn \__dbshow_identity:n {#1} +\cs_gset_eq:NN \dbIntAbs \int_abs:n +\cs_gset_eq:NN \dbIntSign \int_sign:n +\cs_gset_eq:NN \dbIntDivRound \int_div_round:nn +\cs_gset_eq:NN \dbIntDivTruncate \int_div_truncate:nn +\cs_gset_eq:NN \dbIntMax \int_max:nn +\cs_gset_eq:NN \dbIntMin \int_min:nn +\cs_gset_eq:NN \dbIntMod \int_mod:nn +\cs_gset_eq:NN \dbFpSign \fp_sign:n \cs_new_protected:Nn \__dbshow_new_attr_style:nnn { \__dbshow_check_attr:nn {#2} {#3} \keys_define:nn { dbshow/style/#1/#3 } { @@ -391,6 +418,15 @@ g__dbshow_style_attr_after_tl_#1_#2_#3 }, after-code .initial:n = , + code .code:n = { + \bool_gset_false:c { g__dbshow_style_attr_exp_bool_#1_#2_#3 } + \cs_gset:cn { __dbshow_style_attr_code_#1_#2_#3:n } {##1} + }, + code .initial:n = {##1}, + code* .code:n = { + \bool_gset_true:c { g__dbshow_style_attr_exp_bool_#1_#2_#3 } + \cs_gset:cn { __dbshow_style_attr_code_#1_#2_#3:n } {##1} + }, sep .clist_gset:c = { g__dbshow_style_attr_sep_#1_#2_#3 }, @@ -402,15 +438,25 @@ g__dbshow_style_attr_item_after_tl_#1_#2_#3 }, item-after-code .initial:n = , + item-code .code:n = { + \bool_gset_false:c { g__dbshow_style_clist_item_exp_bool_#1_#2_#3 } + \cs_gset:cn { __dbshow_style_clist_item_code_#1_#2_#3:n } {##1} + }, + item-code .initial:n = {##1}, + item-code* .code:n = { + \bool_gset_true:c { g__dbshow_style_clist_item_exp_bool_#1_#2_#3 } + \cs_gset:cn { __dbshow_style_clist_item_code_#1_#2_#3:n } {##1} + }, zfill .bool_gset:c = { - g__dbshow_style_attr_zfill_bool_#1_#2_#3 + g__dbshow_style_date_zfill_bool_#1_#2_#3 }, zfill .initial:n = true, zfill .default:n = true, - wrapper .tl_gset:c = { - g__dbshow_style_attr_wrapper_#1_#2_#3 + format-code .code:n = { + \cs_gset:cn { __dbshow_style_date_format_code_#1_#2_#3:nnn } {##1} + \cs_generate_variant:cn + { __dbshow_style_date_format_code_#1_#2_#3:nnn } { xxx } }, - wrapper .initial:n = { \__dbshow_identity:n }, } \str_case_e:nn { \__dbshow_get_type:nn {#2} {#3} } { { clist } @@ -427,26 +473,34 @@ \str_set:Nx \l__dbshow_raw_filter_str { -raw\int_use:N \g__dbshow_raw_filter_int - } \tl_gset:cV { g__dbshow_filter_#1_#2 } \l__dbshow_raw_filter_str - \__dbshow_combine_conditional:nnn {#2} \l__dbshow_raw_filter_str {##1} + \__dbshow_combine_conditional:nVn {#2} \l__dbshow_raw_filter_str {##1} + }, + filter .tl_gset:c = { g__dbshow_filter_#1_#2 }, + filter .initial:n = -none-, + sort .clist_gset:c = { g__dbshow_sort_clist_#1_#2 }, + before-code .tl_gset:c = { g__dbshow_style_before_tl_#1_#2 }, + before-code .initial:n = , + after-code .tl_gset:c = { g__dbshow_style_after_tl_#1_#2 }, + after-code .initial:n = , + item-before-code .tl_gset:c = { g__dbshow_style_item_before_tl_#1_#2 }, + item-before-code .initial:n = , + item-after-code .tl_gset:c = { g__dbshow_style_item_after_tl_#1_#2 }, + item-after-code .initial:n = , + item-code .code:n = { + \bool_gset_false:c { g__dbshow_style_item_exp_bool_#1_#2 } + \tl_gset:cn { g__dbshow_style_item_tl_#1_#2 } {##1} + }, + item-code .initial:n = , + item-code* .code:n = { + \bool_gset_true:c { g__dbshow_style_item_exp_bool_#1_#2 } + \tl_gset:cn { g__dbshow_style_item_tl_#1_#2 } {##1} }, - filter .tl_gset:c = { g__dbshow_filter_#1_#2 }, - filter .initial:n = -none-, - sort .clist_gset:c = { g__dbshow_sort_clist_#1_#2 }, - before-code .tl_gset:c = { g__dbshow_style_before_tl_#1_#2 }, - before-code .initial:n = , - item-code .tl_gset:c = { g__dbshow_style_database_item_tl_#1_#2 }, - item-code .initial:n = , - after-code .tl_gset:c = { g__dbshow_style_after_tl_#1_#2 }, - after-code .initial:n = , - record-before-code .tl_gset:c = { g__dbshow_style_record_before_tl_#1_#2 }, - record-before-code .initial:n = , - record-after-code .tl_gset:c = { g__dbshow_style_record_after_tl_#1_#2 }, - record-after-code .initial:n = , } \prop_map_inline:cn { g__dbshow_attr_type_prop_#2 } { \__dbshow_new_attr_style:nnn {#1} {#2} {##1} } } \NewDocumentCommand { \dbNewStyle } { o m m +m } { + \__dbshow_check_database:n {#3} \tl_gset:cn { g__dbshow_style_opts_tl_#2_#3 } { #4, } \IfValueT {#1} { \tl_clear_new:N \l__dbshow_style_tmp_tl @@ -497,7 +551,7 @@ { \__dbshow_get_type:nV {#1} \l__dbshow_sort_attr_str } \clist_if_in:nVF { str, int, date, fp } { \l__dbshow_sort_type_tl } { - \msg_error:nnx { dbshow } { unsupported-sort-type } + \msg_fatal:nnx { dbshow } { unsupported-sort-type } { \l__dbshow_sort_type_tl } } \str_if_eq:eeT { \l__dbshow_sort_type_tl } { date } @@ -526,31 +580,33 @@ \__dbshow_sort_single: } } -\cs_new:Nn \__dbshow_clist_wrapper:NNn { - \exp_not:n { { #1#3#2 }, } +\cs_new:Nn \__dbshow_clist_wrapper:NNNNn { + \bool_if:NTF #4 + { \exp_not:n { { #1\exp_args:Nx#3{#5}#2 }, } } + { \exp_not:n { { #1#3{#5}#2 }, } } } -\cs_new:Nn \__dbshow_clist_use:NNNN { +\cs_new:Nn \__dbshow_clist_use:NNNNNN { \int_case:nnF { \clist_count:N #2 } { { 1 } { \clist_use:xx - { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNn #3 #4 } } + { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNNNn #3#4#5#6 } } { \clist_item:Nn #2 { 1 } } } { 3 } { \clist_use:xxxx - { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNn #3 #4 } } + { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNNNn #3#4#5#6 } } { \clist_item:Nn #2 { 1 } } { \clist_item:Nn #2 { 2 } } { \clist_item:Nn #2 { 3 } } } } { - \__dbshow_sep_error:xxx + \__dbshow_sep_fatal:xxx { 1~or~3 } { \clist_count:N #2 } { \clist_use:Nn #2 { ,~ } } } } -\cs_generate_variant:Nn \__dbshow_clist_use:NNNN { cccc } +\cs_generate_variant:Nn \__dbshow_clist_use:NNNNNN { cccccc } \cs_new:Nn \__dbshow_date_use:nNN { \int_case:nnF { \clist_count:N #2 } { { 1 } { @@ -571,7 +627,7 @@ { \clist_item:Nn #2 { 4 } } } } { - \__dbshow_sep_error:xxx + \__dbshow_sep_fatal:xxx { 1~or~4 } { \clist_count:N #2 } { \clist_use:Nn #2 { ,~ } } @@ -579,24 +635,39 @@ } \cs_generate_variant:Nn \__dbshow_date_use:nNN { ncc } \cs_new:Nn \__dbshow_use_data:nnnn { + \bool_if:cTF { g__dbshow_style_attr_exp_bool_#4_#1_#2 } { + \protected@edef\@dbshow@tmp{\__dbshow_use_data_raw:nnnn {#1} {#2} {#3} {#4}} + \exp_args:Nno + \use:c { __dbshow_style_attr_code_#4_#1_#2:n } { \@dbshow@tmp } + } { + \use:c { __dbshow_style_attr_code_#4_#1_#2:n } + { \__dbshow_use_data_raw:nnnn {#1} {#2} {#3} {#4} } + } +} +\cs_new:Nn \__dbshow_use_data_raw:nnnn { \str_case_e:nn { \prop_item:cn { g__dbshow_attr_type_prop_#1 } {#2} } { { str } { \str_use:c { g__dbshow_data_#1_#2_#3 } } - { tl } { \tl_use:c { g__dbshow_data_#1_#2_#3 } } + { tl } { \tl_use:c { g__dbshow_data_#1_#2_#3 } } { int } { \int_use:c { g__dbshow_data_#1_#2_#3 } } - { fp } { \fp_use:c { g__dbshow_data_#1_#2_#3 } } + { fp } { \fp_use:c { g__dbshow_data_#1_#2_#3 } } { clist } { - \__dbshow_clist_use:cccc { g__dbshow_data_#1_#2_#3 } + \__dbshow_clist_use:cccccc { g__dbshow_data_#1_#2_#3 } { g__dbshow_style_attr_sep_#4_#1_#2 } { g__dbshow_style_attr_item_before_tl_#4_#1_#2 } - { g__dbshow_style_attr_item_after_tl_#4_#1_#2 } + { g__dbshow_style_attr_item_after_ tl_#4_#1_#2 } + { __dbshow_style_clist_item_code_ #4_#1_#2:n } + { g__dbshow_style_clist_item_exp_bool_#4_#1_#2 } } { date } { - \exp_args:Nnx - \tl_use:c { g__dbshow_style_attr_wrapper_#4_#1_#2 } { + \cs_if_exist_use:cTF { __dbshow_style_date_format_code_#4_#1_#2:xxx } { + { \__dbdate_get_year:n { g__dbshow_data_#1_#2_#3 } } + { \__dbdate_get_month:n { g__dbshow_data_#1_#2_#3 } } + { \__dbdate_get_day:n { g__dbshow_data_#1_#2_#3 } } + } { \__dbshow_date_use:ncc { g__dbshow_data_#1_#2_#3 } { g__dbshow_style_attr_sep_#4_#1_#2 } - { g__dbshow_style_attr_zfill_bool_#4_#1_#2 } + { g__dbshow_style_date_zfill_bool_#4_#1_#2 } } } } @@ -619,28 +690,51 @@ } } \cs_new_protected:Nn \__dbshow_show_set_counter:N { - \tl_set:Nx \dbalph { \int_to_alph:n {#1} } - \tl_set:Nx \dbAlph { \int_to_Alph:n {#1} } + \tl_set:Nx \dbalph { \int_to_alph:n {#1} } + \tl_set:Nx \dbAlph { \int_to_Alph:n {#1} } \tl_set:Nx \dbarabic { \int_to_arabic:n {#1} } - \tl_set:Nx \dbRoman { \int_to_Roman:n {#1} } - \tl_set:Nx \dbroman { \int_to_roman:n {#1} } + \tl_set:Nx \dbRoman { \int_to_Roman:n {#1} } + \tl_set:Nx \dbroman { \int_to_roman:n {#1} } +} +\cs_new_protected:Nn \__dbshow_show_set_if_last:NN { + \prg_set_conditional:Nnn \__dbshow_show_if_last: { T, F, TF } { + \int_compare:nNnTF {#1} = {#2} + { \prg_return_true: } + { \prg_return_false: } + } + \cs_set_eq:NN \dbIfLastT \__dbshow_show_if_last:T + \cs_set_eq:NN \dbIfLastF \__dbshow_show_if_last:F + \cs_set_eq:NN \dbIfLastTF \__dbshow_show_if_last:TF } \cs_new_protected:Nn \__dbshow_show_item:nnN { \int_zero_new:N \l__dbshow_show_int + \int_zero_new:N \l__dbshow_show_count_int + \int_set:Nn \l__dbshow_show_count_int { \clist_count:N #3 } + \tl_clear_new:N \l__dbshow_item_tl \clist_map_inline:Nn #3 { \int_incr:N \l__dbshow_show_int - \__dbshow_show_set_counter:N \l__dbshow_show_int + \__dbshow_show_set_if_last:NN \l__dbshow_show_int \l__dbshow_show_count_int + \__dbshow_show_set_counter:N \l__dbshow_show_int \tl_set:Nn \dbIndex {##1} \cs_set:Npn \dbuse ####1 { \__dbshow_check_attr:nn {#2} {####1} \tl_use:c { g__dbshow_style_attr_before_tl_#1_#2_####1 } \__dbshow_use_data:nnnn {#2} {####1} {##1} {#1} - \tl_use:c { g__dbshow_style_attr_after_tl_#1_#2_####1 } + \tl_use:c { g__dbshow_style_attr_after_ tl_#1_#2_####1 } + } + \bool_if:cTF { g__dbshow_style_item_exp_bool_#1_#2 } { + \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_before_tl_#1_#2 }} + \tl_put_right:No \l__dbshow_item_tl { \@dbshow@tmp } + \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_ tl_#1_#2 }} + \tl_put_right:No \l__dbshow_item_tl { \@dbshow@tmp } + \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_after_ tl_#1_#2 }} + } { + \tl_use:c { g__dbshow_style_item_before_tl_#1_#2 } + \tl_use:c { g__dbshow_style_item_ tl_#1_#2 } + \tl_use:c { g__dbshow_style_item_after_ tl_#1_#2 } } - \tl_use:c { g__dbshow_style_record_before_tl_#1_#2 } - \tl_use:c { g__dbshow_style_database_item_tl_#1_#2 } - \tl_use:c { g__dbshow_style_record_after_tl_#1_#2 } } + \l__dbshow_item_tl } \cs_new_protected:Nn \__dbshow_show_set_cond:N { \prg_set_conditional:Nnn \__dbshow_if_empty: { T, F, TF } { @@ -658,6 +752,7 @@ \__dbshow_show_filter:nnN {#2} {#3} \l__dbshow_show_index_clist \clist_if_empty:cF { g__dbshow_sort_clist_#1_#2 } { \__dbshow_sort:nNn {#2} \l__dbshow_show_index_clist {#1} } + \__dbshow_show_set_cond:N \l__dbshow_show_index_clist \tl_use:c { g__dbshow_style_before_tl_#1_#2 } \__dbshow_show_item:nnN {#1} {#2} \l__dbshow_show_index_clist \tl_use:c { g__dbshow_style_after_tl_#1_#2 } @@ -665,9 +760,25 @@ \cs_generate_variant:Nn \__dbshow_show:nnn { nnv } \NewDocumentCommand { \dbshow } { m m } { \__dbshow_check_database:n {#2} - \__dbshow_check_filter:nv {#2} { g__dbshow_filter_#1_#2 } - \__dbshow_show:nnv {#1} {#2} { g__dbshow_filter_#1_#2 } + \__dbshow_check_style:nn {#1} {#2} + \__dbshow_check_filter:nv {#2} { g__dbshow_filter_#1_#2 } + \__dbshow_show:nnv {#1} {#2} { g__dbshow_filter_#1_#2 } +} +\msg_new:nnn { dbshow } { wrong-date-sep } { + can~not~parse~the~date~'#1'~with~the~global~date~separator~'#2'~ + \msg_line_context:.~Please~set~the~correct~date~separator~with~ + \dbdatesep. +} +\cs_new:Nn \__dbdate_check_date_sep:nn { + \int_zero_new:N \l__dbdate_sep_int + \tl_map_inline:nn {#1} { + \tl_if_eq:nnT {#2} {##1} { \int_incr:N \l__dbdate_sep_int } + \int_compare:nNnT { \l__dbdate_sep_int } > { 2 } { \tl_map_break: } + } + \int_compare:nNnF { \l__dbdate_sep_int } = { 2 } + { \msg_fatal:nnnn { dbshow } { wrong-date-sep } {#1} {#2} } } +\cs_generate_variant:Nn \__dbdate_check_date_sep:nn { nV } \prg_new_conditional:Nnn \__dbdate_if_leap:n { T, F, TF, p } { \bool_if:nTF { \int_compare_p:nNn { \int_mod:nn {#1} { 400 } } = { 0 } || @@ -752,6 +863,18 @@ \__dbdate_ginit:n {#1} } \cs_generate_variant:Nn \__dbdate_gclear_new:n { x } +\cs_new:Nn \__dbdate_get_year:n { + \int_use:c { __dbdate_year_#1 } +} +\cs_new:Nn \__dbdate_get_month:n { + \int_use:c { __dbdate_month_#1 } +} +\cs_new:Nn \__dbdate_get_day:n { + \int_use:c { __dbdate_day_#1 } +} +\cs_generate_variant:Nn \__dbdate_get_year:n { x } +\cs_generate_variant:Nn \__dbdate_get_month:n { x } +\cs_generate_variant:Nn \__dbdate_get_day:n { x } \cs_new_protected:Nn \__dbdate_set:nnnn { \int_set:cn { __dbdate_year_#1 } {#2} \int_set:cn { __dbdate_month_#1 } {#3} @@ -778,10 +901,12 @@ \cs_gset_eq:NN \dbdatesep \__dbdate_set_sep:n \dbdatesep{/} \cs_new_protected:Nn \__dbdate_set:nn { + \__dbdate_check_date_sep:nV {#2} \g__dbdate_sep_tl \__dbdate_set:w #1\__dbdate_sep#2\__dbdate_stop } \cs_generate_variant:Nn \__dbdate_set:nn { xx } \cs_new_protected:Nn \__dbdate_gset:nn { + \__dbdate_check_date_sep:nV {#2} \g__dbdate_sep_tl \__dbdate_gset:w #1\__dbdate_sep#2\__dbdate_stop } \cs_generate_variant:Nn \__dbdate_gset:nn { xx } |