diff options
author | Norbert Preining <norbert@preining.info> | 2021-06-04 03:02:48 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-06-04 03:02:48 +0000 |
commit | a5ae129f3aa3a3a0aeaa21c55b75a1d543fe4111 (patch) | |
tree | fe5e1e212aec203e668df8581a17374cdde352a1 /macros/generic | |
parent | d231c6331f53a048d29c2f847254a9f56d5ee2dd (diff) |
CTAN sync 202106040302
Diffstat (limited to 'macros/generic')
-rw-r--r-- | macros/generic/expkv-cs/README.md | 2 | ||||
-rw-r--r-- | macros/generic/expkv-cs/expkv-cs.dtx | 47 | ||||
-rw-r--r-- | macros/generic/expkv-cs/expkv-cs.pdf | bin | 363784 -> 361934 bytes | |||
-rw-r--r-- | macros/generic/expkv/README.md | 2 | ||||
-rw-r--r-- | macros/generic/expkv/expkv.dtx | 68 | ||||
-rw-r--r-- | macros/generic/expkv/expkv.pdf | bin | 481077 -> 480586 bytes |
6 files changed, 56 insertions, 63 deletions
diff --git a/macros/generic/expkv-cs/README.md b/macros/generic/expkv-cs/README.md index a9df8b801f..89ab6b6de6 100644 --- a/macros/generic/expkv-cs/README.md +++ b/macros/generic/expkv-cs/README.md @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- # expkv-cs -- define expandable key=val macros using expkv -Version 2021-05-24 v0.9 +Version 2021-06-03 v0.10 Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt diff --git a/macros/generic/expkv-cs/expkv-cs.dtx b/macros/generic/expkv-cs/expkv-cs.dtx index 38a70349d7..55a6a134aa 100644 --- a/macros/generic/expkv-cs/expkv-cs.dtx +++ b/macros/generic/expkv-cs/expkv-cs.dtx @@ -282,7 +282,7 @@ and the derived files expkv-cs.pdf \DoNotIndex{\protected,\ProvidesFile,\ProvidesPackage,\relax,\space,\advance} \DoNotIndex{\@,\unexpanded,\string,\expanded,\dimexpr,\global,\glueexpr,\hbox} \DoNotIndex{\numexpr,\RequirePackage,\setbox,\the,\unless,\xdef,\gdef,\newcount} -\DoNotIndex{\romannumeral,\^,\@firstofone,\@firstoftwo,\@gobble} +\DoNotIndex{\^,\@firstofone,\@firstoftwo,\@gobble} \DoNotIndex{\ifcsname} \DoNotIndex{\ifx} \DoNotIndex{\ifnum} @@ -506,13 +506,15 @@ and the derived files expkv-cs.pdf % \begin{syntax} % \cs{ekvcValue}\{\key\}\marg{key list} % \end{syntax} -% This is a safe (but slow) way to access your keys in a hash variant. \key\ +% This is a safe way to access your keys in a hash variant. \key\ % is the key which's \val\ you want to use out of the \meta{key list}. % \meta{key list} should be the key list argument forwarded to your underlying % macro by |\ekvcHash|, |\ekvcHashAndForward|, or |\ekvcHashAndUse|. It will % be tested whether the hash function to access that \key\ exists, the \key\ % argument is not empty, and that the \meta{key list} really contains a \val\ -% of that \key. This macro needs exactly two steps of expansion. +% of that \key. This macro needs exactly two steps of expansion and if used +% inside of an |\edef| or |\expanded| context will protect the \val\ from +% further expanding. % \end{function} % % \begin{function}{\ekvcValueFast} @@ -1125,8 +1127,8 @@ and the derived files expkv-cs.pdf % \begin{macro}{\ekvcVersion,\ekvcDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvcVersion{0.9} -\def\ekvcDate{2021-05-24} +\def\ekvcVersion{0.10} +\def\ekvcDate{2021-06-03} % \end{macrocode} % \end{macro} % @@ -1146,21 +1148,6 @@ and the derived files expkv-cs.pdf % |\ekvc@tmp| will be reused later, but we don't need it to ever store % information long-term after \expkvc\ was initialized. % -% \begin{macro}[internal]{\ekvc@zero} -% There are different ways to define a |\romannumeral| expansion. If the -% control is never given to user input, the fastest way is to just execute -% your code and use a |\dimendef|ed zero to end it afterwards. If the control -% is given to user input (so user input should be expanded) the fastest and -% best way is to use |\romannumeral`\^^@|, this will expand the user input -% until something unexpandable is found or a space (which would then be -% gobbled). However, we want to use the former approach since we don't want to -% expand any user input, just make sure own code is expanded in two steps. -% Since we want to use the |\dimendef| variant, we have to actually provide -% such a token. Since both plain \TeX\ and \LaTeX\ define |\z@| we can use -% that (but we use a private name for it). Luckily, \expkv\ already contains -% |\ekv@zero|, which we can use in \expkvc. -% \end{macro} -% % \begin{macro}[internal]{\ekvc@keycount} % We'll need to keep count how many keys must be defined for each macro in the % |split| variants. @@ -1713,8 +1700,8 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}[internal]{\ekvc@setup@hashmacro} -% The safe hash macros will be executed inside of a |\romannumeral| expansion -% context, so they have to insert a stop mark for that once they are done. +% The safe hash macros will be executed inside of an |\unexpanded| expansion +% context, so they have to insert braces for that once they are done. % Most of the tests which have to be executed will already be done, but we % have to play safe if the hash doesn't show up in the hash list. Therefore we % use some |\ekvc@mark|s and |\ekvc@stop| to throw errors if the hash isn't @@ -1723,7 +1710,7 @@ and the derived files expkv-cs.pdf % \begin{macrocode} \protected\def\ekvc@setup@hashmacro#1% {% - \ekv@ifdefined{ekvc@hash@#1}{}% + \ekv@ifdefined{ekvc@fasthash@#1}{}% {% \begingroup \edef\ekvc@tmp @@ -1739,10 +1726,10 @@ and the derived files expkv-cs.pdf ####1% {% \unexpanded\expandafter{\csname ekvc@@safehash@#1\endcsname}% - ####1\unexpanded{\ekvc@mark\ekv@zero}% + ####1\unexpanded{\ekvc@mark}{}% \unexpanded\expandafter {% - \csname ekvc@hashmark@#1\endcsname\ekv@zero + \csname ekvc@hashmark@#1\endcsname{}% \ekvc@mark{\ekvc@err@missing@hash{#1}}\ekvc@stop }% }% @@ -1753,7 +1740,7 @@ and the derived files expkv-cs.pdf ####2####3\unexpanded{\ekvc@mark}####4####5% \unexpanded{\ekvc@stop}% {% - ####4####2% + ####4{####2}% }% \long\gdef\unexpanded\expandafter {\csname ekvc@fastsplithash@#1\endcsname}% @@ -1800,10 +1787,10 @@ and the derived files expkv-cs.pdf % \begin{macrocode} \long\def\ekvcValue#1% {% - \romannumeral + \unexpanded \ekv@ifdefined{ekvc@safehash@#1}% {\csname ekvc@safehash@#1\endcsname}% - {\ekvc@err@unknown@hash{#1}\@firstoftwo\ekv@zero}% + {\ekvc@err@unknown@hash{#1}\@firstoftwo{{}}}% } % \end{macrocode} % \end{macro} @@ -1867,9 +1854,9 @@ and the derived files expkv-cs.pdf % without affecting performance by just defining the macro that would be build % in that case. There is of course a downside to this, the error will not be % thrown by |\ekvcValueFast| in three expansion steps. The safe hash variant -% has to also stop the |\romannumeral| expansion. +% has to also stop the |\unexpanded| expansion. % \begin{macrocode} -\long\def\ekvc@safehash@#1{\ekvc@err@empty@hash\ekv@zero} +\long\def\ekvc@safehash@#1{\ekvc@err@empty@hash{}} \long\def\ekvc@fasthash@#1\ekvc@stop{\ekvc@err@empty@hash} \long\def\ekvc@safesplithash@#1#2{\ekvc@err@empty@hash#2{#1}{}} \long\def\ekvc@fastsplithash@#1\ekvc@stop#2{\ekvc@err@empty@hash#2{#1}{}} diff --git a/macros/generic/expkv-cs/expkv-cs.pdf b/macros/generic/expkv-cs/expkv-cs.pdf Binary files differindex 50dd5124bf..1e19349f76 100644 --- a/macros/generic/expkv-cs/expkv-cs.pdf +++ b/macros/generic/expkv-cs/expkv-cs.pdf diff --git a/macros/generic/expkv/README.md b/macros/generic/expkv/README.md index adc545fd80..a402daa774 100644 --- a/macros/generic/expkv/README.md +++ b/macros/generic/expkv/README.md @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- # expkv -- an expandable key=val implementation -Version 2021-05-24 v1.8 +Version 2021-06-03 v1.8a Released under the LaTeX Project Public License v1.3c or later See http://www.latex-project.org/lppl.txt diff --git a/macros/generic/expkv/expkv.dtx b/macros/generic/expkv/expkv.dtx index 37a67fc781..283cd0353d 100644 --- a/macros/generic/expkv/expkv.dtx +++ b/macros/generic/expkv/expkv.dtx @@ -529,7 +529,7 @@ and the derived files expkv.pdf % sets are discarded, if the \key\ isn't found in any set an error will be % thrown eventually. Note that the error messages are affected by the use of % this macro, in particular, it isn't checked whether a |NoVal| key of the -% same name is defined in order to throw a |value forbidden| error. +% same name is defined in order to throw an |unwanted value| error. % |\ekvdefunknown| and |\ekvredirectunknown| are mutually exclusive, % you can't use both. % \end{function} @@ -547,7 +547,7 @@ and the derived files expkv.pdf % |NoVal| keys. Again no prefixes are supported. Note that the error messages % are affected by the use of this macro, in particular, it isn't checked % whether a normal key of the same name is defined in order to throw a -% |value forbidden| error. +% |missing value| error. % |\ekvdefunknownNoVal| and |\ekvredirectunknownNoVal| are mutually exclusive, % you can't use both. % \end{function} @@ -694,12 +694,17 @@ and the derived files expkv.pdf % the \key. There are no macros like these two contained in \expkv, you have % to set them up yourself if you want to use |\ekvparse| (of course the names % might differ). If you need the results of |\ekvparse| as the argument for -% another macro, you should use |\expanded| as only then the input stream will -% contain the output above: +% another macro, you should use |\expanded|, or expand |\ekvparse| twice, as +% only then the input stream will contain the output above: % \begin{lstlisting} % \expandafter\parse\expanded{\ekvparse\k\kv{foo = bar, key, baz={zzz}}} % \end{lstlisting} -% would expand to +% or +% \begin{lstlisting} +% \expandafter\expandafter\expandafter +% \parse\ekvparse\k\kv{foo = bar, key, baz={zzz}} +% \end{lstlisting} +% would both expand to % \begin{lstlisting} % \parse\kv{foo}{bar}\k{key}\kv{baz}{zzz} % \end{lstlisting} @@ -808,11 +813,12 @@ and the derived files expkv.pdf % \meta{next}\marg{default}\marg{mandatory} (so the default will be used and % the mandatory argument will be wrapped in braces). % \end{function} -% |\ekvoptarg| expands in exactly two steps and is alignment safe. It has its -% limitations however. It can't tell the difference between |[| and |{[}|, so it -% doesn't work if the mandatory argument is a single bracket. Also if the -% optional argument should contain a nested closing bracket, the optional -% argument has to use nested braces like so: |[{arg]ument}]|. +% |\ekvoptarg| expands in exactly two steps, grabs all the arguments only at the +% second expansion step, and is alignment safe. It has its limitations however. +% It can't tell the difference between |[| and |{[}|, so it doesn't work if the +% mandatory argument is a single bracket. Also if the optional argument should +% contain a nested closing bracket, the optional argument has to use nested +% braces like so: |[{arg]ument}]|. % \example Say we have a macro that should take an optional argument defaulting % to 1: % \begin{lstlisting}[aboveskip=0pt,belowskip=0pt] @@ -828,8 +834,9 @@ and the derived files expkv.pdf % \meta{true}\marg{optional}\meta{mandatory} or \meta{false}\marg{mandatory} % instead of placing a default value. % \end{function} -% |\ekvoptargTF| expands in exactly two steps and is alignment safe. It has the -% same limitations as |\ekvoptarg|. +% |\ekvoptargTF| expands in exactly two steps, grabs all the arguments only at +% the second expansion step, and is alignment safe. It has the same limitations +% as |\ekvoptarg|. % \example Say we have a macro that should behave differently depending on % whether there was an optional argument or not. This could be done with: % \begin{lstlisting}[aboveskip=0pt,belowskip=0pt] @@ -1207,7 +1214,7 @@ and the derived files expkv.pdf % \file{expkv.tex} checks whether \eTeX\ and the |\expanded| primitive are % available. If it isn't, an error will be thrown using |\errmessage|: % \begin{lstlisting} -% ! expkv Error: e-TeX required. +% ! expkv Error: e-TeX and \expanded required. % \end{lstlisting} % % \subsubsection{Defining Keys} @@ -1547,8 +1554,8 @@ and the derived files expkv.pdf % \begin{macro}{\ekvVersion,\ekvDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvVersion{1.8} -\def\ekvDate{2021-05-24} +\def\ekvVersion{1.8a} +\def\ekvDate{2021-06-03} % \end{macrocode} % \end{macro} % @@ -2689,30 +2696,28 @@ and the derived files expkv.pdf \def\ekvoptarg#1#2{% \endgroup % \end{macrocode} -% The real definition starts an expansion context after grabbing the arguments. -% |#1| will be the next step, |#2| the default value, and |#3| might be an -% opening bracket, or the mandatory argument. We check for the opening bracket, -% if it is found grab the optional argument, else leave |#1{#2}| in the input -% stream after ending the expansion context. +% The real definition starts an expansion context and afterwards grabs the +% arguments. |#1| will be the next step, |#2| the default value, and |#3| might +% be an opening bracket, or the mandatory argument. We check for the opening +% bracket, if it is found grab the optional argument, else leave |#1{#2}| in the +% input stream after ending the expansion context. % \begin{macrocode} -\long\def\ekvoptarg##1##2##3% +\def\ekvoptarg{\romannumeral#1\ekv@optarg@a} +\long\def\ekv@optarg@a##1##2##3% {% - \romannumeral - #1% - \ekv@optarg@if\ekv@mark##3\ekv@mark\ekv@optarg\ekv@mark[\ekv@mark + \ekv@optarg@if\ekv@mark##3\ekv@mark\ekv@optarg@b\ekv@mark[\ekv@mark #2% \@firstofone{\ekv@zero##1}{##2}{##3}% - } + }% % \end{macrocode} % The other variant of this will do roughly the same. Here, |#1| will be the % next step if an optional argument is found, |#2| the next step else, and |#3| % might be the opening bracket or mandatory argument. % \begin{macrocode} -\long\def\ekvoptargTF##1##2##3% +\def\ekvoptargTF{\romannumeral#1\ekv@optargTF@a} +\long\def\ekv@optargTF@a##1##2##3% {% - \romannumeral - #1% - \ekv@optarg@if\ekv@mark##3\ekv@mark\ekv@optargTF{##1}\ekv@mark[\ekv@mark + \ekv@optarg@if\ekv@mark##3\ekv@mark\ekv@optargTF@b{##1}\ekv@mark[\ekv@mark #2% \@firstofone{\ekv@zero##2}{##3}% } @@ -2720,9 +2725,10 @@ and the derived files expkv.pdf % The two macros to grab the optional argument have to remove the remainder of % the test and the wrong next step as well as grabbing the argument. % \begin{macrocode} -\long\def\ekv@optarg\ekv@mark[\ekv@mark\ifnum`##1\fi\@firstofone##2##3##4##5]% +\long\def\ekv@optarg@b\ekv@mark[\ekv@mark\ifnum`##1\fi\@firstofone##2##3##4##5]% {#2##2{##5}} -\long\def\ekv@optargTF##1\ekv@mark[\ekv@mark\ifnum`##2\fi\@firstofone##3##4##5]% +\long\def\ekv@optargTF@b + ##1\ekv@mark[\ekv@mark\ifnum`##2\fi\@firstofone##3##4##5]% {#2\ekv@zero##1{##5}} } % \end{macrocode} diff --git a/macros/generic/expkv/expkv.pdf b/macros/generic/expkv/expkv.pdf Binary files differindex 1f9248c9ec..c72c22153a 100644 --- a/macros/generic/expkv/expkv.pdf +++ b/macros/generic/expkv/expkv.pdf |