diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/ducksay/ducksay.animals.tex | 63 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ducksay/ducksay.code.v1.tex | 27 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ducksay/ducksay.code.v2.tex | 218 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ducksay/ducksay.sty | 150 |
4 files changed, 270 insertions, 188 deletions
diff --git a/Master/texmf-dist/tex/latex/ducksay/ducksay.animals.tex b/Master/texmf-dist/tex/latex/ducksay/ducksay.animals.tex index 32f8df1aa2d..e0077f6f47b 100644 --- a/Master/texmf-dist/tex/latex/ducksay/ducksay.animals.tex +++ b/Master/texmf-dist/tex/latex/ducksay/ducksay.animals.tex @@ -104,9 +104,9 @@ (") >-( : )-< (__:__)}%<<< -\AddAnimal{hedgehog}%>>> -{ \ .\|//||\||. - \ |/\/||/|//|/| +\AddAnimal[tail-symbol=s]{hedgehog}%>>> +{ s .\|//||\||. + s |/\/||/|//|/| /. `|/\\|/||/|| o__,_|//|/||\||'}%<<< \AddAnimal{kangaroo}%>>> @@ -117,10 +117,10 @@ \,\ / \\ // \\ ,/' `\_,}%<<< -\AddAnimal{rabbit}%>>> -{ \ / \`\ __ - \ | \ `\ /`/ \ - \ \_/`\ \-"-/` /\ \ +\AddAnimal[tail-symbol=s,tail-count=3]{rabbit}%>>> +{ s / \`\ __ + s | \ `\ /`/ \ + s \_/`\ \-"-/` /\ \ | | \ | (d b) \_/ / \ @@ -143,10 +143,10 @@ \ _// (')---. _/-_( )o}%<<< -\AddAnimal{dragon}%>>> -{ \ / \ //\ - \ |\___/| / \// \\ - \ /0 0 \__ / // | \ \ +\AddAnimal[tail-symbol=s,tail-count=3]{dragon}%>>> +{ s / \ //\ + s |\___/| / \// \\ + s /0 0 \__ / // | \ \ / / \/_/ // | \ \ @_^_@'/ \/_ // | \ \ //_^_/ \/_ // | \ \ @@ -201,14 +201,14 @@ \_| / / / / _// _// /_| /_|}%<<< -\AddAnimal{whale}%>>> -{ \ |-. - \ .-""-._ \ \.--| - \ / `-..__) ,-' +\AddAnimal[tail-count=3,tail-symbol=s]{whale}%>>> +{ s |-. + s .-""-._ \ \.--| + s / `-..__) ,-' | . / \--.__, .__.,' `-.___'._\_.'}%<<< -\AddAnimal{yoda}%>>> +\AddAnimal[tail-count=3]{yoda}%>>> { \ \ ____ \ _.' : `._ @@ -245,7 +245,7 @@ :-""-.`./-.' / `.___.' \ `t ._ / "-.t-._:'}%<<< -\AddAnimal{yoda-head}%>>> +\AddAnimal[tail-count=3]{yoda-head}%>>> { \ \ ____ \ _.' : `._ @@ -299,6 +299,35 @@ /_ \O========O/ _\ `--...__|`-._ _.-'|__...--' | `' |}%<<< +\AddAnimal[tail-symbol=|,tail-count=1]{crusader}%>>> +{ | +\[T]/} +\csname bool_if:cT\endcsname {l_ducksay_version_one_bool} + {\AnimalOptions{crusader}{tail-1=|,rel-align=c}} +\csname bool_if:cT\endcsname {l_ducksay_version_two_bool} + {\AnimalOptions{crusader}{tail-1=|,body-align=c}}%<<< +\AddAnimal[tail-count=3]{knight}%>>> +{ \ + \ ,-"""-. + \ | === | + ) | ( + .=='\" "/`==. + .'\ (`:') /`. + _/_ |_.-' : `-._|__\_ + <___>'\ : / `<___> + / / >=======< / / + _/ .' / ,-:-. \/=,' +/ _/ |__/v^v^v\__) \ +\(\) |V^V^V^V^V|\_/ + (\\ \`---|---'/ + \\ \-._|_,-/ + \\ |__|__| + \\ <___X___> + \\ \..|../ + \\ \ | / + \\ /V|V\ + \|/ | \ + '--' `--`}%<<< %% %% %% End of file `ducksay.animals.tex'. diff --git a/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v1.tex b/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v1.tex index a5a1bab3414..1d6487c7674 100644 --- a/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v1.tex +++ b/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v1.tex @@ -125,29 +125,24 @@ \group_end: } \cs_generate_variant:Nn \ducksay_print:nn { nV } -\cs_new:Npn \ducksay_prepare_say_and_think:n #1 - { - \int_set:Nn \l_ducksay_msg_width_int { -\c_max_int } - \int_set:Nn \l_ducksay_msg_height_int { -\c_max_int } - \keys_set:nn { ducksay } { #1 } - \tl_if_empty:NT \l_ducksay_animal_tl - { \keys_set:nn { ducksay } { default_animal } } - } -\NewDocumentCommand \ducksay { O{} m } +\cs_new:Npn \ducksay_say_and_think:nn #1 #2 { \group_begin: - \tl_set:Nn \l_ducksay_say_or_think_tl { say } - \ducksay_prepare_say_and_think:n { #1 } + \int_set:Nn \l_ducksay_msg_width_int { -\c_max_int } + \int_set:Nn \l_ducksay_msg_height_int { -\c_max_int } + \keys_set:nn { ducksay } { #1 } + \tl_if_empty:NT \l_ducksay_animal_tl + { \keys_set:nn { ducksay } { default_animal } } \ducksay_print:nV { #2 } \l_ducksay_rel_align_tl \group_end: } +\NewDocumentCommand \ducksay { O{} m } + { + \ducksay_say_and_think:nn { #1 } { #2 } + } \NewDocumentCommand \duckthink { O{} m } { - \group_begin: - \tl_set:Nn \l_ducksay_say_or_think_tl { think } - \ducksay_prepare_say_and_think:n { #1 } - \ducksay_print:nV { #2 } \l_ducksay_rel_align_tl - \group_end: + \ducksay_say_and_think:nn { think, #1 } { #2 } } %% %% diff --git a/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v2.tex b/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v2.tex index fbd1143b637..413e221bbaa 100644 --- a/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v2.tex +++ b/Master/texmf-dist/tex/latex/ducksay/ducksay.code.v2.tex @@ -43,6 +43,8 @@ The~specified~message~alignment~`\exp_not:n { #1 }`~is~unknown.~ `l`~is~used~as~fallback. } +\msg_new:nnn { ducksay } { v1-key-only } + { The~`\l_keys_key_tl`~key~is~only~available~for~`version=1`. } \tl_new:N \l_ducksay_msg_align_vbox_tl \box_new:N \l_ducksay_msg_box \bool_new:N \l_ducksay_eat_arg_box_bool @@ -76,6 +78,7 @@ ,wd* .initial:n = -\c_max_dim ,wd* .value_required:n = true ,none .bool_set:N = \l_ducksay_no_body_bool + ,no-bubble .bool_set:N = \l_ducksay_no_bubble_bool ,body-mirrored .bool_set:N = \l_ducksay_mirrored_body_bool ,ignore-body .bool_set:N = \l_ducksay_ignored_body_bool ,body-x .dim_set:N = \l_ducksay_body_x_offset_dim @@ -137,7 +140,7 @@ ,bubble-bot-kern .initial:n = { .2ex } ,bubble-bot-kern .value_required:n = true ,bubble-side-kern .tl_set:N = \l_ducksay_bubble_side_kern_tl - ,bubble-side-kern .initial:n = { 0.2em } + ,bubble-side-kern .initial:n = { .2em } ,bubble-side-kern .value_required:n = true ,bubble-delim-top .tl_set:N = \l_ducksay_bubble_delim_top_tl ,bubble-delim-left-1 .tl_set:N = \l_ducksay_bubble_delim_left_a_tl @@ -159,6 +162,12 @@ ,bubble-delim-right-4 .initial:n = / ,strip-spaces .bool_set:N = \l_ducksay_msg_strip_spaces_bool } +\clist_map_inline:nn + { align, rel-align } + { + \keys_define:nn { ducksay } + { #1 .code:n = \msg_error:nn { ducksay } { v1-key-only } } + } \cs_new:Npn \ducksay_evaluate_message_alignment_fixed_width_common: { \str_case:Vn \l_ducksay_msg_align_tl @@ -210,6 +219,7 @@ } \cs_new:Npn \ducksay_digest_options:n #1 { + \group_begin: \keys_set:nn { ducksay } { #1 } \tl_if_empty:NT \l_ducksay_animal_tl { \keys_set:nn { ducksay } { default_animal } } @@ -264,6 +274,7 @@ } \cs_set_eq:NN \ducksay_eat_argument:w \ducksay_eat_argument_tabular:w } + \ducksay_eat_argument:w } \cs_new:Npn \ducksay_set_bubble_top_kern: { @@ -285,88 +296,119 @@ } \cs_new_protected:Npn \ducksay_shipout: { - \hbox_set:Nn \l_ducksay_tmpa_box - { \l_ducksay_bubble_fount_tl \l_ducksay_bubble_delim_top_tl } - \int_set:Nn \l_ducksay_msg_width_int - { - \fp_eval:n - { - ceil - ( \box_wd:N \l_ducksay_msg_box / \box_wd:N \l_ducksay_tmpa_box ) - } - } - \group_begin: - \l_ducksay_bubble_fount_tl - \exp_args:NNNx - \group_end: - \int_set:Nn \l_ducksay_msg_height_int + \hcoffin_set:Nn \l_ducksay_msg_coffin { \box_use:N \l_ducksay_msg_box } + \bool_if:NF \l_ducksay_no_bubble_bool { - \int_max:nn + \hbox_set:Nn \l_ducksay_tmpa_box + { \l_ducksay_bubble_fount_tl \l_ducksay_bubble_delim_top_tl } + \int_set:Nn \l_ducksay_msg_width_int { \fp_eval:n { ceil ( - ( - \box_ht:N \l_ducksay_msg_box - + \box_dp:N \l_ducksay_msg_box - ) - / ( \arraystretch * \baselineskip ) + \box_wd:N \l_ducksay_msg_box / \box_wd:N \l_ducksay_tmpa_box ) } - + \l_ducksay_vpad_int } - { \l_ducksay_msg_height_int } - } - \hcoffin_set:Nn \l_ducksay_bubble_open_coffin - { + \group_begin: \l_ducksay_bubble_fount_tl - \begin{tabular}{@{}l@{}} - \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int } - { - \l_ducksay_bubble_delim_left_a_tl - } - { - \l_ducksay_bubble_delim_left_b_tl\\ - \int_step_inline:nnn - { 3 } { \l_ducksay_msg_height_int } + \exp_args:NNNx + \group_end: + \int_set:Nn \l_ducksay_msg_height_int + { + \int_max:nn + { + \fp_eval:n + { + ceil + ( + ( + \box_ht:N \l_ducksay_msg_box + + \box_dp:N \l_ducksay_msg_box + ) + / ( \arraystretch * \baselineskip ) + ) + } + + \l_ducksay_vpad_int + } + { \l_ducksay_msg_height_int } + } + \hcoffin_set:Nn \l_ducksay_bubble_open_coffin + { + \l_ducksay_bubble_fount_tl + \begin{tabular}{@{}l@{}} + \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int } { - \kern-\l_ducksay_bubble_side_kern_tl - \l_ducksay_bubble_delim_left_c_tl - \\ + \l_ducksay_bubble_delim_left_a_tl } - \l_ducksay_bubble_delim_left_d_tl - } - \end{tabular} - } - \hcoffin_set:Nn \l_ducksay_bubble_close_coffin - { - \l_ducksay_bubble_fount_tl - \begin{tabular}{@{}r@{}} - \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int } - { - \l_ducksay_bubble_delim_right_a_tl - } - { - \l_ducksay_bubble_delim_right_b_tl \\ - \int_step_inline:nnn - { 3 } { \l_ducksay_msg_height_int } { - \l_ducksay_bubble_delim_right_c_tl - \kern-\l_ducksay_bubble_side_kern_tl - \\ + \l_ducksay_bubble_delim_left_b_tl\\ + \int_step_inline:nnn + { 3 } { \l_ducksay_msg_height_int } + { + \kern-\l_ducksay_bubble_side_kern_tl + \l_ducksay_bubble_delim_left_c_tl + \\ + } + \l_ducksay_bubble_delim_left_d_tl } - \l_ducksay_bubble_delim_right_d_tl - } - \end{tabular} - } - \hcoffin_set:Nn \l_ducksay_bubble_top_coffin - { - \l_ducksay_bubble_fount_tl - \int_step_inline:nn { \l_ducksay_msg_width_int + \l_ducksay_hpad_int } - { \l_ducksay_bubble_delim_top_tl } + \end{tabular} + } + \hcoffin_set:Nn \l_ducksay_bubble_close_coffin + { + \l_ducksay_bubble_fount_tl + \begin{tabular}{@{}r@{}} + \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int } + { + \l_ducksay_bubble_delim_right_a_tl + } + { + \l_ducksay_bubble_delim_right_b_tl \\ + \int_step_inline:nnn + { 3 } { \l_ducksay_msg_height_int } + { + \l_ducksay_bubble_delim_right_c_tl + \kern-\l_ducksay_bubble_side_kern_tl + \\ + } + \l_ducksay_bubble_delim_right_d_tl + } + \end{tabular} + } + \hcoffin_set:Nn \l_ducksay_bubble_top_coffin + { + \l_ducksay_bubble_fount_tl + \int_step_inline:nn + { \l_ducksay_msg_width_int + \l_ducksay_hpad_int } + { \l_ducksay_bubble_delim_top_tl } + } + \dim_set:Nn \l_ducksay_hpad_dim + { + ( + \coffin_wd:N \l_ducksay_bubble_top_coffin + - \coffin_wd:N \l_ducksay_msg_coffin + ) / 2 + } + \coffin_join:NnnNnnnn + \l_ducksay_msg_coffin { l } { vc } + \l_ducksay_bubble_open_coffin { r } { vc } + { - \l_ducksay_hpad_dim } { \c_zero_dim } + \coffin_join:NnnNnnnn + \l_ducksay_msg_coffin { r } { vc } + \l_ducksay_bubble_close_coffin { l } { vc } + { \l_ducksay_hpad_dim } { \c_zero_dim } + \ducksay_set_bubble_top_kern: + \ducksay_set_bubble_bottom_kern: + \coffin_join:NnnNnnnn + \l_ducksay_msg_coffin { hc } { t } + \l_ducksay_bubble_top_coffin { hc } { b } + { \c_zero_dim } { \l_ducksay_bubble_top_kern_dim } + \coffin_join:NnnNnnnn + \l_ducksay_msg_coffin { hc } { b } + \l_ducksay_bubble_top_coffin { hc } { t } + { \c_zero_dim } { \l_ducksay_bubble_bottom_kern_dim } } - \hcoffin_set:Nn \l_ducksay_msg_coffin { \box_use:N \l_ducksay_msg_box } \bool_if:NF \l_ducksay_no_body_bool { \hcoffin_set:Nn \l_ducksay_body_coffin @@ -387,34 +429,6 @@ { r } { \tl_set:Nn \l_ducksay_body_to_msg_align_body_tl { l } } } } - } - \dim_set:Nn \l_ducksay_hpad_dim - { - ( - \coffin_wd:N \l_ducksay_bubble_top_coffin - - \coffin_wd:N \l_ducksay_msg_coffin - ) / 2 - } - \coffin_join:NnnNnnnn - \l_ducksay_msg_coffin { l } { vc } - \l_ducksay_bubble_open_coffin { r } { vc } - { - \l_ducksay_hpad_dim } { \c_zero_dim } - \coffin_join:NnnNnnnn - \l_ducksay_msg_coffin { r } { vc } - \l_ducksay_bubble_close_coffin { l } { vc } - { \l_ducksay_hpad_dim } { \c_zero_dim } - \ducksay_set_bubble_top_kern: - \ducksay_set_bubble_bottom_kern: - \coffin_join:NnnNnnnn - \l_ducksay_msg_coffin { hc } { t } - \l_ducksay_bubble_top_coffin { hc } { b } - { \c_zero_dim } { \l_ducksay_bubble_top_kern_dim } - \coffin_join:NnnNnnnn - \l_ducksay_msg_coffin { hc } { b } - \l_ducksay_bubble_top_coffin { hc } { t } - { \c_zero_dim } { \l_ducksay_bubble_bottom_kern_dim } - \bool_if:NF \l_ducksay_no_body_bool - { \bool_if:NTF \l_ducksay_ignored_body_bool { \coffin_attach:NVnNVnnn } { \coffin_join:NVnNVnnn } @@ -485,22 +499,14 @@ \cs_generate_variant:Nn \coffin_join:NnnNnnnn { NVnNVnnn } \cs_generate_variant:Nn \coffin_attach:NnnNnnnn { NVnNVnnn } \cs_generate_variant:Nn \coffin_typeset:Nnnnn { NVVnn } -\cs_generate_variant:Nn \tl_if_eq:nnT { VnT } \cs_generate_variant:Nn \str_case:nn { Vn } -\cs_generate_variant:Nn \regex_replace_all:NnN { Nnc } \NewDocumentCommand \ducksay { O{} } { - \group_begin: - \tl_set:Nn \l_ducksay_say_or_think_tl { say } - \ducksay_digest_options:n { #1 } - \ducksay_eat_argument:w + \ducksay_digest_options:n { #1 } } \NewDocumentCommand \duckthink { O{} } { - \group_begin: - \tl_set:Nn \l_ducksay_say_or_think_tl { think } - \ducksay_digest_options:n { #1 } - \ducksay_eat_argument:w + \ducksay_digest_options:n { think, #1 } } %% %% diff --git a/Master/texmf-dist/tex/latex/ducksay/ducksay.sty b/Master/texmf-dist/tex/latex/ducksay/ducksay.sty index 6d140038d95..98d096c4175 100644 --- a/Master/texmf-dist/tex/latex/ducksay/ducksay.sty +++ b/Master/texmf-dist/tex/latex/ducksay/ducksay.sty @@ -35,8 +35,8 @@ \NeedsTeXFormat{LaTeX2e} \RequirePackage{xparse,l3keys2e} -\def\ducksay@version{2.2.1} -\def\ducksay@date{2019-01-08} +\def\ducksay@version{2.3} +\def\ducksay@date{2019-01-13} \ProvidesExplPackage {ducksay} {\ducksay@date} @@ -44,22 +44,20 @@ \int_new:N \l_ducksay_msg_width_int \int_new:N \l_ducksay_msg_height_int +\int_new:N \l_ducksay_tail_symbol_count_int \seq_new:N \l_ducksay_msg_lines_seq -\tl_new:N \l_ducksay_say_or_think_tl \tl_new:N \l_ducksay_align_tl \tl_new:N \l_ducksay_msg_align_tl \tl_new:N \l_ducksay_animal_tl \tl_new:N \l_ducksay_body_tl \tl_new:N \l_ducksay_bubble_tl \tl_new:N \l_ducksay_tmpa_tl -\bool_new:N \l_ducksay_also_add_think_bool +\tl_new:N \l_ducksay_tail_symbol_out_one_tl +\tl_new:N \l_ducksay_tail_symbol_out_two_tl +\tl_new:N \l_ducksay_tail_symbol_in_tl \bool_new:N \l_ducksay_version_one_bool \bool_new:N \l_ducksay_version_two_bool \box_new:N \l_ducksay_tmpa_box -\regex_const:Nn \c_ducksay_first_regex { \A(.\s*)\\ } -\regex_const:Nn \c_ducksay_second_regex { \A(.[^\c{null}]*\c{null}\s*)\\ } -\regex_const:Nn \c_ducksay_third_regex { - \A(.[^\c{null}]*\c{null}[^\c{null}]*\c{null}\s*)\\ } \regex_const:Nn \c_ducksay_textcolor_regex { \cO(?:\\textcolor\{(.*?)\}\{(.*?)\}) } \regex_const:Nn \c_ducksay_color_delim_regex @@ -68,6 +66,8 @@ { \cO(?:\\color\{(.*?)\}) } \msg_new:nnn { ducksay } { load-time-only } { The~`#1`~key~is~to~be~used~only~during~package~load~time. } +\msg_new:nnn { ducksay } { deprecated-key } + { The~`\l_keys_key_tl`~key~is~deprecated.~Sorry~for~the~inconvenience. } \keys_define:nn { ducksay } { ,bubble .tl_set:N = \l_ducksay_bubble_tl @@ -91,7 +91,17 @@ ,rel-align .value_required:n = true ,ligatures .tl_set:N = \l_ducksay_ligatures_tl ,ligatures .initial:n = { `<>,'- } - ,add-think .bool_set:N = \l_ducksay_also_add_think_bool + ,tail-1 .tl_set:N = \l_ducksay_tail_symbol_out_one_tl + ,tail-1 .initial:x = \c_backslash_str + ,tail-2 .tl_set:N = \l_ducksay_tail_symbol_out_two_tl + ,tail-2 .initial:x = \c_backslash_str + ,no-tail .meta:n = { tail-1 = { ~ }, tail-2 = { ~ } } + ,think .meta:n = { tail-1 = { O }, tail-2 = { o } } + ,say .code:n = + { + \exp_args:Nx \DucksayOptions + { tail-1 = { \c_backslash_str }, tail-2 = { \c_backslash_str } } + } ,version .choice: ,version / 1 .code:n = { @@ -104,23 +114,23 @@ \bool_set_true:N \l_ducksay_version_two_bool } ,version .initial:n = 2 + ,add-think .code:n = \msg_error:nn { ducksay } { deprecated-key } } \ProcessKeysOptions { ducksay } \keys_define:nn { ducksay } { version .code:n = \msg_error:nnn { ducksay } { load-time-only } { version } } -\cs_generate_variant:Nn \tl_if_eq:nnT { VnT } -\cs_new_protected:Npn \ducksay_create_think_animal:n #1 +\keys_define:nn { ducksay / add-animal } { - \group_begin: - \tl_set_eq:Nc \l_ducksay_tmpa_tl { g_ducksay_animal_say_#1_tl } - \regex_replace_once:NnN \c_ducksay_first_regex { \1O } \l_ducksay_tmpa_tl - \regex_replace_once:NnN \c_ducksay_second_regex { \1o } \l_ducksay_tmpa_tl - \regex_replace_once:NnN \c_ducksay_third_regex { \1o } \l_ducksay_tmpa_tl - \tl_gset_eq:cN { g_ducksay_animal_think_#1_tl } \l_ducksay_tmpa_tl - \group_end: + ,tail-symbol .code:n = + \tl_set:Nx \l_ducksay_tail_symbol_in_tl { \tl_to_str:n { #1 } } + ,tail-symbol .initial:o = \c_backslash_str + ,tail-count .int_set:N = \l_ducksay_tail_symbol_count_int + ,tail-count .initial:n = 2 } +\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn } +\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn } \cs_new_protected:Npx \ducksay_replace_verb_newline:Nn #1 #2 { \tl_replace_all:Nnn #1 { \char_generate:nn { 13 } { 12 } } { #2 } @@ -136,25 +146,63 @@ \ducksay_replace_verb_newline_newline:Nn \ProcessedArgument { #2 } \ducksay_replace_verb_newline:Nn \ProcessedArgument { #1 } } -\cs_new_protected:Npn \ducksay_add_animal_inner:nn #1 #2 +\cs_new_protected:Npn \ducksay_add_animal_inner:nnnn #1 #2 #3 #4 { - \tl_set:Nn \l_ducksay_tmpa_tl { \ #2 } - \tl_map_inline:Nn \l_ducksay_ligatures_tl - { \tl_replace_all:Nnn \l_ducksay_tmpa_tl { ##1 } { { ##1 } } } - \ducksay_replace_verb_newline:Nn \l_ducksay_tmpa_tl { \tabularnewline\null } - \tl_gset_eq:cN { g_ducksay_animal_say_#1_tl } \l_ducksay_tmpa_tl - \keys_define:nn { ducksay } + \group_begin: + \keys_set:nn { ducksay / add-animal } { #1 } + \tl_set:Nn \l_ducksay_tmpa_tl { \ #3 } + \int_compare:nNnTF { \l_ducksay_tail_symbol_count_int } < { \c_zero_int } + { + \tl_replace_once:NVn + \l_ducksay_tmpa_tl + \l_ducksay_tail_symbol_in_tl + \l_ducksay_tail_symbol_out_one_tl + \tl_replace_all:NVn + \l_ducksay_tmpa_tl + \l_ducksay_tail_symbol_in_tl + \l_ducksay_tail_symbol_out_two_tl + } + { + \int_compare:nNnT { \l_ducksay_tail_symbol_count_int } > + { \c_zero_int } + { + \tl_replace_once:NVn + \l_ducksay_tmpa_tl + \l_ducksay_tail_symbol_in_tl + \l_ducksay_tail_symbol_out_one_tl + \int_step_inline:nnn { 2 } { \l_ducksay_tail_symbol_count_int } + { + \tl_replace_once:NVn + \l_ducksay_tmpa_tl + \l_ducksay_tail_symbol_in_tl + \l_ducksay_tail_symbol_out_two_tl + } + } + } + \tl_map_inline:Nn \l_ducksay_ligatures_tl + { \tl_replace_all:Nnn \l_ducksay_tmpa_tl { ##1 } { { ##1 } } } + \ducksay_replace_verb_newline:Nn \l_ducksay_tmpa_tl + { \tabularnewline\null } + \exp_args:NNnV + \group_end: + \tl_set:cn { l_ducksay_animal_#2_tl } \l_ducksay_tmpa_tl + \exp_args:Nnx \keys_define:nn { ducksay } { - #1 .code:n = + #2 .code:n = { - \tl_if_exist:cF - { g_ducksay_animal_ \l_ducksay_say_or_think_tl _#1_tl } - { \ducksay_create_think_animal:n { #1 } } - \tl_set_eq:Nc \l_ducksay_animal_tl - { g_ducksay_animal_ \l_ducksay_say_or_think_tl _#1_tl } + \exp_not:n { \tl_set_eq:NN \l_ducksay_animal_tl } + \exp_after:wN \exp_not:N \cs:w l_ducksay_animal_#2_tl \cs_end: + \exp_not:n { \exp_args:NV \DucksayOptions } + \exp_after:wN + \exp_not:N \cs:w l_ducksay_animal_#2_options_tl \cs_end: } } + \tl_if_exist:cF { l_ducksay_animal_#2_options_tl } + { \tl_new:c { l_ducksay_animal_#2_options_tl } } + \IfBooleanT { #4 } + { \keys_define:nn { ducksay } { default_animal .meta:n = { #2 } } } } +\cs_generate_variant:Nn \ducksay_add_animal_inner:nnnn { nnVn } \NewDocumentCommand \DefaultAnimal { m } { \keys_define:nn { ducksay } { default_animal .meta:n = { #1 } } @@ -163,30 +211,34 @@ { \keys_set:nn { ducksay } { #1 } } -\NewDocumentCommand \AddAnimal { s m +v } +\NewDocumentCommand \AddAnimal { s O{} m +v } { - \ducksay_add_animal_inner:nn { #2 } { #3 } - \bool_if:NT \l_ducksay_also_add_think_bool - { \ducksay_create_think_animal:n { #2 } } - \IfBooleanT{#1} - { \keys_define:nn { ducksay } { default_animal .meta:n = { #2 } } } + \ducksay_add_animal_inner:nnnn { #2 } { #3 } { #4 } { #1 } } -\NewDocumentCommand \AddColoredAnimal { s m +v } +\NewDocumentCommand \AddColoredAnimal { s O{} m +v } { - \ducksay_add_animal_inner:nn { #2 } { #3 } - \regex_replace_all:Nnc \c_ducksay_color_delim_regex + \tl_set:Nn \l_ducksay_tmpa_tl { #4 } + \regex_replace_all:NnN \c_ducksay_color_delim_regex { \c{bgroup}\c{color}\cB\{\1\cE\}\2\c{egroup} } - { g_ducksay_animal_say_#2_tl } - \regex_replace_all:Nnc \c_ducksay_color_regex + \l_ducksay_tmpa_tl + \regex_replace_all:NnN \c_ducksay_color_regex { \c{color}\cB\{\1\cE\} } - { g_ducksay_animal_say_#2_tl } - \regex_replace_all:Nnc \c_ducksay_textcolor_regex + \l_ducksay_tmpa_tl + \regex_replace_all:NnN \c_ducksay_textcolor_regex { \c{textcolor}\cB\{\1\cE\}\cB\{\2\cE\} } - { g_ducksay_animal_say_#2_tl } - \bool_if:NT \l_ducksay_also_add_think_bool - { \ducksay_create_think_animal:n { #2 } } - \IfBooleanT{#1} - { \keys_define:nn { ducksay } { default_animal .meta:n = { #2 } } } + \l_ducksay_tmpa_tl + \ducksay_add_animal_inner:nnVn { #2 } { #3 } \l_ducksay_tmpa_tl { #1 } + } +\NewDocumentCommand \AnimalOptions { s m m } + { + \tl_if_exist:cTF { l_ducksay_animal_#2_options_tl } + { + \IfBooleanTF { #1 } + { \tl_set:cn } + { \tl_put_right:cn } + } + { \tl_set:cn } + { l_ducksay_animal_#2_options_tl } { #3, } } \bool_if:NT \l_ducksay_version_one_bool { \file_input:n { ducksay.code.v1.tex } } |