summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-03 21:18:30 +0000
committerKarl Berry <karl@freefriends.org>2024-01-03 21:18:30 +0000
commit9fe5b3b4175b31a43a984d069b3aaae580e130a7 (patch)
tree62c43a3db2b7196b85eecae4cb9c3fbd73687254
parent353c0f08203d3cbe6012341e8e048755ed360bab (diff)
collargs (3jan24)
git-svn-id: svn://tug.org/texlive/trunk@69284 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/generic/collargs/CHANGELOG.md25
-rw-r--r--Master/texmf-dist/doc/generic/collargs/FILES3
-rw-r--r--Master/texmf-dist/doc/generic/collargs/README.md11
-rw-r--r--Master/texmf-dist/source/generic/collargs/collargs.edtx107
-rw-r--r--Master/texmf-dist/source/generic/collargs/collargs.ins10
-rw-r--r--Master/texmf-dist/tex/context/third/collargs/t-collargs.tex77
-rw-r--r--Master/texmf-dist/tex/latex/collargs/collargs.sty75
-rw-r--r--Master/texmf-dist/tex/plain/collargs/collargs.tex73
8 files changed, 250 insertions, 131 deletions
diff --git a/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md b/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md
new file mode 100644
index 00000000000..e3e1204b2d6
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/collargs/CHANGELOG.md
@@ -0,0 +1,25 @@
+# CollArgs changelog
+
+This package was developed as an auxiliary package of
+[Memoize](https://ctan.org/pkg/memoize), and is documented alongside that
+package. Note, however, that the Memoize manual, `memoize-doc.pdf`, is not
+reissued for patch-level releases of CollArgs; the version of the Memoize manual
+fully applicable to the particular version of CollArgs is indicated at each
+version.
+
+Whenever the date of the Memoize manual is older than the release date of a
+particular version of CollArgs, the documented source of CollArgs shown in that
+version of `memoize-code.pdf` of course does not reflect the latest changes; in
+those cases, please see [Memoize's GitHub
+repository](https://github.com/sasozivanovic/memoize) for the recent
+development history.
+
+## 2024/01/02 v1.1.0
+* Implement `brace collected`.
+
+Manual: Memoize 2024/01/02 v1.1.0
+
+## 2023/10/10 v1.0.0
+* The initial release.
+
+Manual: Memoize 2023/10/10 v1.0.0
diff --git a/Master/texmf-dist/doc/generic/collargs/FILES b/Master/texmf-dist/doc/generic/collargs/FILES
index 626a9ab54e4..695158b5b18 100644
--- a/Master/texmf-dist/doc/generic/collargs/FILES
+++ b/Master/texmf-dist/doc/generic/collargs/FILES
@@ -1,9 +1,10 @@
doc/generic/collargs/LICENCE
doc/generic/collargs/INSTALL.md
+doc/generic/collargs/CHANGELOG.md
doc/generic/collargs/FILES
doc/generic/collargs/README.md
tex/latex/collargs/collargs.sty
-tex/context/collargs/t-collargs.tex
+tex/context/third/collargs/t-collargs.tex
tex/plain/collargs/collargs.tex
source/generic/collargs/collargs.edtx
source/generic/collargs/Makefile
diff --git a/Master/texmf-dist/doc/generic/collargs/README.md b/Master/texmf-dist/doc/generic/collargs/README.md
index f36abea78a0..235225f08a9 100644
--- a/Master/texmf-dist/doc/generic/collargs/README.md
+++ b/Master/texmf-dist/doc/generic/collargs/README.md
@@ -6,3 +6,14 @@ This package was developed as an auxiliary package of
[Memoize](https://ctan.org/pkg/memoize). This is why it is, somewhat
unconventionally, documented alongside that package. This applies to both the
manual and the documented code listing.
+
+# LICENCE
+
+This work may be distributed and/or modified under the conditions of the LaTeX
+Project Public License, either version 1.3c of this license or (at your option)
+any later version. The latest version of this license is in
+https://www.latex-project.org/lppl.txt and version 1.3c or later is part of all
+distributions of LaTeX version 2008 or later.
+
+This work has the LPPL maintenance status `maintained'. The Current Maintainer
+of this work is Sašo Živanović (saso.zivanovic@guest.arnes.si).
diff --git a/Master/texmf-dist/source/generic/collargs/collargs.edtx b/Master/texmf-dist/source/generic/collargs/collargs.edtx
index 40a102c1a87..6cd39ad4cac 100644
--- a/Master/texmf-dist/source/generic/collargs/collargs.edtx
+++ b/Master/texmf-dist/source/generic/collargs/collargs.edtx
@@ -10,11 +10,11 @@
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%%
%% This work may be distributed and/or modified under the conditions of the
-%% LaTeX Project Public License, either version 1.3 of this license or (at your
-%% option) any later version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
-%% all distributions of LaTeX version 2005/12/01 or later.
-%%
+%% LaTeX Project Public License, either version 1.3c of this license or (at
+%% your option) any later version. The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
+%% all distributions of LaTeX version 2008 or later.
+%%
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Saso Zivanovic.
%%
@@ -46,14 +46,14 @@
%
%
% \paragraph{Identification}
-%<latex>\ProvidesPackage{collargs}[2023/10/10 v1.0.0 Collect arguments of any command]
+%<latex>\ProvidesPackage{collargs}[2024/01/02 v1.1.0 Collect arguments of any command]
%<context>%D \module[
%<context>%D file=t-collargs.tex,
-%<context>%D version=1.0.0,
+%<context>%D version=1.1.0,
%<context>%D title=CollArgs,
%<context>%D subtitle=Collect arguments of any command,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2023-10-10,
+%<context>%D date=2024-01-02,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
@@ -70,24 +70,38 @@
%<plain>\catcode`\@11\relax
%
% \begin{macro}{\toksapp,\gtoksapp,\etoksapp,\xtoksapp}
-% Our macros for appending to a token register only accept a control sequence
-% defined by |\toksdef| (like |\mytoks|) but not an explicit register
-% designation like |\toks0|, so we only define them if noone else did; the
-% names of the macros match the \hologo{LuaTeX} primitives, so they surely
-% won't be defined there.
-\ifdefined\toksapp\else
- \long\def\toksapp#1#2{#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\etoksapp\else
- \long\def\etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
-\fi
-\ifdefined\gtoksapp\else
- \long\def\gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\xtoksapp\else
- \long\def\xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
+% Macros for appending to a token register. We don't have to define them in
+% \hologo{LuaTeX}, where they exist as primitives. Same as these primitives,
+% out macros accept either a register number or a |\toksdef|fed control
+% sequence as the (unbraced) |#1|; |#2| is the text to append.
+\ifdefined\luatexversion
+\else
+ \def\toksapp{\toks@cs@or@num\@toksapp}
+ \def\gtoksapp{\toks@cs@or@num\@gtoksapp}
+ \def\etoksapp{\toks@cs@or@num\@etoksapp}
+ \def\xtoksapp{\toks@cs@or@num\@xtoksapp}
+ \def\toks@cs@or@num#1#2#{%
+ % Test whether |#2| (the original |#1|) is a number or a control sequence.
+ \ifnum-2>-1#2
+ % It is a number. |\toks@cs@or@num@num| will gobble |\toks@cs@or@num@cs|
+ % below.
+ \expandafter\toks@cs@or@num@num
+ % The register control sequence in |#2| is skipped over in the false
+ % branch.
+ \fi
+ \toks@cs@or@num@cs{#1}{#2}%
+ }
+ % |#1| is one of |\@toksapp| and friends. The second macro prefixes the
+ % register number by |\toks|.
+ \def\toks@cs@or@num@cs#1#2{#1{#2}}
+ \def\toks@cs@or@num@num\toks@cs@or@num@cs#1#2{#1{\toks#2 }}
+ % Having either |\tokscs| or |\toks<number>| in |#1|, we can finally do the
+ % real job.
+ \long\def\@toksapp#1#2{#1\expandafter{\the#1#2}}%
+ \long\def\@etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
+ \long\def\@gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
+ \long\def\@xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
\fi
-\ifdefined\toks@\else\toksdef\toks@=0 \fi
% \end{macro}
%
% \begin{macro}{\CollectArguments,\CollectArgumentsRaw}
@@ -521,7 +535,19 @@
\newif\ifcollargsNoDelimiters
% \end{macro}
% \end{collargskey}
-%
+
+% \begin{collargskey}{brace collected}
+% \begin{macro}{\ifcollargsBraceCollected}
+% When this conditional is set to false, the collected arguments are not
+% enclosed in braces when passed on to \meta{next-code}.
+\collargsSet{%
+ brace collected/.is if=collargsBraceCollected,
+}
+\newif\ifcollargsBraceCollected
+\collargsBraceCollectedtrue
+% \end{macro}
+% \end{collargskey}
+%
% \subsubsection{The central loop}
% \label{sec:code:collargs:central-loop}
%
@@ -678,7 +704,12 @@
\expanded{%
\endgroup
\noexpand\collargs@fix{%
- \expandonce\collargs@next{\the\collargs@toks}%
+ \expandonce\collargs@next
+ \ifcollargsBraceCollected
+ {\the\collargs@toks}%
+ \else
+ \the\collargs@toks
+ \fi
\collargs@spaces
}%
}%
@@ -1680,7 +1711,7 @@
\collargs@CPT@def\collargs@gobbleOneB\collargs@begintag{%
% Assign the collected tokens into a register. The first token in |##1|
% will be |\collargs@empty|, so we expand to get rid of it.
- \expandafter\toks@\expandafter{##1}%
+ \toks0\expandafter{##1}%
% |cprotect| simply grabs the token following the |\collargs@begintag| with
% a parameter. We can't do this, because we need the code to work in the
% non-verbatim mode, as well, and we might stumble upon a brace there. So
@@ -1692,13 +1723,13 @@
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleUntilE\collargs@endtag{%
% Expand |\collargs@empty| at the start of |##1|.
- \expandafter\toksapp\expandafter\toks@\expandafter{##1}%
+ \expandafter\toksapp\expandafter0\expandafter{##1}%
\collargs@gobbleUntilE@i
}%
% Initialize.
\collargs@begins=0\relax
\collargsArg{}%
- \toks@{}%
+ \toks0{}%
% We will call |\collargs@gobbleUntilE| via the caller control sequence.
\collargs@letusecollector\collargs@gobbleUntilE
% We insert |\collargs@empty| to avoid the potential debracing problem.
@@ -1726,7 +1757,7 @@
\expandafter\collargs@gobbleOneB@v
\else
% Append the real begin-tag to the temporary tokens.
- \etoksapp\toks@{\expandonce\collargs@begintag}%
+ \etoksapp0{\expandonce\collargs@begintag}%
\expandafter\collargs@gobbleOneB@ii
\fi
}%
@@ -1754,14 +1785,14 @@
\fi
% Whatever the result was, we have to append the gobbled group to the
% temporary toks.
- \etoksapp\toks@{\collargs@grabbed@spaces\unexpanded{{#1}}}%
+ \etoksapp0{\collargs@grabbed@spaces\unexpanded{{#1}}}%
\collargs@init@grabspaces
\collargs@gobbleOneB@vi
}
\def\collargs@gobbleOneB@v#1{\collargs@gobbleOneB@vi}
\def\collargs@gobbleOneB@vi{%
% Store.
- \etoksapp\collargsArg{\the\toks@}%
+ \etoksapp\collargsArg{\the\toks0}%
% Advance the begin-tag counter.
\advance\collargs@begins\collargs@begins@increment\relax
% Find more begin-tags, unless this was the final one.
@@ -1785,7 +1816,7 @@
}%
}
\def\collargs@gobbleUntilE@iii#1{%
- \etoksapp\toks@{\collargs@grabbed@spaces}%
+ \etoksapp0{\collargs@grabbed@spaces}%
\collargs@init@grabspaces
\def\collargs@tempa{#1}%
\ifx\collargs@tempa\collargs@tagarg
@@ -1794,7 +1825,7 @@
\else
% Nope, this |\end| belongs to someone else. Insert the end tag plus the
% tag argument, and collect until the next |\end|.
- \expandafter\toksapp\expandafter\toks@\expandafter{\collargs@endtag{#1}}%
+ \expandafter\toksapp\expandafter0\expandafter{\collargs@endtag{#1}}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\fi
}
@@ -1802,7 +1833,7 @@
% Invoke |\collargs@gobbleOneB| with the collected material, plus a fake
% begin-tag and a quark guard.
\ifcollargsIgnoreNesting
- \expandafter\collargsArg\expandafter{\the\toks@}%
+ \expandafter\collargsArg\expandafter{\the\toks0}%
\expandafter\collargs@commandatend
\else
\expandafter\collargs@gobbleUntilE@v
@@ -1812,7 +1843,7 @@
\expanded{%
\noexpand\collargs@letusecollector\noexpand\collargs@gobbleOneB
\noexpand\collargs@empty
- \the\toks@
+ \the\toks0
% Add a fake begin-tag and a quark guard.
\expandonce\collargs@begintag
\noexpand\collargs@qend
@@ -1825,7 +1856,7 @@
\expandafter\ifx\expandafter\relax\collargs@tagarg\relax\else{%
\expandonce\collargs@tagarg}\fi
}%
- \toks@={}%
+ \toks0={}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\expandafter\collargs@empty
\fi
diff --git a/Master/texmf-dist/source/generic/collargs/collargs.ins b/Master/texmf-dist/source/generic/collargs/collargs.ins
index a8673b6edc4..5cde9e2b722 100644
--- a/Master/texmf-dist/source/generic/collargs/collargs.ins
+++ b/Master/texmf-dist/source/generic/collargs/collargs.ins
@@ -9,11 +9,11 @@
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%%
%% This work may be distributed and/or modified under the conditions of the
-%% LaTeX Project Public License, either version 1.3 of this license or (at your
-%% option) any later version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
-%% all distributions of LaTeX version 2005/12/01 or later.
-%%
+%% LaTeX Project Public License, either version 1.3c of this license or (at
+%% your option) any later version. The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
+%% all distributions of LaTeX version 2008 or later.
+%%
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Saso Zivanovic.
%%
diff --git a/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex b/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
index 1581e661e06..157882a2eaa 100644
--- a/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
+++ b/Master/texmf-dist/tex/context/third/collargs/t-collargs.tex
@@ -16,10 +16,10 @@
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%%
%% This work may be distributed and/or modified under the conditions of the
-%% LaTeX Project Public License, either version 1.3 of this license or (at your
-%% option) any later version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
-%% all distributions of LaTeX version 2005/12/01 or later.
+%% LaTeX Project Public License, either version 1.3c of this license or (at
+%% your option) any later version. The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
+%% all distributions of LaTeX version 2008 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Saso Zivanovic.
@@ -28,11 +28,11 @@
%% (<texmf>/doc/generic/collargs/)FILES.
%D \module[
%D file=t-collargs.tex,
-%D version=1.0.0,
+%D version=1.1.0,
%D title=CollArgs,
%D subtitle=Collect arguments of any command,
%D author=Saso Zivanovic,
-%D date=2023-10-07,
+%D date=2024-01-02,
%D copyright=Saso Zivanovic,
%D license=LPPL,
%D ]
@@ -41,19 +41,25 @@
\startmodule[collargs]
\input t-pgfkey
\input etoolbox-generic
-\ifdefined\toksapp\else
- \long\def\toksapp#1#2{#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\etoksapp\else
- \long\def\etoksapp#1#2{#1\expandafter{\normalexpanded{\the#1#2}}}%
-\fi
-\ifdefined\gtoksapp\else
- \long\def\gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\xtoksapp\else
- \long\def\xtoksapp#1#2{\global#1\expandafter{\normalexpanded{\the#1#2}}}%
+\ifdefined\luatexversion
+\else
+ \def\toksapp{\toks@cs@or@num\@toksapp}
+ \def\gtoksapp{\toks@cs@or@num\@gtoksapp}
+ \def\etoksapp{\toks@cs@or@num\@etoksapp}
+ \def\xtoksapp{\toks@cs@or@num\@xtoksapp}
+ \def\toks@cs@or@num#1#2#{%
+ \ifnum-2>-1#2
+ \expandafter\toks@cs@or@num@num
+ \fi
+ \toks@cs@or@num@cs{#1}{#2}%
+ }
+ \def\toks@cs@or@num@cs#1#2{#1{#2}}
+ \def\toks@cs@or@num@num\toks@cs@or@num@cs#1#2{#1{\toks#2 }}
+ \long\def\@toksapp#1#2{#1\expandafter{\the#1#2}}%
+ \long\def\@etoksapp#1#2{#1\expandafter{\normalexpanded{\the#1#2}}}%
+ \long\def\@gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
+ \long\def\@xtoksapp#1#2{\global#1\expandafter{\normalexpanded{\the#1#2}}}%
\fi
-\ifdefined\toks@\else\toksdef\toks@=0 \fi
\protected\def\CollectArguments{%
\pgf@keys@utilifnextchar[\CollectArguments@i{\CollectArgumentsRaw{}}%]
}
@@ -253,6 +259,12 @@
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
+
+\collargsSet{%
+ brace collected/.is if=collargsBraceCollected,
+}
+\newif\ifcollargsBraceCollected
+\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -322,7 +334,12 @@
\normalexpanded{%
\endgroup
\noexpand\collargs@fix{%
- \expandonce\collargs@next{\the\collargs@toks}%
+ \expandonce\collargs@next
+ \ifcollargsBraceCollected
+ {\the\collargs@toks}%
+ \else
+ \the\collargs@toks
+ \fi
\collargs@spaces
}%
}%
@@ -895,17 +912,17 @@
\def\collargs@readContent{%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleOneB\collargs@begintag{%
- \expandafter\toks@\expandafter{##1}%
+ \toks0\expandafter{##1}%
\futurelet\collargs@temp\collargs@gobbleOneB@i
}%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleUntilE\collargs@endtag{%
- \expandafter\toksapp\expandafter\toks@\expandafter{##1}%
+ \expandafter\toksapp\expandafter0\expandafter{##1}%
\collargs@gobbleUntilE@i
}%
\collargs@begins=0\relax
\collargsArg{}%
- \toks@{}%
+ \toks0{}%
\collargs@letusecollector\collargs@gobbleUntilE
\collargs@empty
}
@@ -921,7 +938,7 @@
\def\collargs@begins@increment{-1}%
\expandafter\collargs@gobbleOneB@v
\else
- \etoksapp\toks@{\expandonce\collargs@begintag}%
+ \etoksapp0{\expandonce\collargs@begintag}%
\expandafter\collargs@gobbleOneB@ii
\fi
}%
@@ -943,13 +960,13 @@
\else
\def\collargs@begins@increment{0}%
\fi
- \etoksapp\toks@{\collargs@grabbed@spaces\normalunexpanded{{#1}}}%
+ \etoksapp0{\collargs@grabbed@spaces\normalunexpanded{{#1}}}%
\collargs@init@grabspaces
\collargs@gobbleOneB@vi
}
\def\collargs@gobbleOneB@v#1{\collargs@gobbleOneB@vi}
\def\collargs@gobbleOneB@vi{%
- \etoksapp\collargsArg{\the\toks@}%
+ \etoksapp\collargsArg{\the\toks0}%
\advance\collargs@begins\collargs@begins@increment\relax
\ifnum\collargs@begins@increment=-1
\else
@@ -969,19 +986,19 @@
}%
}
\def\collargs@gobbleUntilE@iii#1{%
- \etoksapp\toks@{\collargs@grabbed@spaces}%
+ \etoksapp0{\collargs@grabbed@spaces}%
\collargs@init@grabspaces
\def\collargs@tempa{#1}%
\ifx\collargs@tempa\collargs@tagarg
\expandafter\collargs@gobbleUntilE@iv
\else
- \expandafter\toksapp\expandafter\toks@\expandafter{\collargs@endtag{#1}}%
+ \expandafter\toksapp\expandafter0\expandafter{\collargs@endtag{#1}}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\fi
}
\def\collargs@gobbleUntilE@iv{%
\ifcollargsIgnoreNesting
- \expandafter\collargsArg\expandafter{\the\toks@}%
+ \expandafter\collargsArg\expandafter{\the\toks0}%
\expandafter\collargs@commandatend
\else
\expandafter\collargs@gobbleUntilE@v
@@ -991,7 +1008,7 @@
\normalexpanded{%
\noexpand\collargs@letusecollector\noexpand\collargs@gobbleOneB
\noexpand\collargs@empty
- \the\toks@
+ \the\toks0
\expandonce\collargs@begintag
\noexpand\collargs@qend
}%
@@ -1003,7 +1020,7 @@
\expandafter\ifx\expandafter\relax\collargs@tagarg\relax\else{%
\expandonce\collargs@tagarg}\fi
}%
- \toks@={}%
+ \toks0={}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\expandafter\collargs@empty
\fi
diff --git a/Master/texmf-dist/tex/latex/collargs/collargs.sty b/Master/texmf-dist/tex/latex/collargs/collargs.sty
index 6697b2bd01d..2db86e8540b 100644
--- a/Master/texmf-dist/tex/latex/collargs/collargs.sty
+++ b/Master/texmf-dist/tex/latex/collargs/collargs.sty
@@ -16,32 +16,38 @@
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%%
%% This work may be distributed and/or modified under the conditions of the
-%% LaTeX Project Public License, either version 1.3 of this license or (at your
-%% option) any later version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
-%% all distributions of LaTeX version 2005/12/01 or later.
+%% LaTeX Project Public License, either version 1.3c of this license or (at
+%% your option) any later version. The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
+%% all distributions of LaTeX version 2008 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Saso Zivanovic.
%%
%% The files belonging to this work and covered by LPPL are listed in
%% (<texmf>/doc/generic/collargs/)FILES.
-\ProvidesPackage{collargs}[2023/10/07 v1.0.0 Collect arguments of any command]
+\ProvidesPackage{collargs}[2024/01/02 v1.1.0 Collect arguments of any command]
\RequirePackage{pgfkeys}
\RequirePackage{etoolbox}
-\ifdefined\toksapp\else
- \long\def\toksapp#1#2{#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\etoksapp\else
- \long\def\etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
-\fi
-\ifdefined\gtoksapp\else
- \long\def\gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\xtoksapp\else
- \long\def\xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
+\ifdefined\luatexversion
+\else
+ \def\toksapp{\toks@cs@or@num\@toksapp}
+ \def\gtoksapp{\toks@cs@or@num\@gtoksapp}
+ \def\etoksapp{\toks@cs@or@num\@etoksapp}
+ \def\xtoksapp{\toks@cs@or@num\@xtoksapp}
+ \def\toks@cs@or@num#1#2#{%
+ \ifnum-2>-1#2
+ \expandafter\toks@cs@or@num@num
+ \fi
+ \toks@cs@or@num@cs{#1}{#2}%
+ }
+ \def\toks@cs@or@num@cs#1#2{#1{#2}}
+ \def\toks@cs@or@num@num\toks@cs@or@num@cs#1#2{#1{\toks#2 }}
+ \long\def\@toksapp#1#2{#1\expandafter{\the#1#2}}%
+ \long\def\@etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
+ \long\def\@gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
+ \long\def\@xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
\fi
-\ifdefined\toks@\else\toksdef\toks@=0 \fi
\protected\def\CollectArguments{%
\pgf@keys@utilifnextchar[\CollectArguments@i{\CollectArgumentsRaw{}}%]
}
@@ -242,6 +248,12 @@
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
+
+\collargsSet{%
+ brace collected/.is if=collargsBraceCollected,
+}
+\newif\ifcollargsBraceCollected
+\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -311,7 +323,12 @@
\expanded{%
\endgroup
\noexpand\collargs@fix{%
- \expandonce\collargs@next{\the\collargs@toks}%
+ \expandonce\collargs@next
+ \ifcollargsBraceCollected
+ {\the\collargs@toks}%
+ \else
+ \the\collargs@toks
+ \fi
\collargs@spaces
}%
}%
@@ -913,17 +930,17 @@
\def\collargs@readContent{%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleOneB\collargs@begintag{%
- \expandafter\toks@\expandafter{##1}%
+ \toks0\expandafter{##1}%
\futurelet\collargs@temp\collargs@gobbleOneB@i
}%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleUntilE\collargs@endtag{%
- \expandafter\toksapp\expandafter\toks@\expandafter{##1}%
+ \expandafter\toksapp\expandafter0\expandafter{##1}%
\collargs@gobbleUntilE@i
}%
\collargs@begins=0\relax
\collargsArg{}%
- \toks@{}%
+ \toks0{}%
\collargs@letusecollector\collargs@gobbleUntilE
\collargs@empty
}
@@ -939,7 +956,7 @@
\def\collargs@begins@increment{-1}%
\expandafter\collargs@gobbleOneB@v
\else
- \etoksapp\toks@{\expandonce\collargs@begintag}%
+ \etoksapp0{\expandonce\collargs@begintag}%
\expandafter\collargs@gobbleOneB@ii
\fi
}%
@@ -961,13 +978,13 @@
\else
\def\collargs@begins@increment{0}%
\fi
- \etoksapp\toks@{\collargs@grabbed@spaces\unexpanded{{#1}}}%
+ \etoksapp0{\collargs@grabbed@spaces\unexpanded{{#1}}}%
\collargs@init@grabspaces
\collargs@gobbleOneB@vi
}
\def\collargs@gobbleOneB@v#1{\collargs@gobbleOneB@vi}
\def\collargs@gobbleOneB@vi{%
- \etoksapp\collargsArg{\the\toks@}%
+ \etoksapp\collargsArg{\the\toks0}%
\advance\collargs@begins\collargs@begins@increment\relax
\ifnum\collargs@begins@increment=-1
\else
@@ -987,19 +1004,19 @@
}%
}
\def\collargs@gobbleUntilE@iii#1{%
- \etoksapp\toks@{\collargs@grabbed@spaces}%
+ \etoksapp0{\collargs@grabbed@spaces}%
\collargs@init@grabspaces
\def\collargs@tempa{#1}%
\ifx\collargs@tempa\collargs@tagarg
\expandafter\collargs@gobbleUntilE@iv
\else
- \expandafter\toksapp\expandafter\toks@\expandafter{\collargs@endtag{#1}}%
+ \expandafter\toksapp\expandafter0\expandafter{\collargs@endtag{#1}}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\fi
}
\def\collargs@gobbleUntilE@iv{%
\ifcollargsIgnoreNesting
- \expandafter\collargsArg\expandafter{\the\toks@}%
+ \expandafter\collargsArg\expandafter{\the\toks0}%
\expandafter\collargs@commandatend
\else
\expandafter\collargs@gobbleUntilE@v
@@ -1009,7 +1026,7 @@
\expanded{%
\noexpand\collargs@letusecollector\noexpand\collargs@gobbleOneB
\noexpand\collargs@empty
- \the\toks@
+ \the\toks0
\expandonce\collargs@begintag
\noexpand\collargs@qend
}%
@@ -1021,7 +1038,7 @@
\expandafter\ifx\expandafter\relax\collargs@tagarg\relax\else{%
\expandonce\collargs@tagarg}\fi
}%
- \toks@={}%
+ \toks0={}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\expandafter\collargs@empty
\fi
diff --git a/Master/texmf-dist/tex/plain/collargs/collargs.tex b/Master/texmf-dist/tex/plain/collargs/collargs.tex
index 0a91a3c5402..e67c3633b4b 100644
--- a/Master/texmf-dist/tex/plain/collargs/collargs.tex
+++ b/Master/texmf-dist/tex/plain/collargs/collargs.tex
@@ -16,10 +16,10 @@
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%%
%% This work may be distributed and/or modified under the conditions of the
-%% LaTeX Project Public License, either version 1.3 of this license or (at your
-%% option) any later version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
-%% all distributions of LaTeX version 2005/12/01 or later.
+%% LaTeX Project Public License, either version 1.3c of this license or (at
+%% your option) any later version. The latest version of this license is in
+%% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
+%% all distributions of LaTeX version 2008 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Saso Zivanovic.
@@ -30,19 +30,25 @@
\input etoolbox-generic
\edef\resetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}
\catcode`\@11\relax
-\ifdefined\toksapp\else
- \long\def\toksapp#1#2{#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\etoksapp\else
- \long\def\etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
-\fi
-\ifdefined\gtoksapp\else
- \long\def\gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
-\fi
-\ifdefined\xtoksapp\else
- \long\def\xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
+\ifdefined\luatexversion
+\else
+ \def\toksapp{\toks@cs@or@num\@toksapp}
+ \def\gtoksapp{\toks@cs@or@num\@gtoksapp}
+ \def\etoksapp{\toks@cs@or@num\@etoksapp}
+ \def\xtoksapp{\toks@cs@or@num\@xtoksapp}
+ \def\toks@cs@or@num#1#2#{%
+ \ifnum-2>-1#2
+ \expandafter\toks@cs@or@num@num
+ \fi
+ \toks@cs@or@num@cs{#1}{#2}%
+ }
+ \def\toks@cs@or@num@cs#1#2{#1{#2}}
+ \def\toks@cs@or@num@num\toks@cs@or@num@cs#1#2{#1{\toks#2 }}
+ \long\def\@toksapp#1#2{#1\expandafter{\the#1#2}}%
+ \long\def\@etoksapp#1#2{#1\expandafter{\expanded{\the#1#2}}}%
+ \long\def\@gtoksapp#1#2{\global#1\expandafter{\the#1#2}}%
+ \long\def\@xtoksapp#1#2{\global#1\expandafter{\expanded{\the#1#2}}}%
\fi
-\ifdefined\toks@\else\toksdef\toks@=0 \fi
\protected\def\CollectArguments{%
\pgf@keys@utilifnextchar[\CollectArguments@i{\CollectArgumentsRaw{}}%]
}
@@ -241,6 +247,12 @@
no delimiters/.is if=collargsNoDelimiters,
}
\newif\ifcollargsNoDelimiters
+
+\collargsSet{%
+ brace collected/.is if=collargsBraceCollected,
+}
+\newif\ifcollargsBraceCollected
+\collargsBraceCollectedtrue
\def\collargs@{%
\begingroup
\collargs@@@
@@ -310,7 +322,12 @@
\expanded{%
\endgroup
\noexpand\collargs@fix{%
- \expandonce\collargs@next{\the\collargs@toks}%
+ \expandonce\collargs@next
+ \ifcollargsBraceCollected
+ {\the\collargs@toks}%
+ \else
+ \the\collargs@toks
+ \fi
\collargs@spaces
}%
}%
@@ -882,17 +899,17 @@
\def\collargs@readContent{%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleOneB\collargs@begintag{%
- \expandafter\toks@\expandafter{##1}%
+ \toks0\expandafter{##1}%
\futurelet\collargs@temp\collargs@gobbleOneB@i
}%
\ifcollargs@long\long\fi
\collargs@CPT@def\collargs@gobbleUntilE\collargs@endtag{%
- \expandafter\toksapp\expandafter\toks@\expandafter{##1}%
+ \expandafter\toksapp\expandafter0\expandafter{##1}%
\collargs@gobbleUntilE@i
}%
\collargs@begins=0\relax
\collargsArg{}%
- \toks@{}%
+ \toks0{}%
\collargs@letusecollector\collargs@gobbleUntilE
\collargs@empty
}
@@ -908,7 +925,7 @@
\def\collargs@begins@increment{-1}%
\expandafter\collargs@gobbleOneB@v
\else
- \etoksapp\toks@{\expandonce\collargs@begintag}%
+ \etoksapp0{\expandonce\collargs@begintag}%
\expandafter\collargs@gobbleOneB@ii
\fi
}%
@@ -930,13 +947,13 @@
\else
\def\collargs@begins@increment{0}%
\fi
- \etoksapp\toks@{\collargs@grabbed@spaces\unexpanded{{#1}}}%
+ \etoksapp0{\collargs@grabbed@spaces\unexpanded{{#1}}}%
\collargs@init@grabspaces
\collargs@gobbleOneB@vi
}
\def\collargs@gobbleOneB@v#1{\collargs@gobbleOneB@vi}
\def\collargs@gobbleOneB@vi{%
- \etoksapp\collargsArg{\the\toks@}%
+ \etoksapp\collargsArg{\the\toks0}%
\advance\collargs@begins\collargs@begins@increment\relax
\ifnum\collargs@begins@increment=-1
\else
@@ -956,19 +973,19 @@
}%
}
\def\collargs@gobbleUntilE@iii#1{%
- \etoksapp\toks@{\collargs@grabbed@spaces}%
+ \etoksapp0{\collargs@grabbed@spaces}%
\collargs@init@grabspaces
\def\collargs@tempa{#1}%
\ifx\collargs@tempa\collargs@tagarg
\expandafter\collargs@gobbleUntilE@iv
\else
- \expandafter\toksapp\expandafter\toks@\expandafter{\collargs@endtag{#1}}%
+ \expandafter\toksapp\expandafter0\expandafter{\collargs@endtag{#1}}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\fi
}
\def\collargs@gobbleUntilE@iv{%
\ifcollargsIgnoreNesting
- \expandafter\collargsArg\expandafter{\the\toks@}%
+ \expandafter\collargsArg\expandafter{\the\toks0}%
\expandafter\collargs@commandatend
\else
\expandafter\collargs@gobbleUntilE@v
@@ -978,7 +995,7 @@
\expanded{%
\noexpand\collargs@letusecollector\noexpand\collargs@gobbleOneB
\noexpand\collargs@empty
- \the\toks@
+ \the\toks0
\expandonce\collargs@begintag
\noexpand\collargs@qend
}%
@@ -990,7 +1007,7 @@
\expandafter\ifx\expandafter\relax\collargs@tagarg\relax\else{%
\expandonce\collargs@tagarg}\fi
}%
- \toks@={}%
+ \toks0={}%
\expandafter\collargs@letusecollector\expandafter\collargs@gobbleUntilE
\expandafter\collargs@empty
\fi