Debian Codegraph @

texmf-dist/source/latex/sauerj/processkv.dtx

raw
1 % \iffalse meta-comment
2 % Line endings: UNIX
3 % Tab size: 4
4 %
5 % Copyright 2004 Jonathan Sauer
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.3
9 % of this license or (at your option) any later version.
10 % The latest version of this license is in
11 %
12 % http://www.latex-project.org/lppl.txt
13 %
14 % and version 1.3 or later is part of all distributions of LaTeX
15 % version 2003/12/01 or later.
16 %
17 % This work has the LPPL maintenance status "maintained".
18 %
19 % The Current Maintainer of this work is Jonathan Sauer
20 % (<[email protected]>).
21 %
22 % This work consists of the files processkv.dtx and processkv.ins and
23 % the derived file processkv.sty.
24 %
25 % This work is based on the package keyval.
26 %
27 % \fi
28 %
29 % \iffalse
30 %
31 %<*driver>
32 \documentclass{ltxdoc}
33 \IfFileExists{processkv.sty}{\usepackage{processkv}}{}
34 \EnableCrossrefs
35 \CodelineIndex
36 \RecordChanges
37 % Modification of verbatim for tabs in listings
38 \makeatletter
39 {\catcode`\ =\active%
40 \catcode`\^^I=\active%
41 \gdef\@vobeyspaces{%
42 \catcode`\ \active\let \@xobeysp%
43 \catcode`\^^I\active\def^^I{~~}%
44 }}%
45 \makeatother
46 \begin{document}
47 \DocInput{\jobname.dtx}
48 \end{document}
49 %</driver>
50 %
51 %<package>\NeedsTeXFormat{LaTeX2e}
52 %<package>\ProvidesPackage{processkv}
53 %<package> [2004/08/09 v1.0.1 process key=value lists]
54 %<package>\RequirePackage{keyval}[1999/03/16]
55 %
56 % \fi
57 %
58 % \CheckSum{41}
59 % \CharacterTable
60 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
61 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
62 % Digits \0\1\2\3\4\5\6\7\8\9
63 % Exclamation \! Double quote \" Hash (number) \#
64 % Dollar \$ Percent \% Ampersand \&
65 % Acute accent \' Left paren \( Right paren \)
66 % Asterisk \* Plus \+ Comma \,
67 % Minus \- Point \. Solidus \/
68 % Colon \: Semicolon \; Less than \<
69 % Equals \= Greater than \> Question mark \?
70 % Commercial at \@ Left bracket \[ Backslash \\
71 % Right bracket \] Circumflex \^ Underscore \_
72 % Grave accent \` Left brace \{ Vertical bar \|
73 % Right brace \} Tilde \~}
74 %
75 % \DoNotIndex{\@empty,\@tempa,\@tempb,\def,\else,\empty,\expandafter}
76 % \DoNotIndex{\fi,\ifx,\relax}
77 %
78 % \changes{1.0.1}{2004/08/09}{Mangled macronames corrected.}
79 %
80 % \GetFileInfo{\jobname.sty}
81 %
82 % \title{The \textsf{processkv} package\thanks{This document
83 % corresponds to \textsf{\filename}~\fileversion, dated \filedate.}}
84 %
85 % \author{Jonathan Sauer \\ \texttt{[email protected]}}
86 %
87 % \date{\filedate}
88 %
89 % \maketitle
90 %
91 % \begin{abstract}
92 % This file describes the \textsf{processkv} package that provides
93 % macros for processing of key-value-lists by calling a user-defined
94 % macro for each key-value-pair.
95 %
96 % \end{abstract}
97 %
98 % \tableofcontents
99 %
100 % \section{Introduction}
101 %
102 % The \textsf{keyval} package provides the possibility of specifying
103 % macro arguments as |key=value|, where |key| is one of previously
104 % defined keys. Sometimes it is necessary not to have to define the
105 % keys in advance, but to specify arbitrary keys which are then
106 % processed.
107 %
108 % This package provides the macro |\processkeyvalues| that calls a
109 % user-defined macro for each key-value-pair.
110 %
111 % This package makes use of some internal macros of the package
112 % \textsf{keyval}. I hope this will not break someday \ldots
113 %
114 %
115 % \section{Using the package}
116 %
117 % \DescribeMacro{\processkeyvalues} Usage: |\processkeyvalues|
118 % \marg{keyvalue-list} \marg{macro}.
119 %
120 % The main macro of this package. It calls \meta{macro} for each
121 % key-value-pair in \meta{keyvalue-list}. Macros in the list are not
122 % expanded.
123 %
124 % \meta{macro} can be any macro with two parameters, i.e:
125 %
126 % \begin{verbatim}
127 % \def\testmacro#1#2{%
128 % \message{Key = `#1', value = `#2'}%
129 % }
130 % \end{verbatim}
131 % Or
132 %
133 % \begin{verbatim}
134 % \newcommand{\testmacro}[2]{%
135 % \message{Key = `#1', value = `#2'}%
136 % }
137 % \end{verbatim}
138 %
139 %
140 % \StopEventually{}
141 %
142 % \section{Implementation}
143 %
144 % \subsection{Main macros}
145 %
146 % \begin{macro}{\processkeyvalues}
147 %
148 % Usage: |\processkeyvalues| \marg{keyvalue-list} \marg{macro}.
149 %
150 % Calls \meta{macro} for each key-value-pair in the list. \meta{macro}
151 % must have two parameters, \meta{key} and \meta{value}.
152 %
153 % \begin{macrocode}
154 \def\processkeyvalues#1#2{%
155 \def\PKV@process{#2}%
156 \PKV@do#1,\relax,%
157 }
158 % \end{macrocode}
159 % \end{macro}
160 %
161 %
162 % \subsection{Internal macros}
163 %
164 % \begin{macro}{\PKV@do}
165 %
166 % Processes the list.
167 %
168 % \begin{macrocode}
169 \def\PKV@do#1,{%
170 \ifx\relax#1\empty\else%
171 \PKV@split#1==\relax%
172 \expandafter\PKV@do\fi%
173 }
174 % \end{macrocode}
175 % \end{macro}
176 %
177 %
178 % \begin{macro}{\PKV@split}
179 %
180 % Processes a key-value-pair of the list. Uses some macros of the
181 % \textsf{keyval} package.
182 %
183 % \begin{macrocode}
184 \def\PKV@split#1=#2=#3\relax{%
185 \KV@@sp@def\@tempa{#1}%
186 \ifx\@tempa\@empty\else%
187 \KV@@sp@def\@tempb{#2}%
188 \expandafter\expandafter\expandafter\PKV@process%
189 \expandafter\expandafter\expandafter{\expandafter\@tempa%
190 \expandafter}\expandafter{\@tempb}%
191 \fi%
192 }
193 % \end{macrocode}
194 % \end{macro}
195 %
196 % \Finale
197 % \PrintChanges
198 % \PrintIndex
199 \endinput