diff options
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/conv-xkv/conv-xkv.dtx | 141 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/conv-xkv/conv-xkv.ins | 2 |
2 files changed, 106 insertions, 37 deletions
diff --git a/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.dtx b/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.dtx index 478fdad7135..57fc4b6e194 100644 --- a/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.dtx +++ b/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.dtx @@ -1,20 +1,20 @@ % \iffalse %<*copyright> -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% conv-xkv package %% -%% Copyright (C) 2016 D. P. Story %% -%% dpstory@uakron.edu %% -%% %% -%% This program can redistributed and/or modified under %% -%% the terms of the LaTeX Project Public License %% -%% Distributed from CTAN archives in directory %% -%% macros/latex/base/lppl.txt; either version 1 of the %% -%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% conv-xkv package %% +%% Copyright (C) 2016--2017 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1.2 of the %% +%% License, or (at your option) any later version. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %</copyright> %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{conv-xkv} -%<package> [2016/12/20 v1.0 convert xkeyval format (dps)] +%<package> [2017/01/09 v1.1b convert xkeyval format (dps)] %<*driver> \documentclass{ltxdoc} \usepackage[colorlinks,hyperindex=false]{hyperref} @@ -51,6 +51,7 @@ % \fi % % \MakeShortVerb{|} +% \DoNotIndex{\w,\x,\y,\z} % \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}} % {\PackageInfo{web}{cannot find aebdonotindex.def}} % @@ -75,11 +76,33 @@ %\end{quote} %Use the newly declared delimited as follows: %\begin{quote} -%\cs{cxkvsetkeys[\ameta{name}]}\darg{\ameta{family}}\darg{\ameta{KV-pairs}} +%\cs{cxkvsetkeys(\ameta{name})}\darg{\ameta{family}}\darg{\ameta{KV-pairs}} %\end{quote} %The case of using a colon (:) for the delimiter is already defined, its name is `\texttt{colon}' and need not be declared. % -% The example file is \texttt{convert2xkeyval.tex}, use it to explore the possibilities and is found +%\paragraph*{Important change in syntax} With version dated 2017/01/03 or later, the optional argument \ameta{name} is now delimited +%by \textbf{parentheses}, rather than the standard brackets. This is to be able to detect \ameta{name} when the full syntax +%of \cs{setkeys} is used: +%\changes{v1.1a}{2017/01/03}{Change in syntax, use parentheses rather than brackets} +%\begin{quote} +% \cs{setkeys*[\ameta{prefix}]\darg{\ameta{families}}[\ameta{na}]\darg{\ameta{keys}}} +%\end{quote} +%The syntax for \cs{cxkvsetkeys} shall be +%\begin{quote} +% \cs{cxkvsetkeys(\ameta{name})*[\ameta{prefix}]\darg{\ameta{families}}[\ameta{na}]\darg{\ameta{keys}}} +%\end{quote} +% The \pkg{conv-xkv} package does nothing with \pkg{xkeyval} arguments \texttt{*[\ameta{prefix}]} and +% \texttt{[\ameta{na}]} other than to collect them and pass them on to \cs{setkeys} at the appropriate time. +% The \pkg{conv-xkv} is concerned only with converting a new notation \texttt{\ameta{key}\ameta{delim}\ameta{value}} +% to \texttt{\ameta{key}=\ameta{value}}. +% +% If the key-values do not contain the designated delimiter, \pkg{conv-xkv} simply passes everything on to \cs{setkeys}. +% What this means is that, for example, both \cs{cxkvsetkeys\darg{myfam}\darg{fname:Don,lname:Story}} works as does +% \cs{cxkvsetkeys\darg{myfam}\darg{fname=Don,lname=Story}}. One then has the option of using the standard notation +% or an alternate notation. +% +% +% \paragraph*{Demo file} The example file is \texttt{convert2xkeyval.tex}, use it to explore the possibilities and is found % in the \texttt{examples} folder of this distribution. % % \section{Preliminaries} @@ -180,13 +203,12 @@ \def\DeclareDelimiter{\ckv@SetCatcodes\DeclareDelimiter@i} \def\DeclareDelimiter@i#1#2{\@ifundefined{kvdelim-#1} {\csarg\def{kvdelim-#1}{#2}\ckv@RestoreCatcodes\cxkvSetup{#1}} - {\ckv@RestoreCatcodes}% -} + {\ckv@RestoreCatcodes}} \@onlypreamble\DeclareDelimiter % \end{macrocode} % \end{macro} % \cs{cxkv@tmptoks} is used to hold the converted key-values, the contents of -% this token register is passed to \cs{setkeys} in \cs{cxkv@convertColoniiEquali} +% this token register is passed to \cs{setkeys} in \cs{cxkv@cnvrtDelimniiEquali} % \begin{macrocode} \newtoks\cxkv@tmptoks \cxkv@tmptoks={} \def\cxkv@dummy{dummy} @@ -216,23 +238,53 @@ %\end{verbatim} % \begin{macrocode} \def\cxkv@colon{colon} -\newcommand\cxkvsetkeys[1][colon]{% - \def\@rgi{#1}\ifx\@rgi\cxkv@colon\else - \InputIfFileExists{xkv-#1.cut} - {\PackageInfo{conv-xkv}{Inputting xkv-#1.cut}} - {\PackageInfo{conv-xkv}{Cannot find xkv-#1.cut}}\fi - \@nameuse{cxkvsetkeys-#1}} % \end{macrocode} +% The general form for \cs{setkeys} is +%\begin{quote} +% \cs{setkeys*[\ameta{prefix}]\darg{\ameta{families}}[\ameta{na}]\darg{\ameta{keys}}} +%\end{quote} +% \begin{macro}{\cxkvsetkeys} +%The syntax for \cs{cxkvsetkeys} shall be +%\begin{quote} +% \cs{cxkvsetkeys(\ameta{name})*[\ameta{prefix}]\darg{\ameta{families}}[\ameta{na}]\darg{\ameta{keys}}} +%\end{quote} +%The process to pick up the full parameter set of \cs{setkeys} is lengthy. +% \begin{macrocode} +\newcommand\cxkvsetkeys{% + \@ifnextchar({\cxkvsetkeys@i}{\cxkvsetkeys@i(colon)}} +\def\cxkvsetkeys@i(#1){\cxkvsetkeys@ii{#1}} +\def\cxkvsetkeys@ii#1{\def\cxkv@delimname{#1}\@ifstar + {\def\cxkv@skOpts{*}\cxkvsetkeys@iii} + {\def\cxkv@skOpts{}\cxkvsetkeys@iii}} +\newcommand\cxkvsetkeys@iii[2][]{\def\@rgi{#1}\ifx\@rgi\@empty + \expandafter\def\expandafter\cxkv@skOpts + \expandafter{\cxkv@skOpts{#2}}\else + \expandafter\def\expandafter + \cxkv@skOpts\expandafter{\cxkv@skOpts[#1]{#2}}\fi + \def\thisxkvF@mily{#2}\cxkvsetkeys@iv} +\newcommand\cxkvsetkeys@iv[2][]{\def\@rgi{#1}\ifx\@rgi\@empty\else + \expandafter\def\expandafter\cxkv@skOpts + \expandafter{\cxkv@skOpts[#1]}\fi + \expandafter\cxkvsetkeys@v\expandafter{\thisxkvF@mily}{#2}} +\def\cxkvsetkeys@v#1#2{\cxkv@skipfalse + \ifx\cxkv@delimname\cxkv@colon\else + \InputIfFileExists{xkv-\cxkv@delimname.cut} + {\PackageInfo{conv-xkv}{Inputting xkv-\cxkv@delimname.cut}} + {\PackageInfo{conv-xkv}{Cannot find xkv-\cxkv@delimname.cut}}\fi + \@nameuse{cxkvsetkeys-\cxkv@delimname}{#1}{#2}} +% \end{macrocode} +% \end{macro} % \begin{macrocode} \csarg\def{cxkvsetkeys-colon}#1#2{% - \def\thisxkvF@mily{#1}\def\cxkv@scratch{}\cxkv@tmptoks={}% - \@nameuse{cxkv@convertColoniiEqual-colon}#2,dummy:dummy,\@nil} -\csarg\def{cxkv@convertColoniiEqual-colon}#1:#2,#3\@nil{% - \cxkv@convertColoniiEquali{colon}{#1}{#2}{#3}} + \def\thisxkvF@mily{#1}\def\thisxkvV@lues{#2}\def\cxkv@scratch{}% + \cxkv@tmptoks={}% + \@nameuse{cxkv@cnvrtDelimniiEqual-colon}#2,dummy:dummy,\@nil} +\csarg\def{cxkv@cnvrtDelimniiEqual-colon}#1:#2,#3\@nil{% + \cxkv@cnvrtDelimniiEquali{colon}{#1}{#2}{#3}} % \end{macrocode} % \end{macro} % \begin{macro}{\cxkvSetup} -% Write the definitions of \cs{cxkvsetkeys} and \cs{cxkv@convertColoniiEqual} to +% Write the definitions of \cs{cxkvsetkeys} and \cs{cxkv@cnvrtDelimniiEqual} to % the file \texttt{conv-xkv.cut} then input this file back in. % \begin{macrocode} \def\cxkvSetup#1{\bgroup @@ -243,18 +295,19 @@ \newwrite \cxkv@write \uccode`c=`\% \def\w{#1}\def\x{cxkvsetkeys-#1}% - \def\y{cxkv@convertColoniiEqual-#1}% + \def\y{cxkv@cnvrtDelimniiEqual-#1}% \def\z{kvdelim-#1}% \immediate\openout \cxkv@write xkv-#1.cut \immediate\write\cxkv@write{\string\makeatletter}% \uppercase{\immediate\write\cxkv@write{\string \csarg\string\def{\y}\cxkvarg1\@nameuse{\z}% \cxkvarg2,\cxkvarg3\string\@nil{c^^J\cxkv@TAB - \string\cxkv@convertColoniiEquali{\w}{\cxkvarg1}% + \string\cxkv@cnvrtDelimniiEquali{\w}{\cxkvarg1}% {\cxkvarg2}{\cxkvarg3}}}} \uppercase{\immediate\write\cxkv@write{\string\csarg\string\def {\x}\cxkvarg1\cxkvarg2{c^^J\cxkv@TAB \string\def\string\thisxkvF@mily{\cxkvarg1}\string + \def\string\thisxkvV@lues{\cxkvarg2}\string \let\string\cxkv@scratch\string\@empty\string \cxkv@tmptoks={}c^^J\cxkv@TAB \string\@nameuse{\y}\cxkvarg2,% @@ -265,7 +318,7 @@ \egroup} % \end{macrocode} % \end{macro} -% \cs{cxkv@convertColoniiEquali} continues \cs{cxkv@convertColoniiEqual}. It is +% \cs{cxkv@cnvrtDelimniiEquali} continues \cs{cxkv@cnvrtDelimniiEqual}. It is % the part that does not need to be redefined. % \begin{macrocode} \newif\ifcxkv@keyonly \cxkv@keyonlyfalse @@ -274,7 +327,23 @@ \def\cxkv@parsecomma#1,#2\@nil{\def\@rgi{#1}\def\@rgii{#2}% \ifx\@rgii\@empty\cxkv@keyonlyfalse\else \cxkv@keyonlytrue\cxkv@removecomma#2\@nil\fi} -\def\cxkv@convertColoniiEquali#1#2#3#4{\def\cxkv@rgiii{#3}% +\newif\ifcxkv@skip \cxkv@skipfalse +\def\cxkv@cnvrtDelimniiEquali#1#2#3#4{% + \def\cxkv@rgiii{#3}\def\cxkv@rgiv{#4}% +% \end{macrocode} +% If the fourth argument is empty, that means there were no delimiters in the argument, +% so we pass the original argument \cs{thisxkvF@mily} to \cs{setkeys}. +% \changes{v1.1}{2017/01/03}{Try to detect if the expected delimiter is present at all} +% \begin{macrocode} + \ifx\thisxkvV@lues\@empty\else + \ifx\cxkv@rgiv\@empty + \edef\cxkv@next{\noexpand + \setkeys\cxkv@skOpts{\thisxkvV@lues}}% + \cxkv@skiptrue + \fi + \fi + \let\thisxkvV@lues\@empty + \ifcxkv@skip\else \ifx\cxkv@rgiii\cxkv@dummy \cxkv@parsecomma#2,\@nil \ifcxkv@keyonly @@ -282,10 +351,10 @@ \cxkv@tmptoks=\expandafter{\cxkv@tmp}% \edef\cxkv@scratch{\the\cxkv@tmptoks}% \edef\cxkv@next{\noexpand - \setkeys{\thisxkvF@mily}{\the\cxkv@tmptoks}}% + \setkeys\cxkv@skOpts{\the\cxkv@tmptoks}}% \else \edef\cxkv@next{\noexpand - \setkeys{\thisxkvF@mily}{\the\cxkv@tmptoks}}% + \setkeys\cxkv@skOpts{\the\cxkv@tmptoks}}% \fi \else \cxkv@parsecomma#2,\@nil @@ -294,14 +363,14 @@ \cxkv@tmptoks=\expandafter{\cxkv@tmp}% \edef\cxkv@scratch{\the\cxkv@tmptoks}% \edef\cxkv@next{\noexpand - \@nameuse{cxkv@convertColoniiEqual-#1}\cxkv@key + \@nameuse{cxkv@cnvrtDelimniiEqual-#1}\cxkv@key \@nameuse{kvdelim-#1}#3,#4\noexpand\@nil} \else \cxkv@tmptoks=\expandafter{\cxkv@scratch,#2=#3}% \edef\cxkv@scratch{\the\cxkv@tmptoks}% \def\cxkv@next{% - \@nameuse{cxkv@convertColoniiEqual-#1}#4\@nil}\fi - \fi\cxkv@next + \@nameuse{cxkv@cnvrtDelimniiEqual-#1}#4\@nil}\fi + \fi\fi\cxkv@next } \ckv@RestoreCatcodes % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.ins b/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.ins index 8f2eeb7aaec..0267adec6ca 100644 --- a/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.ins +++ b/Master/texmf-dist/source/latex/conv-xkv/conv-xkv.ins @@ -17,7 +17,7 @@ %% %% --------------- start of docstrip commands ------------------ %% -\def\filedate{2010/08/02} +\def\filedate{2016/12/21} \def\batchfile{conv-xkv.ins} % % If you can assume that the target audience for the document all have |