summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ducksay/ducksay.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/ducksay/ducksay.sty')
-rw-r--r--Master/texmf-dist/tex/latex/ducksay/ducksay.sty36
1 files changed, 30 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/latex/ducksay/ducksay.sty b/Master/texmf-dist/tex/latex/ducksay/ducksay.sty
index 50a7318fd03..00234f5418a 100644
--- a/Master/texmf-dist/tex/latex/ducksay/ducksay.sty
+++ b/Master/texmf-dist/tex/latex/ducksay/ducksay.sty
@@ -13,7 +13,7 @@
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%%
-%% Copyright (C) 2017-2019 Jonathan P. Spratte
+%% Copyright (C) 2017-2020 Jonathan P. Spratte
%%
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this license or
@@ -35,8 +35,8 @@
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{xparse,l3keys2e}
-\def\ducksay@version{2.4.1}
-\def\ducksay@date{2019-09-28}
+\def\ducksay@version{2.5}
+\def\ducksay@date{2020-02-01}
\ProvidesExplPackage
{ducksay} {\ducksay@date}
@@ -46,6 +46,7 @@
\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
+\seq_new:N \l_ducksay_defined_animals_seq
\tl_new:N \l_ducksay_align_tl
\tl_new:N \l_ducksay_msg_align_tl
\tl_new:N \l_ducksay_animal_tl
@@ -57,6 +58,7 @@
\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
+\bool_new:N \l_ducksay_random_animal_bool
\box_new:N \l_ducksay_tmpa_box
\regex_const:Nn \c_ducksay_textcolor_regex
{ \cO(?:\\textcolor\{(.*?)\}\{(.*?)\}) }
@@ -95,11 +97,19 @@
,tail-2 .initial:x = \c_backslash_str
,no-tail .meta:n = { tail-1 = { ~ }, tail-2 = { ~ } }
,think .meta:n = { tail-1 = { O }, tail-2 = { o } }
+ ,random .bool_set:N = \l_ducksay_random_animal_bool
,say .code:n =
{
\exp_args:Nx \DucksayOptions
{ tail-1 = { \c_backslash_str }, tail-2 = { \c_backslash_str } }
}
+ ,schroedinger .code:n =
+ {
+ \int_compare:nNnTF { \int_rand:n { 2 } } = \c_one_int
+ { \keys_set:nn { ducksay } { animal = schroedinger-dead } }
+ { \keys_set:nn { ducksay } { animal = schroedinger-alive } }
+ }
+ ,schroedinger .value_forbidden:n = true
,version .choice:
,version / 1 .code:n =
{
@@ -128,6 +138,7 @@
}
\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
+\cs_generate_variant:Nn \keys_set:nn { nx }
\cs_set_eq:NN \__ducksay_everyeof:w \tex_everyeof:D
\cs_set_eq:NN \__ducksay_scantokens:w \tex_scantokens:D
\cs_new_protected:Npx \ducksay_replace_verb_newline:Nn #1 #2
@@ -190,18 +201,31 @@
#2 .code:n =
{
\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:c { l_ducksay_animal_#2_tl }
\exp_not:n { \exp_args:NV \DucksayOptions }
- \exp_after:wN
- \exp_not:N \cs:w l_ducksay_animal_#2_options_tl \cs_end:
+ \exp_not:c { l_ducksay_animal_#2_options_tl }
}
}
\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 } } }
+ \seq_if_in:NnF \l_ducksay_defined_animals_seq { #2 }
+ { \seq_push:Nn \l_ducksay_defined_animals_seq { #2 } }
}
\cs_generate_variant:Nn \ducksay_add_animal_inner:nnnn { nnVn }
+\cs_new_protected:Npn \ducksay_default_or_random_animal:
+ {
+ \tl_if_empty:NT \l_ducksay_animal_tl
+ {
+ \bool_if:NTF \l_ducksay_random_animal_bool
+ {
+ \keys_set:nx { ducksay }
+ { \seq_rand_item:N \l_ducksay_defined_animals_seq }
+ }
+ { \keys_set:nn { ducksay } { default_animal } }
+ }
+ }
\NewDocumentCommand \DefaultAnimal { m }
{
\keys_define:nn { ducksay } { default_animal .meta:n = { #1 } }