diff options
author | Norbert Preining <norbert@preining.info> | 2021-09-22 03:00:42 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-09-22 03:00:42 +0000 |
commit | 094234b56c200ad35a041aa579c18cbcac8933ed (patch) | |
tree | 730b37a8684e85e78d7098d8cf34facf76684b3d /macros/generic | |
parent | 32e0f5d0a5abc4f2b6c7341f19b854b5945c3ebd (diff) |
CTAN sync 202109220300
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 | 344 | ||||
-rw-r--r-- | macros/generic/expkv-cs/expkv-cs.pdf | bin | 454716 -> 460837 bytes | |||
-rw-r--r-- | macros/generic/expkv-def/README.md | 2 | ||||
-rw-r--r-- | macros/generic/expkv-def/expkv-def.dtx | 79 | ||||
-rw-r--r-- | macros/generic/expkv-def/expkv-def.pdf | bin | 407494 -> 410977 bytes | |||
-rw-r--r-- | macros/generic/expkv/README.md | 2 | ||||
-rw-r--r-- | macros/generic/expkv/expkv.dtx | 181 | ||||
-rw-r--r-- | macros/generic/expkv/expkv.pdf | bin | 487605 -> 490757 bytes |
9 files changed, 372 insertions, 238 deletions
diff --git a/macros/generic/expkv-cs/README.md b/macros/generic/expkv-cs/README.md index 329a8f6ef2..648b3b5a59 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-07-07 v1.1 +Version 2021-09-20 v1.1a 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 f0582ca236..ffb706b221 100644 --- a/macros/generic/expkv-cs/expkv-cs.dtx +++ b/macros/generic/expkv-cs/expkv-cs.dtx @@ -43,6 +43,7 @@ This work consists of the file expkv-cs.dtx and the derived files expkv-cs.pdf expkv-cs.sty expkv-cs.tex + t-expkv-cs.tex \endpreamble % stop docstrip adding \endinput @@ -50,6 +51,7 @@ and the derived files expkv-cs.pdf \endpostamble \generate{\file{expkv-cs.sty}{\from{expkv-cs.dtx}{pkg}}} \generate{\file{expkv-cs.tex}{\from{expkv-cs.dtx}{tex}}} +\generate{\file{t-expkv-cs.tex}{\from{expkv-cs.dtx}{ctx}}} \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -108,6 +110,7 @@ and the derived files expkv-cs.pdf TeX, textit,texttt, usepackage, + usemodule, } ,moretexcs=[6]^^A used packages { @@ -285,8 +288,8 @@ 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{\number,\detokenize,\meaning} -\DoNotIndex{\^,\@firstofone,\@firstoftwo,\@gobble,\@secondoftwo} +\DoNotIndex{\number,\detokenize,\meaning,\lccode,\lowercase} +\DoNotIndex{\^,\\,\@firstofone,\@firstoftwo,\@gobble,\@secondoftwo} \DoNotIndex{\ifcsname} \DoNotIndex{\ifx} \DoNotIndex{\ifodd} @@ -372,12 +375,13 @@ and the derived files expkv-cs.pdf % |\ekvcSplit|, is very convenient in my opinion, so if you just want to define % a single macro with just a few keys this might be the way to go. % -% \expkvc\ is usable as generic code and as a \LaTeX\ package. It'll -% automatically load \expkv\ in the same mode as well. To use it, just use one -% of +% \expkvc\ is usable as generic code, as a \LaTeX\ package, and as a \ConTeXt\ +% module. It'll automatically load \expkv\ in the same mode as well. To use it, +% just use one of % \begin{lstlisting} -% \usepackage{expkv-cs} % LaTeX % \input expkv-cs % plainTeX +% \usepackage{expkv-cs} % LaTeX +% \usemodule[expkv-cs] % ConTeXt % \end{lstlisting} % % @@ -1523,6 +1527,22 @@ and the derived files expkv-cs.pdf % \gobbledocstriptag %</pkg> %^^A=<< +%^^A the ConTeXt module >>= +% \subsection{The \ConTeXt\ module} +% \gobbledocstriptag +%<*ctx> +% \begin{macrocode} +\writestatus{loading}{ConTeXt User Module / expkv-cs} +\usemodule[expkv] +\unprotect +\input expkv-cs.tex +\writestatus{loading} + {ConTeXt User Module / expkv-cs / Version \ekvcVersion\space loaded} +\protect\endinput +% \end{macrocode} +% \gobbledocstriptag +%</ctx> +%^^A=<< %^^A main file >>= % \subsection{The Generic Code} % The rest of this implementation will be the generic code. @@ -1548,8 +1568,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{1.1} -\def\ekvcDate{2021-07-07} +\def\ekvcVersion{1.1a} +\def\ekvcDate{2021-09-20} % \end{macrocode} % \end{macro} % @@ -1636,9 +1656,9 @@ and the derived files expkv-cs.pdf } \def\ekvc@ekvset@pre@expander@b#1\ekvc@stop#2\ekvc@stop {% - \unexpanded\expandafter{\ekv@alignsafe}% - \unexpanded{#1}##1\unexpanded{#2}% - \unexpanded\expandafter{\ekv@endalignsafe}% + \ekv@unexpanded\expandafter{\ekv@alignsafe}% + \ekv@unexpanded{#1}##1\ekv@unexpanded{#2}% + \ekv@unexpanded\expandafter{\ekv@endalignsafe}% } % \end{macrocode} % \end{macro} @@ -1675,17 +1695,17 @@ and the derived files expkv-cs.pdf \ekvc@any@long\edef#1##1% {% \expandafter\ekvc@ekvset@pre@expander\expandafter{\ekvc@set}% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\csname ekvc@split@\the\ekvc@keycount\endcsname}% - \unexpanded\expandafter{\ekvc@initials{}#2}% + \ekv@unexpanded\expandafter{\ekvc@initials{}#2}% }% }% {% \ekvc@any@long\edef#1##1% {% \expandafter\ekvc@ekvset@pre@expander\expandafter{\ekvc@set}% - \unexpanded{#2}% - \unexpanded\expandafter{\ekvc@initials}% + \ekv@unexpanded{#2}% + \ekv@unexpanded\expandafter{\ekvc@initials}% }% }% } @@ -1743,7 +1763,7 @@ and the derived files expkv-cs.pdf {% \begingroup \edef\ekvc@tmp - {\endgroup\def\unexpanded{\ekvc@tmp}{\ekvcSplit@build@argspec@{1}}}% + {\endgroup\def\ekv@unexpanded{\ekvc@tmp}{\ekvcSplit@build@argspec@{1}}}% \ekvc@tmp } \def\ekvcSplit@build@argspec@#1% @@ -1753,7 +1773,7 @@ and the derived files expkv-cs.pdf \fi \@firstofone {% - \unexpanded\expandafter{\csname ekvc@splitmark@#1\endcsname####}#1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@#1\endcsname####}#1% \expandafter\ekvcSplit@build@argspec@\expandafter{\the\numexpr#1+1}% }% } @@ -1763,7 +1783,7 @@ and the derived files expkv-cs.pdf % \begin{macro}[internal] % { % \ekvc@SetupSplitKeys, \ekvc@SetupSplitKeys@a, \ekvc@SetupSplitKeys@b, -% \ekvc@SetupSplitKeys@c, +% \ekvc@SetupSplitKeys@c, \ekvc@SetupSplitKeys@d % \ekvc@SetupSplitKeys@check@unknown,\ekvc@SetupSplitKeys@unknown % } % These macros parse the list of keys and set up the key macros. First we need @@ -1780,24 +1800,26 @@ and the derived files expkv-cs.pdf % Then we need to step the key counter for each key. Also we have to check % whether this key has a |long| prefix so we initialise |\ekvc@long|. % \begin{macrocode} -\protected\def\ekvc@SetupSplitKeys@a#1% +\protected\long\def\ekvc@SetupSplitKeys@a#1% + {\expandafter\ekvc@SetupSplitKeys@b\detokenize{#1}\ekvc@stop} +\protected\def\ekvc@SetupSplitKeys@b#1\ekvc@stop {% \advance\ekvc@keycount1 \let\ekvc@long\ekv@empty \ekvc@ifspace{#1}% - {\ekvc@SetupSplitKeys@b#1\ekvc@stop}% - {\ekvc@SetupSplitKeys@c{#1}}% + {\ekvc@SetupSplitKeys@c#1\ekvc@stop}% + {\ekvc@SetupSplitKeys@d{#1}}% } % \end{macrocode} % If there was a space, there might be a prefix. If so call the prefix macro, -% else call the next step |\ekvc@SetupSplitKeys@c| which will define the key +% else call the next step |\ekvc@SetupSplitKeys@d| which will define the key % macro and add the key's value to the initials list. % \begin{macrocode} -\protected\def\ekvc@SetupSplitKeys@b#1 #2\ekvc@stop +\protected\long\def\ekvc@SetupSplitKeys@c#1 #2\ekvc@stop {% \ekv@ifdefined{ekvc@split@p@#1}% {\csname ekvc@split@p@#1\endcsname{#2}}% - {\ekvc@SetupSplitKeys@c{#1 #2}}% + {\ekvc@SetupSplitKeys@d{#1 #2}}% } % \end{macrocode} % The inner definition is grouped, because we don't want to actually define @@ -1807,18 +1829,18 @@ and the derived files expkv-cs.pdf % the value given to the key. Additionally we'll need a sorting macro for each % key count in use so we set it up with |\ekvc@setup@splitmacro|. % \begin{macrocode} -\protected\long\def\ekvc@SetupSplitKeys@c#1#2% +\protected\long\def\ekvc@SetupSplitKeys@d#1#2% {% \begingroup \edef\ekvc@tmp {% \endgroup - \long\def\unexpanded{\ekvc@tmp}####1####2% - \unexpanded\expandafter + \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% + \ekv@unexpanded\expandafter {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}####3% {% ####2% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname}{####1}% }% % \end{macrocode} @@ -1829,18 +1851,19 @@ and the derived files expkv-cs.pdf % reordering. % \begin{macrocode} \unless\ifx\ekvc@long\long - \let\unexpanded\expandafter - {\csname ekvc@\ekvc@set(#1)\endcsname\ekvc@tmp}% - \def\unexpanded{\ekvc@tmp}####1% + \let\ekv@unexpanded\expandafter + {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname\ekvc@tmp}% + \def\ekv@unexpanded{\ekvc@tmp}####1% {% - \unexpanded\expandafter{\csname ekvc@\ekvc@set(#1)\endcsname}% + \ekv@unexpanded\expandafter + {\csname ekvc@\ekvc@set(\detokenize{#1})\endcsname}% {####1}% }% \fi - \def\unexpanded{\ekvc@initials}% + \def\ekv@unexpanded{\ekvc@initials}% {% - \unexpanded\expandafter{\ekvc@initials}% - \unexpanded\expandafter + \ekv@unexpanded\expandafter{\ekvc@initials}% + \ekv@unexpanded\expandafter {\csname ekvc@splitmark@\the\ekvc@keycount\endcsname{#2}}% }% }% @@ -1886,7 +1909,7 @@ and the derived files expkv-cs.pdf {##3#1{##4,##2= {##1} }}% \long\expandafter\def\csname\ekv@name\ekvc@set{}uN\endcsname##1##2#1##3% {##2#1{##3,##1}}% - \edef\ekvc@initials{\unexpanded\expandafter{\ekvc@initials#1{}}}% + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{}}}% \ekvc@helpers@needed {\expandafter\ekvc@setup@splitmacro\expandafter{\the\ekvc@keycount}}% {}% @@ -1902,7 +1925,7 @@ and the derived files expkv-cs.pdf {% \let\ekvc@long\long \let\ekvc@any@long\long - \ekvc@SetupSplitKeys@c + \ekvc@SetupSplitKeys@d } % \end{macrocode} % \end{macro} @@ -1911,7 +1934,7 @@ and the derived files expkv-cs.pdf % The |short| prefix does essentially nothing, it is only provided to allow % key names starting with |long| that aren't |\long|. % \begin{macrocode} -\def\ekvc@split@p@short{\ekvc@SetupSplitKeys@c} +\def\ekvc@split@p@short{\ekvc@SetupSplitKeys@d} % \end{macrocode} % \end{macro} % @@ -1939,53 +1962,53 @@ and the derived files expkv-cs.pdf \begingroup \edef\ekvc@tmp {% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@1\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@1\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}% ##1##2##3% {##3{##1}##2}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@2\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@2\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% ##3##4% {##4{##1}{##2}##3}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@3\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% - \unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@3\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% ##4##5% {##5{##1}{##2}{##3}##4}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@4\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% - \unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% - \unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@4\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% ##5##6% {##6{##1}{##2}{##3}{##4}##5}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@5\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% - \unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% - \unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% - \unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@5\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% ##6##7% {##7{##1}{##2}{##3}{##4}{##5}##6}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@6\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% - \unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% - \unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% - \unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% - \unexpanded\expandafter{\csname ekvc@splitmark@6\endcsname}##6% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@6\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@6\endcsname}##6% ##7##8% {##8{##1}{##2}{##3}{##4}{##5}{##6}##7}% - \long\gdef\unexpanded\expandafter{\csname ekvc@split@7\endcsname}% - \unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% - \unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% - \unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% - \unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% - \unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% - \unexpanded\expandafter{\csname ekvc@splitmark@6\endcsname}##6% - \unexpanded\expandafter{\csname ekvc@splitmark@7\endcsname}##7% + \long\gdef\ekv@unexpanded\expandafter{\csname ekvc@split@7\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@1\endcsname}##1% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@2\endcsname}##2% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@3\endcsname}##3% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@4\endcsname}##4% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@5\endcsname}##5% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@6\endcsname}##6% + \ekv@unexpanded\expandafter{\csname ekvc@splitmark@7\endcsname}##7% ##8##9% {##9{##1}{##2}{##3}{##4}{##5}{##6}{##7}##8}% } @@ -1999,12 +2022,13 @@ and the derived files expkv-cs.pdf \edef\ekvc@tmp {% \long\gdef - \unexpanded\expandafter{\csname ekvc@split@#1\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@split@#1\endcsname}% ####1% - \unexpanded\expandafter{\csname ekvc@splitmark@#1\endcsname}% + \ekv@unexpanded\expandafter + {\csname ekvc@splitmark@#1\endcsname}% ####2####3% {% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\csname ekvc@split@\the\numexpr#1-1\relax\endcsname}% ####1{{####2}####3}% }% @@ -2043,16 +2067,16 @@ and the derived files expkv-cs.pdf \ekvc@any@long\edef#1##1% {% \expandafter\ekvc@ekvset@pre@expander\expandafter{\ekvc@set}% - \unexpanded{\ekvc@hash@pack@argument}% - \unexpanded\expandafter{\ekvc@initials\ekvc@stop#2}% + \ekv@unexpanded{\ekvc@hash@pack@argument}% + \ekv@unexpanded\expandafter{\ekvc@initials\ekvc@stop#2}% }% }% {% \ekvc@any@long\edef#1##1% {% \expandafter\ekvc@ekvset@pre@expander\expandafter{\ekvc@set}% - \unexpanded{#2}% - \unexpanded\expandafter{\ekvc@initials\ekvc@stop}% + \ekv@unexpanded{#2}% + \ekv@unexpanded\expandafter{\ekvc@initials\ekvc@stop}% }% }% } @@ -2102,9 +2126,9 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}[internal] -% {% +% { % \ekvc@SetupHashKeys,\ekvc@SetupHashKeys@a,\ekvc@SetupHashKeys@b, -% \ekvc@SetupHashKeys@c, +% \ekvc@SetupHashKeys@c,\ekvc@SetupHashKeys@d % \ekvc@SetupHashKeys@check@unknown,\ekvc@SetupHashKeys@unknown % } % This should look awfully familiar as well, since it's just the same as for @@ -2116,18 +2140,20 @@ and the derived files expkv-cs.pdf \let\ekvc@initials\ekv@empty \ekvparse\ekvc@SetupHashKeys@check@unknown\ekvc@SetupHashKeys@a{#1}% } -\protected\def\ekvc@SetupHashKeys@a#1% +\protected\long\def\ekvc@SetupHashKeys@a#1% + {\expandafter\ekvc@SetupHashKeys@b\detokenize{#1}\ekvc@stop} +\protected\def\ekvc@SetupHashKeys@b#1\ekvc@stop {% \let\ekvc@long\ekv@empty \ekvc@ifspace{#1}% - {\ekvc@SetupHashKeys@b#1\ekvc@stop}% - {\ekvc@SetupHashKeys@c{#1}}% + {\ekvc@SetupHashKeys@c#1\ekvc@stop}% + {\ekvc@SetupHashKeys@d{#1}}% } -\protected\def\ekvc@SetupHashKeys@b#1 #2\ekvc@stop +\protected\def\ekvc@SetupHashKeys@c#1 #2\ekvc@stop {% \ekv@ifdefined{ekvc@hash@p@#1}% {\csname ekvc@hash@p@#1\endcsname{#2}}% - {\ekvc@SetupHashKeys@c{#1 #2}}% + {\ekvc@SetupHashKeys@d{#1 #2}}% } % \end{macrocode} % Yes, even the defining macro looks awfully familiar. Instead of numbered we @@ -2136,31 +2162,33 @@ and the derived files expkv-cs.pdf % short keys. And instead of the |\ekvc@setup@splitmacro| we use % |\ekvc@setup@hashmacro|. % \begin{macrocode} -\protected\long\def\ekvc@SetupHashKeys@c#1#2% +\protected\long\def\ekvc@SetupHashKeys@d#1#2% {% \begingroup \edef\ekvc@tmp {% \endgroup - \long\def\unexpanded{\ekvc@tmp}####1####2% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}####3% + \long\def\ekv@unexpanded{\ekvc@tmp}####1####2% + \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% + ####3% {% ####2% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}{####1}% + \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% + {####1}% }% \unless\ifx\ekvc@long\long - \let\unexpanded\expandafter + \let\ekv@unexpanded\expandafter {\csname ekvc@\ekvc@set(#1)\endcsname\ekvc@tmp}% - \def\unexpanded{\ekvc@tmp}####1% + \def\ekv@unexpanded{\ekvc@tmp}####1% {% - \unexpanded\expandafter{\csname ekvc@\ekvc@set(#1)\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@\ekvc@set(#1)\endcsname}% {####1}% }% \fi - \def\unexpanded{\ekvc@initials}% + \def\ekv@unexpanded{\ekvc@initials}% {% - \unexpanded\expandafter{\ekvc@initials}% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname{#2}}% + \ekv@unexpanded\expandafter{\ekvc@initials}% + \ekv@unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname{#2}}% }% }% \ekvc@tmp @@ -2192,7 +2220,7 @@ and the derived files expkv-cs.pdf \let\csname\ekv@name\ekvc@set{}u\endcsname\ekvc@hash@unknown@kv \expandafter \let\csname\ekv@name\ekvc@set{}uN\endcsname\ekvc@hash@unknown@k - \edef\ekvc@initials{\unexpanded\expandafter{\ekvc@initials#1{}}}% + \edef\ekvc@initials{\ekv@unexpanded\expandafter{\ekvc@initials#1{}}}% \ekvc@setup@hashmacro{...}% }% \long\def\ekvc@hash@unknown@kv##1##2##3#1##4{##3#1{##4,##2= {##1} }}% @@ -2210,7 +2238,7 @@ and the derived files expkv-cs.pdf {% \let\ekvc@long\long \let\ekvc@any@long\long - \ekvc@SetupHashKeys@c + \ekvc@SetupHashKeys@d } % \end{macrocode} % \end{macro} @@ -2219,7 +2247,7 @@ and the derived files expkv-cs.pdf % The |short| prefix does essentially nothing, it is only provided to allow % key names starting with |long| that aren't |\long|. % \begin{macrocode} -\def\ekvc@hash@p@short{\ekvc@SetupHashKeys@c} +\def\ekvc@hash@p@short{\ekvc@SetupHashKeys@d} % \end{macrocode} % \end{macro} % @@ -2240,47 +2268,52 @@ and the derived files expkv-cs.pdf \edef\ekvc@tmp {% \long\gdef - \unexpanded\expandafter{\csname ekvc@fasthash@#1\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@fasthash@#1\endcsname}% ####1% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####2####3\unexpanded{\ekvc@stop}% + \ekv@unexpanded\expandafter + {\csname ekvc@hashmark@#1\endcsname}% + ####2####3\ekv@unexpanded{\ekvc@stop}% {####2}% \long\gdef - \unexpanded\expandafter{\csname ekvc@safehash@#1\endcsname}% + \ekv@unexpanded\expandafter{\csname ekvc@safehash@#1\endcsname}% ####1% {% - \unexpanded\expandafter{\csname ekvc@@safehash@#1\endcsname}% - ####1\unexpanded{\ekvc@mark}{}% - \unexpanded\expandafter + \ekv@unexpanded\expandafter + {\csname ekvc@@safehash@#1\endcsname}% + ####1\ekv@unexpanded{\ekvc@mark}{}% + \ekv@unexpanded\expandafter {% \csname ekvc@hashmark@#1\endcsname{}% \ekvc@mark{\ekvc@err@missing@hash{#1}}\ekvc@stop }% }% \long\gdef - \unexpanded\expandafter{\csname ekvc@@safehash@#1\endcsname}% + \ekv@unexpanded\expandafter + {\csname ekvc@@safehash@#1\endcsname}% ####1% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####2####3\unexpanded{\ekvc@mark}####4####5% - \unexpanded{\ekvc@stop}% + \ekv@unexpanded\expandafter + {\csname ekvc@hashmark@#1\endcsname}% + ####2####3\ekv@unexpanded{\ekvc@mark}####4####5% + \ekv@unexpanded{\ekvc@stop}% {% ####4{####2}% }% - \long\gdef\unexpanded\expandafter + \long\gdef\ekv@unexpanded\expandafter {\csname ekvc@fastsplithash@#1\endcsname}% ####1% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####2####3\unexpanded{\ekvc@stop}####4% + \ekv@unexpanded\expandafter + {\csname ekvc@hashmark@#1\endcsname}% + ####2####3\ekv@unexpanded{\ekvc@stop}####4% {% ####4{####2}% }% - \long\gdef\unexpanded\expandafter + \long\gdef\ekv@unexpanded\expandafter {\csname ekvc@safesplithash@#1\endcsname}####1% {% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\csname ekvc@@safesplithash@#1\endcsname}% - ####1\unexpanded{\ekvc@mark\ekvc@safe@after@hash}% - \unexpanded\expandafter + ####1\ekv@unexpanded{\ekvc@mark\ekvc@safe@after@hash}% + \ekv@unexpanded\expandafter {% \csname ekvc@hashmark@#1\endcsname{}% \ekvc@mark @@ -2288,12 +2321,13 @@ and the derived files expkv-cs.pdf \ekvc@stop }% }% - \long\gdef\unexpanded\expandafter + \long\gdef\ekv@unexpanded\expandafter {\csname ekvc@@safesplithash@#1\endcsname}% ####1% - \unexpanded\expandafter{\csname ekvc@hashmark@#1\endcsname}% - ####2####3\unexpanded{\ekvc@mark}####4####5% - \unexpanded{\ekvc@stop}% + \ekv@unexpanded\expandafter + {\csname ekvc@hashmark@#1\endcsname}% + ####2####3\ekv@unexpanded{\ekvc@mark}####4####5% + \ekv@unexpanded{\ekvc@stop}% {% ####4{####2}% }% @@ -2306,32 +2340,42 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}{\ekvcValue} +% \begin{macro}[internal]{\ekvcValue@} % All this does is a few consistency checks on the first argument (not empty, % hash macro exists) and then call that hash-grabbing macro that will also % test whether the hash is inside of |#2| or not. % \begin{macrocode} \long\def\ekvcValue#1% {% - \unexpanded + \ekv@unexpanded + \expandafter\ekvcValue@\detokenize{#1}\ekvc@stop + } +\def\ekvcValue@#1\ekvc@stop + {% \ekv@ifdefined{ekvc@safehash@#1}% {\csname ekvc@safehash@#1\endcsname}% {\ekvc@err@unknown@hash{#1}\@firstoftwo{{}}}% } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\ekvcValueFast} % To be as fast as possible, this doesn't test for anything, assuming the user % knows best. % \begin{macrocode} -\long\def\ekvcValueFast#1#2{\csname ekvc@fasthash@#1\endcsname#2\ekvc@stop} +\long\def\ekvcValueFast#1#2% + {\csname ekvc@fasthash@\detokenize{#1}\endcsname#2\ekvc@stop} % \end{macrocode} % \end{macro} % -% \begin{macro}{\ekvcValueSplit,\ekvcValueSplit@recover} +% \begin{macro}{\ekvcValueSplit} +% \begin{macro}[internal]{\ekvcValueSplit@,\ekvcValueSplit@recover} % This splits off a single value. % \begin{macrocode} \long\def\ekvcValueSplit#1% + {\expandafter\ekvcValueSplit@\detokenize{#1}\ekvc@stop} +\def\ekvcValueSplit@#1\ekvc@stop {% \ekv@ifdefined{ekvc@safesplithash@#1}% {\csname ekvc@safesplithash@#1\endcsname}% @@ -2340,6 +2384,7 @@ and the derived files expkv-cs.pdf \long\def\ekvcValueSplit@recover#1#2{#2{}} % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}[internal]{\ekvc@safe@after@hash} % \begin{macrocode} @@ -2357,7 +2402,7 @@ and the derived files expkv-cs.pdf % sequence. % \begin{macrocode} \long\def\ekvcValueSplitFast#1#2% - {\csname ekvc@fastsplithash@#1\endcsname#2\ekvc@stop} + {\csname ekvc@fastsplithash@\detokenize{#1}\endcsname#2\ekvc@stop} % \end{macrocode} % \end{macro} % @@ -2380,6 +2425,8 @@ and the derived files expkv-cs.pdf % \end{macro} % % \begin{macro}{\ekvcSecondaryKeys} +% \begin{macro}[internal] +% {\ekvcSecondaryKeys@a,\ekvcSecondaryKeys@b,\ekvcSecondaryKeys@c} % The secondary keys are defined pretty similar to the way the originals are, % but here we also introduce some key types (those have a |@t@| in their name) % additionally to the prefixes. @@ -2389,14 +2436,16 @@ and the derived files expkv-cs.pdf \edef\ekvc@set{\string#1}% \ekvparse\ekvc@err@value@required\ekvcSecondaryKeys@a{#2}% } -\protected\def\ekvcSecondaryKeys@a#1% +\protected\long\def\ekvcSecondaryKeys@a#1% + {\expandafter\ekvcSecondaryKeys@b\detokenize{#1}\ekvc@stop} +\protected\def\ekvcSecondaryKeys@b#1\ekvc@stop {% \let\ekvc@long\ekv@empty \ekvc@ifspace{#1}% - {\ekvcSecondaryKeys@b#1\ekvc@stop}% + {\ekvcSecondaryKeys@c#1\ekvc@stop}% {\ekvc@err@missing@type{#1}\@gobble}% } -\protected\def\ekvcSecondaryKeys@b#1 #2\ekvc@stop +\protected\def\ekvcSecondaryKeys@c#1 #2\ekvc@stop {% \ekv@ifdefined{ekvc@p@#1}% {\csname ekvc@p@#1\endcsname}% @@ -2409,6 +2458,7 @@ and the derived files expkv-cs.pdf } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\ekvcChange} % This can be used to change the defaults of an \expkvc\ defined macro. It @@ -2616,7 +2666,7 @@ and the derived files expkv-cs.pdf \ekvc@assert@not@long{default #1}% \edef\ekvc@tmp {% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\csname\ekv@name\ekvc@set{#1}\endcsname{#2}}% }% \ekvletNoVal\ekvc@set{#1}\ekvc@tmp @@ -2882,8 +2932,8 @@ and the derived files expkv-cs.pdf {% \edef#1% {% - \unexpanded{\ekvc@flag@height}% - \unexpanded\expandafter{\csname\ekvc@flag@name#1\endcsname}% + \ekv@unexpanded{\ekvc@flag@height}% + \ekv@unexpanded\expandafter{\csname\ekvc@flag@name#1\endcsname}% }% \ekv@expargtwice {\expandafter\def\csname\ekvc@flag@name#1\endcsname##1}% @@ -3100,7 +3150,7 @@ and the derived files expkv-cs.pdf % \begin{macrocode} \def\ekvc@extract@mark#1{\expandafter\ekvc@extract@mark@\meaning#1\ekv@stop} \begingroup -\lccode`;=`\# +\lccode`;=`# \lccode`/=`\\ \lowercase{\endgroup \def\ekvc@extract@mark@#1:#2/#3 ;#4\ekv@stop{#3}% @@ -3142,41 +3192,41 @@ and the derived files expkv-cs.pdf {% \errmessage{expkv-cs Error: Too many keys for macro `\string#1'}% } -\protected\def\ekvc@err@value@required#1% +\protected\long\def\ekvc@err@value@required#1% {% - \errmessage{expkv-cs Error: Missing value for key `\unexpanded{#1}'}% + \errmessage{expkv-cs Error: Missing value for key `\ekv@unexpanded{#1}'}% } -\protected\def\ekvc@err@missing@type#1% +\protected\long\def\ekvc@err@missing@type#1% {% \errmessage - {expkv-cs Error: Missing type for secondary key `\unexpanded{#1}'}% + {expkv-cs Error: Missing type for secondary key `\ekv@unexpanded{#1}'}% } -\protected\def\ekvc@err@no@long#1% +\protected\long\def\ekvc@err@no@long#1% {% \errmessage - {expkv-cs Error: prefix `long' not accepted for `\unexpanded{#1}'}% + {expkv-cs Error: prefix `long' not accepted for `\ekv@unexpanded{#1}'}% } -\protected\def\ekvc@err@already@defined#1% +\protected\long\def\ekvc@err@already@defined#1% {% \errmessage{expkv-cs Error: Macro `\string#1' already defined}% } -\protected\def\ekvc@err@unknown@keytype#1% +\protected\long\def\ekvc@err@unknown@keytype#1% {% - \errmessage{expkv-cs Error: Unknown key type `\unexpanded{#1}'}% + \errmessage{expkv-cs Error: Unknown key type `\ekv@unexpanded{#1}'}% } -\protected\def\ekvc@err@unknown@key#1% +\protected\long\def\ekvc@err@unknown@key#1% {% \errmessage - {expkv-cs Error: Unknown key `\unexpanded{#1}' for macro `\ekvc@set'}% + {expkv-cs Error: Unknown key `\ekv@unexpanded{#1}' for macro `\ekvc@set'}% } -\long\def\ekvc@err@no@key@macro#1% +\protected\long\def\ekvc@err@no@key@macro#1% {\errmessage{expkv-cs Error: \string#1 is no key=val macro}} \protected\long\def\ekvc@err@not@two#1% {% \errmessage {% - expkv-cs Error: Definition of `\unexpanded{#1}' doesn't contain exactly - two arguments% + expkv-cs Error: Definition of `\ekv@unexpanded{#1}' doesn't contain + exactly two arguments% }% } % \end{macrocode} diff --git a/macros/generic/expkv-cs/expkv-cs.pdf b/macros/generic/expkv-cs/expkv-cs.pdf Binary files differindex 2d341f0e6a..130e142fb3 100644 --- a/macros/generic/expkv-cs/expkv-cs.pdf +++ b/macros/generic/expkv-cs/expkv-cs.pdf diff --git a/macros/generic/expkv-def/README.md b/macros/generic/expkv-def/README.md index da6fb32a6c..3b4417a2cb 100644 --- a/macros/generic/expkv-def/README.md +++ b/macros/generic/expkv-def/README.md @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- # expkv-def -- a key-defining frontend for expkv -Version 2021-09-18 v0.8b +Version 2021-09-20 v0.8c 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-def/expkv-def.dtx b/macros/generic/expkv-def/expkv-def.dtx index 8aa537402e..c9d6ebe5b7 100644 --- a/macros/generic/expkv-def/expkv-def.dtx +++ b/macros/generic/expkv-def/expkv-def.dtx @@ -43,6 +43,7 @@ This work consists of the file expkv-def.dtx and the derived files expkv-def.pdf expkv-def.sty expkv-def.tex + t-expkv-def.tex \endpreamble % stop docstrip adding \endinput @@ -50,6 +51,7 @@ and the derived files expkv-def.pdf \endpostamble \generate{\file{expkv-def.sty}{\from{expkv-def.dtx}{pkg}}} \generate{\file{expkv-def.tex}{\from{expkv-def.dtx}{tex}}} +\generate{\file{t-expkv-def.tex}{\from{expkv-def.dtx}{ctx}}} \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -317,8 +319,8 @@ and the derived files expkv-def.pdf % \expkvd\ provides a small \kv\ interface to define keys for \expkv. Key-types % are declared using prefixes, similar to static typed languages. The stylised % name is \expkvd\ but the files use \file{expkv-def}, this is due to CTAN-rules -% which don't allow \string| in package names since that is the pipe symbol in *nix -% shells. +% which don't allow \string| in package names since that is the pipe symbol in +% *nix shells. % \end{abstract} % % \tableofcontents @@ -345,12 +347,13 @@ and the derived files expkv-def.pdf % \autoref{sec:prefix:p}, the |t|-prefixes are described in % \autoref{sec:prefix:t}. % -% \expkvd\ is usable as generic code and as a \LaTeX\ package. It'll -% automatically load \expkv\ in the same mode as well. To use it, just use one -% of +% \expkvd\ is usable as generic code, as a \LaTeX\ package, and as a \ConTeXt\ +% module. It'll automatically load \expkv\ in the same mode as well. To use it, +% just use one of % \begin{lstlisting} -% \usepackage{expkv-def} % LaTeX % \input expkv-def % plainTeX +% \usepackage{expkv-def} % LaTeX +% \usemodule[expkv-def] % ConTeXt % \end{lstlisting} % % \subsection{Macros} @@ -480,8 +483,9 @@ and the derived files expkv-def.pdf % expand the \key's code once, so will be slightly quicker, but not change if % you redefine \key. |odefault| is just another name for |qdefault|. The % |fdefault| version will expand the key code until a non-expandable token or -% a space is found, a space would be gobbled.\footnotemark{} The |edefault| on the other hand fully expands -% the \key-code with \meta{definition} as its argument inside of an |\edef|. +% a space is found, a space would be gobbled.\footnotemark{} The |edefault| on +% the other hand fully expands the \key-code with \meta{definition} as its +% argument inside of an |\edef|. % \end{function} % \footnotetext % {^^A @@ -911,6 +915,22 @@ and the derived files expkv-def.pdf % \gobbledocstriptag %</pkg> %^^A=<< +%^^A the ConTeXt module >>= +% \subsection{The \ConTeXt\ module} +% \gobbledocstriptag +%<*ctx> +% \begin{macrocode} +\writestatus{loading}{ConTeXt User Module / expkv-def} +\usemodule[expkv] +\unprotect +\input expkv-def.tex +\writestatus{loading} + {ConTeXt User Module / expkv-def / Version \ekvdVersion\space loaded} +\protect\endinput +% \end{macrocode} +% \gobbledocstriptag +%</ctx> +%^^A=<< %^^A main file >>= % \subsection{The Generic Code} % The rest of this implementation will be the generic code. @@ -936,8 +956,8 @@ and the derived files expkv-def.pdf % \begin{macro}{\ekvdVersion,\ekvdDate} % We're on our first input, so lets store the version and date in a macro. % \begin{macrocode} -\def\ekvdVersion{0.8b} -\def\ekvdDate{2021-09-18} +\def\ekvdVersion{0.8c} +\def\ekvdDate{2021-09-20} % \end{macrocode} % \end{macro} % @@ -998,17 +1018,17 @@ and the derived files expkv-def.pdf % if so calls the prefix grabbing routine, else we throw an error and ignore the % key. % \begin{macrocode} -\protected\def\ekvd@noarg#1% +\protected\long\def\ekvd@noarg#1% {% \let\ekvd@ifnoarg\@firstoftwo - \ekvd@handle{#1}{}% + \expandafter\ekvd@handle\detokenize{#1}\ekvd@stop{}% } -\protected\def\ekvd@arg +\protected\long\def\ekvd@arg#1% {% \let\ekvd@ifnoarg\@secondoftwo - \ekvd@handle + \expandafter\ekvd@handle\detokenize{#1}\ekvd@stop } -\protected\long\def\ekvd@handle#1#2% +\protected\long\def\ekvd@handle#1\ekvd@stop#2% {% \ekvd@clear@prefixes \edef\ekvd@cur{\detokenize{#1}}% @@ -1172,7 +1192,7 @@ and the derived files expkv-def.pdf \ekvd@assert@not@long \ekvd@prot\edef\ekvd@tmp {% - \unexpanded\expandafter#1% + \ekv@unexpanded\expandafter#1% {#2\csname\ekv@name\ekvd@set{#3}\endcsname{#4}}% }% \ekvd@ifalso @@ -1358,14 +1378,16 @@ and the derived files expkv-def.pdf }% } \protected\def\ekvd@t@data - {\ekvd@type@data\@secondoftwo\edef{####2}{\unexpanded{##1}}} + {\ekvd@type@data\@secondoftwo\edef{####2}{\ekv@unexpanded{##1}}} \protected\def\ekvd@t@edata{\ekvd@type@data\@secondoftwo\edef{####2}{##1}} \protected\def\ekvd@t@gdata - {\ekvd@type@data\@secondoftwo\xdef{####2}{\unexpanded{##1}}} + {\ekvd@type@data\@secondoftwo\xdef{####2}{\ekv@unexpanded{##1}}} \protected\def\ekvd@t@xdata{\ekvd@type@data\@secondoftwo\xdef{####2}{##1}} -\protected\def\ekvd@t@dataT{\ekvd@type@data\@gobble\edef{}{\unexpanded{##1}}} +\protected\def\ekvd@t@dataT + {\ekvd@type@data\@gobble\edef{}{\ekv@unexpanded{##1}}} \protected\def\ekvd@t@edataT{\ekvd@type@data\@gobble\edef{}{##1}} -\protected\def\ekvd@t@gdataT{\ekvd@type@data\@gobble\xdef{}{\unexpanded{##1}}} +\protected\def\ekvd@t@gdataT + {\ekvd@type@data\@gobble\xdef{}{\ekv@unexpanded{##1}}} \protected\def\ekvd@t@xdataT{\ekvd@type@data\@gobble\xdef{}{##1}} % \end{macrocode} % \end{macro} @@ -1513,8 +1535,8 @@ and the derived files expkv-def.pdf }% }% } -\protected\def\ekvd@t@store{\ekvd@type@store\edef{\unexpanded{##1}}} -\protected\def\ekvd@t@gstore{\ekvd@type@store\xdef{\unexpanded{##1}}} +\protected\def\ekvd@t@store{\ekvd@type@store\edef{\ekv@unexpanded{##1}}} +\protected\def\ekvd@t@gstore{\ekvd@type@store\xdef{\ekv@unexpanded{##1}}} \protected\def\ekvd@t@estore{\ekvd@type@store\edef{##1}} \protected\def\ekvd@t@xstore{\ekvd@type@store\xdef{##1}} % \end{macrocode} @@ -1608,7 +1630,7 @@ and the derived files expkv-def.pdf {% \ekvd@assert@not@long \ekvd@prot\edef\ekvd@tmp##1% - {\unexpanded{\ekvd@h@choice}{\ekvd@choice@name\ekvd@set{#1}{##1}}}% + {\ekv@unexpanded{\ekvd@h@choice}{\ekvd@choice@name\ekvd@set{#1}{##1}}}% \ekvd@ifalso {% \ekvd@assert@val{#1}% @@ -2159,18 +2181,21 @@ and the derived files expkv-def.pdf \protected\def\ekvd@err@missing@definition {\ekvd@errm{Missing definition for key `\ekvd@cur'}} \protected\def\ekvd@err@missing@definition@msg#1% - {\ekvd@errm{Missing definition for key `\unexpanded{#1}'}} + {\ekvd@errm{Missing definition for key `\ekv@unexpanded{#1}'}} \protected\def\ekvd@err@missing@type {\ekvd@errm{Missing type prefix for key `\ekvd@cur'}} \protected\def\ekvd@err@undefined@prefix#1% {% \ekvd@errm - {Undefined prefix `\unexpanded{#1}' found while processing `\ekvd@cur'}% + {% + Undefined prefix `\ekv@unexpanded{#1}' found while processing + `\ekvd@cur'% + }% } \protected\def\ekvd@err@undefined@key#1% {% \ekvd@errm - {Undefined key `\unexpanded{#1}' found while processing `\ekvd@cur'}% + {Undefined key `\ekv@unexpanded{#1}' found while processing `\ekvd@cur'}% } \protected\def\ekvd@err@undefined@noval#1% {% @@ -2183,7 +2208,7 @@ and the derived files expkv-def.pdf \protected\def\ekvd@err@no@prefix#1% {\ekvd@errm{prefix `#1' not accepted in `\ekvd@cur'}} \protected\def\ekvd@err@no@prefix@msg#1#2% - {\ekvd@errm{prefix `#2' not accepted in `\unexpanded{#1}'}} + {\ekvd@errm{prefix `#2' not accepted in `\ekv@unexpanded{#1}'}} \protected\def\ekvd@err@no@prefix@also#1% {\ekvd@errm{`\ekvd@cur' not allowed with a `#1' key}} \protected\def\ekvd@err@add@val@on@noval diff --git a/macros/generic/expkv-def/expkv-def.pdf b/macros/generic/expkv-def/expkv-def.pdf Binary files differindex 59c3673f09..800ae3dae3 100644 --- a/macros/generic/expkv-def/expkv-def.pdf +++ b/macros/generic/expkv-def/expkv-def.pdf diff --git a/macros/generic/expkv/README.md b/macros/generic/expkv/README.md index 8c241c4217..ccfa3194b3 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-07-15 v1.9 +Version 2021-09-20 v1.9a 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 da6fcf2542..8651ad97a3 100644 --- a/macros/generic/expkv/expkv.dtx +++ b/macros/generic/expkv/expkv.dtx @@ -43,6 +43,7 @@ This work consists of the file expkv.dtx and the derived files expkv.pdf expkv.sty expkv.tex + t-expkv.tex \endpreamble % stop docstrip adding \endinput @@ -50,6 +51,7 @@ and the derived files expkv.pdf \endpostamble \generate{\file{expkv.sty}{\from{expkv.dtx}{pkg}}} \generate{\file{expkv.tex}{\from{expkv.dtx}{tex}}} +\generate{\file{t-expkv.tex}{\from{expkv.dtx}{ctx}}} \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -98,7 +100,7 @@ and the derived files expkv.pdf numexpr, protected, } - ,moretexcs=[5]^^A plain/LaTeX + ,moretexcs=[5]^^A plain/LaTeX/ConTeXt { approx, begin, @@ -112,6 +114,7 @@ and the derived files expkv.pdf TeX, textit,texttt, usepackage, + usemodule, } ,moretexcs=[6]^^A used packages { @@ -299,16 +302,25 @@ and the derived files expkv.pdf \newcommand\val{\meta{value}} \newcommand\set{\meta{set}} \hypersetup{linkcolor=red!80!black,urlcolor=purple!80!black} +\DoNotIndex{\directlua} \DoNotIndex{\def,\edef,\,,\=,\begingroup,\catcode,\chardef,\csname,\endcsname} \DoNotIndex{\endgroup,\endinput,\errmessage,\expandafter,\input,\let,\long} \DoNotIndex{\protected,\ProvidesFile,\ProvidesPackage,\relax,\space} -\DoNotIndex{\@,\unexpanded,\string,\expanded,\detokenize,\meaning,\lastnamedcs} -\DoNotIndex{\romannumeral,\z@} +\DoNotIndex{\^,\@,\unexpanded,\string,\expanded,\detokenize,\meaning} +\DoNotIndex{\lastnamedcs,\romannumeral,\z@} +\DoNotIndex{\noexpand,\normalexpanded,\normalunexpanded} +\DoNotIndex{\par,\protect} +\DoNotIndex{\unprotect} +\DoNotIndex{\writestatus} \DoNotIndex{\ifcsname} \DoNotIndex{\ifx} +\DoNotIndex{\iffalse} +\DoNotIndex{\ifnum} \DoNotIndex{\else} \DoNotIndex{\fi} -\@gobble\fi ^^A ignoring \ifx and \ifcsname, but only one \fi +\@gobble\fi ^^A ignoring \ifx etc., but only one \fi +\@gobble\fi ^^A ignoring \ifx etc., but only one \fi +\@gobble\fi ^^A ignoring \ifx etc., but only one \fi \@ifdefinable\gobbledocstriptag{\def\gobbledocstriptag#1>{}} \newcommand*\pmso[1] ^^A poor man's strike out {^^A @@ -365,15 +377,19 @@ and the derived files expkv.pdf % example \pkg{babel} turns characters active for some languages, for instance % the equal sign is turned active for Turkish. % -% \expkv\ is usable as generic code or as a \LaTeX\ package. To use it, just -% use one of: +% \expkv\ is usable as generic code, as a \LaTeX\ package or as a \ConTeXt\ +% module. To use it, just use one of: % \begin{lstlisting} -% \usepackage{expkv} % LaTeX % \input expkv % plainTeX +% \usepackage{expkv} % LaTeX +% \usemodule[expkv] % ConTeXt % \end{lstlisting} -% The \LaTeX\ package doesn't do more than \file{expkv.tex}, except calling -% |\ProvidesPackage| and setting things up such that \file{expkv.tex} will use -% |\ProvidesFile|. +% Both the \LaTeX\ package and the \ConTeXt\ module don't do more than +% \file{expkv.tex}, except calling |\ProvidesPackage| and setting things up such +% that \file{expkv.tex} will use |\ProvidesFile|, or printing some status +% information. The \ConTeXt\ support is not thoroughly tested, though (since I +% don't use \ConTeXt\ myself I don't know if there are additional pitfalls I +% wasn't aware of). % % In the \expkv\ family are other packages contained which provide additional % functionality. Those packages currently are: @@ -410,7 +426,7 @@ and the derived files expkv.pdf % prefixes allowed for |\let| can prefix those with ``|let|'' in their name, % accordingly. Neither \set\ nor \key\ are allowed to be empty for new keys. % \set\ will be used as is inside of |\csname ...\endcsname| and \key\ will get -% |\detokenize|d. +% |\detokenize|d. Also \set\ should not contain an explicit |\par| token. % % \begin{function}{\ekvdef} % \begin{syntax} @@ -919,6 +935,11 @@ and the derived files expkv.pdf % \end{verbatim} % Any clean up has to be done by you, |\ekverr| will expand to nothing after % throwing the error message. +% +% In \ConTeXt\ this macro works differently. While still being fully expandable, +% it doesn't have the character count limitation and doesn't impose restrictions +% on \meta{package}. It will not display the additional text and adding line +% breaks is not possible. % \example Say we set up a small calculation which works with user input. In our % calculation we need a division, so have to watch out for division by zero. If % we detect such a case we throw an error and do the recovery by using the @@ -926,7 +947,7 @@ and the derived files expkv.pdf % \begin{lstlisting} % \newcommand*\mydivision[2] % {% -% \number\numexpr +% \the\numexpr % \ifnum\numexpr#2=0 % space here on purpose % \ekverr{my}{division by 0. Setting result to 2147483647.}% % 2147483647% @@ -1562,6 +1583,27 @@ and the derived files expkv.pdf % \gobbledocstriptag %</pkg> %^^A=<< +%^^A the ConTeXt module >>= +% \subsection{The \ConTeXt\ module} +% This is pretty straight forward, we just have to change the error throwing +% mechanism for \ConTeXt\ (the approach taken for plain and \LaTeX\ breaks in +% \ConTeXt, effectively breaking \ConTeXt, dropping you in an interactive \TeX\ +% session with almost no means of escape). +% \gobbledocstriptag +%<*ctx> +% \begin{macrocode} +\writestatus{loading}{ConTeXt User Module / expkv} +\unprotect +\input expkv.tex +\long\def\ekv@err@collect#1\par#2% + {\directlua{tex.error[[\detokenize{#2} Error: #1]]}} +\writestatus{loading} + {ConTeXt User Module / expkv / Version \ekvVersion\space loaded} +\protect\endinput +% \end{macrocode} +% \gobbledocstriptag +%</ctx> +%^^A=<< %^^A main file >>= % \subsection{The Generic Code} % The rest of this implementation will be the generic code. @@ -1584,17 +1626,30 @@ and the derived files expkv.pdf \expandafter \endgroup \ifx\ekvtmpa\ekvtmpb + \expandafter\let\csname ekv@expanded\endcsname\expanded + \expandafter\let\csname ekv@unexpanded\endcsname\unexpanded \else - \errmessage{expkv Error: e-TeX and \noexpand\expanded required} - \expandafter\endinput + \begingroup + \edef\ekvtmpa{\string\expanded} + \edef\ekvtmpb{\meaning\normalexpanded} + \expandafter + \endgroup + \ifx\ekvtmpa\ekvtmpb + \expandafter\let\csname ekv@expanded\endcsname\normalexpanded + \expandafter\let\csname ekv@unexpanded\endcsname\normalunexpanded + \else + \errmessage + {expkv Error: e-TeX and the \noexpand\expanded primitive required}% + \expandafter\endinput + \fi \fi % \end{macrocode} % % \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.9} -\def\ekvDate{2021-07-15} +\def\ekvVersion{1.9a} +\def\ekvDate{2021-09-20} % \end{macrocode} % \end{macro} % @@ -1731,7 +1786,7 @@ and the derived files expkv.pdf % \begin{macrocode} \ekv@if@lastnamedcs {% - \def\ekv@ifdefined#1{\ifcsname#1\endcsname\ekv@ifdef@\fi\@secondoftwo} + \long\def\ekv@ifdefined#1{\ifcsname#1\endcsname\ekv@ifdef@\fi\@secondoftwo} \def\ekv@ifdef@\fi\@secondoftwo {% \fi @@ -1742,7 +1797,7 @@ and the derived files expkv.pdf } } {% - \def\ekv@ifdefined#1% + \long\def\ekv@ifdefined#1% {% \ifcsname#1\endcsname\ekv@ifdef@\fi\ekv@ifdef@false#1\endcsname\relax \ekv@fi@secondoftwo @@ -1853,7 +1908,7 @@ and the derived files expkv.pdf }% } \expandafter\ekv@csv@loop\expandafter{\ekv@strip{#2}} -\long\def\ekv@csv@loop@do#1#2{\unexpanded{#2{#1}}\ekv@csv@loop{#2}\ekv@mark} +\long\def\ekv@csv@loop@do#1#2{\ekv@unexpanded{#2{#1}}\ekv@csv@loop{#2}\ekv@mark} \def\ekv@csv@loop@end#1% {% \long\def\ekv@csv@loop@end @@ -1875,13 +1930,13 @@ and the derived files expkv.pdf % The keys will all follow the same naming scheme, so we define it here. % \begin{macrocode} \def\ekv@name@set#1{ekv#1(} -\def\ekv@name@key#1{#1)} +\long\def\ekv@name@key#1{#1)} \edef\ekv@name {% - \unexpanded\expandafter{\ekv@name@set{#1}}% - \unexpanded\expandafter{\ekv@name@key{\detokenize{#2}}}% + \ekv@unexpanded\expandafter{\ekv@name@set{#1}}% + \ekv@unexpanded\expandafter{\ekv@name@key{\detokenize{#2}}}% } -\ekv@exparg{\def\ekv@name#1#2}{\ekv@name} +\long\ekv@exparg{\def\ekv@name#1#2}{\ekv@name} % \end{macrocode} % \end{macro} % @@ -1908,15 +1963,15 @@ and the derived files expkv.pdf % \begin{macrocode} \edef\ekv@checkvalid {% - \unexpanded\expandafter{\ekv@ifempty{#1}}% - \unexpanded + \ekv@unexpanded\expandafter{\ekv@ifempty{#1}}% + \ekv@unexpanded {{% \def\ekv@tmp{}% \errmessage{expkv Error: empty set name not allowed}% }}% {% - \unexpanded\expandafter{\ekv@ifempty{#2}}% - \unexpanded + \ekv@unexpanded\expandafter{\ekv@ifempty{#2}}% + \ekv@unexpanded {% {% \def\ekv@tmp{}% @@ -1925,7 +1980,7 @@ and the derived files expkv.pdf \@secondoftwo }% }% - \unexpanded{\@gobble}% + \ekv@unexpanded{\@gobble}% } \ekv@exparg{\protected\def\ekv@checkvalid#1#2}{\ekv@checkvalid}% % \end{macrocode} @@ -1934,9 +1989,9 @@ and the derived files expkv.pdf % \begin{macro}{\ekvifdefined,\ekvifdefinedNoVal} % And provide user-level macros to test whether a key is defined. % \begin{macrocode} -\ekv@expargtwice{\def\ekvifdefined#1#2}% +\ekv@expargtwice{\long\def\ekvifdefined#1#2}% {\expandafter\ekv@ifdefined\expandafter{\ekv@name{#1}{#2}}} -\ekv@expargtwice{\def\ekvifdefinedNoVal#1#2}% +\ekv@expargtwice{\long\def\ekvifdefinedNoVal#1#2}% {\expandafter\ekv@ifdefined\expandafter{\ekv@name{#1}{#2}N}} % \end{macrocode} % \end{macro} @@ -1955,9 +2010,9 @@ and the derived files expkv.pdf {#1{\expandafter\def\csname#2\endcsname####1{##3}#3}}% \protected\long\def\ekvdefNoVal##1##2##3% {#1{\expandafter\def\csname#2N\endcsname{##3}#3}}% - \protected\def\ekvlet##1##2##3% + \protected\long\def\ekvlet##1##2##3% {#1{\expandafter\let\csname#2\endcsname##3#3}}% - \protected\def\ekvletNoVal##1##2##3% + \protected\long\def\ekvletNoVal##1##2##3% {#1{\expandafter\let\csname#2N\endcsname##3#3}}% \ekv@expargtwice{\protected\long\def\ekvdefunknown##1##2}% {% @@ -1981,7 +2036,7 @@ and the derived files expkv.pdf }% {\ekv@zero\ekv@checkvalid{##1}.}% }% - \protected\def\ekvletkv##1##2##3##4% + \protected\long\def\ekvletkv##1##2##3##4% {% #1% {% @@ -1990,7 +2045,7 @@ and the derived files expkv.pdf #3% }% }% - \protected\def\ekvletkvNoVal##1##2##3##4% + \protected\long\def\ekvletkvNoVal##1##2##3##4% {% #1% {% @@ -2002,13 +2057,13 @@ and the derived files expkv.pdf } \edef\ekvdefNoVal {% - {\unexpanded\expandafter{\ekv@checkvalid{#1}{#2}}}% - {\unexpanded\expandafter{\ekv@name{#1}{#2}}}% + {\ekv@unexpanded\expandafter{\ekv@checkvalid{#1}{#2}}}% + {\ekv@unexpanded\expandafter{\ekv@name{#1}{#2}}}% {% - \unexpanded{\expandafter\ekv@defsetmacro\csname}% - \unexpanded\expandafter{\ekv@undefined@set{#1}\endcsname{#1}}% + \ekv@unexpanded{\expandafter\ekv@defsetmacro\csname}% + \ekv@unexpanded\expandafter{\ekv@undefined@set{#1}\endcsname{#1}}% }% - {\unexpanded\expandafter{\ekv@name{#3}{#4}}}% + {\ekv@unexpanded\expandafter{\ekv@name{#3}{#4}}}% } \expandafter\ekvdef\ekvdefNoVal % \end{macrocode} @@ -2047,7 +2102,7 @@ and the derived files expkv.pdf \edef\ekv@tmp {% \ekvcsvloop#1{#6}% - \unexpanded{#2}% + \ekv@unexpanded{#2}% {\ekvcsvloop{}{#5,#6}}% }% \ekv@expargtwice @@ -2092,7 +2147,7 @@ and the derived files expkv.pdf {% \ifcsname#2\endcsname\ekv@redirect@kv@a\fi\@gobble{##1}% ##4{##1}{##2}% - } + }% \def\ekv@redirect@kv@a\fi\@gobble {\fi\expandafter\ekv@redirect@kv@b\lastnamedcs}% } @@ -2111,17 +2166,17 @@ and the derived files expkv.pdf \ifcsname#2\endcsname\ekv@redirect@kv@a\fi\ekv@redirect@kv@a@ #2\endcsname{##1}% ##4{##1}{##2}% - } + }% \long\def\ekv@redirect@kv@a@#4\endcsname##3{}% \def\ekv@redirect@kv@a\fi\ekv@redirect@kv@a@ {\fi\expandafter\ekv@redirect@kv@b\csname}% - } + }% } % \end{macrocode} % The key name given to this loop will already be |\detokenize|d by |\ekvset|, % so we can safely remove the |\detokenize| here for some performance gain. % \begin{macrocode} -\def\ekv@redirect@kv#1\detokenize#2#3\ekv@stop{\unexpanded{#1#2#3}} +\def\ekv@redirect@kv#1\detokenize#2#3\ekv@stop{\ekv@unexpanded{#1#2#3}} \edef\ekv@redirect@kv {% {\expandafter\ekv@redirect@kv\ekv@name{#2}{#1}N\ekv@stop}% @@ -2158,12 +2213,12 @@ and the derived files expkv.pdf % \begin{macrocode} \edef\ekv@defsetmacro {% - \unexpanded{\ifx#1\relax\edef#1##1}% + \ekv@unexpanded{\ifx#1\relax\edef#1##1}% {% - \unexpanded\expandafter{\ekv@name@set{#2}}% - \unexpanded\expandafter{\ekv@name@key{##1}}% + \ekv@unexpanded\expandafter{\ekv@name@set{#2}}% + \ekv@unexpanded\expandafter{\ekv@name@key{##1}}% }% - \unexpanded{\fi}% + \ekv@unexpanded{\fi}% } \ekv@exparg{\protected\def\ekv@defsetmacro#1#2}{\ekv@defsetmacro} % \end{macrocode} @@ -2341,12 +2396,12 @@ and the derived files expkv.pdf % \begin{macrocode} \edef\ekv@set@noeq {% - \unexpanded + \ekv@unexpanded {% \ekv@ifblank@##1\ekv@nil\ekv@ifempty@B\ekv@set@was@blank \ekv@ifempty@A\ekv@ifempty@B }% - \unexpanded\expandafter + \ekv@unexpanded\expandafter {\ekv@strip{##1}{\expandafter\ekv@set@key\detokenize}\ekv@mark}% } \ekv@exparg @@ -2398,12 +2453,15 @@ and the derived files expkv.pdf % macro, that has the same scope as |\keyval_parse:NNn| from \pkg{expl3}. % This is pretty analogue to the |\ekvset| implementation, we just put an % |\unexpanded| here and there instead of other macros to stop the |\expanded| -% on our output. The |\unexpanded\expanded{{...}}| ensures that the material is -% in an alignment safe group at all time, and that it doesn't expand any further -% in an |\edef| or |\expanded| context. +% on our output. The |\unexpanded\expanded{{...}}| ensures that the material +% is in an alignment safe group at all time, and that it doesn't expand any +% further in an |\edef| or |\expanded| context. % \begin{macrocode} \long\def\ekvparse##1##2##3% - {\unexpanded\expanded{{\ekv@parse{##1}{##2}\ekv@mark##3#1\ekv@stop#1}}} + {% + \ekv@unexpanded\ekv@expanded + {{\ekv@parse{##1}{##2}\ekv@mark##3#1\ekv@stop#1}}% + } % \end{macrocode} % \end{macro} % @@ -2485,12 +2543,12 @@ and the derived files expkv.pdf % \begin{macrocode} \edef\ekv@parse@noeq {% - \unexpanded + \ekv@unexpanded {% \ekv@ifblank@##1\ekv@nil\ekv@ifempty@B\ekv@parse@was@blank \ekv@ifempty@A\ekv@ifempty@B }% - \unexpanded\expandafter{\ekv@strip{##1}\ekv@parse@key}% + \ekv@unexpanded\expandafter{\ekv@strip{##1}\ekv@parse@key}% } \ekv@exparg {% @@ -2521,7 +2579,7 @@ and the derived files expkv.pdf {\ekv@strip{##2}\ekv@parse@pair@{##1}} \long\def\ekv@parse@pair@##1##2##3##4% {% - \unexpanded{##4{##2}{##1}}% + \ekv@unexpanded{##4{##2}{##1}}% \ekv@parse@other{##3}{##4}% } % \end{macrocode} @@ -2531,7 +2589,7 @@ and the derived files expkv.pdf % \begin{macrocode} \long\def\ekv@parse@key##1##2% {% - \unexpanded{##2{##1}}% + \ekv@unexpanded{##2{##1}}% \ekv@parse@other{##2}% } % \end{macrocode} @@ -2552,8 +2610,8 @@ and the derived files expkv.pdf % \begin{macrocode} \edef\ekvsetSneaked {% - \unexpanded{\ekvsneak{#2}}% - \unexpanded\expandafter{\ekvset{#1}{#3}}% + \ekv@unexpanded{\ekvsneak{#2}}% + \ekv@unexpanded\expandafter{\ekvset{#1}{#3}}% } \ekv@expargtwice{\long\def\ekvsetSneaked#1#2#3}{\ekvsetSneaked} % \end{macrocode} @@ -2891,7 +2949,8 @@ and the derived files expkv.pdf \ekv@exparg{\long\def\ekv@err@common@#1`#2' #3.#4#5}% {\ekv@err{#4 `#5' in set `#2'}} \ekv@exparg{\long\def\ekv@err@unknown#1}{\ekv@err@common{unknown key}{#1}} -\ekv@exparg{\long\def\ekv@err@noarg #1}{\ekv@err@common{unwanted value for}{#1}} +\ekv@exparg{\long\def\ekv@err@noarg #1} + {\ekv@err@common{unwanted value for}{#1}} \ekv@exparg{\long\def\ekv@err@reqval #1}{\ekv@err@common{missing value for}{#1}} \ekv@exparg{\long\def\ekv@err@redirect@kv@notfound#1#2#3\ekv@stop}% {\ekv@err{no key `#2' in sets #3}} diff --git a/macros/generic/expkv/expkv.pdf b/macros/generic/expkv/expkv.pdf Binary files differindex 59012eccd1..2da6f6dada 100644 --- a/macros/generic/expkv/expkv.pdf +++ b/macros/generic/expkv/expkv.pdf |