diff options
author | Karl Berry <karl@freefriends.org> | 2022-10-06 14:40:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-10-06 14:40:30 +0000 |
commit | 6b1b98950123ed2ac838b652eb5f1e692fd35aeb (patch) | |
tree | f9581a8698c00be5cec9270967b4764cd3265ea6 /Master | |
parent | 2c0b0f741df253507e796248221dd64de28899c1 (diff) |
kvsetkeys[.sty]
git-svn-id: svn://tug.org/texlive/trunk@64632 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/kvsetkeys/kvsetkeys-example.tex | 92 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty | 572 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
3 files changed, 665 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/kvsetkeys/kvsetkeys-example.tex b/Master/texmf-dist/doc/latex/kvsetkeys/kvsetkeys-example.tex new file mode 100644 index 00000000000..80027ebf804 --- /dev/null +++ b/Master/texmf-dist/doc/latex/kvsetkeys/kvsetkeys-example.tex @@ -0,0 +1,92 @@ +%% +%% This is file `kvsetkeys-example.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% kvsetkeys.dtx (with options: `example') +%% +%% This is a generated file. +%% +%% Project: kvsetkeys +%% Version: 2022-10-05 v1.19 +%% +%% Copyright (C) +%% 2006, 2007, 2009-2012 Heiko Oberdiek +%% 2016-2022 Oberdiek Package Support Group +%% +%% 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. This version of this license is in +%% https://www.latex-project.org/lppl/lppl-1-3c.txt +%% and the latest version of this license is in +%% https://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. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% The Current Maintainers of this work are +%% Heiko Oberdiek and the Oberdiek Package Support Group +%% https://github.com/ho-tex/kvsetkeys/issues +%% +%% The Base Interpreter refers to any `TeX-Format', +%% because some files are installed in TDS:tex/generic//. +%% +%% This work consists of the main source file kvsetkeys.dtx +%% and the derived files +%% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex, +%% kvsetkeys-test4.tex. +%% +\documentclass{article} +\usepackage[T1]{fontenc} +\usepackage{kvsetkeys} +\usepackage{keyval} + +\makeatletter +\newcommand*{\tag}[2][]{% + % #1: attributes + % #2: tag name + \begingroup + \toks@={}% + \let\@endslash\@empty + \kvsetkeys{tag}{#1}% + \texttt{% + \textless #2\the\toks@\@endslash\textgreater + }% + \endgroup +} +\kv@set@family@handler{tag}{% + % #1: key + % #2: value + \toks@\expandafter{% + \the\toks@ + \space + #1=\string"#2\string"% + }% +} +\define@key{tag}{/}[]{% + \def\@endslash{/}% +} +\makeatother + +\begin{document} +\begin{tabbing} + \mbox{}\qquad\=\qquad\=\kill + \tag{html}\\ + \>\dots\\ + \>\tag[border=1]{table}\\ + \>\>\tag[width=200, span=3, /]{colgroup}\\ + \>\>\dots\\ + \>\tag{/table}\\ + \>\dots\\ + \tag{/html}\\ +\end{tabbing} +\end{document} +%% \section{Installation} +\endinput +%% +%% End of file `kvsetkeys-example.tex'. diff --git a/Master/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty b/Master/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty new file mode 100644 index 00000000000..1b8f1d1ac94 --- /dev/null +++ b/Master/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty @@ -0,0 +1,572 @@ +%% +%% This is file `kvsetkeys.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% kvsetkeys.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Project: kvsetkeys +%% Version: 2022-10-05 v1.19 +%% +%% Copyright (C) +%% 2006, 2007, 2009-2012 Heiko Oberdiek +%% 2016-2022 Oberdiek Package Support Group +%% +%% 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. This version of this license is in +%% https://www.latex-project.org/lppl/lppl-1-3c.txt +%% and the latest version of this license is in +%% https://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. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% The Current Maintainers of this work are +%% Heiko Oberdiek and the Oberdiek Package Support Group +%% https://github.com/ho-tex/kvsetkeys/issues +%% +%% The Base Interpreter refers to any `TeX-Format', +%% because some files are installed in TDS:tex/generic//. +%% +%% This work consists of the main source file kvsetkeys.dtx +%% and the derived files +%% kvsetkeys.sty, kvsetkeys.pdf, kvsetkeys.ins, kvsetkeys.drv, +%% kvsetkeys-example.tex, kvsetkeys-test1.tex, +%% kvsetkeys-test2.tex, kvsetkeys-test3.tex, +%% kvsetkeys-test4.tex. +%% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode35=6 % # + \catcode39=12 % ' + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode58=12 % : + \catcode64=11 % @ + \catcode123=1 % { + \catcode125=2 % } + \expandafter\let\expandafter\x\csname ver@kvsetkeys.sty\endcsname + \ifx\x\relax % plain-TeX, first loading + \else + \def\empty{}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \else + \expandafter\ifx\csname PackageInfo\endcsname\relax + \def\x#1#2{% + \immediate\write-1{Package #1 Info: #2.}% + }% + \else + \def\x#1#2{\PackageInfo{#1}{#2, stopped}}% + \fi + \x{kvsetkeys}{The package is already loaded}% + \aftergroup\endinput + \fi + \fi +\endgroup% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode35=6 % # + \catcode39=12 % ' + \catcode40=12 % ( + \catcode41=12 % ) + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode47=12 % / + \catcode58=12 % : + \catcode64=11 % @ + \catcode91=12 % [ + \catcode93=12 % ] + \catcode123=1 % { + \catcode125=2 % } + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\@undefined + \xdef#1{#3}% + \fi + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@kvsetkeys.sty\endcsname +\ProvidesPackage{kvsetkeys}% + [2022-10-05 v1.19 Key value parser (HO)]% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ + \def\x{\endgroup + \expandafter\edef\csname KVS@AtEnd\endcsname{% + \endlinechar=\the\endlinechar\relax + \catcode13=\the\catcode13\relax + \catcode32=\the\catcode32\relax + \catcode35=\the\catcode35\relax + \catcode61=\the\catcode61\relax + \catcode64=\the\catcode64\relax + \catcode123=\the\catcode123\relax + \catcode125=\the\catcode125\relax + }% + }% +\x\catcode61\catcode48\catcode32=10\relax% +\catcode13=5 % ^^M +\endlinechar=13 % +\catcode35=6 % # +\catcode64=11 % @ +\catcode123=1 % { +\catcode125=2 % } +\def\TMP@EnsureCode#1#2{% + \edef\KVS@AtEnd{% + \KVS@AtEnd + \catcode#1=\the\catcode#1\relax + }% + \catcode#1=#2\relax +} +\TMP@EnsureCode{36}{3}% $ +\TMP@EnsureCode{38}{4}% & +\TMP@EnsureCode{39}{12}% ' +\TMP@EnsureCode{43}{12}% + +\TMP@EnsureCode{44}{12}% , +\TMP@EnsureCode{45}{12}% - +\TMP@EnsureCode{46}{12}% . +\TMP@EnsureCode{47}{12}% / +\TMP@EnsureCode{91}{12}% [ +\TMP@EnsureCode{93}{12}% ] +\TMP@EnsureCode{94}{7}% ^ (superscript) +\TMP@EnsureCode{96}{12}% ` +\TMP@EnsureCode{126}{13}% ~ (active) +\edef\KVS@AtEnd{\KVS@AtEnd\noexpand\endinput} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \def\TMP@RequirePackage#1[#2]{% + \begingroup\expandafter\expandafter\expandafter\endgroup + \expandafter\ifx\csname ver@#1.sty\endcsname\relax + \input #1.sty\relax + \fi + }% + \TMP@RequirePackage{infwarerr}[2007/09/09]% + \let\PackageError\@PackageError +\else +\fi +\expandafter\ifx\csname toks@\endcsname\relax + \toksdef\toks@=0 % +\fi +\ifx\numexpr\@undefined + \catcode`\$=9 % ignore + \catcode`\&=14 % comment +\else % e-TeX + \catcode`\$=14 % comment + \catcode`\&=9 % ignore +\fi +\def\KVS@Empty{} +\long\def\KVS@FirstOfTwo#1#2{#1} +\long\def\KVS@SecondOfTwo#1#2{#2} +\long\def\KVS@IfEmpty#1{% +& \edef\KVS@Temp{\unexpanded{#1}}% +$ \begingroup +$ \toks@{#1}% +$ \edef\KVS@Temp{\the\toks@}% +$ \expandafter\endgroup + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo + \else + \expandafter\KVS@SecondOfTwo + \fi +} +\long\def\kv@normalize#1{% + \begingroup + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma + \KVS@CommaSpace + \KVS@CommaComma + \KVS@Equals + \KVS@SpaceEquals + \KVS@EqualsSpace + \xdef\KVS@Global{\the\toks@}% + \endgroup + \let\kv@list\KVS@Global +} +\def\comma@normalize#1{% + \begingroup + \toks@{,#1,}% + \KVS@Comma + \KVS@SpaceComma + \KVS@CommaSpace + \KVS@CommaComma + \xdef\KVS@Global{\the\toks@}% + \endgroup + \let\comma@list\KVS@Global +} +\begingroup + \lccode`\,=`\,% + \lccode`\~=`\,% +\lowercase{\endgroup + \def\KVS@Comma{% + \toks@\expandafter{\expandafter}\expandafter + \KVS@@Comma\the\toks@~\KVS@Nil + }% + \long\def\KVS@@Comma#1~#2\KVS@Nil{% + \toks@\expandafter{\the\toks@#1}% + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Comma,#2\KVS@Nil + }% + }% +} +\def\KVS@SpaceComma#1{% + \def\KVS@SpaceComma{% + \expandafter\KVS@@SpaceComma\the\toks@#1,\KVS@Nil + }% +} +\KVS@SpaceComma{ } +\long\def\KVS@@SpaceComma#1 ,#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \KVS@@SpaceComma#1,#2\KVS@Nil + }% +} +\def\KVS@CommaSpace{% + \expandafter\KVS@@CommaSpace\the\toks@, \KVS@Nil +} +\long\def\KVS@@CommaSpace#1, #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \KVS@@CommaSpace#1,#2\KVS@Nil + }% +} +\def\KVS@CommaComma{% + \expandafter\KVS@@CommaComma\the\toks@,\KVS@Nil +} +\long\def\KVS@@CommaComma#1,,#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1,}% (!) + }{% + \KVS@@CommaComma#1,#2\KVS@Nil + }% +} +\begingroup + \lccode`\==`\=% + \lccode`\~=`\=% +\lowercase{\endgroup + \def\KVS@Equals{% + \toks@\expandafter{\expandafter}\expandafter + \KVS@@Equals\the\toks@~\KVS@Nil + }% + \long\def\KVS@@Equals#1~#2\KVS@Nil{% + \edef\KVS@Temp{\the\toks@}% + \ifx\KVS@Temp\KVS@Empty + \expandafter\KVS@FirstOfTwo + \else + \expandafter\KVS@SecondOfTwo + \fi + {% + \toks@{#1}% + }{% + \toks@\expandafter{\the\toks@=#1}% + }% + \KVS@IfEmpty{#2}{% + }{% + \KVS@@Equals#2\KVS@Nil + }% + }% +} +\def\KVS@SpaceEquals#1{% + \def\KVS@SpaceEquals{% + \expandafter\KVS@@SpaceEquals\the\toks@#1=\KVS@Nil + }% +} +\KVS@SpaceEquals{ } +\long\def\KVS@@SpaceEquals#1 =#2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \KVS@@SpaceEquals#1=#2\KVS@Nil + }% +} +\def\KVS@EqualsSpace{% + \expandafter\KVS@@EqualsSpace\the\toks@= \KVS@Nil +} +\long\def\KVS@@EqualsSpace#1= #2\KVS@Nil{% + \KVS@IfEmpty{#2}{% + \toks@{#1}% + }{% + \KVS@@EqualsSpace#1=#2\KVS@Nil + }% +} +\long\def\kv@parse#1{% + \kv@normalize{#1}% + \expandafter\kv@parse@normalized\expandafter{\kv@list}% +} +\long\def\kv@parse@normalized#1#2{% + \KVS@Parse#1,\KVS@Nil{#2}% +} +\long\def\KVS@Parse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \KVS@Process#1=\KVS@Nil{#3}% + }% + \KVS@MaybeBreak + \KVS@IfEmpty{#2}{% + }{% + \KVS@Parse#2\KVS@Nil{#3}% + }% +} +\long\def\KVS@Process#1=#2\KVS@Nil#3{% + \let\KVS@MaybeBreak\relax + \def\kv@key{#1}% + \KVS@IfEmpty{#2}{% + \let\kv@value\relax + #3{#1}{}% + }{% + \KVS@@Process{#1}#2\KVS@Nil{#3}% + }% +} +\long\def\KVS@@Process#1#2=\KVS@Nil#3{% +& \edef\kv@value{\unexpanded{#2}}% +$ \begingroup +$ \toks@{#2}% +$ \xdef\KVS@Global{\the\toks@}% +$ \endgroup +$ \let\kv@value\KVS@Global + #3{#1}{#2}% +} +\let\KVS@MaybeBreak\relax +\def\KVS@break#1#2#3#4{% + \let\KVS@MaybeBreak\relax +} +\def\kv@break{% + \let\KVS@MaybeBreak\KVS@break +} +\def\comma@parse#1{% + \comma@normalize{#1}% + \expandafter\comma@parse@normalized\expandafter{\comma@list}% +} +\def\comma@parse@normalized#1#2{% + \KVS@CommaParse#1,\KVS@Nil{#2}% +} +\def\KVS@CommaParse#1,#2\KVS@Nil#3{% + \KVS@IfEmpty{#1}{% + }{% + \def\comma@entry{#1}% + #3{#1}% + }% + \KVS@MaybeBreak + \KVS@IfEmpty{#2}{% + }{% + \KVS@CommaParse#2\KVS@Nil{#3}% + }% +} +\def\comma@break{% + \let\KVS@MaybeBreak\KVS@break +} +\def\kv@handled@false{% + \let\ifkv@handled@\iffalse +} +\def\kv@handled@true{% + \let\ifkv@handled@\iftrue +} +\kv@handled@true +\def\kv@processor@default#1#2{% + \begingroup + \csname @safe@activestrue\endcsname + \let\ifincsname\iftrue + \edef\KVS@temp{\endgroup + \noexpand\KVS@ProcessorDefault{#1}{#2}% + }% + \KVS@temp +} +\long\def\KVS@ProcessorDefault#1#2#3{% + \def\kv@fam{#1}% +& \unless\ifcsname KV@#1@#2\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2\endcsname\relax +& \unless\ifcsname KVS@#1@handler\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax + \kv@error@unknownkey{#1}{#2}% + \else + \kv@handled@true + \csname KVS@#1@handler\endcsname{#2}{#3}% + \relax + \ifkv@handled@ + \else + \kv@error@unknownkey{#1}{#2}% + \fi + \fi + \else + \ifx\kv@value\relax +& \unless\ifcsname KV@#1@#2@default\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#2@default\endcsname\relax + \kv@error@novalue{#1}{#2}% + \else + \csname KV@#1@#2@default\endcsname + \relax + \fi + \else + \csname KV@#1@#2\endcsname{#3}% + \fi + \fi +} +\def\kv@processor@known#1#2#3{% + \begingroup + \csname @safe@activestrue\endcsname + \let\ifincsname\iftrue + \edef\KVS@temp{\endgroup + \noexpand\KVS@ProcessorKnown{#1}\noexpand#2{#3}% + }% + \KVS@temp +} +\long\def\KVS@ProcessorKnown#1#2#3#4{% + \def\kv@fam{#1}% +& \unless\ifcsname KV@#1@#3\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#3\endcsname\relax +& \unless\ifcsname KVS@#1@handler\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KVS@#1@handler\endcsname\relax + \KVS@AddUnhandled#2{#3}{#4}% + \else + \kv@handled@true + \csname KVS@#1@handler\endcsname{#3}{#4}% + \relax + \ifkv@handled@ + \else + \KVS@AddUnhandled#2{#3}{#4}% + \fi + \fi + \else + \ifx\kv@value\relax +& \unless\ifcsname KV@#1@#2@default\endcsname +$ \begingroup\expandafter\expandafter\expandafter\endgroup +$ \expandafter\ifx\csname KV@#1@#3@default\endcsname\relax + \kv@error@novalue{#1}{#3}% + \else + \csname KV@#1@#3@default\endcsname + \relax + \fi + \else + \csname KV@#1@#3\endcsname{#4}% + \fi + \fi +} +\long\def\KVS@AddUnhandled#1#2#3{% +& \edef#1{% +& \ifx#1\KVS@empty +& \else +& \unexpanded\expandafter{#1},% +& \fi +& \unexpanded{{#2}={#3}}% +& }% +$ \begingroup +$ \ifx#1\KVS@empty +$ \toks@{{#2}={#3}}% +$ \else +$ \toks@\expandafter{#1,{#2}={#3}}% +$ \fi +$ \xdef\KVS@Global{\the\toks@}% +$ \endgroup +$ \let#1\KVS@Global +} +\long\def\kv@set@family@handler#1#2{% + \begingroup + \csname @safe@activestrue\endcsname + \let\ifincsname\iftrue + \expandafter\endgroup + \expandafter\def\csname KVS@#1@handler\endcsname##1##2{#2}% +} +\long\def\kv@unset@family@handler#1#2{% + \begingroup + \csname @safe@activestrue\endcsname + \let\ifincsname\iftrue + \expandafter\endgroup + \expandafter\let\csname KVS@#1@handler\endcsname\@UnDeFiNeD +} +\def\kv@error@novalue{% + \kv@error@generic{No value specified for}% +} +\def\kv@error@unknownkey{% + \kv@error@generic{Undefined}% +} +\def\kv@error@generic#1#2#3{% + \PackageError{kvsetkeys}{% + #1 key `#3'% + }{% + The keyval family of the key `#3' is `#2'.\MessageBreak + The setting of the key is ignored because of the error.\MessageBreak + \MessageBreak + \@ehc + }% +} +\long\def\kvsetkeys#1#2{% + \kv@parse{#2}{\kv@processor@default{#1}}% +} +\def\kvsetkeys@expandafter#1#2{% + \expandafter\kv@parse\expandafter{#2}{% + \kv@processor@default{#1}% + }% +} +\def\KVS@cmd{0}% +\def\KVS@cmd@inc{% +& \edef\KVS@cmd{\the\numexpr\KVS@cmd+1}% +$ \begingroup +$ \count255=\KVS@cmd\relax +$ \advance\count255 by 1\relax +$ \edef\x{\endgroup +$ \noexpand\def\noexpand\KVS@cmd{\number\count255}% +$ }% +$ \x +} +\def\KVS@cmd@dec{% +& \edef\KVS@cmd{\the\numexpr\KVS@cmd-1}% +$ \begingroup +$ \count255=\KVS@cmd\relax +$ \advance\count255 by -1\relax +$ \edef\x{\endgroup +$ \noexpand\def\noexpand\KVS@cmd{\number\count255}% +$ }% +$ \x +} +\def\KVS@empty{} +\def\kvsetknownkeys{% + \expandafter + \KVS@setknownkeys\csname KVS@cmd\KVS@cmd\endcsname{}% +} +\long\def\KVS@setknownkeys#1#2#3#4#5{% + \let#1\KVS@empty + \KVS@cmd@inc + #2\kv@parse#2{#5}{\kv@processor@known{#3}#1}% + \KVS@cmd@dec + \let#4=#1% +} +\def\kvsetknownkeys@expandafter{% + \expandafter + \KVS@setknownkeys + \csname KVS@cmd\KVS@cmd\endcsname\expandafter +} +\KVS@AtEnd% +%% \section{Installation} +\endinput +%% +%% End of file `kvsetkeys.sty'. diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 21b9d33a837..eb8a73042d8 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -3126,6 +3126,7 @@ my $core_latex = "$Master/texmf-dist/tex/latex"; 'kdgdocs' => 'latex', # requires interaction 'komacv' => 'latex', # requires interaction 'kvoptions' => 'etex', + 'kvsetkeys' => 'etex', 'labelcas' => 'latex', # requires interaction 'lastpage' => 'tex', 'latex-veryshortguide' => 'latex', # requires interaction |