diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx | 250 |
1 files changed, 133 insertions, 117 deletions
diff --git a/Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx b/Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx index 0222eb14161..14a6705c67e 100644 --- a/Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx +++ b/Master/texmf-dist/source/latex/stex/metakeys/metakeys.dtx @@ -1,28 +1,27 @@ % \iffalse meta-comment % An Infrastructure for marking up Metadata in LaTeX documents -% $URL: https://svn.kwarc.info/repos/stex/trunk/sty/metakeys/metakeys.dtx $ -% $Rev: 1999 $; last modified by $Author: kohlhase $ -% $Date: 2012-01-28 08:32:11 +0100 (Sat, 28 Jan 2012) $ % Copyright (c) 2009 Michael Kohlhase, all rights reserved % this file is released under the % LaTeX Project Public License (LPPL) +% The original of this file is in the public repository at +% http://github.com/KWARC/sTeX/ % \fi % % \iffalse %<*package> \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{metakeys}[2012/01/28 v0.9 Framework for Metadata Keys] +\ProvidesPackage{metakeys}[2016/04/07 v0.9 Framework for Metadata Keys] %</package> %<*driver> \documentclass{ltxdoc} \usepackage{stex-logo,url,array,float} \usepackage[show]{ed} -\usepackage{../ctansvn} -\usepackage[eso-foot,today]{svninfo} +\usepackage{ctangit} \usepackage[hyperref=auto,style=alphabetic]{biblatex} -\bibliography{kwarc} -\svnInfo $Id: metakeys.dtx 1999 2012-01-28 07:32:11Z kohlhase $ -\svnKeyword $HeadURL: https://svn.kwarc.info/repos/stex/trunk/sty/metakeys/metakeys.dtx $ +\addbibresource{kwarcpubs.bib} +\addbibresource{extpubs.bib} +\addbibresource{kwarccrossrefs.bib} +\addbibresource{extcrossrefs.bib} \usepackage{hyperref} %\makeindex \floatstyle{boxed} @@ -34,7 +33,7 @@ %</driver> % \fi % -%\CheckSum{176} +%\CheckSum{135} % % \changes{v0.1}{2009/12/14}{First version} % \changes{v0.8}{2010/06/18}{This is almost done} @@ -83,7 +82,7 @@ % \subsection{Adding Metadata Keys to Commands}\label{sec:user:keys} % % Key/value pairs in \stex are organized in \textbf{key groups}: every {\stex} macro and -% environment that takes a key/value argument has an associtated key group, and only keys +% environment that takes a key/value argument has an associated key group, and only keys % that are registered in this group can be utilized. The |metakeys| package supplies the % \DescribeMacro{\addmetakey}|\addmetakey| macro to add a new key to a key group: If % \meta{group} is the name of a key group \meta{key} is a metadata keyword name, then @@ -91,9 +90,9 @@ % |\addmetakey[|\meta{default}|]{|\meta{group}|}{|\meta{key}|}[|\meta{dval}|]| % \end{quote} % registers \meta{key} in the metadata group \meta{group}, with an optional values -% \meta{default} and \meta{dval} for \meta{key}. The \meta{default} is the default value -% for \meta{key}, if it is not specified, and \meta{dval} the value it gets, if \meta{key} -% is given without specifying a value. These two defaults are often used as +% \meta{default} and \meta{dval} for \meta{key}. \meta{default} is the default value for +% \meta{key}, if it is not specified, and \meta{dval} is the value \meta{key} gets, if +% \meta{key} is given without specifying a value. These two defaults are often used as % \begin{quote} % |\addmetakey[false]{|\meta{group}|}{|\meta{key}|}[true]| % \end{quote} @@ -105,11 +104,17 @@ % % The keys registered for a metadata group can be used for defining macros with a % key/value arguments via the \DescribeMacro{\metasetkeys}|\metasetkeys| macro, see for -% instance the the definition in Figure~\ref{fig:foo}. +% instance the the definition in Figure~\ref{fig:foo}. This macro is used exactly like the +% |\setkeys| macro from the |keyval| package~\cite{Carlisle:tkp99}, but integrates custom +% initialization and draft display functionality. This usage is mostly for package +% designers. There is another: If a macro or environment cannot be extended by an optional +% argument, e.g. because anther package already does so (e.g. the |document| environment +% is extended -- by redefining it -- by various packages, which causes problems), the +% |\metasetkeys| macro can be used directly. % % The \DescribeMacro{\addmetalistkey}|\addmetalistkey| macro is a variant of |\addmetakey| % that adds a list-valued metadata key. The |\addmetalistkey{foo}{val}| in -% Figure~\ref{fig:foo} would allows to use multiple occurrences of teh |val| keys in the +% Figure~\ref{fig:foo} would allows to use multiple occurrences of the |val| keys in the % metadata argument of |\foo|, the values of the |val| keys are collected as a % comma-separated list in the token register |\foo@vals|. Note that the |val| key can also % deal with comma-separated lists for convenience. @@ -179,7 +184,7 @@ % % In this section we document known limitations. If you want to help alleviate them, % please feel free to contact the package author. Some of them are currently discussed in -% the \sTeX TRAC~\cite{sTeX:online}. +% the \sTeX GitHub repository~\cite{sTeX:github:on}. % \begin{compactenum} % \item none reported yet % \end{compactenum} @@ -188,12 +193,6 @@ % % \section{The Implementation}\label{sec:impl} % -% The |metakeys| package generates two files: the {\LaTeX} package (all the code between -% {\textsf{$\langle$*package$\rangle$}} and {\textsf{$\langle$/package$\rangle$}}) and the -% {\latexml} bindings (between {\textsf{$\langle$*ltxml$\rangle$ and -% $\langle$/ltxml$\rangle$}}). We keep the corresponding code fragments together, since -% the documentation applies to both of them and to prevent them from getting out of sync. -% % \subsection{Package Options}\label{sec:impl:options} % % We declare some switches which will modify the behavior according to the package @@ -203,16 +202,15 @@ %<*package> \newif\ifmetakeys@showmeta\metakeys@showmetafalse \DeclareOption{showmeta}{\metakeys@showmetatrue} -% \end{macrocode} -% Finally, we need to declare the end of the option declaration section to {\LaTeX}. -% \begin{macrocode} -\ProcessOptions +\DeclareOption*{} +\ProcessOptions % \end{macrocode} % -% We build on the |keyval| package which we first need to load. +% We build on the |keyval| package which we first need to load. For {\latexml}, we also +% initialize the package inclusions. % \begin{macrocode} \RequirePackage{keyval}[1997/11/10] -%</package> +\RequirePackage{etoolbox} % \end{macrocode} % % \subsection{Adding Metadata Keys}\label{sec:impl:keys} @@ -220,9 +218,7 @@ % \begin{macro}{\addmetakey} % The |\addmetakey| macro looks at the next character and invokes helper macros accordingly. % \begin{macrocode} -%<*package> -\newcommand\addmetakey{\@ifstar\addmetakey@star\addmetakey@nostar} -%</package> +\newcommand\addmetakey{\@ifstar\addmetakey@star\addmetakey@nostar}% % \end{macrocode} % \end{macro} % @@ -233,38 +229,52 @@ % |\define@key| macro from the |keyval| package. This stores the key value given in the % local macro |\|\meta{group}|@|\meta{key}. % \begin{macrocode} -%<*package> -\newcommand\addmetakey@star[3][]% -{\@ifnextchar[{\addmetakey@star@aux[#1]{#2}{#3}}{\addmetakey@star@aux[#1]{#2}{#3}[]}} -\def\addmetakey@star@aux[#1]#2#3[#4]{\metakeys@ext@clear@keys{#2}{#3}{#1}% -\metakeys@initialize@showkeys{#2}% -\define@key{#2}{#3}[#4]{\expandafter\gdef\csname #2@#3\endcsname{##1}}} +\newcommand\addmetakey@star[3][]{% + \@ifnextchar[{% + \addmetakey@star@aux[#1]{#2}{#3}% + }{% + \addmetakey@star@aux[#1]{#2}{#3}[]% + }% +}% +\def\addmetakey@star@aux[#1]#2#3[#4]{% + \metakeys@ext@clear@keys{#2}{#3}{#1}% + \metakeys@initialize@showkeys{#2}% + \define@key{#2}{#3}[#4]{% + \csxdef{#2@#3}{##1}% + }% +}% % \end{macrocode} % \end{macro} % % \begin{macro}{\addmetakey@nostar} -% |\addmetakey@nostar| takes care of the starred form of |\addmetakey| by first extending the +% |\addmetakey@nostar| takes care of the no-starred form of |\addmetakey| by first extending the % |\metakeys@|\meta{group}|@showkeys| macro which contains those keys that should be % shown and then calling |\addmetakey@star|. % \begin{macrocode} -\newcommand\addmetakey@nostar[3][]% -{\metakeys@ext@showkeys{#2}{#3}\addmetakey@star[#1]{#2}{#3}} -%</package> +\newcommand\addmetakey@nostar[3][]{% + \metakeys@ext@showkeys{#2}{#3}% + \addmetakey@star[#1]{#2}{#3}% +}% % \end{macrocode} % \end{macro} % % \begin{macro}{\metasetkeys} % The |\metasetkeys{|\meta{group}|}| clears/presets the key of \meta{group} via -% |\clear@|\meta{group}|@clearkeys|, (if the |showmeta| option is set) shows them, and +% |\clear@|\meta{group}|@keys|, (if the |showmeta| option is set) shows them, and % then sets the keys via |keyval|s |\setkeys| command. % \begin{macrocode} -%<*package> -\newcommand\metasetkeys[2]{\@nameuse{clear@#1@keys}\setkeys{#1}{#2}% -\ifmetakeys@showmeta% -\edef\@@keys{\@nameuse{#1@showkeys}}% -\metakeys@show@keys{#1}{\@for\@I:=\@@keys\do{\metakeys@show@keyval{#1}{\@I}}}% -\fi} -%</package> +\newcommand\metasetkeys[2]{% + \@nameuse{clear@#1@keys}% + \setkeys{#1}{#2}% + \ifmetakeys@showmeta% + \edef\@@keys{\@nameuse{#1@showkeys}}% + \metakeys@show@keys{#1}{% + \@for\@I:=\@@keys\do{% + \metakeys@show@keyval{#1}{\@I}% + }% + }% + \fi% +}% % \end{macrocode} % \end{macro} % @@ -276,31 +286,39 @@ % |\metasetkeys| macro below. The variant |\@metakeys@ext@clear@keys| is provided for % use in the |sref| package. % \begin{macrocode} -%<*package> -\newcommand\metakeys@ext@clear@keys[3]{\@metakeys@ext@clear@keys{#1}{#1@#2}{#3}} -\newcommand\@metakeys@ext@clear@keys[3]{\@ifundefined{clear@#1@keys}% -{\expandafter\gdef\csname clear@#1@keys\endcsname% -{\expandafter\gdef\csname #2\endcsname{#3}}}% -{\expandafter\g@addto@macro\csname clear@#1@keys\endcsname% -{\expandafter\gdef\csname #2\endcsname{#3}}}} -%</package> +\newrobustcmd\metakeys@ext@clear@keys[3]{% + \@metakeys@ext@clear@keys{#1}{#1@#2}{#3}% +}% +\newrobustcmd\@metakeys@ext@clear@keys[3]{% + \@ifundefined{clear@#1@keys}{% + \csgdef{clear@#1@keys}{\csgdef{#2}{#3}}% + }% + {\expandafter\gappto\csname clear@#1@keys\endcsname{\csgdef{#2}{#3}}}% +}% % \end{macrocode} % \end{macro} % % \begin{macro}{\addmetalistkey} % \begin{macrocode} -%<*package> -\newcommand\addmetalistkey{\@ifstar\addmetalistkey@star\addmetalistkey@nostar} -\newcommand\addmetalistkey@star[3][]{\metakeys@ext@clear@keys{#2}{#3}{#1}% -\metakeys@initialize@showkeys{#2}% -\expandafter\gdef\csname #2@#3s\endcsname{} -\define@key{#2}{#3}[#1]{% -\expandafter\ifx\csname #2@#3s\endcsname\@empty\expandafter\gdef\csname #2@#3s\endcsname{##1}% -\else\expandafter\xdef\csname #2@#3s\endcsname{\csname #2@#3s\endcsname,##1}% -\fi}} -\newcommand\addmetalistkey@nostar[3][]% -{\metakeys@ext@showkeys{#2}{#3}\addmetalistkey@star[#1]{#2}{#3}} -%</package> +\newrobustcmd\addmetalistkey{% + \@ifstar\addmetalistkey@star\addmetalistkey@nostar% +}% +\newrobustcmd\addmetalistkey@star[3][]{% + \metakeys@ext@clear@keys{#2}{#3}{#1}% + \metakeys@initialize@showkeys{#2}% + \csgdef{#2@#3s}{}% + \define@key{#2}{#3}[#1]{% + \ifcsempty{#2@#3s}{% + \csgdef{#2@#3s}{##1}% + }{% + \csxdef{#2@#3s}{\csuse{#2@#3s},##1}% + }% + }% +}% +\newrobustcmd\addmetalistkey@nostar[3][]{% + \metakeys@ext@showkeys{#2}{#3}% + \addmetalistkey@star[#1]{#2}{#3}% +}% % \end{macrocode} % \end{macro} % @@ -311,9 +329,11 @@ % macro which is is used to store the keys to be shown of the metadata in in the generic % |\setmetakeys| macro below. % \begin{macrocode} -%<*package> -\newcommand\metakeys@initialize@showkeys[1]% -{\@ifundefined{#1@showkeys}{\expandafter\def\csname #1@showkeys\endcsname{}}{}}% +\newrobustcmd\metakeys@initialize@showkeys[1]{% + \@ifundefined{#1@showkeys}{% + \csdef{#1@showkeys}{}% + }{}% +}% % \end{macrocode} % \end{macro} % @@ -322,9 +342,13 @@ % |\|\meta{group}|@showkeys| macro which is is used to store the keys to be shown of the % metadata in in the generic |\setmetakeys| macro below. % \begin{macrocode} -\newcommand\metakeys@ext@showkeys[2]{\@ifundefined{#1@showkeys}% -{\expandafter\def\csname #1@showkeys\endcsname{#2}}% -{\expandafter\edef\csname #1@showkeys\endcsname{\csname #1@showkeys\endcsname,#2}}} +\newrobustcmd\metakeys@ext@showkeys[2]{% + \@ifundefined{#1@showkeys}{% + \csdef{#1@showkeys}{#2}% + }{% + \csedef{#1@showkeys}{\csuse{#1@showkeys},#2}% + }% +}% % \end{macrocode} % \end{macro} % @@ -332,8 +356,11 @@ % |\metakeys@show@key{|\meta{key}|}{|\meta{value}|}| shows the a single key value pair, as a % default we just write \meta{key}|:|\meta{value}. % \begin{macrocode} -\newcommand\@metakeys@show@key[2]{\metakeys@show@key{#2}{#1}} -\newcommand\metakeys@show@key[2]{\edef\@test{#2}\ifx\@test\@empty\else #1:#2\quad\fi} +\newrobustcmd\@metakeys@show@key[2]{\metakeys@show@key{#2}{#1}}% +\newrobustcmd\metakeys@show@key[2]{% + \edef\@test{#2}% + \ifx\@test\@empty\else #1:#2\quad\fi% +}% % \end{macrocode} % \end{macro} % @@ -341,38 +368,28 @@ % |\metakeys@show@keys{|\meta{group}|}{|\meta{keys}|}| shows the metadata, by default we % disregard the \meta{group} and show \meta{keys} in a marginpar. % \begin{macrocode} -\newcommand\metakeys@show@keys[2]{\marginpar{{\scriptsize #2}}} +\newrobustcmd\metakeys@show@keys[2]{\marginpar{{\scriptsize #2}}}% % \end{macrocode} % \end{macro} % % \begin{macro}{\metakeys@show@keyval} % |\metakeys@show@keyval{|\meta{group}|}|{|\meta{key}|} shows the key/value pair of a given key \meta{key}. % \begin{macrocode} -\newcommand\metakeys@show@keyval[2]% -{\expandafter\@metakeys@show@key\csname #1@#2\endcsname{#2}} -%</package> +\newrobustcmd\metakeys@show@keyval[2]{% + \expandafter\@metakeys@show@key\csname #1@#2\endcsname{#2}% +}% % \end{macrocode} % \end{macro} % % \begin{macro}{\showmetakeys} % \begin{macrocode} -%<*package> -\newcommand\showmetakeys{\metakeys@showmetatrue} -%</package> -%<*ltxml> -DefConstructor('\showmetakeys',''); -%</ltxml> +\newrobustcmd\showmetakeys{\metakeys@showmetatrue}% % \end{macrocode} % \end{macro} % % \begin{macro}{\hidemetakeys} % \begin{macrocode} -%<*package> -\newcommand\hidemetakeys{\metakeys@showmetafalse} -%</package> -%<*ltxml> -DefConstructor('\hidemetakeys',''); -%</ltxml> +\newrobustcmd\hidemetakeys{\metakeys@showmetafalse}% % \end{macrocode} % \end{macro} % @@ -383,36 +400,34 @@ DefConstructor('\hidemetakeys',''); % |\omd@unspecified| as an optional argument, so that it is used as the default value % here and then test for it in |\omfidus|. But unfortunately, this does not work yet. % \begin{macrocode} -%<*package> -\newcommand\addmetakeynew[3][]{\metakeys@ext@clear@keys{#2}{#3}{#1}% -\define@key{#2}{#3}{\expandafter\gdef\csname #2@#3\endcsname{##1}}} +\newrobustcmd\addmetakeynew[3][]{% + \metakeys@ext@clear@keys{#2}{#3}{#1}% + \define@key{#2}{#3}{% + \csgdef{#2@#3}{##1}% + }% +}% % \end{macrocode} % \end{macro} % % % \begin{macro}{\metakeys@unspecified} -% Ain internal macro for unspecified values. It is used to initialize keys.\ednote{MK: +% An internal macro for unspecified values. It is used to initialize keys.\ednote{MK: % we could probably embed an package error or warning in here} % \begin{macrocode} -\newcommand\metakeys@unspecified{an metakeys-defined key left unspecified} +\newrobustcmd\metakeys@unspecified{an metakeys-defined key left unspecified}% % \end{macrocode} % \end{macro} % % \begin{macro}{\metakeysifus} % This just tests for equality of the first arg with |\metakeys@unspecified| % \begin{macrocode} -\newcommand\metakeysifus[4]{\message{testing #1@#2=\csname#1@#2\endcsname}% -\expandafter\ifx\csname #1@#2\endcsname\metakeys@unspecified{#3}\else{#4}\fi} +\newrobustcmd\metakeysifus[4]{% + \message{testing #1@#2=\csname#1@#2\endcsname}% + \expandafter\ifx\csname #1@#2\endcsname\metakeys@unspecified{#3}\else{#4}\fi% +}% %</package> % \end{macrocode} % \end{macro} -% -% \subsection{Finale} -% -% Finally, we need to terminate the file with a success mark for perl. -% \begin{macrocode} -%<ltxml>1; -% \end{macrocode} % \Finale \endinput % \iffalse @@ -424,12 +439,13 @@ DefConstructor('\hidemetakeys',''); % LocalWords: iffalse kohlhase Thu metakeys metakeys.dtx scsys sc sc latexml omdoc foo -% LocalWords: omdocv texttt fileversion maketitle setcounter tocdepth newpage -% LocalWords: tableofcontents ednote showmeta -% LocalWords: makeatletter newcommand emph makeatother exfig vspace impl ltxml -% LocalWords: printbibliography keyval clearkeys expandafter gdef csname ifx -% LocalWords: endcsname setkeys ifundefined omfidus metakeysifus addmetakey -% LocalWords: doctex metasetkeys metasetkeys marginpar hidemetakeys textsf omd -% LocalWords: hidemetakeys showmetakeys showmetakeys langle textsf langle -% LocalWords: newif ifmetakeys showmetafalse showmetatrue ifstar showkeys -% LocalWords: nameuse setmetakeys addmetakeynew +% LocalWords: omdocv texttt fileversion maketitle setcounter tocdepth newpage filedate +% LocalWords: tableofcontents ednote showmeta NeedsTeXFormat stex rdfmeta ctancite dval +% LocalWords: makeatletter newcommand emph makeatother exfig vspace impl ltxml textbf +% LocalWords: printbibliography keyval expandafter gdef csname ifx tkp99 sref +% LocalWords: endcsname setkeys ifundefined omfidus metakeysifus addmetakey foo@vals +% LocalWords: doctex metasetkeys metasetkeys marginpar hidemetakeys textsf omd rangle +% LocalWords: hidemetakeys showmetakeys showmetakeys langle textsf langle addmetalistkey +% LocalWords: newif ifmetakeys showmetafalse showmetatrue ifstar showkeys addmetalistkey +% LocalWords: nameuse setmetakeys addmetakeynew textbackslash compactenum rangle xdef +% LocalWords: addmetakey@nostar addmetalistkey@nostar scriptsize endinput |