summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-02-14 21:28:58 +0000
committerKarl Berry <karl@freefriends.org>2024-02-14 21:28:58 +0000
commit45167e7e3302f278649e669816603c8fe3b097bc (patch)
tree4ff44ef99e5ec2cd576e1d48dcdf1b8271734713
parent91494cd6db11b2eab523a4d7115b704a96f1a1df (diff)
l3 (14feb24)
git-svn-id: svn://tug.org/texlive/trunk@69859 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/CHANGELOG.md17
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/README.md104
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/l3keys2e/l3keys2e.pdfbin412557 -> 412717 bytes
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/xfp/xfp.pdfbin332260 -> 332421 bytes
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/xfrac/xfrac.pdfbin482959 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/xparse/xparse.pdfbin534533 -> 534182 bytes
-rw-r--r--Master/texmf-dist/doc/latex/l3packages/xtemplate/xtemplate.pdfbin450604 -> 448106 bytes
-rw-r--r--Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx8
-rw-r--r--Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.ins4
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xfp/xfp.dtx8
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xfp/xfp.ins4
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx1141
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.ins49
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx8
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xparse/xparse.ins4
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx2265
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.ins4
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty4
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty4
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty424
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xparse/xparse.ltx2
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty4
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-2023-10-10.sty1371
-rw-r--r--Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty1358
24 files changed, 1469 insertions, 5314 deletions
diff --git a/Master/texmf-dist/doc/latex/l3packages/CHANGELOG.md b/Master/texmf-dist/doc/latex/l3packages/CHANGELOG.md
index 05001a0e8fa..abef360b7a7 100644
--- a/Master/texmf-dist/doc/latex/l3packages/CHANGELOG.md
+++ b/Master/texmf-dist/doc/latex/l3packages/CHANGELOG.md
@@ -7,6 +7,15 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+## [2024-02-13]
+
+### Changed
+- Preparation for move of `xtemplate` concepts to the kernel
+
+### Removed
+- `\IfInstanceExist(TF)`
+- `xfrac`: moved to https://github.com/latex3/xfrac
+
## [2023-10-10]
### Changed
@@ -65,7 +74,7 @@ this project uses date-based 'snapshot' version identifiers.
## [2022-05-30]
-## Added
+### Added
- `\SetTemplateKeys` for _ad hoc_ adjustment of template values
### Changed
@@ -99,19 +108,16 @@ this project uses date-based 'snapshot' version identifiers.
## [2021-06-18]
### Fixed
-
- Correct internal changes to message naming
## [2021-06-01]
### Fixed
-
- Restore one parameter in `xfrac`
## [2021-05-27]
### Changed
-
- Internal changes to message naming
## [2021-05-07]
@@ -237,7 +243,8 @@ this project uses date-based 'snapshot' version identifiers.
- Switch to ISO date format
- Improve cross-module use of internal functions
-[Unreleased]: https://github.com/latex3/latex3/compare/2023-10-10...HEAD
+[Unreleased]: https://github.com/latex3/latex3/compare/2024-02-13...HEAD
+[2024-02-13]: https://github.com/latex3/latex3/compare/2023-10-10...2024-02-13
[2023-10-10]: https://github.com/latex3/latex3/compare/2023-08-29...2023-10-10
[2023-08-29]: https://github.com/latex3/latex3/compare/2023-02-02...2023-08-29
[2023-02-02]: https://github.com/latex3/latex3/compare/2023-02-01...2023-02-02
diff --git a/Master/texmf-dist/doc/latex/l3packages/README.md b/Master/texmf-dist/doc/latex/l3packages/README.md
index d3ecea70287..2579ee6e961 100644
--- a/Master/texmf-dist/doc/latex/l3packages/README.md
+++ b/Master/texmf-dist/doc/latex/l3packages/README.md
@@ -1,99 +1,37 @@
-LaTeX3 High-Level Concepts
-==========================
+# `l3packages`: Higher-level LaTeX3 Concepts (Deprecated)
-Release 2023-10-10
+Release 2024-02-13
-Overview
---------
+## Overview
-The `l3packages` collection contains implementations for aspects of the
-LaTeX3 kernel, dealing with higher-level ideas such as the Designer Interface.
-The packages here are considered broadly stable (The LaTeX Project does not
-expect the interfaces to alter radically). These packages are build on LaTeX2e
-conventions at the interface level, and so may not migrate in the current form
-to a stand-alone LaTeX3 format.
+The `l3packages` collection dealing with higher-level ideas such as the
+Designer Interface, as part of 'LaTeX3' developments. The packages here have
+over time migrated into the LaTeX kernel: the material here is retained to
+support older files.
-All of the material in the collection requires the LaTeX3 base layer package
-[`l3kernel`](http://ctan.org/pkg/l3kernel). The two packages must be installed
-in matching versions: if you update `l3packages`, make sure that `l3kernel` is
-updated at the same time.
+The appropriate LaTeX kernel releases incorporating the ideas from the packages
+here are
-Currently included in the CTAN release of `l3packages` are the following
-bundles:
-* `l3keys2e` (deprecated in favor of updated LaTeX kernel methods)
-* `xfp` (from 2022-06-01 part of the LaTeX format)
-* `xfrac`
-* `xparse` (deprecated in favor of elements move to the LaTeX kernel)
-* `xtemplate`
+- `l3keys2e` 2022-06-01
+- `xfp` 2022-06-01
+- `xparse` 2020-10-01
+- `xtemplate` 2024-06-01
-`l3keys2e` (deprecated)
-----------
+## Issues
-The `l3keys2e` package allows keys defined using `l3keys` to be used as package
-and class options with LaTeX2e. This is tied to the method the existing kernel
-uses for processing options, and so it is likely that a stand-alone LaTeX3
-kernel will use a very different approach.
-
-`xfp` (deprecated)
------
-
-The `xfp` package provides a document-level interface for the LaTeX3
-FPU. As such, it is a wrapper around the core `\fp_eval:n` function
-but does not require code syntax. It provides the expandable command
-`\fpeval`, which can be used inside for example `\edef` or contexts
-where TeX requires a number.
-
-From 2022-06-01 release of LaTeX this will be included in the format
-so that the package doesn't need loading any longer.
-
-`xfrac`
--------
-
-The `xfrac` package uses the interface defined by `xtemplate` to provide
-flexible split-level fractions _via_ the `\sfrac` macro. This is both a
-demonstration of the power of the template concept and also a useful addition
-to the available functionality in LaTeX2e.
-
-`xparse` (deprecated)
--------
-
-The `xparse` package provides a high-level interface for declaring document
-commands, e.g., a uniform way to define commands taking optional arguments,
-optional stars (and others), mandatory arguments and more.
-
-The development of `xparse` moved to the
-[LaTeX2e repository](https://github.com/latex3/latex2e) as `ltcmd`, which is
-preloaded in the LaTeX format, and the code for `xparse` in this repository
-contains only the deprecated argument types `G`, `l`, and `u`.
-
-`xtemplate`
------------
-
-The `xtemplate` package provides an interface for defining generic
-functions using a key=val syntax. This is designed to be
-"self-documenting", with the key definitions providing information
-on how they are to be used.
-
-
-Issues
-------
-
-The issue tracker for LaTeX3 is currently located
+The issue tracker for LaTeX is currently located
[on GitHub](https://github.com/latex3/latex3/issues).
+## Development team
-The LaTeX Project
-------------------
+This code is developed by [The LaTeX Project](https://latex-project.org).
-Development of LaTeX3 is carried out by
-[The LaTeX Project](https://www.latex-project.org/latex3/).
+## License
-The development team can be contacted
-by e-mail: <latex-team@latex-project.org>; for general LaTeX3 discussion
-the [LaTeX-L list](#Discussion) should be used.
+Released under the LaTeX Project Public License v1.3c or later. See https://www.latex-project.org/lppl.txt
-----
-<p>Copyright (C) 1998-2012,2015-2023 The LaTeX Project <br />
-<a href="http://latex-project.org/">http://latex-project.org/</a> <br />
+<p>Copyright (C) 2024 The LaTeX Project <br />
+<a href="https://latex-project.org/">https://latex-project.org/</a> <br />
All rights reserved.</p>
diff --git a/Master/texmf-dist/doc/latex/l3packages/l3keys2e/l3keys2e.pdf b/Master/texmf-dist/doc/latex/l3packages/l3keys2e/l3keys2e.pdf
index cfef37deffa..a6e0bd9e415 100644
--- a/Master/texmf-dist/doc/latex/l3packages/l3keys2e/l3keys2e.pdf
+++ b/Master/texmf-dist/doc/latex/l3packages/l3keys2e/l3keys2e.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/l3packages/xfp/xfp.pdf b/Master/texmf-dist/doc/latex/l3packages/xfp/xfp.pdf
index aa5b6c02933..b45cdd5b15d 100644
--- a/Master/texmf-dist/doc/latex/l3packages/xfp/xfp.pdf
+++ b/Master/texmf-dist/doc/latex/l3packages/xfp/xfp.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/l3packages/xfrac/xfrac.pdf b/Master/texmf-dist/doc/latex/l3packages/xfrac/xfrac.pdf
deleted file mode 100644
index 61a472a9012..00000000000
--- a/Master/texmf-dist/doc/latex/l3packages/xfrac/xfrac.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/l3packages/xparse/xparse.pdf b/Master/texmf-dist/doc/latex/l3packages/xparse/xparse.pdf
index 483370f2fc5..183ebaaa78c 100644
--- a/Master/texmf-dist/doc/latex/l3packages/xparse/xparse.pdf
+++ b/Master/texmf-dist/doc/latex/l3packages/xparse/xparse.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/l3packages/xtemplate/xtemplate.pdf b/Master/texmf-dist/doc/latex/l3packages/xtemplate/xtemplate.pdf
index 57ab72b1487..c5fc4658354 100644
--- a/Master/texmf-dist/doc/latex/l3packages/xtemplate/xtemplate.pdf
+++ b/Master/texmf-dist/doc/latex/l3packages/xtemplate/xtemplate.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx
index 376cb136acb..f5c494120a0 100644
--- a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx
+++ b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.dtx
@@ -2,7 +2,7 @@
%
%% File: l3keys2e.dtx
%
-% Copyright (C) 2009,2011-2023 The LaTeX Project
+% Copyright (C) 2009-2024 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -49,7 +49,7 @@
% \fi
%
% \title{^^A
-% The \textsf{l3keys2e} package\\
+% The \pkg{l3keys2e} package\\
% \LaTeXe{} option processing using \LaTeX3 keys^^A
% }
%
@@ -62,7 +62,7 @@
% }^^A
% }
%
-% \date{Released 2023-10-10}
+% \date{Released 2024-02-13}
%
% \maketitle
%
@@ -154,7 +154,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{l3keys2e}{2023-10-10}{}
+\ProvidesExplPackage{l3keys2e}{2024-02-13}{}
{LaTeX2e option processing using LaTeX3 keys}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.ins b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.ins
index 667debde59f..c4d1545e133 100644
--- a/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.ins
+++ b/Master/texmf-dist/source/latex/l3packages/l3keys2e/l3keys2e.ins
@@ -2,7 +2,7 @@
File: l3keys2e.ins
-Copyright (C) 2009,2011,2012,2016,2017,2019-2023 The LaTeX Project
+Copyright (C) 2009,2011,2012,2016,2017,2019-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -23,7 +23,7 @@ The released version of this bundle is available from CTAN.
\preamble
-Copyright (C) 2009-2023 The LaTeX Project
+Copyright (C) 2009-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/Master/texmf-dist/source/latex/l3packages/xfp/xfp.dtx b/Master/texmf-dist/source/latex/l3packages/xfp/xfp.dtx
index 2c3a5bf7329..d695d44bb13 100644
--- a/Master/texmf-dist/source/latex/l3packages/xfp/xfp.dtx
+++ b/Master/texmf-dist/source/latex/l3packages/xfp/xfp.dtx
@@ -2,7 +2,7 @@
%
%% File: xfp.dtx
%
-% Copyright (C) 2017-2023 The LaTeX Project
+% Copyright (C) 2017-2024 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -51,7 +51,7 @@
% \providecommand\nan{\texttt{NaN}}
%
% \title{^^A
-% The \textsf{xfp} package\\Floating Point Unit^^A
+% The \pkg{xfp} package\\ Floating Point Unit^^A
% }
%
% \author{^^A
@@ -63,7 +63,7 @@
% }^^A
% }
%
-% \date{Released 2023-10-10}
+% \date{Released 2024-02-13}
%
% \maketitle
%
@@ -171,7 +171,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{xfp}{2023-10-10}{}
+\ProvidesExplPackage{xfp}{2024-02-13}{}
{L3 Floating point unit}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/l3packages/xfp/xfp.ins b/Master/texmf-dist/source/latex/l3packages/xfp/xfp.ins
index 266bfa16616..d7d1ff046a1 100644
--- a/Master/texmf-dist/source/latex/l3packages/xfp/xfp.ins
+++ b/Master/texmf-dist/source/latex/l3packages/xfp/xfp.ins
@@ -2,7 +2,7 @@
File: xfp.ins
-Copyright (C) 2017,2019-2023 The LaTeX Project
+Copyright (C) 2017,2019-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -23,7 +23,7 @@ The released version of this bundle is available from CTAN.
\preamble
-Copyright (C) 2017-2023 The LaTeX Project
+Copyright (C) 2017-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx b/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx
deleted file mode 100644
index 6bce5f93ee9..00000000000
--- a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.dtx
+++ /dev/null
@@ -1,1141 +0,0 @@
-% \iffalse meta-comment
-%
-%% File: xfrac.dtx
-%
-% Copyright (C) 2004,2008-2010 Morten Hoegholm
-% (C) 2011,2012,2014-2023 The LaTeX Project
-%
-% It may be distributed and/or modified under the conditions of the
-% LaTeX Project Public License (LPPL), either version 1.3c of this
-% license or (at your option) any later version. The latest version
-% of this license is in the file
-%
-% https://www.latex-project.org/lppl.txt
-%
-% This file is part of the "l3packages bundle" (The Work in LPPL)
-% and all files in that bundle must be distributed together.
-%
-% -----------------------------------------------------------------------
-%
-% The development version of the bundle can be found at
-%
-% https://github.com/latex3/latex3
-%
-% for those people who are interested.
-%
-%<*driver|package>
-% The version of expl3 required is tested as early as possible, as
-% some really old versions do not define \ProvidesExplPackage.
-\RequirePackage{expl3}[2018/02/21]
-%<package>\@ifpackagelater{expl3}{2018/02/21}
-%<package> {}
-%<package> {%
-%<package> \PackageError{xfrac}{Support package l3kernel too old}
-%<package> {%
-%<package> Please install an up to date version of l3kernel\MessageBreak
-%<package> using your TeX package manager or from CTAN.\MessageBreak
-%<package> \MessageBreak
-%<package> Loading xfrac will abort!%
-%<package> }%
-%<package> \endinput
-%<package> }
-\RequirePackage{amstext,graphicx,l3keys2e,textcomp,xparse,xtemplate}
-%</driver|package>
-%<*driver>
-\documentclass[full]{l3doc}
-\usepackage{nicefrac,xfrac} ^^A Need nicefrac for demo purposes
-\providecommand*\key[1]{\textbf{#1}}
-\newcommand*\switch[2]{{\fontfamily{#1}\selectfont #2}}
-\begin{document}
- \DocInput{\jobname.dtx}
-\end{document}
-%</driver>
-% \fi
-%
-% \title{^^A
-% The \textsf{xfrac} package\\ Split-level fractions^^A
-% }
-%
-% \author{^^A
-% The \LaTeX{} Project\thanks
-% {^^A
-% E-mail:
-% \href{mailto:latex-team@latex-project.org}
-% {latex-team@latex-project.org}^^A
-% }^^A
-% }
-%
-% \date{Released 2023-10-10}
-%
-% \maketitle
-%
-% \begin{documentation}
-%
-% The \pkg{xfrac} package defines a document command \cs{sfrac}
-% with the following syntax:
-% \begin{quote}
-% \cs{sfrac}\oarg{instance}\marg{num}\oarg{sep}\marg{denom}
-% \end{quote}
-% Let's show a few examples:
-% \begin{verbatim}
-% \sfrac{1}{2}, $\sfrac{1}{2}$,
-% $\mathbf{3\times\sfrac{1}{2}}$
-% \quad \fontfamily{ppl}\selectfont Palatino: \sfrac{1}{2}
-% \quad \fontfamily{ptm}\selectfont Times: \sfrac{1}{2}
-% \end{verbatim}
-% \begin{quote}
-% \sfrac{1}{2}, $\sfrac{1}{2}$, $\mathbf{3\times\sfrac{1}{2}}$
-% \quad \fontfamily{ppl}\selectfont Palatino: \sfrac{1}{2}
-% \quad \fontfamily{ptm}\selectfont Times: \sfrac{1}{2}
-% \end{quote}
-% You'll notice something interesting: not only does the \cs{sfrac}
-% command work as it should in math mode, it also gets the job done
-% for other fonts as well.
-%
-% \section{A Bit of History}
-%
-% \subsection{The Past}
-%
-% One of the first exercises in \emph{The \TeX{}Book} is to design a
-% macro for split level fractions. The solution presented is fairly
-% simple, using a \emph{virgule} (a slash) for separating the two
-% components. It looks okay because the text font and math font of
-% Computer Modern look almost identical.
-%
-% The proper symbol to use instead of the virgule is a \emph{solidus}
-% which does not exist in Computer Modern. It is however available in
-% the European Computer Modern fonts, but I'll get back to that.
-%
-% \subsection{The Present}
-%
-% The most common way to produce split level fractions within \LaTeXe{}
-% is by means of the \pkg{nicefrac} package. Part of the reason it
-% has found widespread use is due to the strange design of the
-% built-in text fractions of the EC fonts, which look like this:
-% \textonehalf{}. The package is very simple to use but there are a few
-% issues:
-% \begin{itemize}
-% \item It uses the virgule instead of the solidus.
-% \item Font size of numerator and denominator is bigger than in the
-% built-in symbol. Compare Palatino: \switch{ppl}{\nicefrac{1}{2}}
-% \emph{vs.}~\switch{ppl}{\textonehalf}.
-% \item It doesn't correct for fonts using text figures such as in the
-% \pkg{eco} package. Compare \switch{cmor}{\nicefrac{1}{2}} and
-% \switch{cmor}{\nicefrac{8}{9}}.
-% \item In math mode, it doesn't always pick up the correct math
-% alphabet.
-% \end{itemize}
-% In short: \pkg{nicefrac} doesn't attempt to be the answer to
-% everything and so this is not a criticism of the package. It works
-% quite well for Computer Modern which was pretty much what was widely
-% available at the time it was developed. Users these days, however,
-% have a choice of many fonts when they write their documents.
-%
-% \subsection{The Future}
-%
-% Fonts are wildly different; one macro that works fine for Computer
-% Modern obviously doesn't work well at all in Palatino. For one we
-% have to make the separator symbol configurable, and we need to
-% take care of several details as well: font scaling of the
-% numerator/denominator pair (ND), font selection of ND, \emph{etc.} If we
-% are to have a single package for this in the future we have to define a
-% totally generic interface for the fraction commands and then adjust
-% parameters depending on the current font. What you see in this
-% prototype implementation of \pkg{xfrac} is just that.
-%
-% \section{Advanced User Interface}
-%
-% \subsection{Text mode}
-%
-% The usual problem in text mode has a name: Computer Modern. The
-% solidi of all the Computer Modern fonts leave a lot to be desired,
-% although things are potentially looking better as the Latin Modern
-% fonts are becoming more stable and widespread. As long as the
-% default fonts are Computer Modern variants we must however work
-% around this. One idea that comes to mind is to see what happens
-% when you use a solidus from another font instead. Let's try with
-% Times:
-% \begin{quote}
-% \DeclareInstance{xfrac}{cmr2}{text}
-% {slash-symbol-font = ptm}
-% \enquote{You take \sfrac[cmr2]{1}{2} cup of sugar, \ldots}
-% \end{quote}
-% That looks quite good actually, so it was probably very difficult
-% to obtain that result. Nope, it was extremely easy---if you happen
-% to know about \emph{instances}:
-% \begin{verbatim}
-% \DeclareInstance{xfrac}{cmr}{text}
-% {slash-symbol-font = ptm}
-% \end{verbatim}
-% So we define an instance with the name |cmr| from the template
-% |text| which in turn is of object type |xfrac|. You'll notice
-% the |cmr| is also the name of the font family for Computer Modern
-% Roman and the reasoning behind is that every font family should
-% have it's own settings, and if a document command is to work well
-% in that scheme, letting it use the name of the current font family
-% seems like a good idea. Thus the \cs{sfrac} command checks to see
-% whether an instance with same name as the current font family
-% exists and uses it if the test is true; otherwise the default
-% setting is used. Here we defined the instance to be used for the
-% font family |cmr| and just told it to use the Times font for
-% typesetting the slash symbol which turns out to be a solidus by
-% default.
-%
-% The option \texttt{cm-recommended} which is loaded by default uses
-% the Times solidus for Computer Modern Roman and Computer Modern
-% Sans Serif and the Palatino solidus for Computer Modern Typewriter
-% Type. This looks quite good. Should you however not want this you
-% can use the option \texttt{cm-standard} which produces somewhat
-% acceptable results using Computer Modern exclusively.
-%
-% So what about old style figures? If you use the \pkg{eco}
-% package you might define an instance similar to this (`cmor' is
-% the name of the roman font activated by \pkg{eco}):
-% \DeclareInstance{xfrac}{cmor}{text}
-% {
-% slash-symbol-font = ptm,
-% numerator-font = cmr,
-% denominator-font = cmr
-% }
-% \begin{verbatim}
-% \DeclareInstance{xfrac}{cmor}{text}
-% {
-% slash-symbol-font = ptm,
-% numerator-font = cmr,
-% denominator-font = cmr
-% }
-% \end{verbatim}
-% We also use regular Computer Modern Roman for typesetting ND, so
-% we end up with \switch{cmor}{\sfrac{1}{2}} and
-% \switch{cmor}{\sfrac{8}{9}} instead of
-% \switch{cmor}{\nicefrac{1}{2}} and \switch{cmor}{\nicefrac{8}{9}}.
-% Much better.
-%
-% There are also situations where other tricks are useful. If you
-% don't have the inferior and superior figures available in a font,
-% or the font doesn't have a wider design for small font sizes, you
-% can cheat by manually scaling the ND-pair. I got nice results for
-% Adobe's Stempel Garamond (with small caps and old style figures)
-% with the following setup:
-% \begin{verbatim}
-% \DeclareInstance{xfrac}{pegj}{text}
-% {
-% numerator-font = pegx,
-% denominator-font = pegx,
-% scale-factor = 0.9,
-% h-scale = 1.1
-% }
-% \end{verbatim}
-% We use the font family |pegx| (Stempel Garamond with real small
-% caps) for typesetting the ND-pair. Additionally the key
-% \key{scale-factor} specifies that the font size used for the
-% ND-pair should be $0.9$ of the height of the solidus, and the key
-% \key{h-scale} specifies that the ND-pair should be scaled an extra
-% 10\,\% horizontally.
-%
-% Should you be so fortunate the have a font with inferior and
-% superior figures like in the Monotype Janson example from Philipp
-% Lehman's excellent \emph{The Font Installation Guide}. In that
-% example Philipp defines the font families |mjn0| for the inferior
-% figures and |mjn1| for the superior. Thus to get the \cs{sfrac}
-% command to use them on the fly for the font family |mjnj| (Janson,
-% old style figures) we would say
-% \begin{verbatim}
-% \DeclareInstance{xfrac}{mjnj}{text}
-% {
-% numerator-font = mjn1,
-% denominator-font = mjn0,
-% scaling = false,
-% numerator-bot-sep = 0 pt,
-% denominator-bot-sep = 0 pt
-% }
-% \end{verbatim}
-% I think this example is a very clean way to do it. An alternative
-% approach could be to use the keys \key{numerator-format} and
-% \key{denominator-format} to process the arguments and let them
-% determine what to do.
-%
-% \subsection{Math Mode}
-%
-% In math mode the choices are a lot fewer because first of all
-% \TeX{} comes with a built-in limitation of $16$ math families.
-% Additionally we will not need a solidus for typesetting split
-% fractions in math, as tradition is to use a virgule instead. We
-% define the basic |mathdefault| instance to simply use the math
-% family in use when the instance is run. So if we're in normal math
-% like |$\sfrac{7}{9}$| we simply get family~$-1$. If we're inside a
-% \cs{mathbf} we're in family~$4$ (in the standard setup at least),
-% and so the fraction is typeset with the same math family. Simple,
-% isn't?
-%
-% You can also declare instances for the math families, but I really
-% don't see why you would. If you do then name them according to the
-% scheme \texttt{mathfam\meta{N}}, where \meta{N} is the family number, and
-% only do it if you \emph{really} know how to set up math fonts.
-% That is, if \cs{DeclareMathAlphabet} is unbeknownst to you, then
-% just don't go there.
-%
-% Another example: If we want \cs{sfrac} to produce split fractions
-% without doing anything at all, we can choose the collection
-% |plainmath|, which is defined as
-% \begin{verbatim}
-% \DeclareCollectionInstance{plainmath}{xfrac}{mathdefault}{math}
-% {
-% denominator-bot-sep = 0 pt,
-% numerator-bot-sep = 0 pt,
-% numerator-top-sep = \c_max_dim,
-% scaling = false,
-% slash-right-mkern = 0 mu,
-% slash-left-mkern = 0 mu
-% }
-% \end{verbatim}
-% This creates an alternative version of the instance |mathdefault|
-% with settings as specified by the keys. In the default math setup
-% \key{numerator-top-sep} is set to 0~pt, and here we set
-% \key{numerator-bot-sep} to 0~pt as well, so in order to avoid
-% over-specification (and an error message) we must set
-% \key{numerator-top-sep} to \cs{c_max_dim}. We activate (obeying
-% normal scoping rules) it with:
-% \begin{verbatim}
-% \UseCollection{xfrac}{plainmath}
-% \end{verbatim}
-% Then |$\sfrac{8}{13}$| produces^^A
-% \begingroup
-% \UseCollection{xfrac}{plainmath}
-% $\sfrac{8}{13}$ and just typing |$8/13$| gives the same result:
-% $8/13$.
-% \endgroup
-%
-% \section{The Template Interface}
-%
-% \begin{TemplateInterfaceDescription}{xfrac}
-%
-% \TemplateArgument{1}{The numerator}
-%
-% \TemplateArgument{2}{The separator}
-%
-% \TemplateArgument{3}{The denominator}
-%
-% \TemplateSemantics
-%
-% Typesets arguments 1 and 3 separated by argument 2, which in text
-% mode by default is a \emph{solidus}. This is taken from
-% \pkg{textcomp} where it is denoted \cs{textfractionsolidus}.
-% This is the character used for the ready made split level
-% fractions such as \textonehalf{}---except in the (European) Computer
-% Modern fonts. In math mode a \emph{virgule} is used instead as
-% this is more appropriate and it is always available in the math
-% fonts. The solidus is a text symbol only.
-%
-% \end{TemplateInterfaceDescription}
-%
-% \begin{TemplateDescription}{xfrac}{text}
-%
-% \TemplateKey{numerator-font}{tokenlist}
-% {Font family specification to use for the numerator.}
-% {\cs{f@family}}
-%
-% \TemplateKey{numerator-format}{function 1 arg}
-% {Action to be taken on the numerator.}
-% {Process argument unchanged}
-%
-% \TemplateKey{slash-symbol}{tokenlist}
-% {The separator symbol. If not specified the default value will be
-% used instead.}
-% {Solidus (\cs{textfractionsolidus})}
-%
-% \TemplateKey{slash-symbol-font}{tokenlist}
-% {Font family specification to use for the separator symbol.}
-% {\cs{f@family}}
-%
-% \TemplateKey{slash-symbol-format}{function 1 arg}
-% {Action to be taken on the separator symbol.}
-% {Process argument unchanged}
-%
-% \TemplateKey{denominator-font}{tokenlist}
-% {Font family specification to use for the denominator.}
-% {\cs{f@family}}
-%
-% \TemplateKey{denominator-format}{function 1 arg}
-% {Action to be taken on the denominator.}
-% {Process argument unchanged}
-%
-% \TemplateKey{h-scale}{real}
-% {Factor by which the numerator and denominator should be
-% horizontally scaled. It should only be used if the real superior
-% and inferior fonts are not available. For instance Stempel
-% Garamond looks excellent if scaled 10\,\% extra horizontally, \emph{i.e.},
-% by a factor of 1.1.}
-% {1}
-%
-% \TemplateKey{v-scale}{real}
-% {Same as \key{h-scale} only vertically. Probably not of much use
-% but added for completeness.}
-% {1}
-%
-% \TemplateKey{scale-factor}{real}
-% {Fraction of the size of \key{slash-symbol}. Used for setting the
-% font size of numerator and denominator. Usually a value of app.\
-% \sfrac{5}{6} produces fine results. It should only be used if the
-% real superior and inferior fonts are not available. As an example
-% Stempel Garamond looks better if the factor is 0.9.}
-% {0.83333}
-%
-% \TemplateKey{scale-relative}{choice}
-% {If set to |true| the font size of the numerator and denominator
-% is scaled with respect to the height of the \key{slash-symbol}. If
-% set to |false| the font is scaled with respect to the total height
-% of the \key{slash-symbol}.}
-% {true}
-%
-% \TemplateKey{scaling}{choice}
-% {If set to |true| the fonts are allowed to scale. If set to
-% |false| they are not. See the `Janson' example for an application.}
-% {true}
-%
-% \TemplateKey{numerator-top-sep}{length}
-% {Dimension specifying the space between the top of the
-% \key{slash-symbol} and the top of the numerator. If not specified,
-% the depth of the solidus will be used, because this value will
-% make the fraction look even.}
-% {Unspecified}
-%
-% \TemplateKey{numerator-bot-sep}{length}
-% {Dimension specifying the lift of the numerator from the
-% baseline.}
-% {Unspecified}
-%
-% \TemplateKey{denominator-bot-sep}{length}
-% {Dimension specifying the lift of the denominator from the
-% baseline.}
-% {Unspecified}
-%
-% \TemplateKey{slash-right-kern}{length}
-% {Dimension specifying the kerning between the \key{slash-symbol}
-% and the numerator.}
-% {\texttt{0pt}}
-%
-% \TemplateKey{slash-left-kern}{length}
-% {Dimension specifying the kerning between the \key{slash-symbol}
-% and the denominator.}
-% {\texttt{0pt}}
-%
-% \TemplateKey{math-mode}{choice}
-% {Are we in math mode or not?}
-% {false}
-%
-% \TemplateKey{phantom}{tokenlist}
-% {A character that suits the common cases. As we would mostly want
-% to use numbers in text mode we choose a \enquote{tall} number, while in
-% math it is somewhat different.}
-% {8}
-%
-% \TemplateSemantics
-%
-% This template is also the foundation for the \enquote{math} template. The
-% keys \key{slash-right-mkern} and \key{slash-left-mkern} can only
-% be used in math mode and are not shown here.
-%
-% \end{TemplateDescription}
-%
-% \begin{TemplateDescription}{xfrac}{math}
-%
-% \TemplateKey{numerator-font}{tokenlist}
-% {Font family specification to use for the numerator.}
-% {\cs{number}\cs{fam}}
-%
-% \TemplateKey{slash-symbol}{tokenlist}
-% {The separator symbol. If not specified the default value will be
-% used instead.}
-% {Virgule ($/$)}
-%
-% \TemplateKey{slash-symbol-font}{tokenlist}
-% {Font family specification to use for the separator symbol.}
-% {\cs{number}\cs{fam}}
-%
-% \TemplateKey{denominator-font}{tokenlist}
-% {Font family specification to use for the denominator.}
-% {\cs{number}\cs{fam}}
-%
-% \TemplateKey{scale-factor}{real}
-% {Fraction of the size of \key{slash-symbol}. In math mode we
-% cannot rely on the fonts to be able to scale, but giving a default
-% scale of 0.7 fits into the regular size changing scheme---the
-% default scheme has values $(D,T,S,SS)=(1,1,0.7,0.5)$ whereas we
-% with a default \key{scale-factor} of 0.7 get $(1,1,0.7,0.49)$.
-% That's close enough.}
-% {0.7}
-%
-% \TemplateKey{scale-relative}{choice}
-% {If set to |true| the font size of the numerator and denominator
-% is scaled with respect to the height of the \key{slash-symbol}. If
-% set to |false| the font is scaled with respect to the total height
-% of the \key{slash-symbol}.}
-% {false}
-%
-% \TemplateKey{scaling}{choice}
-% {If set to |true| the fonts are allowed to scale. If set to
-% |false| they are not. See the |plainmath| example for an application.}
-% {true}
-%
-% \TemplateKey{numerator-top-sep}{length}
-% {Dimension specifying the space between the top of the
-% \key{slash-symbol} and the top of the numerator. If not specified,
-% the depth of the virgule will be used, because this value will
-% make the fraction look even.}
-% {\texttt{0pt}}
-%
-% \TemplateKey{denominator-bot-sep}{length}
-% {Dimension specifying the lift of the denominator from the
-% baseline.}
-% {\texttt{0pt}}
-%
-% \TemplateKey{slash-right-mkern}{muskip}
-% {Same as \key{slash-right-kern} but for math mode only and should
-% be specified in \texttt{mu} units.}
-% {\texttt{-2mu}}
-%
-% \TemplateKey{slash-left-mkern}{muskip}
-% {Same as \key{slash-left-kern} but for math mode only and should
-% be specified in \texttt{mu} units.}
-% {\texttt{-1mu}}
-%
-% \TemplateKey{math-mode}{choice}
-% {Are we in math mode or not?}
-% {true}
-%
-% \TemplateKey{phantom}{tokenlist}
-% {A character that suits the common cases. In math we have a high
-% risk of using a parenthesis, so we choose that. Text mode is
-% another story.}
-% {(^^A)
-% }
-%
-% \TemplateSemantics
-%
-% This template is a restricted version of the |text| template. Only
-% the keys that are different from the |text| template are shown
-% here. Also bear in mind that the attributes \key{slash-left-kern}
-% and \key{slash-right-kern} have no meaning in this template.
-%
-% \end{TemplateDescription}
-%
-% \end{documentation}
-%
-% \begin{implementation}
-%
-% \section{\pkg{xfrac} implementation}
-%
-% \begin{macrocode}
-%<*package>
-% \end{macrocode}
-%
-% \begin{macrocode}
-%<@@=xfrac>
-% \end{macrocode}
-%
-% \begin{macrocode}
-\ProvidesExplPackage{xfrac}{2023-10-10}{}
- {L3 Experimental split-level fractions}
-% \end{macrocode}
-%
-% \begin{variable}{\l_@@_cm_std_bool}
-% There is one option to support.
-% \begin{macrocode}
-\keys_define:nn { xfrac }
- {
- cm-recommended .choice:,
- cm-recommended /
- false .code:n =
- { \bool_set_true:N \l_@@_cm_std_bool },
- cm-recommended /
- true .code:n =
- { \bool_set_false:N \l_@@_cm_std_bool },
- cm-recommended .default:n = { true },
- cm-standard .bool_set:N = \l_@@_cm_std_bool
- }
-\ProcessKeysOptions { xfrac }
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_slash_box}
-% \begin{variable}{\l_@@_tmp_box}
-% In keeping with the \LaTeX3 philosophy, rather than use generic
-% scratch boxes and get confused, \pkg{xfrac} reserves its own named
-% working space.
-% \begin{macrocode}
-\box_new:N \l_@@_slash_box
-\box_new:N \l_@@_tmp_box
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-%
-% \begin{macro}{\@@_tmp:w}
-% Used for the raised boxes: weird as it does not take an argument
-% but the \cs{raisebox} does.
-% \begin{macrocode}
-\cs_new:Npn \@@_tmp:w { }
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \subsection{Initialisation of variables}
-%
-% Variables used in templates have to be set up: there is not
-% much to say about these, other than that they must exist.
-%
-% \begin{variable}{\l_@@_denominator_bot_sep_dim}
-% \begin{variable}{\l_@@_numerator_bot_sep_dim}
-% \begin{variable}{\l_@@_numerator_top_sep_dim}
-% \begin{variable}{\l_@@_slash_left_sep_dim}
-% \begin{variable}{\l_@@_slash_right_sep_dim}
-% Fixed lengths.
-% \begin{macrocode}
-\dim_new:N \l_@@_denominator_bot_sep_dim
-\dim_new:N \l_@@_numerator_bot_sep_dim
-\dim_new:N \l_@@_numerator_top_sep_dim
-\dim_new:N \l_@@_slash_left_sep_dim
-\dim_new:N \l_@@_slash_right_sep_dim
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_slash_left_muskip}
-% \begin{variable}{\l_@@_slash_right_muskip}
-% Math mode skips.
-% \begin{macrocode}
-\muskip_new:N \l_@@_slash_left_muskip
-\muskip_new:N \l_@@_slash_right_muskip
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_hscale_fp}
-% \begin{variable}{\l_@@_scale_factor_fp}
-% \begin{variable}{\l_@@_vscale_fp}
-% Floating point values.
-% \begin{macrocode}
-\fp_new:N \l_@@_hscale_fp
-\fp_new:N \l_@@_scale_factor_fp
-\fp_new:N \l_@@_vscale_fp
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_denominator_font_tl}
-% \begin{variable}{\l_@@_numerator_font_tl}
-% \begin{variable}{\l_@@_phantom_tl }
-% \begin{variable}{\l_@@_slash_symbol_tl}
-% \begin{variable}{\l_@@_slash_symbol_font_tl}
-% Token lists, which include floating-point numbers and math(s)
-% skips.
-% \begin{macrocode}
-\tl_new:N \l_@@_denominator_font_tl
-\tl_new:N \l_@@_numerator_font_tl
-\tl_new:N \l_@@_phantom_tl
-\tl_new:N \l_@@_slash_symbol_tl
-\tl_new:N \l_@@_slash_symbol_font_tl
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{macro}{\@@_fontscale:}
-% \begin{macro}{\@@_math:n}
-% \begin{macro}{\@@_denominator_font_change:}
-% \begin{macro}{\@@_denominator_format:n}
-% \begin{macro}{\@@_numerator_font_change:}
-% \begin{macro}{\@@_numerator_format:n}
-% \begin{macro}{\@@_relscale:}
-% \begin{macro}{\@@_slash_symbol_font_change:}
-% \begin{macro}{\@@_slash_symbol_format:n}
-% \begin{macro}{\@@_text_or_math:n}
-% Functions, either things which are calculated \enquote{on the fly}
-% (no argument required) or are functions taking one argument in the
-% code.
-% \begin{macrocode}
-\cs_new:Npn \@@_fontscale: { }
-\cs_new:Npn \@@_math:n #1 { }
-\cs_new:Npn \@@_denominator_font_change: { }
-\cs_new:Npn \@@_denominator_format:n #1 { }
-\cs_new:Npn \@@_numerator_font_change: { }
-\cs_new:Npn \@@_numerator_format:n #1 { }
-\cs_new:Npn \@@_relscale: { }
-\cs_new:Npn \@@_slash_symbol_font_change: { }
-\cs_new:Npn \@@_slash_symbol_format:n #1 { }
-\cs_new:Npn \@@_text_or_math:n #1 { }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{The template}
-%
-% There is only one object type in \pkg{xfrac}, rather unimaginatively
-% named \texttt{xfrac}.
-% \begin{macrocode}
-\DeclareObjectType { xfrac } { 3 }
-% \end{macrocode}
-%
-% A single template interface is used for both text and math(s), which
-% does make a few things a little complex later.
-% \begin{macrocode}
-\DeclareTemplateInterface { xfrac } { text } { 3 }
- {
- denominator-bot-sep : length = \c_max_dim ,
- denominator-font : tokenlist = \f@family ,
- denominator-format : function 1 = #1 ,
- h-scale : real = 1 ,
- math-mode : choice { false , true }
- = false ,
- numerator-font : tokenlist = \f@family ,
- numerator-format : function 1 = #1 ,
- numerator-bot-sep : length = \c_max_dim ,
- numerator-top-sep : length = \c_max_dim ,
- phantom : tokenlist = 8 ,
- scale-factor : real = 0.83333 ,
- scale-relative : choice { false , true }
- = true ,
- scaling : choice { false , true }
- = true ,
- slash-left-kern : length = 0 pt ,
- slash-left-mkern : muskip = -2 mu ,
- slash-right-kern : length = 0 pt ,
- slash-right-mkern : muskip = -1 mu ,
- slash-symbol : tokenlist = \textfractionsolidus ,
- slash-symbol-font : tokenlist = \f@family ,
- slash-symbol-format : function 1 = #1 ,
- v-scale : real = 1 ,
- }
-% \end{macrocode}
-% Most of the variable binding is quite simple: of course, the choices
-% are a little more complicated. That is particularly true where
-% these have to set up \enquote{on the fly} functions.
-% \begin{macrocode}
-\DeclareTemplateCode { xfrac } { text } { 3 }
- {
- denominator-bot-sep = \l_@@_denominator_bot_sep_dim ,
- denominator-font = \l_@@_denominator_font_tl ,
- denominator-format = \@@_denominator_format:n ,
- h-scale = \l_@@_hscale_fp ,
- math-mode =
- {
- false = \cs_set_eq:NN \@@_math:n \use:n,
- true = \cs_set_eq:NN \@@_math:n \ensuremath
- },
- numerator-font = \l_@@_numerator_font_tl ,
- numerator-format = \@@_numerator_format:n ,
- numerator-bot-sep = \l_@@_numerator_bot_sep_dim ,
- numerator-top-sep = \l_@@_numerator_top_sep_dim ,
- phantom = \l_@@_phantom_tl ,
- scale-factor = \l_@@_scale_factor_fp ,
- scale-relative =
- {
- false =
- \cs_set:Npn \@@_relscale:
- {
- \dim_eval:n
- { \box_ht:N \l_@@_tmp_box + \box_dp:N \l_@@_tmp_box }
- },
- true =
- \cs_set:Npn \@@_relscale:
- { \dim_eval:n { \box_ht:N \l_@@_slash_box } }
- },
- scaling =
- {
- false = \cs_set_eq:NN \@@_fontscale: \prg_do_nothing:,
- true =
- \cs_set:Npn \@@_fontscale:
- {
- \fontsize
- { \fp_to_dim:n { \l_@@_scale_factor_fp * \@@_relscale: } }
- { \c_zero_dim }
- \selectfont
- }
- },
- slash-left-kern = \l_@@_slash_left_sep_dim ,
- slash-left-mkern = \l_@@_slash_left_muskip ,
- slash-right-kern = \l_@@_slash_right_sep_dim ,
- slash-right-mkern = \l_@@_slash_right_muskip ,
- slash-symbol = \l_@@_slash_symbol_tl ,
- slash-symbol-font = \l_@@_slash_symbol_font_tl ,
- slash-symbol-format = \@@_slash_symbol_format:n ,
- v-scale = \l_@@_vscale_fp
- }
-% \end{macrocode}
-% The implementation part starts with applying all of the settings
-% from above. The first part of the set up is then to determine
-% whether the surroundings are text or math(s), and react accordingly.
-% \begin{macrocode}
- {
- \mode_if_math:TF
- {
- \cs_set_eq:NN \@@_text_or_math:n \text
- \cs_set:Npe \@@_denominator_font_change:
- { \tex_fam:D \l_@@_denominator_font_tl }
- \cs_set:Npe \@@_numerator_font_change:
- { \tex_fam:D \l_@@_numerator_font_tl }
- \cs_set:Npe \@@_slash_symbol_font_change:
- { \tex_fam:D \l_@@_slash_symbol_font_tl }
- }
- {
- \cs_set_eq:NN \@@_text_or_math:n \mbox
- \cs_set:Npn \@@_denominator_font_change:
- {
- \fontfamily { \l_@@_denominator_font_tl }
- \selectfont
- }
- \cs_set:Npn \@@_numerator_font_change:
- {
- \fontfamily { \l_@@_numerator_font_tl }
- \selectfont
- }
- \cs_set:Npn \@@_slash_symbol_font_change:
- {
- \fontfamily { \l_@@_slash_symbol_font_tl }
- \selectfont
- }
- }
-% \end{macrocode}
-% Everything is now either inside \cs{text} or an \cs{mbox}, depending
-% upon the surroundings. First, there are some boxes to set up.
-% \begin{macrocode}
- \@@_text_or_math:n
- {
- \m@th
- \hbox_set:Nn \l_@@_tmp_box
- { \@@_math:n { \vphantom { ( ) } } }
- \hbox_set:Nn \l_@@_slash_box
- {
- \@@_math:n
- {
- \@@_slash_symbol_format:n
- {
- \@@_math:n
- {
- \@@_slash_symbol_font_change:
- \IfNoValueTF {#2}
- { \l_@@_slash_symbol_tl } {#2}
- }
- }
- }
- }
-% \end{macrocode}
-% Check on the numerator separator dimensions. The code starts with the
-% assumption that neither has been given, as this can then be used to
-% set up a default, which is also used when both values are set
-% erroneously.
-% \begin{macrocode}
- \cs_set:Npn \@@_tmp:w
- {
- \raisebox
- {
- \dim_eval:n
- {
- \box_ht:N \l_@@_slash_box
- - \box_dp:N \l_@@_slash_box
- - \height
- }
- }
- }
- \dim_compare:nNnTF
- { \l_@@_numerator_top_sep_dim } = { \c_max_dim }
- {
- \dim_compare:nNnF
- { \l_@@_numerator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \@@_tmp:w
- {
- \raisebox
- { \dim_use:N \l_@@_numerator_bot_sep_dim }
- }
- }
- }
- {
- \dim_compare:nNnTF
- { \l_@@_numerator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \@@_tmp:w
- {
- \raisebox
- {
- \dim_eval:n
- {
- \box_ht:N \l_@@_slash_box
- - \dim_use:N \l_@@_numerator_top_sep_dim
- - \height
- }
- }
- }
- }
- {
- \msg_error:nn { xfrac }
- { over-specified-numerator-sep }
- }
- }
-% \end{macrocode}
-% Typeset the numerator.
-% \begin{macrocode}
- \@@_tmp:w
- {
- \@@_fontscale:
- \@@_numerator_format:n
- {
- \scalebox
- { \fp_use:N \l_@@_hscale_fp }
- [ \fp_use:N \l_@@_vscale_fp ]
- {
- \@@_math:n
- {
- \@@_numerator_font_change:
- {
- \vphantom { \l_@@_phantom_tl }
- #1
- }
- }
- }
- }
- }
- \@@_math:n
- { % THIS IS JUST WRONG!
- \mode_if_math:TF
- { \tex_mskip:D \l_@@_slash_right_muskip }
- { \tex_hskip:D \l_@@_slash_right_sep_dim }
- }
-% \end{macrocode}
-% Typeset the separator.
-% \begin{macrocode}
- \box_use:N \l_@@_slash_box
- \@@_math:n
- {
- \mode_if_math:TF
- { \tex_mskip:D \l_@@_slash_left_muskip }
- { \tex_hskip:D \l_@@_slash_left_sep_dim }
- }
-% \end{macrocode}
-% Typeset the denominator.
-% \begin{macrocode}
- \dim_compare:nNnTF
- { \l_@@_denominator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \@@_tmp:w
- { \raisebox { - \box_dp:N \l_@@_slash_box } }
- }
- {
- \cs_set:Npn \@@_tmp:w
- {
- \raisebox
- { \dim_use:N \l_@@_denominator_bot_sep_dim }
- }
- }
- \@@_tmp:w
- {
- \@@_fontscale:
- \@@_denominator_format:n
- {
- \scalebox
- { \fp_use:N \l_@@_hscale_fp }
- [ \fp_use:N \l_@@_vscale_fp ]
- {
- \@@_math:n
- {
- \@@_denominator_font_change:
- {
- \vphantom { \l_@@_phantom_tl }
- #3
- }
- }
- }
- }
- }
- }
- }
-% \end{macrocode}
-%
-% Since math(s) and text mode are wildly different entities we define a
-% separate template for each. You already saw the \enquote{text}
-% template, and here is the \enquote{math} template.
-% \begin{macrocode}
-\DeclareRestrictedTemplate { xfrac } { text } { math }
- {
- numerator-font = \number \fam ,
- slash-symbol = / ,
- slash-symbol-font = \number \fam ,
- denominator-font = \number \fam ,
- scale-factor = 0.7 ,
- scale-relative = false ,
- scaling = true ,
- denominator-bot-sep = 0 pt ,
- math-mode = true ,
- phantom = ( % )
- }
-% \end{macrocode}
-%
-%\subsection{The standard instances}
-%
-% For the default instances we just use the relevant templates with
-% the default settings.
-%
-% The default \enquote{text} instance.
-% \begin{macrocode}
-\DeclareInstance { xfrac } { default } { text } { }
-% \end{macrocode}
-%
-% The default \enquote{math(s)} instance. We annot set the
-% |numerator-top-sep| in the restricted template above as it clashes
-% with the requirements of the |plainmath| collection which comes next.
-% \begin{macrocode}
-\DeclareInstance { xfrac } { mathdefault } { math }
- { numerator-top-sep = 0pt }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\DeclareCollectionInstance { plainmath } { xfrac } { mathdefault } { math }
- {
- numerator-bot-sep = 0 pt ,
- numerator-top-sep = \c_max_dim ,
- scale-factor = 1 ,
- scale-relative = false ,
- scaling = true ,
- slash-right-mkern = 0 mu ,
- slash-left-mkern = 0 mu
- }
-% \end{macrocode}
-%
-% Default Computer Modern setup. Far from optimal, but better than
-% nothing.
-% \begin{macrocode}
-\DeclareInstance { xfrac } { cmr } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-\DeclareInstance { xfrac } { cmss } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-\DeclareInstance { xfrac } { cmtt } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-% \end{macrocode}
-%
-% We can do better for the Computer Modern fonts. For cmr and cmss
-% we choose Times, and for cmtt use Palatino.
-% \begin{macrocode}
-\bool_if:NF \l_@@_cm_std_bool
- {
- \DeclareInstance { xfrac } { cmr } { text }
- { slash-symbol-font = ptm }
- \DeclareInstance { xfrac } { cmss } { text }
- { slash-symbol-font = ptm }
- \DeclareInstance { xfrac } { cmtt } { text }
- { slash-symbol-font = ppl }
- }
-% \end{macrocode}
-%
-% Things works slightly better with Latin Modern.
-% \begin{macrocode}
-\DeclareInstance { xfrac } { lmr } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.1 ex ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-\DeclareInstance { xfrac } { lmss } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0 pt ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-\DeclareInstance { xfrac } { lmtt } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0 pt ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-% \end{macrocode}
-%
-% \subsection{The user command}
-%
-% \begin{macro}{\sfrac}
-% Currently there is just a single user command. \cs{sfrac} takes
-% two mandatory arguments: numerator and denominator. It can take an
-% optional argument between the mandatory specifying the separator
-% like this:
-% \begin{verbatim}
-% \sfrac{7}[/]{12}
-% \end{verbatim}
-% It also has an optional argument that comes before the first
-% mandatory argument. If used it will use that instance instead of
-% the auto-detected one, so a user who has defined the instance
-% \enquote{cmr2} may use
-% \begin{verbatim}
-% \sfrac[cmr2]{7}{12}
-% \end{verbatim}
-% and get the settings from \enquote{cmr2} instead of the settings of
-% the current font family.
-% \begin{macrocode}
-\NewDocumentCommand \sfrac { o m o m }
- {
- \mode_if_math:TF
- {
- \IfInstanceExistTF { xfrac } { mathfam \number \fam }
- { \UseInstance { xfrac } { mathfam \number \fam } }
- { \UseInstance { xfrac } { mathdefault } }
- {#2} {#3} {#4}
- }
- {
- \IfInstanceExistTF { xfrac } {#1}
- { \UseInstance { xfrac } {#1} }
- {
- \IfInstanceExistTF { xfrac } { \f@family }
- { \UseInstance { xfrac } { \f@family } }
- { \UseInstance { xfrac } { default } }
- }
- {#2} {#3} {#4}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Messages}
-%
-% Just the one.
-% \begin{macrocode}
-\msg_new:nnnn { xfrac } { over-specified-numerator-sep }
- { You~have~specified~both~"numerator-top-sep"~and~"numerator-bot-sep". }
- { I~will~pretend~that~you~didn't~specify~either~of~them. }
-% \end{macrocode}
-%
-% \begin{macrocode}
-%</package>
-% \end{macrocode}
-%
-% \end{implementation}
-%
-% \PrintIndex
diff --git a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.ins b/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.ins
deleted file mode 100644
index 511e68c3c35..00000000000
--- a/Master/texmf-dist/source/latex/l3packages/xfrac/xfrac.ins
+++ /dev/null
@@ -1,49 +0,0 @@
-\iffalse meta-comment
-
-File: xfrac.ins
-
-Copyright (C) 2004,2008-2010 Morten Hoegholm
- (C) 2011,2012,2016,2017,2019-2023 The LaTeX Project
-
-It may be distributed and/or modified under the conditions of the
-LaTeX Project Public License (LPPL), either version 1.3c of this
-license or (at your option) any later version. The latest version
-of this license is in the file
-
- http://www.latex-project.org/lppl.txt
-
-This file is part of the "l3packages bundle" (The Work in LPPL)
-and all files in that bundle must be distributed together.
-
-The released version of this bundle is available from CTAN.
-
-\fi
-
-\input docstrip %
-\askforoverwritefalse
-
-\preamble
-
-Copyright (C) 2004,2008-2010 Morten Hoegholm
- (C) 2011-2023 The LaTeX Project
-
-It may be distributed and/or modified under the conditions of
-the LaTeX Project Public License (LPPL), either version 1.3c of
-this license or (at your option) any later version. The latest
-version of this license is in the file:
-
- http://www.latex-project.org/lppl.txt
-
-This file is part of the "l3packages bundle" (The Work in LPPL)
-and all files in that bundle must be distributed together.
-
-\endpreamble
-% stop docstrip adding \endinput
-\postamble
-\endpostamble
-
-\keepsilent
-
-\generate{\file{xfrac.sty} {\from{xfrac.dtx} {package}}}
-
-\endbatchfile
diff --git a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx
index ba98987d7fe..e701edada3e 100644
--- a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx
+++ b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx
@@ -4,7 +4,7 @@
%
% Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle
% (C) 2004-2008 Frank Mittelbach, The LaTeX Project
-% (C) 2009-2023 The LaTeX Project
+% (C) 2009-2024 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -55,7 +55,7 @@
% \begin{itemize}\def\makelabel##1{\hss\llap{\bfseries##1}}}{\end{itemize}}
%
% \title{^^A
-% The \textsf{xparse} package\\ Document command parser^^A
+% The \pkg{xparse} package\\ Document command parser^^A
% }
%
% \author{^^A
@@ -67,7 +67,7 @@
% }^^A
% }
%
-% \date{Released 2023-10-10}
+% \date{Released 2024-02-13}
%
% \maketitle
%
@@ -1064,7 +1064,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesExplPackage{xparse}{2023-10-10}{}
+\ProvidesExplPackage{xparse}{2024-02-13}{}
{L3 Experimental document command parser}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.ins b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.ins
index d7973d49f7a..9177c53dbc5 100644
--- a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.ins
+++ b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.ins
@@ -2,7 +2,7 @@
File: xparse.ins
-Copyright (C) 2000-2012,2016,2017,2019-2023 The LaTeX Project
+Copyright (C) 2000-2012,2016,2017,2019-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -23,7 +23,7 @@ The released version of this bundle is available from CTAN.
\preamble
-Copyright (C) 2009-2023 The LaTeX Project
+Copyright (C) 2009-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
index 5080d94b0fd..ee393ef3b3f 100644
--- a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
+++ b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
@@ -4,7 +4,7 @@
%
% Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle
% (C) 2004-2010 Frank Mittelbach, The LaTeX Project
-% (C) 2011-2023 The LaTeX Project
+% (C) 2011-2024 The LaTeX Project
%\
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -24,23 +24,6 @@
%
% for those people who are interested.
%
-%<*driver|package>
-% The version of expl3 required is tested as early as possible, as
-% some really old versions do not define \ProvidesExplPackage.
-\RequirePackage{expl3}[2018/02/21]
-%<package>\@ifpackagelater{expl3}{2018/02/21}
-%<package> {}
-%<package> {%
-%<package> \PackageError{xtemplate}{Support package l3kernel too old}
-%<package> {%
-%<package> Please install an up to date version of l3kernel\MessageBreak
-%<package> using your TeX package manager or from CTAN.\MessageBreak
-%<package> \MessageBreak
-%<package> Loading xtemplate will abort!%
-%<package> }%
-%<package> \endinput
-%<package> }
-%</driver|package>
%<*driver>
\documentclass[full]{l3doc}
\usepackage{amstext}
@@ -51,7 +34,7 @@
% \fi
%
% \title{^^A
-% The \textsf{xtemplate} package\\ Prototype document functions^^A
+% The \pkg{xtemplate} package\\ Prototype document functions^^A
% }
%
% \author{^^A
@@ -63,7 +46,7 @@
% }^^A
% }
%
-% \date{Released 2023-10-10}
+% \date{Released 2024-02-13}
%
% \maketitle
%
@@ -98,7 +81,7 @@
% \item Loading one of the many packages to customise certain elements of
% the standard classes.
% \item Loading a completely different document class, such as
-% \textsf{KOMA-Script} or \textsf{memoir}, that allows easy customisation.
+% \cls{KOMA-Script} or \cls{memoir}, that allows easy customisation.
% \end{itemize}
% All three of these approaches have their drawbacks and learning curves.
%
@@ -467,14 +450,6 @@
% the general idea of fixing some settings.
% \end{function}
%
-% \begin{function}{\IfInstanceExistT, \IfInstanceExistF, \IfInstanceExistTF}
-% \begin{syntax}
-% \cs{IfInstanceExistTF} \Arg{object type} \Arg{instance} \Arg{true code} \Arg{false code}
-% \end{syntax}
-% Tests if the named \meta{instance} of a \meta{object type} exists, and
-% then inserts the appropriate code into the input stream.
-% \end{function}
-%
% \begin{function}{\DeclareInstanceCopy}
% \begin{syntax}
% \cs{DeclareInstanceCopy}
@@ -707,2225 +682,35 @@
% \end{macrocode}
%
% \begin{macrocode}
-%<@@=xtemplate>
-% \end{macrocode}
-%
-% \begin{macrocode}
-\ProvidesExplPackage{xtemplate}{2023-10-10}{}
- {L3 Experimental prototype document functions}
-% \end{macrocode}
-%
-% \subsection{Variables and constants}
-%
-% \begin{variable}{\c_@@_code_root_tl}
-% \begin{variable}{\c_@@_defaults_root_tl}
-% \begin{variable}{\c_@@_instances_root_tl}
-% \begin{variable}{\c_@@_keytypes_root_tl}
-% \begin{variable}{\c_@@_key_order_root_tl}
-% \begin{variable}{\c_@@_restrict_root_tl}
-% \begin{variable}{\c_@@_values_root_tl}
-% \begin{variable}{\c_@@_vars_root_tl}
-% So that literal values are kept to a minimum.
-% \begin{macrocode}
-\tl_const:Nn \c_@@_code_root_tl { template~code~>~ }
-\tl_const:Nn \c_@@_defaults_root_tl { template~defaults~>~ }
-\tl_const:Nn \c_@@_instances_root_tl { template~instance~>~ }
-\tl_const:Nn \c_@@_keytypes_root_tl { template~key~types~>~ }
-\tl_const:Nn \c_@@_key_order_root_tl { template~key~order~>~ }
-\tl_const:Nn \c_@@_restrict_root_tl { template~restrictions~>~ }
-\tl_const:Nn \c_@@_values_root_tl { template~values~>~ }
-\tl_const:Nn \c_@@_vars_root_tl { template~vars~>~ }
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\c_@@_keytypes_arg_seq}
-% A list of keytypes which also need additional data (an argument),
-% used to parse the keytype correctly. We suspend debugging to allow
-% an assignment to a constant.
-% \begin{macrocode}
-\seq_const_from_clist:Nn \c_@@_keytypes_arg_seq
- { choice , function , instance }
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\g_@@_object_type_prop}
-% For storing types and the associated number of arguments.
-% \begin{macrocode}
-\prop_new:N \g_@@_object_type_prop
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_assignments_tl}
-% When creating an instance, the assigned values are collected here.
-% \begin{macrocode}
-\tl_new:N \l_@@_assignments_tl
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_collection_tl}
-% The current instance collection name is stored here.
-% \begin{macrocode}
-\tl_new:N \l_@@_collection_tl
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_collections_prop}
-% Lists current collection in force, indexed by object type.
-% \begin{macrocode}
-\prop_new:N \l_@@_collections_prop
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{macro}{\l_@@_default_tl}
-% The default value for a key is recovered here from the property list
-% in which it is stored. The internal implementation of property lists
-% means that this is safe even with un-escaped |#| tokens.
-% \begin{macrocode}
-\tl_new:N \l_@@_default_tl
-% \end{macrocode}
-%\ end{macro}
-%
-% \begin{variable}{\l_@@_error_bool}
-% A flag for errors to be carried forward.
-% \begin{macrocode}
-\bool_new:N \l_@@_error_bool
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_global_bool}
-% Used to indicate that assignments should be global.
-% \begin{macrocode}
-\bool_new:N \l_@@_global_bool
+%<@@=template>
% \end{macrocode}
-% \end{variable}
%
-% \begin{variable}{\l_@@_restrict_bool}
-% A flag to indicate that a template is being restricted.
-% \begin{macrocode}
-\bool_new:N \l_@@_restrict_bool
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_restrict_clist}
-% A scratch list for restricting templates.
-% \begin{macrocode}
-\clist_new:N \l_@@_restrict_clist
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_key_name_tl}
-% \begin{variable}{\l_@@_keytype_tl}
-% \begin{variable}{\l_@@_keytype_arg_tl}
-% \begin{variable}{\l_@@_value_tl}
-% \begin{variable}{\l_@@_var_tl}
-% When defining each key in a template, the name and type of the key
-% need to be separated and stored. Any argument needed by the
-% keytype is also stored separately.
-% \begin{macrocode}
-\tl_new:N \l_@@_key_name_tl
-\tl_new:N \l_@@_keytype_tl
-\tl_new:N \l_@@_keytype_arg_tl
-\tl_new:N \l_@@_value_tl
-\tl_new:N \l_@@_var_tl
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_keytypes_prop}
-% \begin{variable}{\l_@@_key_order_seq}
-% \begin{variable}{\l_@@_values_prop}
-% \begin{variable}{\l_@@_vars_prop}
-% To avoid needing too many difficult-to-follow csname assignments,
-% various scratch token registers are used to build up data, which is
-% then transferred
-% \begin{macrocode}
-\prop_new:N \l_@@_keytypes_prop
-\seq_new:N \l_@@_key_order_seq
-\prop_new:N \l_@@_values_prop
-\prop_new:N \l_@@_vars_prop
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_tmp_clist}
-% \begin{variable}{\l_@@_tmp_dim}
-% \begin{variable}{\l_@@_tmp_int}
-% \begin{variable}{\l_@@_tmp_muskip}
-% \begin{variable}{\l_@@_tmp_skip}
-% For pre-processing the data stored by \pkg{xtemplate}, a number of
-% scratch variables are needed. The assignments are made to these in the
-% first instance, unless evaluation is delayed.
-% \begin{macrocode}
-\clist_new:N \l_@@_tmp_clist
-\dim_new:N \l_@@_tmp_dim
-\int_new:N \l_@@_tmp_int
-\muskip_new:N \l_@@_tmp_muskip
-\skip_new:N \l_@@_tmp_skip
-% \end{macrocode}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-% \end{variable}
-%
-% \begin{variable}{\l_@@_tmp_tl}
-% A scratch variable for comparisons and so on.
-% \begin{macrocode}
-\tl_new:N \l_@@_tmp_tl
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\s_@@_mark,\s_@@_stop}
-% Internal scan marks.
-% \begin{macrocode}
-\scan_new:N \s_@@_mark
-\scan_new:N \s_@@_stop
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{variable}{\q_@@_nil}
-% Internal quarks.
-% \begin{macrocode}
-\quark_new:N \q_@@_nil
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{macro}[pTF]{\@@_quark_if_nil:n}
-% Branching quark conditional.
-% \begin{macrocode}
-\__kernel_quark_new_conditional:Nn \@@_quark_if_nil:N { F }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Variant of prop functions}
-%
-% \begin{macro}[TF]{\prop_get:NoN}
-% In some cases, we need to expand the key, and get the corresponding
-% value in a property list if it exists.
-% \begin{macrocode}
-\cs_generate_variant:Nn \prop_get:NnNTF { No }
-\cs_generate_variant:Nn \prop_get:NnNT { No }
-\cs_generate_variant:Nn \prop_get:NnNF { No }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Testing existence and validity}
-%
-% There are a number of checks needed for either the existence of
-% a object type, template or instance. There are also some for the
-% validity of a particular call. All of these are collected up here.
-%
-% \begin{macro}{\@@_execute_if_arg_agree:nnT}
-% A test agreement between the number of arguments for the template
-% type and that specified when creating a template. This is not done as a
-% separate conditional for efficiency and better error message
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_execute_if_arg_agree:nnT #1#2#3
- {
- \prop_get:NnN \g_@@_object_type_prop {#1} \l_@@_tmp_tl
- \int_compare:nNnTF {#2} = \l_@@_tmp_tl
- {#3}
- {
- \msg_error:nneee { xtemplate }
- { argument-number-mismatch } {#1} { \l_@@_tmp_tl } {#2}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_execute_if_code_exist:nnT}
-% A template is only fully declared if the code has been set up,
-% which can be checked by looking for the template function itself.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_execute_if_code_exist:nnT #1#2#3
- {
- \cs_if_exist:cTF { \c_@@_code_root_tl #1 / #2 }
- {#3}
- {
- \msg_error:nnee { xtemplate } { no-template-code }
- {#1} {#2}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_execute_if_keytype_exist:nT}
-% \begin{macro}{\@@_execute_if_keytype_exist:oT}
-% The test for valid keytypes looks for a function to set up the key,
-% which is part of the \enquote{code} side of the template definition.
-% This avoids having different lists for the two parts of the process.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_execute_if_keytype_exist:nT #1#2
- {
- \cs_if_exist:cTF { @@_store_value_ #1 :n }
- {#2}
- { \msg_error:nne { xtemplate } { unknown-keytype } {#1} }
- }
-\cs_generate_variant:Nn \@@_execute_if_keytype_exist:nT { o }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_execute_if_type_exist:nT}
-% To check that a particular object type is valid.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_execute_if_type_exist:nT #1#2
- {
- \prop_if_in:NnTF \g_@@_object_type_prop {#1}
- {#2}
- { \msg_error:nne { xtemplate } { unknown-object-type } {#1} }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_execute_if_keys_exist:nnT}
-% To check that the keys for a template have been set up before trying
-% to create any code, a simple check for the correctly-named keytype
-% property list.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_if_keys_exist:nnT #1#2#3
- {
- \cs_if_exist:cTF { \c_@@_keytypes_root_tl #1 / #2 }
- {#3}
- {
- \msg_error:nnee { xtemplate } { unknown-template }
- {#1} {#2}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[TF]{\@@_if_key_value:n, \@@_if_key_value:o}
-% Tests for the first token in a string being \cs{KeyValue}.
-% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_if_key_value:n #1 { T , F , TF }
- {
- \str_if_eq:noTF { \KeyValue } { \tl_head:w #1 \q_nil \q_stop }
- { \prg_return_true: }
- { \prg_return_false: }
- }
-\cs_generate_variant:Nn \@@_if_key_value:nT { o }
-\cs_generate_variant:Nn \@@_if_key_value:nF { o }
-\cs_generate_variant:Nn \@@_if_key_value:nTF { o }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[TF]{\@@_if_instance_exist:nnn}
-% Testing for an instance is collection dependent.
-% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_if_instance_exist:nnn #1#2#3
- { T, F, TF }
- {
- \cs_if_exist:cTF { \c_@@_instances_root_tl #1 / #2 / #3 }
- { \prg_return_true: }
- { \prg_return_false: }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_if_use_template:nTF}
-% Tests for the first token in a string being \cs{UseTemplate}.
-% \begin{macrocode}
-\prg_new_conditional:Npnn \@@_if_use_template:n #1 { TF }
- {
- \str_if_eq:noTF { \UseTemplate } { \tl_head:w #1 \q_nil \q_stop }
- { \prg_return_true: }
- { \prg_return_false: }
-}
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Saving and recovering property lists}
-%
-% The various property lists for templates have to be shuffled in
-% and out of storage.
-%
-% \begin{macro}{\@@_store_defaults:n}
-% \begin{macro}{\@@_store_keytypes:n}
-% \begin{macro}{\@@_store_restrictions:n}
-% \begin{macro}{\@@_store_values:n}
-% \begin{macro}{\@@_store_vars:n}
-% The defaults and keytypes are transferred from the scratch property
-% lists to the \enquote{proper} lists for the template being created.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_store_defaults:n #1
- {
- \prop_gclear_new:c { \c_@@_defaults_root_tl #1 }
- \prop_gset_eq:cN { \c_@@_defaults_root_tl #1 }
- \l_@@_values_prop
- }
-\cs_new_protected:Npn \@@_store_keytypes:n #1
- {
- \prop_gclear_new:c { \c_@@_keytypes_root_tl #1 }
- \prop_gset_eq:cN { \c_@@_keytypes_root_tl #1 }
- \l_@@_keytypes_prop
- \seq_gclear_new:c { \c_@@_key_order_root_tl #1 }
- \seq_gset_eq:cN { \c_@@_key_order_root_tl #1 }
- \l_@@_key_order_seq
- }
-\cs_new_protected:Npn \@@_store_values:n #1
- {
- \prop_clear_new:c { \c_@@_values_root_tl #1 }
- \prop_set_eq:cN { \c_@@_values_root_tl #1 }
- \l_@@_values_prop
- }
-\cs_new_protected:Npn \@@_store_restrictions:n #1
- {
- \clist_gclear_new:c { \c_@@_restrict_root_tl #1 }
- \clist_gset_eq:cN { \c_@@_restrict_root_tl #1 }
- \l_@@_restrict_clist
- }
-\cs_new_protected:Npn \@@_store_vars:n #1
- {
- \prop_gclear_new:c { \c_@@_vars_root_tl #1 }
- \prop_gset_eq:cN { \c_@@_vars_root_tl #1 }
- \l_@@_vars_prop
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_recover_defaults:n}
-% \begin{macro}{\@@_recover_keytypes:n}
-% \begin{macro}{\@@_recover_restrictions:n}
-% \begin{macro}{\@@_recover_values:n}
-% \begin{macro}{\@@_recover_vars:n}
-% Recovering the stored data for a template is rather less complex
-% than storing it. All that happens is the data is transferred from
-% the permanent to the scratch storage. However, we need to check the
-% scratch storage does exist.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_recover_defaults:n #1
- {
- \prop_if_exist:cTF
- { \c_@@_defaults_root_tl #1 }
- {
- \prop_set_eq:Nc \l_@@_values_prop
- { \c_@@_defaults_root_tl #1 }
- }
- { \prop_clear:N \l_@@_values_prop }
- }
-\cs_new_protected:Npn \@@_recover_keytypes:n #1
- {
- \prop_if_exist:cTF
- { \c_@@_keytypes_root_tl #1 }
- {
- \prop_set_eq:Nc \l_@@_keytypes_prop
- { \c_@@_keytypes_root_tl #1 }
- }
- { \prop_clear:N \l_@@_keytypes_prop }
- \seq_if_exist:cTF { \c_@@_key_order_root_tl #1 }
- {
- \seq_set_eq:Nc \l_@@_key_order_seq
- { \c_@@_key_order_root_tl #1 }
- }
- { \seq_clear:N \l_@@_key_order_seq }
- }
-\cs_new_protected:Npn \@@_recover_restrictions:n #1
- {
- \clist_if_exist:cTF
- { \c_@@_restrict_root_tl #1 }
- {
- \clist_set_eq:Nc \l_@@_restrict_clist
- { \c_@@_restrict_root_tl #1 }
- }
- { \clist_clear:N \l_@@_restrict_clist }
- }
-\cs_new_protected:Npn \@@_recover_values:n #1
- {
- \prop_if_exist:cTF
- { \c_@@_values_root_tl #1 }
- {
- \prop_set_eq:Nc \l_@@_values_prop
- { \c_@@_values_root_tl #1 }
- }
- { \prop_clear:N \l_@@_values_prop }
- }
-\cs_new_protected:Npn \@@_recover_vars:n #1
- {
- \prop_if_exist:cTF
- { \c_@@_vars_root_tl #1 }
- {
- \prop_set_eq:Nc \l_@@_vars_prop
- { \c_@@_vars_root_tl #1 }
- }
- { \prop_clear:N \l_@@_vars_prop }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{Creating new object types}
-%
-% \begin{macro}{\@@_declare_object_type:nn}
-% Although the object type is the \enquote{top level} of the template
-% system, it is actually very easy to implement. All that happens is that
-% the number of arguments required is recorded, indexed by the name of the
-% object type.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_declare_object_type:nn #1#2
- {
- \int_set:Nn \l_@@_tmp_int {#2}
- \int_compare:nTF { 0 <= \l_@@_tmp_int <= 9 }
- {
- \msg_info:nnnV { xtemplate } { declare-object-type }
- {#1} \l_@@_tmp_int
- \prop_gput:NnV \g_@@_object_type_prop {#1}
- \l_@@_tmp_int
- }
- {
- \msg_error:nnee { xtemplate } { bad-number-of-arguments }
- {#1} { \exp_not:V \l_@@_tmp_int }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Design part of template declaration}
-%
-% The \enquote{design} part of a template declaration defines the general
-% behaviour of each key, and possibly a default value. However, it does
-% not include the implementation. This means that what happens here is
-% the two properties are saved to appropriate lists, which can then
-% be used later to recover the information when implementing the keys.
-%
-% \begin{macro}{\@@_declare_template_keys:nnnn}
-% The main function for the \enquote{design} part of creating a template
-% starts by checking that the object type exists and that the number of
-% arguments required agree. If that is all fine, then the two storage
-% areas for defaults and keytypes are initialised. The mechanism is then
-% set up for the \pkg{l3keys} module to actually parse the keys.
-% Finally, the code hands of to the storage routine to save the parsed
-% information properly.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_declare_template_keys:nnnn #1#2#3#4
- {
- \@@_execute_if_type_exist:nT {#1}
- {
- \@@_execute_if_arg_agree:nnT {#1} {#3}
- {
- \prop_clear:N \l_@@_values_prop
- \prop_clear:N \l_@@_keytypes_prop
- \seq_clear:N \l_@@_key_order_seq
- \keyval_parse:NNn
- \@@_parse_keys_elt:n \@@_parse_keys_elt:nn {#4}
- \@@_store_defaults:n { #1 / #2 }
- \@@_store_keytypes:n { #1 / #2 }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_keys_elt:n}
-% \begin{macro}{\@@_parse_keys_elt_aux:n}
-% \begin{macro}{\@@_parse_keys_elt_aux:}
-% Processing the key part of the key--value pair is always carried out
-% using this function, even if a value was found. First, the key name
-% is separated from the keytype, and if necessary the keytype is
-% separated into two parts. This information is then used to check that
-% the keytype is valid, before storing the keytype (plus argument if
-% necessary) as a property of the key name. The key name is also stored
-% (in braces) in the token list to record the order the keys are defined
-% in.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_keys_elt:n #1
- {
- \@@_split_keytype:n {#1}
- \bool_if:NF \l_@@_error_bool
- {
- \@@_execute_if_keytype_exist:oT \l_@@_keytype_tl
- {
- \seq_map_function:NN \c_@@_keytypes_arg_seq
- \@@_parse_keys_elt_aux:n
- \bool_if:NF \l_@@_error_bool
- {
- \seq_if_in:NoTF \l_@@_key_order_seq
- \l_@@_key_name_tl
- {
- \msg_error:nne { xtemplate }
- { duplicate-key-interface }
- { \l_@@_key_name_tl }
- }
- { \@@_parse_keys_elt_aux: }
- }
- }
- }
- }
-\cs_new_protected:Npn \@@_parse_keys_elt_aux:n #1
- {
- \str_if_eq:onT \l_@@_keytype_tl {#1}
- {
- \tl_if_empty:NT \l_@@_keytype_arg_tl
- {
- \msg_error:nne { xtemplate }
- { keytype-requires-argument } {#1}
- \bool_set_true:N \l_@@_error_bool
- \seq_map_break:
- }
- }
- }
-\cs_new:Npn \@@_parse_keys_elt_aux:
- {
- \tl_set:Ne \l_@@_tmp_tl
- {
- \l_@@_keytype_tl
- \tl_if_empty:NF \l_@@_keytype_arg_tl
- { { \l_@@_keytype_arg_tl } }
- }
- \prop_put:Noo \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \seq_put_right:No \l_@@_key_order_seq \l_@@_key_name_tl
- \str_if_eq:onT \l_@@_keytype_tl { choice }
- {
- \exp_args:No \clist_if_in:nnT \l_@@_keytype_arg_tl { unknown }
- { \msg_error:nn { xtemplate } { choice-unknown-reserved } }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_keys_elt:nn}
-% For keys which have a default, the keytype and key name are first
-% separated out by the \cs{@@_parse_keys_elt:n}
-% routine, before storing the default value in the scratch property list.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_keys_elt:nn #1#2
- {
- \@@_parse_keys_elt:n {#1}
- \use:c { @@_store_value_ \l_@@_keytype_tl :n } {#2}
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_split_keytype:n}
-% \begin{macro}{\@@_split_keytype_aux:w}
-% The keytype and key name should be separated by |:|. As the
-% definition might be given inside or outside of a code block,
-% the category code of colons is standardised. After
-% that, the standard delimited argument method is used to separate the
-% two parts.
-% \begin{macrocode}
-\cs_new_protected:Npe \@@_split_keytype:n #1
- {
- \exp_not:N \bool_set_false:N \exp_not:N \l_@@_error_bool
- \tl_set:Nn \exp_not:N \l_@@_tmp_tl {#1}
- \tl_replace_all:Nnn \exp_not:N \l_@@_tmp_tl { : } { \token_to_str:N : }
- \tl_if_in:onTF \exp_not:N \l_@@_tmp_tl { \token_to_str:N : }
- {
- \exp_not:n
- {
- \tl_clear:N \l_@@_key_name_tl
- \exp_after:wN \@@_split_keytype_aux:w
- \l_@@_tmp_tl \s_@@_stop
- }
- }
- {
- \exp_not:N \bool_set_true:N \exp_not:N \l_@@_error_bool
- \msg_error:nne { xtemplate } { missing-keytype } {#1}
- }
- }
-\use:e
- {
- \cs_new_protected:Npn \exp_not:N \@@_split_keytype_aux:w
- #1 \token_to_str:N : #2 \s_@@_stop
- {
- \tl_put_right:Ne \exp_not:N \l_@@_key_name_tl
- {
- \exp_not:N \tl_trim_spaces:e
- { \exp_not:N \tl_to_str:n {#1} }
- }
- \tl_if_in:nnTF {#2} { \token_to_str:N : }
- {
- \tl_put_right:Nn \exp_not:N \l_@@_key_name_tl
- { \token_to_str:N : }
- \exp_not:N \@@_split_keytype_aux:w #2 \s_@@_stop
- }
- {
- \exp_not:N \tl_if_empty:NTF \exp_not:N \l_@@_key_name_tl
- {
- \msg_error:nne { xtemplate } { empty-key-name }
- { \token_to_str:N : #2 }
- }
- { \exp_not:N \@@_split_keytype_arg:n {#2} }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_split_keytype_arg:n, \@@_split_keytype_arg:o}
-% \begin{macro}{\@@_split_keytype_arg_aux:n}
-% \begin{macro}{\@@_split_keytype_arg_aux:w}
-% The second stage of sorting out the keytype is to check for an
-% argument. As there is no convenient delimiting token to look for,
-% a check is made instead for each possible text value for the keytype.
-% To keep things faster, this only involves the keytypes that need an
-% argument. If a match is made, then a check is also needed to see that
-% it is at the start of the keytype information. All being well, the
-% split can then be applied. Any non-matching keytypes are assumed to
-% be \enquote{correct} as given, and are left alone (this is checked by
-% other code).
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_split_keytype_arg:n #1
- {
- \tl_set:Ne \l_@@_keytype_tl { \tl_trim_spaces:n {#1} }
- \tl_clear:N \l_@@_keytype_arg_tl
- \cs_set_protected:Npn \@@_split_keytype_arg_aux:n ##1
- {
- \tl_if_in:nnT {#1} {##1}
- {
- \cs_set:Npn \@@_split_keytype_arg_aux:w
- ####1 ##1 ####2 \s_@@_stop
- {
- \tl_if_blank:nT {####1}
- {
- \tl_set:Ne \l_@@_keytype_tl
- { \tl_trim_spaces:n {##1} }
- \tl_if_blank:nF {####2}
- {
- \tl_set:Ne \l_@@_keytype_arg_tl
- { \use:n ####2 }
- }
- \seq_map_break:
- }
- }
- \@@_split_keytype_arg_aux:w #1 \s_@@_stop
- }
- }
- \seq_map_function:NN \c_@@_keytypes_arg_seq
- \@@_split_keytype_arg_aux:n
- }
-\cs_generate_variant:Nn \@@_split_keytype_arg:n { o }
-\cs_new:Npn \@@_split_keytype_arg_aux:n #1 { }
-\cs_new:Npn \@@_split_keytype_arg_aux:w #1 \s_@@_stop { }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \subsubsection{Storing values}
-%
-% As \pkg{xtemplate} pre-processes key values for efficiency reasons,
-% there is a need to convert the values given as defaults into
-% \enquote{ready to use} data. The same general idea is true when an instance
-% is declared. However, assignments are not made until an instance is
-% used, and so there has to be some intermediate storage. Furthermore,
-% the ability to delay evaluation of results is needed. To achieve these
-% aims, a series of \enquote{process and store} functions are defined here.
-%
-% All of the information about the key (the key name and the keytype)
-% is already stored as variables. The same property list is always used
-% to store the data, meaning that the only argument required is the
-% value to be processed and potentially stored.
-%
-% \begin{macro}{\@@_store_value_boolean:n}
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_store_value_boolean:n #1
- { \prop_put:Non \l_@@_values_prop \l_@@_key_name_tl {#1} }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_store_value:n, \@@_store_value_choice:n,
-% \@@_store_value_function:n, \@@_store_value_instance:n}
-% With no need to worry about delayed evaluation, these keytypes all
-% just store the input directly.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_store_value:n #1
- { \prop_put:Non \l_@@_values_prop \l_@@_key_name_tl {#1} }
-\cs_new_eq:NN \@@_store_value_choice:n \@@_store_value:n
-\cs_new_eq:NN \@@_store_value_function:n \@@_store_value:n
-\cs_new_eq:NN \@@_store_value_instance:n \@@_store_value:n
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_store_value_aux:Nn, \@@_store_value_integer:n,
-% \@@_store_value_length:n, \@@_store_value_muskip:n,
-% \@@_store_value_real:n, \@@_store_value_skip:n,
-% \@@_store_value_tokenlist:n, \@@_store_value_commalist:n}
-% Storing values in \cs{l_@@_values_prop} is in most cases the same.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_store_value_aux:Nn #1#2
- { \prop_put:Non \l_@@_values_prop \l_@@_key_name_tl {#2} }
-\cs_new_protected:Npn \@@_store_value_integer:n
- { \@@_store_value_aux:Nn \int_eval:n }
-\cs_new_protected:Npn \@@_store_value_length:n
- { \@@_store_value_aux:Nn \dim_eval:n }
-\cs_new_protected:Npn \@@_store_value_muskip:n
- { \@@_store_value_aux:Nn \muskip_eval:n }
-\cs_new_protected:Npn \@@_store_value_real:n
- { \@@_store_value_aux:Nn \fp_eval:n }
-\cs_new_protected:Npn \@@_store_value_skip:n
- { \@@_store_value_aux:Nn \skip_eval:n }
-\cs_new_protected:Npn \@@_store_value_tokenlist:n
- { \@@_store_value_aux:Nn \use:n }
-\cs_new_eq:NN \@@_store_value_commalist:n \@@_store_value_tokenlist:n
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Implementation part of template declaration}
-%
-% \begin{macro}{\@@_declare_template_code:nnnnn}
-% \begin{macro}{\@@_declare_template_code:nnn}
-% The main function for implementing a template starts with a couple of
-% simple checks to make sure that there are no obvious mistakes: the
-% number of arguments must agree and the template keys must have been
-% declared.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_declare_template_code:nnnnn #1#2#3#4#5
- {
- \@@_execute_if_type_exist:nT {#1}
- {
- \@@_execute_if_arg_agree:nnT {#1}{#3}
- {
- \@@_if_keys_exist:nnT {#1} {#2}
- {
- \@@_store_key_implementation:nnn {#1} {#2} {#4}
- \regex_match:nnTF { \c { AssignTemplateKeys } } {#5}
- { \@@_declare_template_code:nnn { #1 / #2 } {#3} {#5} }
- {
- \@@_declare_template_code:nnn
- { #1 / #2 } {#3} { \AssignTemplateKeys #5 }
- }
- }
- }
- }
- }
-\cs_new_protected:Npn \@@_declare_template_code:nnn #1#2#3
- {
- \cs_generate_from_arg_count:cNnn
- { \c_@@_code_root_tl #1 }
- \cs_gset_protected:Npn {#2} {#3}
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_store_key_implementation:nnn}
-% Actually storing the implementation part of a template is quite easy
-% as it only requires the list of keys given to be turned into a
-% property list. There is also some error-checking to do, hence the need
-% to have the list of defined keytypes available. In certain cases
-% (when choices are involved) parsing the key results in changes to the
-% default values. That is why they are loaded and then saved again.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_store_key_implementation:nnn #1#2#3
- {
- \@@_recover_defaults:n { #1 / #2 }
- \@@_recover_restrictions:n { #1 / #2 }
- \@@_recover_keytypes:n { #1 / #2 }
- \prop_clear:N \l_@@_vars_prop
- \keyval_parse:nnn
- { \@@_parse_vars_elt:n } { \@@_parse_vars_elt:nnn { #1 / #2 } } {#3}
- \@@_store_vars:n { #1 / #2 }
- \@@_store_restrictions:n { #1 / #2 }
- \prop_map_inline:Nn \l_@@_keytypes_prop
- {
- \msg_error:nneee { xtemplate } { key-not-implemented }
- {##1} {#2} {#1}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_vars_elt:n}
-% At the implementation stage, every key must have a value given. So
-% this is an error function.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_vars_elt:n #1
- { \msg_error:nne { xtemplate } { key-no-variable } {#1} }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_vars_elt:nnn}
-% The actual storage part here is very simple: the storage bin name
-% is placed into the property list. At the same time, a comparison is
-% made with the keytypes defined earlier: if there is a mismatch then
-% an error is raised.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_vars_elt:nnn #1#2#3
- {
- \tl_set:Ne \l_@@_key_name_tl
- { \tl_trim_spaces:e { \tl_to_str:n {#2} } }
- \prop_get:NoNTF
- \l_@@_keytypes_prop
- \l_@@_key_name_tl
- \l_@@_keytype_tl
- {
- \@@_split_keytype_arg:o \l_@@_keytype_tl
- \@@_parse_vars_elt_aux:nn {#1} {#3}
- \prop_remove:NV \l_@@_keytypes_prop \l_@@_key_name_tl
- }
- { \msg_error:nne { xtemplate } { unknown-key } {#2} }
- }
-% \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@@_parse_vars_elt_aux:nn}
-% \begin{macro}{\@@_parse_vars_elt_aux:nw}
-% \begin{macro}{\@@_parse_vars_elt_aux:nnn}
-% \begin{macro}{\@@_parse_vars_elt_key:nn}
-% Split off any leading \texttt{global} and they look for the way to
-% implement.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_vars_elt_aux:nn #1#2
- {
- \@@_parse_vars_elt_aux:nw {#1} #2 global global \s_@@_stop
- }
-\cs_new_protected:Npn \@@_parse_vars_elt_aux:nw
- #1#2 global #3 global #4 \s_@@_stop
- {
- \tl_if_blank:nTF {#4}
- { \@@_parse_vars_elt_aux:nnn {#1} { } {#2} }
- {
- \tl_if_blank:nTF {#2}
- {
- \exp_args:Nnne \@@_parse_vars_elt_aux:nnn
- {#1} { global } { \tl_trim_spaces:n {#3} }
- }
- { \msg_error:nnn { xtemplate } { bad-variable } { #2 global #3 } }
- }
- }
-\cs_new_protected:Npn \@@_parse_vars_elt_aux:nnn #1#2#3
- {
- \str_case:VnF \l_@@_keytype_tl
- {
- { choice } { \@@_implement_choices:nn {#1} {#3} }
- { function }
- {
- \cs_if_exist:NF #3
- { \cs_new:Npn #3 { } }
- \@@_parse_vars_elt_key:nn {#1}
- {
- .code:n =
- {
- \cs_generate_from_arg_count:NNnn
- \exp_not:N #3
- \exp_not:c
- { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
- { \exp_not:o \l_@@_keytype_arg_tl }
- {##1}
- }
- }
- \prop_put:Non \l_@@_vars_prop
- \l_@@_key_name_tl {#2#3}
- }
- { instance }
- {
- \@@_parse_vars_elt_key:nn {#1}
- {
- .code:n =
- {
- \exp_not:c
- { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
- \exp_not:N #3 { \UseInstance {##1} }
- }
- }
- \prop_put:Non \l_@@_vars_prop
- \l_@@_key_name_tl {#2#3}
- }
- }
- {
- \tl_if_single:nTF {#3}
- {
- \cs_if_exist:NF #3
- { \use:c { \@@_map_var_type: _new:N } #3 }
- \@@_parse_vars_elt_key:nn {#1}
- {
- . \@@_map_var_type:
- _ \str_if_eq:nnT {#1} { global } { g } set:N
- = \exp_not:N #3
- }
- \prop_put:Non \l_@@_vars_prop
- \l_@@_key_name_tl {#2#3}
- }
- { \msg_error:nne { xtemplate } { bad-variable } { #2#3 } }
- }
- }
-\cs_new_protected:Npn \@@_parse_vars_elt_key:nn #1#2
- {
- \keys_define:ne { template / #1 }
- { \l_@@_key_name_tl #2 }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}[EXP]{\@@_map_var_type:}
-% Turn a \enquote{friendly} variable type into an \texttt{expl3} one.
-% \begin{macrocode}
-\cs_new:Npn \@@_map_var_type:
- {
- \str_case:on \l_@@_keytype_tl
- {
- { boolean } { bool }
- { commalist } { clist }
- { integer } { int }
- { length } { dim }
- { muskip } { muskip }
- { real } { fp }
- { skip } { skip }
- { tokenlist } { tl }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_implement_choices:nn}
-% \begin{macro}{\@@_implement_choices_default:}
-% Implementing choices requires a second key--value loop. So after a
-% little set-up, the standard parser is called.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_implement_choices:nn #1#2
- {
- \clist_set:No \l_@@_tmp_clist { \l_@@_keytype_arg_tl }
- \prop_put:Non \l_@@_vars_prop \l_@@_key_name_tl { }
- \keys_define:ne { template / #1 } { \l_@@_key_name_tl .choice: }
- \keyval_parse:nnn
- { \@@_implement_choice_elt:n }
- { \@@_implement_choice_elt:nnn {#1} }
- {#2}
- \prop_get:NoNT \l_@@_values_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- { \@@_implement_choices_default: }
- \clist_if_empty:NF \l_@@_tmp_clist
- {
- \clist_map_inline:Nn \l_@@_tmp_clist
- {
- \msg_error:nne { xtemplate } { choice-not-implemented }
- {##1}
- }
- }
- }
-% \end{macrocode}
-% A sanity check for the default value, so that an error is raised
-% now and not when converting to assignments.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_implement_choices_default:
- {
- \tl_set:Ne \l_@@_tmp_tl
- { \l_@@_key_name_tl \c_space_tl \l_@@_tmp_tl }
- \prop_if_in:NoF \l_@@_vars_prop \l_@@_tmp_tl
- {
- \tl_set:Ne \l_@@_tmp_tl
- { \l_@@_key_name_tl \c_space_tl \l_@@_tmp_tl }
- \prop_if_in:NoF \l_@@_vars_prop \l_@@_tmp_tl
- {
- \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \@@_split_keytype_arg:o \l_@@_tmp_tl
- \prop_get:NoN \l_@@_values_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-default-choice }
- { \l_@@_key_name_tl } { \l_@@_key_name_tl }
- { \l_@@_keytype_arg_tl }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_implement_choice_elt:nnn, \@@_implement_choice_elt_aux:nnn}
-% \begin{macro}{\@@_implement_choice_elt:n}
-% The actual storage of the implementation of a choice is mainly about
-% error checking. The code here ensures that all choices have to have
-% been declared, apart from the special \texttt{unknown} choice, which
-% must come last. The code for each choice is stored along with the
-% key name in the variables property list.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_implement_choice_elt:nnn #1#2#3
- {
- \clist_if_empty:NTF \l_@@_tmp_clist
- {
- \str_if_eq:nnTF {#2} { unknown }
- { \@@_implement_choice_elt_aux:nnn {#1} {#2} {#3} }
- {
- \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \@@_split_keytype_arg:o \l_@@_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l_@@_key_name_tl } {#2}
- { \l_@@_keytype_arg_tl }
- }
- }
- {
- \clist_if_in:NnTF \l_@@_tmp_clist {#2}
- {
- \clist_remove_all:Nn \l_@@_tmp_clist {#2}
- \@@_implement_choice_elt_aux:nnn {#1} {#2} {#3}
- }
- {
- \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \@@_split_keytype_arg:o \l_@@_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l_@@_key_name_tl } {#2}
- { \l_@@_keytype_arg_tl }
- }
- }
- }
-\cs_new_protected:Npn \@@_implement_choice_elt_aux:nnn #1#2#3
- {
- \keys_define:ne { template / #1 }
- { \l_@@_key_name_tl / #2 .code:n = { \exp_not:n {#3} } }
- \tl_set:Ne \l_@@_tmp_tl
- { \l_@@_key_name_tl \c_space_tl #2 }
- \prop_put:Non \l_@@_vars_prop \l_@@_tmp_tl {#3}
- }
-\cs_new_protected:Npn \@@_implement_choice_elt:n #1
- {
- \msg_error:nneee { xtemplate } { choice-requires-code }
- { \l_@@_key_name_tl } {#1}
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{Editing template defaults}
-%
-% Template defaults can be edited either with no other changes or
-% to prevent further editing, forming a \enquote{restricted template}.
-% In the later case, a new template results, whereas simple editing
-% does not produce a new template name.
-%
-% \begin{macro}{\@@_declare_restricted:nnnn}
-% Creating a restricted template means copying the old template to the
-% new one first.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_declare_restricted:nnnn #1#2#3#4
- {
- \@@_if_keys_exist:nnT {#1} {#2}
- {
- \@@_set_template_eq:nn { #1 / #3 } { #1 / #2 }
- \bool_set_true:N \l_@@_restrict_bool
- \@@_edit_defaults_aux:nnn {#1} {#3} {#4}
- \bool_set_false:N \l_@@_restrict_bool
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_edit_defaults:nnn}
-% \begin{macro}{\@@_edit_defaults_aux:nnn}
-% Editing the template defaults means getting the values back out
-% of the store, then parsing the list of new values before putting
-% the updated list back into storage. The auxiliary function is used
-% to allow code-sharing with the template-restriction system.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_edit_defaults:nnn
- {
- \bool_set_false:N \l_@@_restrict_bool
- \@@_edit_defaults_aux:nnn
- }
-\cs_new_protected:Npn \@@_edit_defaults_aux:nnn #1#2#3
- {
- \@@_if_keys_exist:nnT {#1} {#2}
- {
- \@@_recover_defaults:n { #1 / #2 }
- \@@_recover_restrictions:n { #1 / #2 }
- \@@_parse_values:nn { #1 / #2 } {#3}
- \@@_store_defaults:n { #1 / #2 }
- \@@_store_restrictions:n { #1 / #2 }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_values:nn, \@@_parse_values_aux:nn}
-% The routine to parse values is the same for both editing a
-% template and setting up an instance. So the code here does only the
-% minimum necessary for reading the values.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_values:nn #1#2
- {
- \clist_clear:N \l_@@_restrict_clist
- \@@_parse_values_aux:nn {#1} {#2}
- }
-\cs_new_protected:Npn \@@_parse_values_aux:nn #1#2
- {
- \@@_recover_keytypes:n {#1}
- \keyval_parse:NNn
- \@@_parse_values_elt:n \@@_parse_values_elt:nn {#2}
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_values_elt:n}
-% Every key needs a value, so this is just an error routine.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_values_elt:n #1
- {
- \bool_set_true:N \l_@@_error_bool
- \msg_error:nne { xtemplate } { key-no-value } {#1}
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_parse_values_elt:nn}
-% \begin{macro}{\@@_parse_values_elt_aux:n}
-% To store the value, find the keytype then call the saving function.
-% These need the current key name saved as \cs{l_@@_key_name_tl}.
-% When a template is being restricted, the setting code will be
-% skipped for restricted keys.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_values_elt:nn #1#2
- {
- \tl_set:Ne \l_@@_key_name_tl
- { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
- \prop_get:NoNTF \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- {
- \bool_if:NTF \l_@@_restrict_bool
- {
- \clist_if_in:NoF \l_@@_restrict_clist
- \l_@@_key_name_tl
- { \@@_parse_values_elt_aux:n {#2} }
- }
- { \@@_parse_values_elt_aux:n {#2} }
- }
- {
- \msg_error:nne { xtemplate } { unknown-key }
- { \l_@@_key_name_tl }
- }
- }
-\cs_new_protected:Npn \@@_parse_values_elt_aux:n #1
- {
- \clist_put_right:No \l_@@_restrict_clist \l_@@_key_name_tl
- \@@_split_keytype_arg:o \l_@@_tmp_tl
- \use:c { @@_store_value_ \l_@@_keytype_tl :n } {#1}
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_set_template_eq:nn}
-% To copy a template, each of the lists plus the code has to be copied
-% across. To keep this independent of the list storage system, it is
-% all done with two-part shuffles.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_set_template_eq:nn #1#2
- {
- \@@_recover_defaults:n {#2}
- \@@_store_defaults:n {#1}
- \@@_recover_keytypes:n {#2}
- \@@_store_keytypes:n {#1}
- \@@_recover_vars:n {#2}
- \@@_store_vars:n {#1}
- \cs_gset_eq:cc { \c_@@_code_root_tl #1 }
- { \c_@@_code_root_tl #2 }
- }
-% \end{macrocode}
-% \end{macro}
-%
-%\subsection{Creating instances of templates}
-%
-% \begin{macro}{\@@_declare_instance:nnnnn}
-% \begin{macro}{\@@_declare_instance_aux:nnnnn}
-% Making an instance has two distinct parts. First, the keys given are
-% parsed to transfer the values into the structured data format used
-% internally. This allows the default and given values to be combined
-% with no repetition. In the second step, the structured data is
-% converted to pre-defined variable assignments, and these are stored
-% in the function for the instance. A final check is also made so that
-% there is always an instance \enquote{outside} of any collection.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_declare_instance:nnnnn #1#2#3#4#5
- {
- \@@_execute_if_code_exist:nnT {#1} {#2}
- {
- \@@_recover_defaults:n { #1 / #2 }
- \@@_recover_restrictions:n { #1 / #2 }
- \@@_recover_vars:n { #1 / #2 }
- \@@_declare_instance_aux:nnnnn {#1} {#2} {#3} {#4} {#5}
- }
- }
-\cs_new_protected:Npn \@@_declare_instance_aux:nnnnn #1#2#3#4#5
- {
- \bool_set_false:N \l_@@_error_bool
- \@@_parse_values_aux:nn { #1 / #2 } {#5}
- \bool_if:NF \l_@@_error_bool
- {
- \prop_put:Nnn \l_@@_values_prop { from~template } {#2}
- \@@_store_values:n { #1 / #3 / #4 }
- \@@_convert_to_assignments:
- \cs_set_protected:cpe { \c_@@_instances_root_tl #1 / #3 / #4 }
- {
- \exp_not:N \@@_assignments_push:n
- { \exp_not:o \l_@@_assignments_tl }
- \exp_not:c { \c_@@_code_root_tl #1 / #2 }
- }
- \@@_if_instance_exist:nnnF {#1} { } {#4}
- {
- \cs_set_eq:cc
- { \c_@@_instances_root_tl #1 / / #4 }
- { \c_@@_instances_root_tl #1 / #3 / #4 }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_copy_instance:nnnn}
-% Copy--paste an instance
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_copy_instance:nnnn #1#2#3#4
- {
- \@@_if_instance_exist:nnnTF {#1} {#2} {#3}
- {
- \@@_recover_values:n { #1 / #2 / #3 }
- \@@_store_values:n { #1 / #2 / #4 }
- \cs_set_eq:cc { \c_@@_instances_root_tl #1 / #2 / #4 }
- { \c_@@_instances_root_tl #1 / #2 / #3 }
- }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#3}
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\@@_edit_instance:nnnn}
-% \begin{macro}{\@@_edit_instance_aux:nnnnn}
-% \begin{macro}{\@@_edit_instance_aux:nonnn}
-% Editing an instance is almost identical to declaring one. The only
-% variation is the source of the values to use. When editing, they are
-% recovered from the previous instance run.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_edit_instance:nnnn #1#2#3#4
- {
- \@@_if_instance_exist:nnnTF {#1} {#2} {#3}
- {
- \@@_recover_values:n { #1 / #2 / #3 }
- \prop_get:NnN \l_@@_values_prop { from~template }
- \l_@@_tmp_tl
- \@@_edit_instance_aux:nonnn {#1} \l_@@_tmp_tl
- {#2} {#3} {#4}
- }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#3}
- }
- }
-\cs_new_protected:Npn \@@_edit_instance_aux:nnnnn #1#2
- {
- \@@_recover_vars:n { #1 / #2 }
- \@@_declare_instance_aux:nnnnn {#1} {#2}
- }
-\cs_generate_variant:Nn \@@_edit_instance_aux:nnnnn { no }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_convert_to_assignments:}
-% \begin{macro}{\@@_convert_to_assignments_aux:n}
-% \begin{macro}{\@@_convert_to_assignments_aux:nn}
-% \begin{macro}{\@@_convert_to_assignments_aux:no}
-% The idea on converting to a set of assignments is to loop over each
-% key, so that the loop order follows the declaration order of the keys.
-% This is done using a sequence as property lists are not
-% \enquote{ordered}.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_convert_to_assignments:
- {
- \tl_clear:N \l_@@_assignments_tl
- \seq_map_function:NN \l_@@_key_order_seq
- \@@_convert_to_assignments_aux:n
- }
-\cs_new_protected:Npn \@@_convert_to_assignments_aux:n #1
- {
- \prop_get:NnN \l_@@_keytypes_prop {#1} \l_@@_tmp_tl
- \@@_convert_to_assignments_aux:no {#1} \l_@@_tmp_tl
- }
-% \end{macrocode}
-% The second auxiliary function actually does the work. The
-% arguments here are the key name (|#1|) and the keytype (|#2|).
-% From those, the value to assign and the name of the appropriate
-% variable are recovered. A bit of work is then needed to sort out
-% keytypes with arguments (for example instances), and to look for
-% global assignments. Once that is done, a hand-off can be made to the
-% handler for the relevant keytype.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_convert_to_assignments_aux:nn #1#2
- {
- \prop_get:NnNT \l_@@_values_prop {#1} \l_@@_value_tl
- {
- \prop_get:NnNTF \l_@@_vars_prop {#1} \l_@@_var_tl
- {
- \@@_split_keytype_arg:n {#2}
- \str_if_eq:onF \l_@@_keytype_tl { choice }
- {
- \str_if_eq:onF \l_@@_keytype_tl { code }
- { \@@_find_global: }
- }
- \tl_set:Nn \l_@@_key_name_tl {#1}
- \use:c { @@_assign_ \l_@@_keytype_tl : }
- }
- { \msg_error:nne { xtemplate } { unknown-attribute } {#1} }
- }
- }
-\cs_generate_variant:Nn \@@_convert_to_assignments_aux:nn { no }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_find_global:}
-% \begin{macro}{\@@_find_global_aux:w}
-% Global assignments should have the phrase |global| at the front.
-% This is pretty easy to find: no other error checking, though.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_find_global:
- {
- \bool_set_false:N \l_@@_global_bool
- \tl_if_in:onT \l_@@_var_tl { global }
- {
- \exp_after:wN \@@_find_global_aux:w \l_@@_var_tl \s_@@_stop
- }
- }
-\cs_new_protected:Npn \@@_find_global_aux:w #1 global #2 \s_@@_stop
- {
- \tl_set:Nn \l_@@_var_tl {#2}
- \bool_set_true:N \l_@@_global_bool
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{Using templates directly}
-%
-% \begin{macro}{\@@_use_template:nnn}
-% Directly use a template with a particular parameter setting.
-% This is also picked up if used in a nested fashion inside a parameter
-% list. The idea is essentially the same as creating an instance,
-% just with no saving of the result.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_use_template:nnn #1#2#3
- {
- \@@_execute_if_code_exist:nnT {#1} {#2}
- {
- \@@_recover_defaults:n { #1 / #2 }
- \@@_recover_vars:n { #1 / #2 }
- \@@_parse_values:nn { #1 / #2 } {#3}
- \@@_convert_to_assignments:
- \use:c { \c_@@_code_root_tl #1 / #2 }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Assigning values to variables}
-%
-% \begin{macro}{\@@_assign_boolean:}
-% \begin{macro}{\@@_assign_boolean_aux:n}
-% Setting a Boolean value is slightly different to everything else
-% as the value can be used to work out which \texttt{set} function to
-% call. As long as there is no need to recover things from another
-% variable, everything is pretty easy. If there is, then we need to allow
-% for the fact that the recovered value here will \emph{not} be expandable,
-% so needs to be converted to something that is.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_boolean:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_boolean_aux:n { bool_gset } }
- { \@@_assign_boolean_aux:n { bool_set } }
- }
-\cs_new_protected:Npn \@@_assign_boolean_aux:n #1
- {
- \@@_if_key_value:oTF \l_@@_value_tl
- {
- \@@_key_to_value:
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- \exp_not:c { #1 _eq:NN }
- \exp_not:o \l_@@_var_tl
- \exp_not:o \l_@@_value_tl
- }
- }
- {
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- \exp_not:c { #1 _ \l_@@_value_tl :N }
- \exp_not:o \l_@@_var_tl
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_choice:}
-% \begin{macro}
-% {\@@_assign_choice_aux:n, \@@_assign_choice_aux:o}
-% The idea here is to find either the choice as-given or else the
-% special |unknown| choice, and to copy the appropriate code across.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_choice:
- {
- \@@_assign_choice_aux:eF
- { \l_@@_key_name_tl \c_space_tl \l_@@_value_tl }
- {
- \@@_assign_choice_aux:eF
- { \l_@@_key_name_tl \c_space_tl unknown }
- {
- \prop_get:NoN \l_@@_keytypes_prop \l_@@_key_name_tl
- \l_@@_tmp_tl
- \@@_split_keytype_arg:o \l_@@_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l_@@_key_name_tl } { \l_@@_value_tl }
- { \l_@@_keytype_arg_tl }
- }
- }
- }
-\cs_new_protected:Npn \@@_assign_choice_aux:nF #1
- {
- \prop_get:NnNTF
- \l_@@_vars_prop
- {#1}
- \l_@@_tmp_tl
- { \tl_put_right:No \l_@@_assignments_tl \l_@@_tmp_tl }
- }
-\cs_generate_variant:Nn \@@_assign_choice_aux:nF { e }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_function:}
-% \begin{macro}{\@@_assign_function_aux:N}
-% This looks a bit messy but is only actually one function.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_function:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_function_aux:N \cs_gset:Npn }
- { \@@_assign_function_aux:N \cs_set:Npn }
- }
-\cs_new_protected:Npn \@@_assign_function_aux:N #1
- {
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- \cs_generate_from_arg_count:NNnn
- \exp_not:o \l_@@_var_tl
- \exp_not:N #1
- { \exp_not:o \l_@@_keytype_arg_tl }
- { \exp_not:o \l_@@_value_tl }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_instance:}
-% \begin{macro}{\@@_assign_instance_aux:N}
-% Using an instance means adding the appropriate function creation to
-% the tl. No checks are made at this stage, so if the instance is
-% not valid then errors will arise later.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_instance:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_instance_aux:N \cs_gset_protected:Npn }
- { \@@_assign_instance_aux:N \cs_set_protected:Npn }
- }
-\cs_new_protected:Npn \@@_assign_instance_aux:N #1
- {
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- \exp_not:N #1 \exp_not:o \l_@@_var_tl
- {
- \@@_use_instance:nn
- { \exp_not:o \l_@@_keytype_arg_tl }
- { \exp_not:o \l_@@_value_tl }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_integer:}
-% \begin{macro}{\@@_assign_length:}
-% \begin{macro}{\@@_assign_muskip:}
-% \begin{macro}{\@@_assign_real:}
-% \begin{macro}{\@@_assign_skip:}
-% All of the calculated assignments use the same underlying code, with
-% only the low-level assignment function changing.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_integer:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_variable:N \int_gset:Nn }
- { \@@_assign_variable:N \int_set:Nn }
- }
-\cs_new_protected:Npn \@@_assign_length:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_variable:N \dim_gset:Nn }
- { \@@_assign_variable:N \dim_set:Nn }
-}
-\cs_new_protected:Npn \@@_assign_muskip:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_variable:N \muskip_gset:Nn }
- { \@@_assign_variable:N \muskip_set:Nn }
- }
-\cs_new_protected:Npn \@@_assign_real:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_variable:N \fp_gset:Nn }
- { \@@_assign_variable:N \fp_set:Nn }
- }
-\cs_new_protected:Npn \@@_assign_skip:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_variable:N \skip_gset:Nn }
- { \@@_assign_variable:N \skip_set:Nn }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_tokenlist:}
-% \begin{macro}{\@@_assign_tokenlist_aux:NN}
-% Life would be easy here if it were not for \cs{KeyValue}. To deal
-% correctly with that, we need to allow for the recovery a stored value
-% at point of use.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_tokenlist:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_tokenlist_aux:NN \tl_gset:NV \tl_gset:Nn }
- { \@@_assign_tokenlist_aux:NN \tl_set:NV \tl_set:Nn }
- }
-\cs_new_protected:Npn \@@_assign_tokenlist_aux:NN #1#2
- {
- \@@_if_key_value:oTF \l_@@_value_tl
- {
- \@@_key_to_value:
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- #1 \exp_not:o \l_@@_var_tl
- \exp_not:o \l_@@_value_tl
- }
- }
- {
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- #2 \exp_not:o \l_@@_var_tl
- { \exp_not:o \l_@@_value_tl }
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_commalist:}
-% Very similar for commas lists, so some code is shared.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_commalist:
- {
- \bool_if:NTF \l_@@_global_bool
- { \@@_assign_tokenlist_aux:NN \clist_gset:NV \clist_gset:Nn }
- { \@@_assign_tokenlist_aux:NN \clist_set:NV \clist_set:Nn }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_assign_variable:N}
-% A general-purpose function for all of the numerical assignments.
-% As long as the value is not coming from another variable, the stored
-% value is simply transferred for output.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assign_variable:N #1
- {
- \@@_if_key_value:oT \l_@@_value_tl
- { \@@_key_to_value: }
- \tl_put_right:Ne \l_@@_assignments_tl
- {
- #1 \exp_not:o \l_@@_var_tl
- { \exp_not:o \l_@@_value_tl }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_key_to_value:}
-% \begin{macro}{\@@_key_to_value_auxi:w}
-% \begin{macro}{\@@_key_to_value_auxii:w}
-% The idea here is to recover the attribute value of another key. To
-% do that, the marker is removed and a look up takes place. If this
-% is successful, then the name of the variable of the attribute is
-% returned. This assumes that the value will be used in context where
-% it will be converted to a value, for example when setting a number.
-% There is also a need to check in case the copied value happens to be
-% \texttt{global}.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_key_to_value:
- { \exp_after:wN \@@_key_to_value_auxi:w \l_@@_value_tl }
-\cs_new_protected:Npn \@@_key_to_value_auxi:w \KeyValue #1
- {
- \tl_set:Ne \l_@@_tmp_tl { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
- \prop_get:NoNTF
- \l_@@_vars_prop
- \l_@@_tmp_tl
- \l_@@_value_tl
- {
- \exp_after:wN \@@_key_to_value_auxii:w \l_@@_value_tl
- \s_@@_mark global \q_@@_nil \s_@@_stop
- }
- {
- \msg_error:nne { xtemplate } { unknown-attribute }
- { \l_@@_tmp_tl }
- }
- }
-\cs_new_protected:Npn \@@_key_to_value_auxii:w #1 global #2#3 \s_@@_stop
- {
- \@@_quark_if_nil:NF #2
- { \tl_set:Nn \l_@@_value_tl {#2} }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{Using instances}
-%
-% \begin{macro}{\@@_use_instance:nn}
-% \begin{macro}{\@@_use_instance_aux:nNnnn}
-% \begin{macro}{\@@_use_instance_aux:nn}
-% Using an instance is just a question of finding the appropriate
-% function. There is the possibility that a collection instance exists,
-% so this is checked before trying the general instance. If nothing is
-% found, an error is raised. One additional complication is that
-% if the first token of argument |#2| is \cs{UseTemplate} then that
-% is also valid. There is an error-test to make sure that the
-% types agree, and if so the template is used directly.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_use_instance:nn #1#2
- {
- \@@_if_use_template:nTF {#2}
- { \@@_use_instance_aux:nNnnn {#1} #2 }
- { \@@_use_instance_aux:nn {#1} {#2} }
- }
-\cs_new_protected:Npn \@@_use_instance_aux:nNnnn #1#2#3#4#5
- {
- \str_if_eq:nnTF {#1} {#3}
- { \@@_use_template:nnn {#3} {#4} {#5} }
- { \msg_error:nnee { xtemplate } { type-mismatch } {#1} {#3} }
-}
-\cs_new_protected:Npn \@@_use_instance_aux:nn #1#2
- {
- \@@_get_collection:n {#1}
- \@@_if_instance_exist:nnnTF
- {#1} { \l_@@_collection_tl } {#2}
- {
- \use:c
- {
- \c_@@_instances_root_tl #1 /
- \l_@@_collection_tl / #2
- }
- }
- {
- \@@_if_instance_exist:nnnTF {#1} { } {#2}
- { \use:c { \c_@@_instances_root_tl #1 / / #2 } }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#2}
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_use_collection:nn}
-% Switching to an instance collection is just a question of setting the
-% appropriate list.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_use_collection:nn #1#2
- { \prop_put:Nnn \l_@@_collections_prop {#1} {#2} }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_get_collection:n}
-% Recovering the collection for a given type is pretty easy: just a read
-% from the list.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_get_collection:n #1
- {
- \prop_get:NnNF \l_@@_collections_prop {#1}
- \l_@@_collection_tl
- { \tl_clear:N \l_@@_collection_tl }
- }
-% \end{macrocode}
-% \end{macro}
-%
-%\subsection{Assignment manipulation}
-%
-% A few functions to transfer assignments about, as this is needed by
-% \cs{AssignTemplateKeys}.
-%
-% \begin{macro}{\@@_assignments_pop:}
-% To actually use the assignments.
-% \begin{macrocode}
-\cs_new:Npn \@@_assignments_pop: { \l_@@_assignments_tl }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_assignments_push:n}
-% Here, the assignments are stored for later use.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_assignments_push:n #1
- { \tl_set:Nn \l_@@_assignments_tl {#1} }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Showing templates and instances}
-%
-% \begin{macro}{\@@_show_code:nn}
-% Showing the code for a template is just a translation of
-% \cs{cs_show:c}.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_show_code:nn #1#2
- { \cs_show:c { \c_@@_code_root_tl #1 / #2 } }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}
-% {
-% \@@_show_defaults:nn, \@@_show_keytypes:nn,
-% \@@_show_vars:nn
-% }
-% \begin{macro}{\@@_show:Nnnn}
-% A modified version of the property-list printing code, such that
-% the output refers to templates and instances rather than to the
-% underlying structures.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_show_defaults:nn #1#2
- {
- \@@_if_keys_exist:nnT {#1} {#2}
- {
- \@@_recover_defaults:n { #1 / #2 }
- \@@_show:Nnnn \l_@@_values_prop
- {#1} {#2} { default~values }
- }
- }
-\cs_new_protected:Npn \@@_show_keytypes:nn #1#2
- {
- \@@_if_keys_exist:nnT {#1} {#2}
- {
- \@@_recover_keytypes:n { #1 / #2 }
- \@@_show:Nnnn \l_@@_keytypes_prop
- {#1} {#2} { interface }
- }
- }
-\cs_new_protected:Npn \@@_show_vars:nn #1#2
- {
- \@@_execute_if_code_exist:nnT {#1} {#2}
- {
- \@@_recover_vars:n { #1 / #2 }
- \@@_show:Nnnn \l_@@_vars_prop
- {#1} {#2} { variable~mapping }
- }
- }
-\cs_new_protected:Npn \@@_show:Nnnn #1#2#3#4
- {
- \msg_show:nneeee { xtemplate } { show-attribute }
- { \tl_to_str:n {#2} }
- { \tl_to_str:n {#3} }
- { \tl_to_str:n {#4} }
- { \prop_map_function:NN #1 \msg_show_item_unbraced:nn }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\@@_show_values:nnn}
-% Instance values are a little more complex, as there are the collection
-% and template to consider.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_show_values:nnn #1#2#3
- {
- \@@_if_instance_exist:nnnT {#1} {#2} {#3}
- {
- \@@_recover_values:n { #1 / #2 / #3 }
- \msg_show:nneeee { xtemplate } { show-values }
- { \tl_to_str:n {#1} }
- { \tl_to_str:n {#2} }
- { \tl_to_str:n {#3} }
- {
- \prop_map_function:NN \l_@@_values_prop
- \msg_show_item_unbraced:nn
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{Messages}
-%
-% The text for error messages: short and long text for all of them.
-% \begin{macrocode}
-\msg_new:nnnn { xtemplate } { argument-number-mismatch }
- { Object~type~'#1'~takes~#2~argument(s). }
- {
- Objects~of~type~'#1'~require~#2~argument(s).\\
- You~have~tried~to~make~a~template~for~'#1'~
- with~#3~argument(s),~which~is~not~possible:~
- the~number~of~arguments~must~agree.
- }
-\msg_new:nnnn { xtemplate } { bad-number-of-arguments }
- { Bad~number~of~arguments~for~object~type~'#1'. }
- {
- An~object~may~accept~between~0~and~9~arguments.\\
- You~asked~to~use~#2~arguments:~this~is~not~supported.
- }
-\msg_new:nnnn { xtemplate } { bad-variable }
- { Incorrect~variable~description~'#1'. }
- {
- The~argument~'#1'~is~not~of~the~form \\
- ~~'<variable>'\\
- ~or~\\
- ~~'global~<variable>'.\\
- It~must~be~given~in~one~of~these~formats~to~be~used~in~a~template.
- }
-\msg_new:nnnn { xtemplate } { choice-not-implemented }
- { The~choice~'#1'~has~no~implementation. }
- {
- Each~choice~listed~in~the~interface~for~a~template~must~
- have~an~implementation.
- }
-\msg_new:nnnn { xtemplate } { choice-no-code }
- { The~choice~'#1'~requires~implementation~details. }
- {
- When~creating~template~code~using~\DeclareTemplateCode,~
- each~choice~name~must~have~an~associated~implementation.\\
- This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
- }
-\msg_new:nnnn { xtemplate } { choice-requires-code }
- { The~choice~'#2'~for~key~'#1'~requires~an~implementation. }
- {
- You~should~have~put:\\
- \ \ #1~:~choice~{~#2 = <code> ~} \\
- but~LaTeX~did~not~find~any~<code>.
- }
-\msg_new:nnnn { xtemplate } { duplicate-key-interface }
- { Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. }
- {
- Each~key~can~only~have~one~interface~declared~in~a~template.\\
- LaTeX~found~two~interfaces~for~'#1'.
- }
-\msg_new:nnnn { xtemplate } { keytype-requires-argument }
- { The~key~type~'#1'~requires~an~argument~\msg_line_context:. }
- {
- You~should~have~put:\\
- \ \ <key-name>~:~#1~{~<argument>~} \\
- but~LaTeX~did~not~find~an~<argument>.
- }
-\msg_new:nnnn { xtemplate } { invalid-keytype }
- { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
- {
- Each~key~in~a~template~requires~a~key-type,~given~in~the~form:\\
- \ \ <key>~:~<key-type>\\
- LaTeX~could~not~find~a~<key-type>~in~your~input.
- }
-\msg_new:nnnn { xtemplate } { key-no-value }
- { The~key~'#1'~has~no~value~\msg_line_context:. }
- {
- When~creating~an~instance~of~a~template~
- every~key~listed~must~include~a~value:\\
- \ \ <key>~=~<value>
- }
-\msg_new:nnnn { xtemplate } { key-no-variable }
- { The~key~'#1'~requires~implementation~details~\msg_line_context:. }
- {
- When~creating~template~code~using~\DeclareTemplateCode,~
- each~key~name~must~have~an~associated~implementation.\\
- This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
- }
-\msg_new:nnnn { xtemplate } { key-not-implemented }
- { Key~'#1'~has~no~implementation~\msg_line_context:. }
- {
- The~definition~of~key~implementations~for~template~'#2'~
- of~object~type~'#3'~does~not~include~any~details~for~key~'#1'.\\
- The~key~was~declared~in~the~interface~definition,~
- and~so~an~implementation~is~required.
- }
-\msg_new:nnnn { xtemplate } { missing-keytype }
- { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
- {
- Key~interface~definitions~should~be~of~the~form\\
- \ \ #1~:~<key-type>\\
- but~LaTeX~could~not~find~a~<key-type>.
- }
-\msg_new:nnnn { xtemplate } { no-template-code }
- {
- The~template~'#2'~of~type~'#1'~is~unknown~
- or~has~no~implementation.
- }
- {
- There~is~no~code~available~for~the~template~name~given.\\
- This~should~be~given~using~\DeclareTemplateCode.
- }
-\msg_new:nnnn { xtemplate } { object-type-mismatch }
- { Object~types~'#1'~and~'#2'~do~not~agree. }
- {
- You~are~trying~to~use~a~template~directly~with~\UseInstance
- (or~a~similar~function),~but~the~object~types~do~not~match.
- }
-\msg_new:nnnn { xtemplate } { unknown-attribute }
- { The~template~attribute~'#1'~is~unknown. }
- {
- There~is~a~definition~in~the~current~template~reading\\
- \ \ \token_to_str:N \KeyValue {~#1~} \\
- but~there~is~no~key~called~'#1'.
- }
-\msg_new:nnnn { xtemplate } { unknown-choice }
- { The~choice~'#2'~was~not~declared~for~key~'#1'. }
- {
- The~key~'#1'~takes~a~fixed~list~of~choices~
- and~this~list~does~not~include~'#2'.
- }
-\msg_new:nnnn { xtemplate } { unknown-default-choice }
- { The~default~choice~'#2'~was~not~declared~for~key~'#1'. }
- {
- The~key~'#1'~takes~a~fixed~list~of~choices~
- and~this~list~does~not~include~'#2'.
- }
-\msg_new:nnnn { xtemplate } { unknown-instance }
- { The~instance~'#2'~of~type~'#1'~is~unknown. }
- {
- You~have~asked~to~use~an~instance~'#2',~
- but~this~has~not~been~created.
- }
-\msg_new:nnnn { xtemplate } { unknown-key }
- { Unknown~template~key~'#1'. }
- {
- The~key~'#1'~was~not~declared~in~the~interface~
- for~the~current~template.
- }
-\msg_new:nnnn { xtemplate } { unknown-keytype }
- { The~key-type~'#1'~is~unknown. }
- {
- Valid~key-types~are:\\
- -~boolean;\\
- -~choice;\\
- -~commalist;\\
- -~function;\\
- -~instance;\\
- -~integer;\\
- -~length;\\
- -~muskip;\\
- -~real;\\
- -~skip;\\
- -~tokenlist.
- }
-\msg_new:nnnn { xtemplate } { unknown-object-type }
- { The~object~type~'#1'~is~unknown. }
- {
- An~object~type~needs~to~be~declared~with~\DeclareObjectType
- prior~to~using~it.
- }
-\msg_new:nnnn { xtemplate } { unknown-template }
- { The~template~'#2'~of~type~'#1'~is~unknown. }
- {
- No~interface~has~been~declared~for~a~template~
- '#2'~of~object~type~'#1'.
- }
-% \end{macrocode}
-%
-% Information messages only have text: more text should not be needed.
-% \begin{macrocode}
-\msg_new:nnn { xtemplate } { declare-object-type }
- { Declaring~object~type~'#1'~taking~#2~argument(s)~\msg_line_context:. }
-\msg_new:nnn { xtemplate } { declare-template-code }
- { Declaring~code~for~template~'#2'~of~object~type'#1'~\msg_line_context:. }
-\msg_new:nnn { xtemplate } { declare-template-interface }
- {
- Declaring~interface~for~template~'#2'~of~object~type~'#1'~
- \msg_line_context:.
- }
-\msg_new:nnn { xtemplate } { show-attribute }
- {
- The~template~'#2'~of~object~type~'#1'~has~
- \tl_if_empty:nTF {#4} { no~#3. } { #3 : #4 }
- }
-\msg_new:nnn { xtemplate } { show-values }
- {
- \tl_if_empty:nTF {#2}
- { The~instance~'#3'~ }
- { The~collection~ instance~'#3'~ (from~collection~'#2')~ }
- of~object~type~'#1'~has~
- \tl_if_empty:nTF {#4} { no~values. } { values: #4 }
- }
-% \end{macrocode}
-%
-% \subsection{User functions}
-%
-% The user functions provided by \pkg{xtemplate} are pretty much direct
-% copies of internal ones. However, by sticking to the \pkg{xparse}
-% approach only the appropriate arguments are long.
-%
-% \begin{macro}{\DeclareObjectType}
-% \begin{macro}{\DeclareTemplateInterface}
-% \begin{macro}{\DeclareTemplateCode}
% \begin{macro}{\DeclareRestrictedTemplate}
-% \begin{macro}{\EditTemplateDefaults}
-% \begin{macro}{\DeclareInstance}
-% \begin{macro}{\DeclareCollectionInstance}
-% \begin{macro}{\DeclareInstanceCopy}
-% \begin{macro}{\EditInstance}
-% \begin{macro}{\EditCollectionInstance}
-% \begin{macro}{\UseTemplate}
-% \begin{macro}{\UseInstance}
-% \begin{macro}{\UseCollection}
-% All simple translations, with the appropriate long/short argument
-% filtering.
-% \begin{macrocode}
+% \begin{macro}{\DeclareObjectType}
+% If the new kernel code is not loaded, make a couple of compatibility
+% additions. Otherwise, hand over to the frozen version.
+% \begin{macrocode}
+\@ifundefined{NewTemplateType}
+ {%
+ \input{xtemplate-2023-10-10.sty}%
+ \endinput
+ }
+ {%
+ \ProvidesExplPackage{xtemplate}{2023-10-10}{}
+ {L3 Experimental prototype document functions}
+ \long\protected\def\DeclareRestrictedTemplate#1#2#3#4{%
+ \DeclareTemplateCopy{#1}{#3}{#2}%
+ \EditTemplateDefaults{#1}{#3}{#4}%
+ }%
+ }
+\ExplSyntaxOn
\cs_new_protected:Npn \DeclareObjectType #1#2
- { \@@_declare_object_type:nn {#1} {#2} }
-\cs_new_protected:Npn \DeclareTemplateInterface #1#2#3#4
- { \@@_declare_template_keys:nnnn {#1} {#2} {#3} {#4} }
-\cs_new_protected:Npn \DeclareTemplateCode #1#2#3#4#5
- { \@@_declare_template_code:nnnnn {#1} {#2} {#3} {#4} {#5} }
-\cs_new_protected:Npn \DeclareRestrictedTemplate #1#2#3#4
- { \@@_declare_restricted:nnnn {#1} {#2} {#3} {#4} }
-\cs_new_protected:Npn \DeclareInstance #1#2#3#4
- { \@@_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} }
-\cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5
- { \@@_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} }
-\cs_new_protected:Npn \DeclareInstanceCopy #1#2#3
- { \@@_copy_instance:nnnn {#1} { } {#3} {#2} }
-\cs_new_protected:Npn \EditTemplateDefaults #1#2#3
- { \@@_edit_defaults:nnn {#1} {#2} {#3} }
-\cs_new_protected:Npn \EditInstance #1#2#3
- { \@@_edit_instance:nnnn {#1} { } {#2} {#3} }
-\cs_new_protected:Npn \EditCollectionInstance #1#2#3#4
- { \@@_edit_instance:nnnn {#2} {#1} {#3} {#4} }
-\cs_new_protected:Npn \UseTemplate #1#2#3
- { \@@_use_template:nnn {#1} {#2} {#3} }
-\cs_new_protected:Npn \UseInstance #1#2
- { \@@_use_instance:nn {#1} {#2} }
-\cs_new_protected:Npn \UseCollection #1#2
- { \@@_use_collection:nn {#1} {#2} }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\ShowTemplateCode}
-% \begin{macro}{\ShowTemplateDefaults}
-% \begin{macro}{\ShowTemplateInterface}
-% \begin{macro}{\ShowTemplateVariables}
-% \begin{macro}{\ShowInstanceValues}
-% \begin{macro}{\ShowCollectionInstanceValues}
-% The show functions are again just translation.
-% \begin{macrocode}
-\cs_new_protected:Npn \ShowTemplateCode #1#2
- { \@@_show_code:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateDefaults #1#2
- { \@@_show_defaults:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateInterface #1#2
- { \@@_show_keytypes:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateVariables #1#2
- { \@@_show_vars:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowInstanceValues #1#2
- { \@@_show_values:nnn {#1} { } {#2} }
-\cs_new_protected:Npn \ShowCollectionInstanceValues #1#2#3
- { \@@_show_values:nnn {#1} {#2} {#3} }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\IfInstanceExistT, \IfInstanceExistF, \IfInstanceExistTF}
-% More direct translation: only the base instance is checked for.
-% \begin{macrocode}
-\cs_new:Npn \IfInstanceExistTF #1#2
- { \@@_if_instance_exist:nnnTF {#1} { } {#2} }
-\cs_new:Npn \IfInstanceExistT #1#2
- { \@@_if_instance_exist:nnnT {#1} { } {#2} }
-\cs_new:Npn \IfInstanceExistF #1#2
- { \@@_if_instance_exist:nnnF {#1} { } {#2} }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\KeyValue}
-% Simply dump the argument when executed: this should not happen.
-% \begin{macrocode}
-\cs_new_protected:Npn \KeyValue #1 {#1}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\AssignTemplateKeys}
-% A short call to use a token register by proxy.
-% \begin{macrocode}
-\cs_new_protected:Npn \AssignTemplateKeys
- { \@@_assignments_pop: }
+ { \@@_declare_type:nn {#1} {#2} }
+\ExplSyntaxOff
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\SetTemplateKeys}
-% A friendly wrapper
-% \begin{macrocode}
-\cs_new_protected:Npn \SetTemplateKeys #1#2#3
- { \keys_set_known:nnN { template / #1 / #2 } {#3} \l_@@_tmp_clist }
-% \end{macrocode}
% \end{macro}
%
-% \begin{macrocode}
-\cs_new_eq:NN \ShowTemplateKeytypes \ShowTemplateInterface
-% \end{macrocode}
-%
-% \begin{macrocode}
%</package>
% \end{macrocode}
%
diff --git a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.ins b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.ins
index 72bf777194f..eaf3fe0ead3 100644
--- a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.ins
+++ b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.ins
@@ -2,7 +2,7 @@
File: xtemplate.ins
-Copyright (C) 2000-2012,2016,2017,2019-2023 The LaTeX Project
+Copyright (C) 2000-2012,2016,2017,2019-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -34,7 +34,7 @@ license information is placed in the derived files.
\preamble
-Copyright (C) 2011-2023 The LaTeX Project
+Copyright (C) 2011-2024 The LaTeX Project
It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
index fde7919c757..31f4a2b13f9 100644
--- a/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
+++ b/Master/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
@@ -6,7 +6,7 @@
%%
%% l3keys2e.dtx (with options: `package')
%%
-%% Copyright (C) 2009-2023 The LaTeX Project
+%% Copyright (C) 2009-2024 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -32,7 +32,7 @@
}%
\endinput
}
-\ProvidesExplPackage{l3keys2e}{2023-10-10}{}
+\ProvidesExplPackage{l3keys2e}{2024-02-13}{}
{LaTeX2e option processing using LaTeX3 keys}
\cs_if_exist:NT \ProcessKeysOptions
{ \file_input_stop: }
diff --git a/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty b/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty
index d7f5038e6df..1204dfee658 100644
--- a/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty
+++ b/Master/texmf-dist/tex/latex/l3packages/xfp/xfp.sty
@@ -6,7 +6,7 @@
%%
%% xfp.dtx (with options: `package')
%%
-%% Copyright (C) 2017-2023 The LaTeX Project
+%% Copyright (C) 2017-2024 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -32,7 +32,7 @@
}%
\endinput
}
-\ProvidesExplPackage{xfp}{2023-10-10}{}
+\ProvidesExplPackage{xfp}{2024-02-13}{}
{L3 Floating point unit}
\ProvideExpandableDocumentCommand \fpeval { m } { \fp_eval:n {#1} }
\ProvideExpandableDocumentCommand \inteval { m } { \int_eval:n {#1} }
diff --git a/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty b/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty
deleted file mode 100644
index e6e40464d91..00000000000
--- a/Master/texmf-dist/tex/latex/l3packages/xfrac/xfrac.sty
+++ /dev/null
@@ -1,424 +0,0 @@
-%%
-%% This is file `xfrac.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% xfrac.dtx (with options: `package')
-%%
-%% Copyright (C) 2004,2008-2010 Morten Hoegholm
-%% (C) 2011-2023 The LaTeX Project
-%%
-%% It may be distributed and/or modified under the conditions of
-%% the LaTeX Project Public License (LPPL), either version 1.3c of
-%% this license or (at your option) any later version. The latest
-%% version of this license is in the file:
-%%
-%% http://www.latex-project.org/lppl.txt
-%%
-%% This file is part of the "l3packages bundle" (The Work in LPPL)
-%% and all files in that bundle must be distributed together.
-%%
-%% File: xfrac.dtx
-\RequirePackage{expl3}[2018/02/21]
-\@ifpackagelater{expl3}{2018/02/21}
- {}
- {%
- \PackageError{xfrac}{Support package l3kernel too old}
- {%
- Please install an up to date version of l3kernel\MessageBreak
- using your TeX package manager or from CTAN.\MessageBreak
- \MessageBreak
- Loading xfrac will abort!%
- }%
- \endinput
- }
-\RequirePackage{amstext,graphicx,l3keys2e,textcomp,xparse,xtemplate}
-\ProvidesExplPackage{xfrac}{2023-10-10}{}
- {L3 Experimental split-level fractions}
-\keys_define:nn { xfrac }
- {
- cm-recommended .choice:,
- cm-recommended /
- false .code:n =
- { \bool_set_true:N \l__xfrac_cm_std_bool },
- cm-recommended /
- true .code:n =
- { \bool_set_false:N \l__xfrac_cm_std_bool },
- cm-recommended .default:n = { true },
- cm-standard .bool_set:N = \l__xfrac_cm_std_bool
- }
-\ProcessKeysOptions { xfrac }
-\box_new:N \l__xfrac_slash_box
-\box_new:N \l__xfrac_tmp_box
-\cs_new:Npn \__xfrac_tmp:w { }
-\dim_new:N \l__xfrac_denominator_bot_sep_dim
-\dim_new:N \l__xfrac_numerator_bot_sep_dim
-\dim_new:N \l__xfrac_numerator_top_sep_dim
-\dim_new:N \l__xfrac_slash_left_sep_dim
-\dim_new:N \l__xfrac_slash_right_sep_dim
-\muskip_new:N \l__xfrac_slash_left_muskip
-\muskip_new:N \l__xfrac_slash_right_muskip
-\fp_new:N \l__xfrac_hscale_fp
-\fp_new:N \l__xfrac_scale_factor_fp
-\fp_new:N \l__xfrac_vscale_fp
-\tl_new:N \l__xfrac_denominator_font_tl
-\tl_new:N \l__xfrac_numerator_font_tl
-\tl_new:N \l__xfrac_phantom_tl
-\tl_new:N \l__xfrac_slash_symbol_tl
-\tl_new:N \l__xfrac_slash_symbol_font_tl
-\cs_new:Npn \__xfrac_fontscale: { }
-\cs_new:Npn \__xfrac_math:n #1 { }
-\cs_new:Npn \__xfrac_denominator_font_change: { }
-\cs_new:Npn \__xfrac_denominator_format:n #1 { }
-\cs_new:Npn \__xfrac_numerator_font_change: { }
-\cs_new:Npn \__xfrac_numerator_format:n #1 { }
-\cs_new:Npn \__xfrac_relscale: { }
-\cs_new:Npn \__xfrac_slash_symbol_font_change: { }
-\cs_new:Npn \__xfrac_slash_symbol_format:n #1 { }
-\cs_new:Npn \__xfrac_text_or_math:n #1 { }
-\DeclareObjectType { xfrac } { 3 }
-\DeclareTemplateInterface { xfrac } { text } { 3 }
- {
- denominator-bot-sep : length = \c_max_dim ,
- denominator-font : tokenlist = \f@family ,
- denominator-format : function 1 = #1 ,
- h-scale : real = 1 ,
- math-mode : choice { false , true }
- = false ,
- numerator-font : tokenlist = \f@family ,
- numerator-format : function 1 = #1 ,
- numerator-bot-sep : length = \c_max_dim ,
- numerator-top-sep : length = \c_max_dim ,
- phantom : tokenlist = 8 ,
- scale-factor : real = 0.83333 ,
- scale-relative : choice { false , true }
- = true ,
- scaling : choice { false , true }
- = true ,
- slash-left-kern : length = 0 pt ,
- slash-left-mkern : muskip = -2 mu ,
- slash-right-kern : length = 0 pt ,
- slash-right-mkern : muskip = -1 mu ,
- slash-symbol : tokenlist = \textfractionsolidus ,
- slash-symbol-font : tokenlist = \f@family ,
- slash-symbol-format : function 1 = #1 ,
- v-scale : real = 1 ,
- }
-\DeclareTemplateCode { xfrac } { text } { 3 }
- {
- denominator-bot-sep = \l__xfrac_denominator_bot_sep_dim ,
- denominator-font = \l__xfrac_denominator_font_tl ,
- denominator-format = \__xfrac_denominator_format:n ,
- h-scale = \l__xfrac_hscale_fp ,
- math-mode =
- {
- false = \cs_set_eq:NN \__xfrac_math:n \use:n,
- true = \cs_set_eq:NN \__xfrac_math:n \ensuremath
- },
- numerator-font = \l__xfrac_numerator_font_tl ,
- numerator-format = \__xfrac_numerator_format:n ,
- numerator-bot-sep = \l__xfrac_numerator_bot_sep_dim ,
- numerator-top-sep = \l__xfrac_numerator_top_sep_dim ,
- phantom = \l__xfrac_phantom_tl ,
- scale-factor = \l__xfrac_scale_factor_fp ,
- scale-relative =
- {
- false =
- \cs_set:Npn \__xfrac_relscale:
- {
- \dim_eval:n
- { \box_ht:N \l__xfrac_tmp_box + \box_dp:N \l__xfrac_tmp_box }
- },
- true =
- \cs_set:Npn \__xfrac_relscale:
- { \dim_eval:n { \box_ht:N \l__xfrac_slash_box } }
- },
- scaling =
- {
- false = \cs_set_eq:NN \__xfrac_fontscale: \prg_do_nothing:,
- true =
- \cs_set:Npn \__xfrac_fontscale:
- {
- \fontsize
- { \fp_to_dim:n { \l__xfrac_scale_factor_fp * \__xfrac_relscale: } }
- { \c_zero_dim }
- \selectfont
- }
- },
- slash-left-kern = \l__xfrac_slash_left_sep_dim ,
- slash-left-mkern = \l__xfrac_slash_left_muskip ,
- slash-right-kern = \l__xfrac_slash_right_sep_dim ,
- slash-right-mkern = \l__xfrac_slash_right_muskip ,
- slash-symbol = \l__xfrac_slash_symbol_tl ,
- slash-symbol-font = \l__xfrac_slash_symbol_font_tl ,
- slash-symbol-format = \__xfrac_slash_symbol_format:n ,
- v-scale = \l__xfrac_vscale_fp
- }
- {
- \mode_if_math:TF
- {
- \cs_set_eq:NN \__xfrac_text_or_math:n \text
- \cs_set:Npe \__xfrac_denominator_font_change:
- { \tex_fam:D \l__xfrac_denominator_font_tl }
- \cs_set:Npe \__xfrac_numerator_font_change:
- { \tex_fam:D \l__xfrac_numerator_font_tl }
- \cs_set:Npe \__xfrac_slash_symbol_font_change:
- { \tex_fam:D \l__xfrac_slash_symbol_font_tl }
- }
- {
- \cs_set_eq:NN \__xfrac_text_or_math:n \mbox
- \cs_set:Npn \__xfrac_denominator_font_change:
- {
- \fontfamily { \l__xfrac_denominator_font_tl }
- \selectfont
- }
- \cs_set:Npn \__xfrac_numerator_font_change:
- {
- \fontfamily { \l__xfrac_numerator_font_tl }
- \selectfont
- }
- \cs_set:Npn \__xfrac_slash_symbol_font_change:
- {
- \fontfamily { \l__xfrac_slash_symbol_font_tl }
- \selectfont
- }
- }
- \__xfrac_text_or_math:n
- {
- \m@th
- \hbox_set:Nn \l__xfrac_tmp_box
- { \__xfrac_math:n { \vphantom { ( ) } } }
- \hbox_set:Nn \l__xfrac_slash_box
- {
- \__xfrac_math:n
- {
- \__xfrac_slash_symbol_format:n
- {
- \__xfrac_math:n
- {
- \__xfrac_slash_symbol_font_change:
- \IfNoValueTF {#2}
- { \l__xfrac_slash_symbol_tl } {#2}
- }
- }
- }
- }
- \cs_set:Npn \__xfrac_tmp:w
- {
- \raisebox
- {
- \dim_eval:n
- {
- \box_ht:N \l__xfrac_slash_box
- - \box_dp:N \l__xfrac_slash_box
- - \height
- }
- }
- }
- \dim_compare:nNnTF
- { \l__xfrac_numerator_top_sep_dim } = { \c_max_dim }
- {
- \dim_compare:nNnF
- { \l__xfrac_numerator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \__xfrac_tmp:w
- {
- \raisebox
- { \dim_use:N \l__xfrac_numerator_bot_sep_dim }
- }
- }
- }
- {
- \dim_compare:nNnTF
- { \l__xfrac_numerator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \__xfrac_tmp:w
- {
- \raisebox
- {
- \dim_eval:n
- {
- \box_ht:N \l__xfrac_slash_box
- - \dim_use:N \l__xfrac_numerator_top_sep_dim
- - \height
- }
- }
- }
- }
- {
- \msg_error:nn { xfrac }
- { over-specified-numerator-sep }
- }
- }
- \__xfrac_tmp:w
- {
- \__xfrac_fontscale:
- \__xfrac_numerator_format:n
- {
- \scalebox
- { \fp_use:N \l__xfrac_hscale_fp }
- [ \fp_use:N \l__xfrac_vscale_fp ]
- {
- \__xfrac_math:n
- {
- \__xfrac_numerator_font_change:
- {
- \vphantom { \l__xfrac_phantom_tl }
- #1
- }
- }
- }
- }
- }
- \__xfrac_math:n
- { % THIS IS JUST WRONG!
- \mode_if_math:TF
- { \tex_mskip:D \l__xfrac_slash_right_muskip }
- { \tex_hskip:D \l__xfrac_slash_right_sep_dim }
- }
- \box_use:N \l__xfrac_slash_box
- \__xfrac_math:n
- {
- \mode_if_math:TF
- { \tex_mskip:D \l__xfrac_slash_left_muskip }
- { \tex_hskip:D \l__xfrac_slash_left_sep_dim }
- }
- \dim_compare:nNnTF
- { \l__xfrac_denominator_bot_sep_dim } = { \c_max_dim }
- {
- \cs_set:Npn \__xfrac_tmp:w
- { \raisebox { - \box_dp:N \l__xfrac_slash_box } }
- }
- {
- \cs_set:Npn \__xfrac_tmp:w
- {
- \raisebox
- { \dim_use:N \l__xfrac_denominator_bot_sep_dim }
- }
- }
- \__xfrac_tmp:w
- {
- \__xfrac_fontscale:
- \__xfrac_denominator_format:n
- {
- \scalebox
- { \fp_use:N \l__xfrac_hscale_fp }
- [ \fp_use:N \l__xfrac_vscale_fp ]
- {
- \__xfrac_math:n
- {
- \__xfrac_denominator_font_change:
- {
- \vphantom { \l__xfrac_phantom_tl }
- #3
- }
- }
- }
- }
- }
- }
- }
-\DeclareRestrictedTemplate { xfrac } { text } { math }
- {
- numerator-font = \number \fam ,
- slash-symbol = / ,
- slash-symbol-font = \number \fam ,
- denominator-font = \number \fam ,
- scale-factor = 0.7 ,
- scale-relative = false ,
- scaling = true ,
- denominator-bot-sep = 0 pt ,
- math-mode = true ,
- phantom = ( % )
- }
-\DeclareInstance { xfrac } { default } { text } { }
-\DeclareInstance { xfrac } { mathdefault } { math }
- { numerator-top-sep = 0pt }
-\DeclareCollectionInstance { plainmath } { xfrac } { mathdefault } { math }
- {
- numerator-bot-sep = 0 pt ,
- numerator-top-sep = \c_max_dim ,
- scale-factor = 1 ,
- scale-relative = false ,
- scaling = true ,
- slash-right-mkern = 0 mu ,
- slash-left-mkern = 0 mu
- }
-\DeclareInstance { xfrac } { cmr } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-\DeclareInstance { xfrac } { cmss } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-\DeclareInstance { xfrac } { cmtt } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.2 ex ,
- slash-left-kern = -0.1 em ,
- slash-right-kern = -0.1 em
- }
-\bool_if:NF \l__xfrac_cm_std_bool
- {
- \DeclareInstance { xfrac } { cmr } { text }
- { slash-symbol-font = ptm }
- \DeclareInstance { xfrac } { cmss } { text }
- { slash-symbol-font = ptm }
- \DeclareInstance { xfrac } { cmtt } { text }
- { slash-symbol-font = ppl }
- }
-\DeclareInstance { xfrac } { lmr } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0.1 ex ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-\DeclareInstance { xfrac } { lmss } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0 pt ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-\DeclareInstance { xfrac } { lmtt } { text }
- {
- denominator-bot-sep = 0 pt ,
- numerator-top-sep = 0 pt ,
- slash-left-kern = -0.15 em ,
- slash-right-kern = -0.15 em
- }
-\NewDocumentCommand \sfrac { o m o m }
- {
- \mode_if_math:TF
- {
- \IfInstanceExistTF { xfrac } { mathfam \number \fam }
- { \UseInstance { xfrac } { mathfam \number \fam } }
- { \UseInstance { xfrac } { mathdefault } }
- {#2} {#3} {#4}
- }
- {
- \IfInstanceExistTF { xfrac } {#1}
- { \UseInstance { xfrac } {#1} }
- {
- \IfInstanceExistTF { xfrac } { \f@family }
- { \UseInstance { xfrac } { \f@family } }
- { \UseInstance { xfrac } { default } }
- }
- {#2} {#3} {#4}
- }
- }
-\msg_new:nnnn { xfrac } { over-specified-numerator-sep }
- { You~have~specified~both~"numerator-top-sep"~and~"numerator-bot-sep". }
- { I~will~pretend~that~you~didn't~specify~either~of~them. }
-%%
-%%
-%% End of file `xfrac.sty'.
diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.ltx b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.ltx
index f7bf6c7be35..7f454c20b11 100644
--- a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.ltx
+++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.ltx
@@ -6,7 +6,7 @@
%%
%% xparse.dtx (with options: `2ekernel')
%%
-%% Copyright (C) 2009-2023 The LaTeX Project
+%% Copyright (C) 2009-2024 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
diff --git a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
index 6dd25e9b1b3..1e256dd4c01 100644
--- a/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
+++ b/Master/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
@@ -6,7 +6,7 @@
%%
%% xparse.dtx (with options: `package')
%%
-%% Copyright (C) 2009-2023 The LaTeX Project
+%% Copyright (C) 2009-2024 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -60,7 +60,7 @@
}
}
\ExplSyntaxOff
-\ProvidesExplPackage{xparse}{2023-10-10}{}
+\ProvidesExplPackage{xparse}{2024-02-13}{}
{L3 Experimental document command parser}
\clist_new:N \l__cmd_options_clist
\DeclareOption* { \clist_put_right:NV \l__cmd_options_clist \CurrentOption }
diff --git a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-2023-10-10.sty b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-2023-10-10.sty
new file mode 100644
index 00000000000..a0a91afd814
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate-2023-10-10.sty
@@ -0,0 +1,1371 @@
+%%
+%% This is file `xtemplate-2023-10-10.sty', generated from
+%% xtemplate.dtx (with options: `package' on 2023-11-14)
+%% then adapted and frozen for compatibility. Development of
+%% xtemplate.dtx will continue in the LaTeX2e kernel as lttemplates.dtx.
+%%
+%% Copyright (C) 2011-2023 The LaTeX Project
+%%
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version. The latest
+%% version of this license is in the file:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This file is part of the "l3packages bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%%
+%% File: xtemplate.dtx
+\RequirePackage{expl3}[2018/02/21]
+\@ifpackagelater{expl3}{2018/02/21}
+ {}
+ {%
+ \PackageError{xtemplate}{Support package l3kernel too old}
+ {%
+ Please install an up to date version of l3kernel\MessageBreak
+ using your TeX package manager or from CTAN.\MessageBreak
+ \MessageBreak
+ Loading xtemplate will abort!%
+ }%
+ \endinput
+ }
+\ProvidesExplPackage{xtemplate}{2023-10-10}{}
+ {L3 Experimental prototype document functions}
+\tl_const:Nn \c__xtemplate_code_root_tl { template~code~>~ }
+\tl_const:Nn \c__xtemplate_defaults_root_tl { template~defaults~>~ }
+\tl_const:Nn \c__xtemplate_instances_root_tl { template~instance~>~ }
+\tl_const:Nn \c__xtemplate_keytypes_root_tl { template~key~types~>~ }
+\tl_const:Nn \c__xtemplate_key_order_root_tl { template~key~order~>~ }
+\tl_const:Nn \c__xtemplate_restrict_root_tl { template~restrictions~>~ }
+\tl_const:Nn \c__xtemplate_values_root_tl { template~values~>~ }
+\tl_const:Nn \c__xtemplate_vars_root_tl { template~vars~>~ }
+\seq_const_from_clist:Nn \c__xtemplate_keytypes_arg_seq
+ { choice , function , instance }
+\prop_new:N \g__xtemplate_object_type_prop
+\tl_new:N \l__xtemplate_assignments_tl
+\tl_new:N \l__xtemplate_collection_tl
+\prop_new:N \l__xtemplate_collections_prop
+\tl_new:N \l__xtemplate_default_tl
+\bool_new:N \l__xtemplate_error_bool
+\bool_new:N \l__xtemplate_global_bool
+\bool_new:N \l__xtemplate_restrict_bool
+\clist_new:N \l__xtemplate_restrict_clist
+\tl_new:N \l__xtemplate_key_name_tl
+\tl_new:N \l__xtemplate_keytype_tl
+\tl_new:N \l__xtemplate_keytype_arg_tl
+\tl_new:N \l__xtemplate_value_tl
+\tl_new:N \l__xtemplate_var_tl
+\prop_new:N \l__xtemplate_keytypes_prop
+\seq_new:N \l__xtemplate_key_order_seq
+\prop_new:N \l__xtemplate_values_prop
+\prop_new:N \l__xtemplate_vars_prop
+\clist_new:N \l__xtemplate_tmp_clist
+\dim_new:N \l__xtemplate_tmp_dim
+\int_new:N \l__xtemplate_tmp_int
+\muskip_new:N \l__xtemplate_tmp_muskip
+\skip_new:N \l__xtemplate_tmp_skip
+\tl_new:N \l__xtemplate_tmp_tl
+\scan_new:N \s__xtemplate_mark
+\scan_new:N \s__xtemplate_stop
+\quark_new:N \q__xtemplate_nil
+\__kernel_quark_new_conditional:Nn \__xtemplate_quark_if_nil:N { F }
+\cs_generate_variant:Nn \prop_get:NnNTF { No }
+\cs_generate_variant:Nn \prop_get:NnNT { No }
+\cs_generate_variant:Nn \prop_get:NnNF { No }
+\cs_new_protected:Npn \__xtemplate_execute_if_arg_agree:nnT #1#2#3
+ {
+ \prop_get:NnN \g__xtemplate_object_type_prop {#1} \l__xtemplate_tmp_tl
+ \int_compare:nNnTF {#2} = \l__xtemplate_tmp_tl
+ {#3}
+ {
+ \msg_error:nneee { xtemplate }
+ { argument-number-mismatch } {#1} { \l__xtemplate_tmp_tl } {#2}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_execute_if_code_exist:nnT #1#2#3
+ {
+ \cs_if_exist:cTF { \c__xtemplate_code_root_tl #1 / #2 }
+ {#3}
+ {
+ \msg_error:nnee { xtemplate } { no-template-code }
+ {#1} {#2}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_execute_if_keytype_exist:nT #1#2
+ {
+ \cs_if_exist:cTF { __xtemplate_store_value_ #1 :n }
+ {#2}
+ { \msg_error:nne { xtemplate } { unknown-keytype } {#1} }
+ }
+\cs_generate_variant:Nn \__xtemplate_execute_if_keytype_exist:nT { o }
+\cs_new_protected:Npn \__xtemplate_execute_if_type_exist:nT #1#2
+ {
+ \prop_if_in:NnTF \g__xtemplate_object_type_prop {#1}
+ {#2}
+ { \msg_error:nne { xtemplate } { unknown-object-type } {#1} }
+ }
+\cs_new_protected:Npn \__xtemplate_if_keys_exist:nnT #1#2#3
+ {
+ \cs_if_exist:cTF { \c__xtemplate_keytypes_root_tl #1 / #2 }
+ {#3}
+ {
+ \msg_error:nnee { xtemplate } { unknown-template }
+ {#1} {#2}
+ }
+ }
+\prg_new_conditional:Npnn \__xtemplate_if_key_value:n #1 { T , F , TF }
+ {
+ \str_if_eq:noTF { \KeyValue } { \tl_head:w #1 \q_nil \q_stop }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_generate_variant:Nn \__xtemplate_if_key_value:nT { o }
+\cs_generate_variant:Nn \__xtemplate_if_key_value:nF { o }
+\cs_generate_variant:Nn \__xtemplate_if_key_value:nTF { o }
+\prg_new_conditional:Npnn \__xtemplate_if_instance_exist:nnn #1#2#3
+ { T, F, TF }
+ {
+ \cs_if_exist:cTF { \c__xtemplate_instances_root_tl #1 / #2 / #3 }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\prg_new_conditional:Npnn \__xtemplate_if_use_template:n #1 { TF }
+ {
+ \str_if_eq:noTF { \UseTemplate } { \tl_head:w #1 \q_nil \q_stop }
+ { \prg_return_true: }
+ { \prg_return_false: }
+}
+\cs_new_protected:Npn \__xtemplate_store_defaults:n #1
+ {
+ \prop_gclear_new:c { \c__xtemplate_defaults_root_tl #1 }
+ \prop_gset_eq:cN { \c__xtemplate_defaults_root_tl #1 }
+ \l__xtemplate_values_prop
+ }
+\cs_new_protected:Npn \__xtemplate_store_keytypes:n #1
+ {
+ \prop_gclear_new:c { \c__xtemplate_keytypes_root_tl #1 }
+ \prop_gset_eq:cN { \c__xtemplate_keytypes_root_tl #1 }
+ \l__xtemplate_keytypes_prop
+ \seq_gclear_new:c { \c__xtemplate_key_order_root_tl #1 }
+ \seq_gset_eq:cN { \c__xtemplate_key_order_root_tl #1 }
+ \l__xtemplate_key_order_seq
+ }
+\cs_new_protected:Npn \__xtemplate_store_values:n #1
+ {
+ \prop_clear_new:c { \c__xtemplate_values_root_tl #1 }
+ \prop_set_eq:cN { \c__xtemplate_values_root_tl #1 }
+ \l__xtemplate_values_prop
+ }
+\cs_new_protected:Npn \__xtemplate_store_restrictions:n #1
+ {
+ \clist_gclear_new:c { \c__xtemplate_restrict_root_tl #1 }
+ \clist_gset_eq:cN { \c__xtemplate_restrict_root_tl #1 }
+ \l__xtemplate_restrict_clist
+ }
+\cs_new_protected:Npn \__xtemplate_store_vars:n #1
+ {
+ \prop_gclear_new:c { \c__xtemplate_vars_root_tl #1 }
+ \prop_gset_eq:cN { \c__xtemplate_vars_root_tl #1 }
+ \l__xtemplate_vars_prop
+ }
+\cs_new_protected:Npn \__xtemplate_recover_defaults:n #1
+ {
+ \prop_if_exist:cTF
+ { \c__xtemplate_defaults_root_tl #1 }
+ {
+ \prop_set_eq:Nc \l__xtemplate_values_prop
+ { \c__xtemplate_defaults_root_tl #1 }
+ }
+ { \prop_clear:N \l__xtemplate_values_prop }
+ }
+\cs_new_protected:Npn \__xtemplate_recover_keytypes:n #1
+ {
+ \prop_if_exist:cTF
+ { \c__xtemplate_keytypes_root_tl #1 }
+ {
+ \prop_set_eq:Nc \l__xtemplate_keytypes_prop
+ { \c__xtemplate_keytypes_root_tl #1 }
+ }
+ { \prop_clear:N \l__xtemplate_keytypes_prop }
+ \seq_if_exist:cTF { \c__xtemplate_key_order_root_tl #1 }
+ {
+ \seq_set_eq:Nc \l__xtemplate_key_order_seq
+ { \c__xtemplate_key_order_root_tl #1 }
+ }
+ { \seq_clear:N \l__xtemplate_key_order_seq }
+ }
+\cs_new_protected:Npn \__xtemplate_recover_restrictions:n #1
+ {
+ \clist_if_exist:cTF
+ { \c__xtemplate_restrict_root_tl #1 }
+ {
+ \clist_set_eq:Nc \l__xtemplate_restrict_clist
+ { \c__xtemplate_restrict_root_tl #1 }
+ }
+ { \clist_clear:N \l__xtemplate_restrict_clist }
+ }
+\cs_new_protected:Npn \__xtemplate_recover_values:n #1
+ {
+ \prop_if_exist:cTF
+ { \c__xtemplate_values_root_tl #1 }
+ {
+ \prop_set_eq:Nc \l__xtemplate_values_prop
+ { \c__xtemplate_values_root_tl #1 }
+ }
+ { \prop_clear:N \l__xtemplate_values_prop }
+ }
+\cs_new_protected:Npn \__xtemplate_recover_vars:n #1
+ {
+ \prop_if_exist:cTF
+ { \c__xtemplate_vars_root_tl #1 }
+ {
+ \prop_set_eq:Nc \l__xtemplate_vars_prop
+ { \c__xtemplate_vars_root_tl #1 }
+ }
+ { \prop_clear:N \l__xtemplate_vars_prop }
+ }
+\cs_new_protected:Npn \__xtemplate_declare_object_type:nn #1#2
+ {
+ \int_set:Nn \l__xtemplate_tmp_int {#2}
+ \int_compare:nTF { 0 <= \l__xtemplate_tmp_int <= 9 }
+ {
+ \msg_info:nnnV { xtemplate } { declare-object-type }
+ {#1} \l__xtemplate_tmp_int
+ \prop_gput:NnV \g__xtemplate_object_type_prop {#1}
+ \l__xtemplate_tmp_int
+ }
+ {
+ \msg_error:nnee { xtemplate } { bad-number-of-arguments }
+ {#1} { \exp_not:V \l__xtemplate_tmp_int }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_declare_template_keys:nnnn #1#2#3#4
+ {
+ \__xtemplate_execute_if_type_exist:nT {#1}
+ {
+ \__xtemplate_execute_if_arg_agree:nnT {#1} {#3}
+ {
+ \prop_clear:N \l__xtemplate_values_prop
+ \prop_clear:N \l__xtemplate_keytypes_prop
+ \seq_clear:N \l__xtemplate_key_order_seq
+ \keyval_parse:NNn
+ \__xtemplate_parse_keys_elt:n \__xtemplate_parse_keys_elt:nn {#4}
+ \__xtemplate_store_defaults:n { #1 / #2 }
+ \__xtemplate_store_keytypes:n { #1 / #2 }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_keys_elt:n #1
+ {
+ \__xtemplate_split_keytype:n {#1}
+ \bool_if:NF \l__xtemplate_error_bool
+ {
+ \__xtemplate_execute_if_keytype_exist:oT \l__xtemplate_keytype_tl
+ {
+ \seq_map_function:NN \c__xtemplate_keytypes_arg_seq
+ \__xtemplate_parse_keys_elt_aux:n
+ \bool_if:NF \l__xtemplate_error_bool
+ {
+ \seq_if_in:NoTF \l__xtemplate_key_order_seq
+ \l__xtemplate_key_name_tl
+ {
+ \msg_error:nne { xtemplate }
+ { duplicate-key-interface }
+ { \l__xtemplate_key_name_tl }
+ }
+ { \__xtemplate_parse_keys_elt_aux: }
+ }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_keys_elt_aux:n #1
+ {
+ \str_if_eq:onT \l__xtemplate_keytype_tl {#1}
+ {
+ \tl_if_empty:NT \l__xtemplate_keytype_arg_tl
+ {
+ \msg_error:nne { xtemplate }
+ { keytype-requires-argument } {#1}
+ \bool_set_true:N \l__xtemplate_error_bool
+ \seq_map_break:
+ }
+ }
+ }
+\cs_new:Npn \__xtemplate_parse_keys_elt_aux:
+ {
+ \tl_set:Ne \l__xtemplate_tmp_tl
+ {
+ \l__xtemplate_keytype_tl
+ \tl_if_empty:NF \l__xtemplate_keytype_arg_tl
+ { { \l__xtemplate_keytype_arg_tl } }
+ }
+ \prop_put:Noo \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \seq_put_right:No \l__xtemplate_key_order_seq \l__xtemplate_key_name_tl
+ \str_if_eq:onT \l__xtemplate_keytype_tl { choice }
+ {
+ \exp_args:No \clist_if_in:nnT \l__xtemplate_keytype_arg_tl { unknown }
+ { \msg_error:nn { xtemplate } { choice-unknown-reserved } }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_keys_elt:nn #1#2
+ {
+ \__xtemplate_parse_keys_elt:n {#1}
+ \use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#2}
+ }
+\cs_new_protected:Npe \__xtemplate_split_keytype:n #1
+ {
+ \exp_not:N \bool_set_false:N \exp_not:N \l__xtemplate_error_bool
+ \tl_set:Nn \exp_not:N \l__xtemplate_tmp_tl {#1}
+ \tl_replace_all:Nnn \exp_not:N \l__xtemplate_tmp_tl { : } { \token_to_str:N : }
+ \tl_if_in:onTF \exp_not:N \l__xtemplate_tmp_tl { \token_to_str:N : }
+ {
+ \exp_not:n
+ {
+ \tl_clear:N \l__xtemplate_key_name_tl
+ \exp_after:wN \__xtemplate_split_keytype_aux:w
+ \l__xtemplate_tmp_tl \s__xtemplate_stop
+ }
+ }
+ {
+ \exp_not:N \bool_set_true:N \exp_not:N \l__xtemplate_error_bool
+ \msg_error:nne { xtemplate } { missing-keytype } {#1}
+ }
+ }
+\use:e
+ {
+ \cs_new_protected:Npn \exp_not:N \__xtemplate_split_keytype_aux:w
+ #1 \token_to_str:N : #2 \s__xtemplate_stop
+ {
+ \tl_put_right:Ne \exp_not:N \l__xtemplate_key_name_tl
+ {
+ \exp_not:N \tl_trim_spaces:e
+ { \exp_not:N \tl_to_str:n {#1} }
+ }
+ \tl_if_in:nnTF {#2} { \token_to_str:N : }
+ {
+ \tl_put_right:Nn \exp_not:N \l__xtemplate_key_name_tl
+ { \token_to_str:N : }
+ \exp_not:N \__xtemplate_split_keytype_aux:w #2 \s__xtemplate_stop
+ }
+ {
+ \exp_not:N \tl_if_empty:NTF \exp_not:N \l__xtemplate_key_name_tl
+ {
+ \msg_error:nne { xtemplate } { empty-key-name }
+ { \token_to_str:N : #2 }
+ }
+ { \exp_not:N \__xtemplate_split_keytype_arg:n {#2} }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_split_keytype_arg:n #1
+ {
+ \tl_set:Ne \l__xtemplate_keytype_tl { \tl_trim_spaces:n {#1} }
+ \tl_clear:N \l__xtemplate_keytype_arg_tl
+ \cs_set_protected:Npn \__xtemplate_split_keytype_arg_aux:n ##1
+ {
+ \tl_if_in:nnT {#1} {##1}
+ {
+ \cs_set:Npn \__xtemplate_split_keytype_arg_aux:w
+ ####1 ##1 ####2 \s__xtemplate_stop
+ {
+ \tl_if_blank:nT {####1}
+ {
+ \tl_set:Ne \l__xtemplate_keytype_tl
+ { \tl_trim_spaces:n {##1} }
+ \tl_if_blank:nF {####2}
+ {
+ \tl_set:Ne \l__xtemplate_keytype_arg_tl
+ { \use:n ####2 }
+ }
+ \seq_map_break:
+ }
+ }
+ \__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop
+ }
+ }
+ \seq_map_function:NN \c__xtemplate_keytypes_arg_seq
+ \__xtemplate_split_keytype_arg_aux:n
+ }
+\cs_generate_variant:Nn \__xtemplate_split_keytype_arg:n { o }
+\cs_new:Npn \__xtemplate_split_keytype_arg_aux:n #1 { }
+\cs_new:Npn \__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop { }
+\cs_new_protected:Npn \__xtemplate_store_value_boolean:n #1
+ { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} }
+\cs_new_protected:Npn \__xtemplate_store_value:n #1
+ { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} }
+\cs_new_eq:NN \__xtemplate_store_value_choice:n \__xtemplate_store_value:n
+\cs_new_eq:NN \__xtemplate_store_value_function:n \__xtemplate_store_value:n
+\cs_new_eq:NN \__xtemplate_store_value_instance:n \__xtemplate_store_value:n
+\cs_new_protected:Npn \__xtemplate_store_value_aux:Nn #1#2
+ { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#2} }
+\cs_new_protected:Npn \__xtemplate_store_value_integer:n
+ { \__xtemplate_store_value_aux:Nn \int_eval:n }
+\cs_new_protected:Npn \__xtemplate_store_value_length:n
+ { \__xtemplate_store_value_aux:Nn \dim_eval:n }
+\cs_new_protected:Npn \__xtemplate_store_value_muskip:n
+ { \__xtemplate_store_value_aux:Nn \muskip_eval:n }
+\cs_new_protected:Npn \__xtemplate_store_value_real:n
+ { \__xtemplate_store_value_aux:Nn \fp_eval:n }
+\cs_new_protected:Npn \__xtemplate_store_value_skip:n
+ { \__xtemplate_store_value_aux:Nn \skip_eval:n }
+\cs_new_protected:Npn \__xtemplate_store_value_tokenlist:n
+ { \__xtemplate_store_value_aux:Nn \use:n }
+\cs_new_eq:NN \__xtemplate_store_value_commalist:n \__xtemplate_store_value_tokenlist:n
+\cs_new_protected:Npn \__xtemplate_declare_template_code:nnnnn #1#2#3#4#5
+ {
+ \__xtemplate_execute_if_type_exist:nT {#1}
+ {
+ \__xtemplate_execute_if_arg_agree:nnT {#1}{#3}
+ {
+ \__xtemplate_if_keys_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_store_key_implementation:nnn {#1} {#2} {#4}
+ \regex_match:nnTF { \c { AssignTemplateKeys } } {#5}
+ { \__xtemplate_declare_template_code:nnn { #1 / #2 } {#3} {#5} }
+ {
+ \__xtemplate_declare_template_code:nnn
+ { #1 / #2 } {#3} { \AssignTemplateKeys #5 }
+ }
+ }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_declare_template_code:nnn #1#2#3
+ {
+ \cs_generate_from_arg_count:cNnn
+ { \c__xtemplate_code_root_tl #1 }
+ \cs_gset_protected:Npn {#2} {#3}
+ }
+\cs_new_protected:Npn \__xtemplate_store_key_implementation:nnn #1#2#3
+ {
+ \__xtemplate_recover_defaults:n { #1 / #2 }
+ \__xtemplate_recover_restrictions:n { #1 / #2 }
+ \__xtemplate_recover_keytypes:n { #1 / #2 }
+ \prop_clear:N \l__xtemplate_vars_prop
+ \keyval_parse:nnn
+ { \__xtemplate_parse_vars_elt:n } { \__xtemplate_parse_vars_elt:nnn { #1 / #2 } } {#3}
+ \__xtemplate_store_vars:n { #1 / #2 }
+ \__xtemplate_store_restrictions:n { #1 / #2 }
+ \prop_map_inline:Nn \l__xtemplate_keytypes_prop
+ {
+ \msg_error:nneee { xtemplate } { key-not-implemented }
+ {##1} {#2} {#1}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt:n #1
+ { \msg_error:nne { xtemplate } { key-no-variable } {#1} }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt:nnn #1#2#3
+ {
+ \tl_set:Ne \l__xtemplate_key_name_tl
+ { \tl_trim_spaces:e { \tl_to_str:n {#2} } }
+ \prop_get:NoNTF
+ \l__xtemplate_keytypes_prop
+ \l__xtemplate_key_name_tl
+ \l__xtemplate_keytype_tl
+ {
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_keytype_tl
+ \__xtemplate_parse_vars_elt_aux:nn {#1} {#3}
+ \prop_remove:NV \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ }
+ { \msg_error:nne { xtemplate } { unknown-key } {#2} }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nn #1#2
+ {
+ \__xtemplate_parse_vars_elt_aux:nw {#1} #2 global global \s__xtemplate_stop
+ }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nw
+ #1#2 global #3 global #4 \s__xtemplate_stop
+ {
+ \tl_if_blank:nTF {#4}
+ { \__xtemplate_parse_vars_elt_aux:nnn {#1} { } {#2} }
+ {
+ \tl_if_blank:nTF {#2}
+ {
+ \exp_args:Nnne \__xtemplate_parse_vars_elt_aux:nnn
+ {#1} { global } { \tl_trim_spaces:n {#3} }
+ }
+ { \msg_error:nnn { xtemplate } { bad-variable } { #2 global #3 } }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nnn #1#2#3
+ {
+ \str_case:VnF \l__xtemplate_keytype_tl
+ {
+ { choice } { \__xtemplate_implement_choices:nn {#1} {#3} }
+ { function }
+ {
+ \cs_if_exist:NF #3
+ { \cs_new:Npn #3 { } }
+ \__xtemplate_parse_vars_elt_key:nn {#1}
+ {
+ .code:n =
+ {
+ \cs_generate_from_arg_count:NNnn
+ \exp_not:N #3
+ \exp_not:c
+ { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
+ { \exp_not:o \l__xtemplate_keytype_arg_tl }
+ {##1}
+ }
+ }
+ \prop_put:Non \l__xtemplate_vars_prop
+ \l__xtemplate_key_name_tl {#2#3}
+ }
+ { instance }
+ {
+ \__xtemplate_parse_vars_elt_key:nn {#1}
+ {
+ .code:n =
+ {
+ \exp_not:c
+ { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
+ \exp_not:N #3 { \UseInstance {##1} }
+ }
+ }
+ \prop_put:Non \l__xtemplate_vars_prop
+ \l__xtemplate_key_name_tl {#2#3}
+ }
+ }
+ {
+ \tl_if_single:nTF {#3}
+ {
+ \cs_if_exist:NF #3
+ { \use:c { \__xtemplate_map_var_type: _new:N } #3 }
+ \__xtemplate_parse_vars_elt_key:nn {#1}
+ {
+ . \__xtemplate_map_var_type:
+ _ \str_if_eq:nnT {#1} { global } { g } set:N
+ = \exp_not:N #3
+ }
+ \prop_put:Non \l__xtemplate_vars_prop
+ \l__xtemplate_key_name_tl {#2#3}
+ }
+ { \msg_error:nne { xtemplate } { bad-variable } { #2#3 } }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_vars_elt_key:nn #1#2
+ {
+ \keys_define:ne { template / #1 }
+ { \l__xtemplate_key_name_tl #2 }
+ }
+\cs_new:Npn \__xtemplate_map_var_type:
+ {
+ \str_case:on \l__xtemplate_keytype_tl
+ {
+ { boolean } { bool }
+ { commalist } { clist }
+ { integer } { int }
+ { length } { dim }
+ { muskip } { muskip }
+ { real } { fp }
+ { skip } { skip }
+ { tokenlist } { tl }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_implement_choices:nn #1#2
+ {
+ \clist_set:No \l__xtemplate_tmp_clist { \l__xtemplate_keytype_arg_tl }
+ \prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_key_name_tl { }
+ \keys_define:ne { template / #1 } { \l__xtemplate_key_name_tl .choice: }
+ \keyval_parse:nnn
+ { \__xtemplate_implement_choice_elt:n }
+ { \__xtemplate_implement_choice_elt:nnn {#1} }
+ {#2}
+ \prop_get:NoNT \l__xtemplate_values_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ { \__xtemplate_implement_choices_default: }
+ \clist_if_empty:NF \l__xtemplate_tmp_clist
+ {
+ \clist_map_inline:Nn \l__xtemplate_tmp_clist
+ {
+ \msg_error:nne { xtemplate } { choice-not-implemented }
+ {##1}
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_implement_choices_default:
+ {
+ \tl_set:Ne \l__xtemplate_tmp_tl
+ { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl }
+ \prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl
+ {
+ \tl_set:Ne \l__xtemplate_tmp_tl
+ { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl }
+ \prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl
+ {
+ \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
+ \prop_get:NoN \l__xtemplate_values_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \msg_error:nneee { xtemplate } { unknown-default-choice }
+ { \l__xtemplate_key_name_tl } { \l__xtemplate_key_name_tl }
+ { \l__xtemplate_keytype_arg_tl }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_implement_choice_elt:nnn #1#2#3
+ {
+ \clist_if_empty:NTF \l__xtemplate_tmp_clist
+ {
+ \str_if_eq:nnTF {#2} { unknown }
+ { \__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3} }
+ {
+ \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
+ \msg_error:nneee { xtemplate } { unknown-choice }
+ { \l__xtemplate_key_name_tl } {#2}
+ { \l__xtemplate_keytype_arg_tl }
+ }
+ }
+ {
+ \clist_if_in:NnTF \l__xtemplate_tmp_clist {#2}
+ {
+ \clist_remove_all:Nn \l__xtemplate_tmp_clist {#2}
+ \__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3}
+ }
+ {
+ \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
+ \msg_error:nneee { xtemplate } { unknown-choice }
+ { \l__xtemplate_key_name_tl } {#2}
+ { \l__xtemplate_keytype_arg_tl }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_implement_choice_elt_aux:nnn #1#2#3
+ {
+ \keys_define:ne { template / #1 }
+ { \l__xtemplate_key_name_tl / #2 .code:n = { \exp_not:n {#3} } }
+ \tl_set:Ne \l__xtemplate_tmp_tl
+ { \l__xtemplate_key_name_tl \c_space_tl #2 }
+ \prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_tmp_tl {#3}
+ }
+\cs_new_protected:Npn \__xtemplate_implement_choice_elt:n #1
+ {
+ \msg_error:nneee { xtemplate } { choice-requires-code }
+ { \l__xtemplate_key_name_tl } {#1}
+ }
+\cs_new_protected:Npn \__xtemplate_declare_restricted:nnnn #1#2#3#4
+ {
+ \__xtemplate_if_keys_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_set_template_eq:nn { #1 / #3 } { #1 / #2 }
+ \bool_set_true:N \l__xtemplate_restrict_bool
+ \__xtemplate_edit_defaults_aux:nnn {#1} {#3} {#4}
+ \bool_set_false:N \l__xtemplate_restrict_bool
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_edit_defaults:nnn
+ {
+ \bool_set_false:N \l__xtemplate_restrict_bool
+ \__xtemplate_edit_defaults_aux:nnn
+ }
+\cs_new_protected:Npn \__xtemplate_edit_defaults_aux:nnn #1#2#3
+ {
+ \__xtemplate_if_keys_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_defaults:n { #1 / #2 }
+ \__xtemplate_recover_restrictions:n { #1 / #2 }
+ \__xtemplate_parse_values:nn { #1 / #2 } {#3}
+ \__xtemplate_store_defaults:n { #1 / #2 }
+ \__xtemplate_store_restrictions:n { #1 / #2 }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_values:nn #1#2
+ {
+ \clist_clear:N \l__xtemplate_restrict_clist
+ \__xtemplate_parse_values_aux:nn {#1} {#2}
+ }
+\cs_new_protected:Npn \__xtemplate_parse_values_aux:nn #1#2
+ {
+ \__xtemplate_recover_keytypes:n {#1}
+ \keyval_parse:NNn
+ \__xtemplate_parse_values_elt:n \__xtemplate_parse_values_elt:nn {#2}
+ }
+\cs_new_protected:Npn \__xtemplate_parse_values_elt:n #1
+ {
+ \bool_set_true:N \l__xtemplate_error_bool
+ \msg_error:nne { xtemplate } { key-no-value } {#1}
+ }
+\cs_new_protected:Npn \__xtemplate_parse_values_elt:nn #1#2
+ {
+ \tl_set:Ne \l__xtemplate_key_name_tl
+ { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
+ \prop_get:NoNTF \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ {
+ \bool_if:NTF \l__xtemplate_restrict_bool
+ {
+ \clist_if_in:NoF \l__xtemplate_restrict_clist
+ \l__xtemplate_key_name_tl
+ { \__xtemplate_parse_values_elt_aux:n {#2} }
+ }
+ { \__xtemplate_parse_values_elt_aux:n {#2} }
+ }
+ {
+ \msg_error:nne { xtemplate } { unknown-key }
+ { \l__xtemplate_key_name_tl }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_parse_values_elt_aux:n #1
+ {
+ \clist_put_right:No \l__xtemplate_restrict_clist \l__xtemplate_key_name_tl
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
+ \use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#1}
+ }
+\cs_new_protected:Npn \__xtemplate_set_template_eq:nn #1#2
+ {
+ \__xtemplate_recover_defaults:n {#2}
+ \__xtemplate_store_defaults:n {#1}
+ \__xtemplate_recover_keytypes:n {#2}
+ \__xtemplate_store_keytypes:n {#1}
+ \__xtemplate_recover_vars:n {#2}
+ \__xtemplate_store_vars:n {#1}
+ \cs_gset_eq:cc { \c__xtemplate_code_root_tl #1 }
+ { \c__xtemplate_code_root_tl #2 }
+ }
+\cs_new_protected:Npn \__xtemplate_declare_instance:nnnnn #1#2#3#4#5
+ {
+ \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_defaults:n { #1 / #2 }
+ \__xtemplate_recover_restrictions:n { #1 / #2 }
+ \__xtemplate_recover_vars:n { #1 / #2 }
+ \__xtemplate_declare_instance_aux:nnnnn {#1} {#2} {#3} {#4} {#5}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_declare_instance_aux:nnnnn #1#2#3#4#5
+ {
+ \bool_set_false:N \l__xtemplate_error_bool
+ \__xtemplate_parse_values_aux:nn { #1 / #2 } {#5}
+ \bool_if:NF \l__xtemplate_error_bool
+ {
+ \prop_put:Nnn \l__xtemplate_values_prop { from~template } {#2}
+ \__xtemplate_store_values:n { #1 / #3 / #4 }
+ \__xtemplate_convert_to_assignments:
+ \cs_set_protected:cpe { \c__xtemplate_instances_root_tl #1 / #3 / #4 }
+ {
+ \exp_not:N \__xtemplate_assignments_push:n
+ { \exp_not:o \l__xtemplate_assignments_tl }
+ \exp_not:c { \c__xtemplate_code_root_tl #1 / #2 }
+ }
+ \__xtemplate_if_instance_exist:nnnF {#1} { } {#4}
+ {
+ \cs_set_eq:cc
+ { \c__xtemplate_instances_root_tl #1 / / #4 }
+ { \c__xtemplate_instances_root_tl #1 / #3 / #4 }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_copy_instance:nnnn #1#2#3#4
+ {
+ \__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3}
+ {
+ \__xtemplate_recover_values:n { #1 / #2 / #3 }
+ \__xtemplate_store_values:n { #1 / #2 / #4 }
+ \cs_set_eq:cc { \c__xtemplate_instances_root_tl #1 / #2 / #4 }
+ { \c__xtemplate_instances_root_tl #1 / #2 / #3 }
+ }
+ {
+ \msg_error:nnee { xtemplate } { unknown-instance }
+ {#1} {#3}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_edit_instance:nnnn #1#2#3#4
+ {
+ \__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3}
+ {
+ \__xtemplate_recover_values:n { #1 / #2 / #3 }
+ \prop_get:NnN \l__xtemplate_values_prop { from~template }
+ \l__xtemplate_tmp_tl
+ \__xtemplate_edit_instance_aux:nonnn {#1} \l__xtemplate_tmp_tl
+ {#2} {#3} {#4}
+ }
+ {
+ \msg_error:nnee { xtemplate } { unknown-instance }
+ {#1} {#3}
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_edit_instance_aux:nnnnn #1#2
+ {
+ \__xtemplate_recover_vars:n { #1 / #2 }
+ \__xtemplate_declare_instance_aux:nnnnn {#1} {#2}
+ }
+\cs_generate_variant:Nn \__xtemplate_edit_instance_aux:nnnnn { no }
+\cs_new_protected:Npn \__xtemplate_convert_to_assignments:
+ {
+ \tl_clear:N \l__xtemplate_assignments_tl
+ \seq_map_function:NN \l__xtemplate_key_order_seq
+ \__xtemplate_convert_to_assignments_aux:n
+ }
+\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:n #1
+ {
+ \prop_get:NnN \l__xtemplate_keytypes_prop {#1} \l__xtemplate_tmp_tl
+ \__xtemplate_convert_to_assignments_aux:no {#1} \l__xtemplate_tmp_tl
+ }
+\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:nn #1#2
+ {
+ \prop_get:NnNT \l__xtemplate_values_prop {#1} \l__xtemplate_value_tl
+ {
+ \prop_get:NnNTF \l__xtemplate_vars_prop {#1} \l__xtemplate_var_tl
+ {
+ \__xtemplate_split_keytype_arg:n {#2}
+ \str_if_eq:onF \l__xtemplate_keytype_tl { choice }
+ {
+ \str_if_eq:onF \l__xtemplate_keytype_tl { code }
+ { \__xtemplate_find_global: }
+ }
+ \tl_set:Nn \l__xtemplate_key_name_tl {#1}
+ \use:c { __xtemplate_assign_ \l__xtemplate_keytype_tl : }
+ }
+ { \msg_error:nne { xtemplate } { unknown-attribute } {#1} }
+ }
+ }
+\cs_generate_variant:Nn \__xtemplate_convert_to_assignments_aux:nn { no }
+\cs_new_protected:Npn \__xtemplate_find_global:
+ {
+ \bool_set_false:N \l__xtemplate_global_bool
+ \tl_if_in:onT \l__xtemplate_var_tl { global }
+ {
+ \exp_after:wN \__xtemplate_find_global_aux:w \l__xtemplate_var_tl \s__xtemplate_stop
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_find_global_aux:w #1 global #2 \s__xtemplate_stop
+ {
+ \tl_set:Nn \l__xtemplate_var_tl {#2}
+ \bool_set_true:N \l__xtemplate_global_bool
+ }
+\cs_new_protected:Npn \__xtemplate_use_template:nnn #1#2#3
+ {
+ \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_defaults:n { #1 / #2 }
+ \__xtemplate_recover_vars:n { #1 / #2 }
+ \__xtemplate_parse_values:nn { #1 / #2 } {#3}
+ \__xtemplate_convert_to_assignments:
+ \use:c { \c__xtemplate_code_root_tl #1 / #2 }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_boolean:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_boolean_aux:n { bool_gset } }
+ { \__xtemplate_assign_boolean_aux:n { bool_set } }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_boolean_aux:n #1
+ {
+ \__xtemplate_if_key_value:oTF \l__xtemplate_value_tl
+ {
+ \__xtemplate_key_to_value:
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ \exp_not:c { #1 _eq:NN }
+ \exp_not:o \l__xtemplate_var_tl
+ \exp_not:o \l__xtemplate_value_tl
+ }
+ }
+ {
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ \exp_not:c { #1 _ \l__xtemplate_value_tl :N }
+ \exp_not:o \l__xtemplate_var_tl
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_choice:
+ {
+ \__xtemplate_assign_choice_aux:eF
+ { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_value_tl }
+ {
+ \__xtemplate_assign_choice_aux:eF
+ { \l__xtemplate_key_name_tl \c_space_tl unknown }
+ {
+ \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
+ \l__xtemplate_tmp_tl
+ \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
+ \msg_error:nneee { xtemplate } { unknown-choice }
+ { \l__xtemplate_key_name_tl } { \l__xtemplate_value_tl }
+ { \l__xtemplate_keytype_arg_tl }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_choice_aux:nF #1
+ {
+ \prop_get:NnNTF
+ \l__xtemplate_vars_prop
+ {#1}
+ \l__xtemplate_tmp_tl
+ { \tl_put_right:No \l__xtemplate_assignments_tl \l__xtemplate_tmp_tl }
+ }
+\cs_generate_variant:Nn \__xtemplate_assign_choice_aux:nF { e }
+\cs_new_protected:Npn \__xtemplate_assign_function:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_function_aux:N \cs_gset:Npn }
+ { \__xtemplate_assign_function_aux:N \cs_set:Npn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_function_aux:N #1
+ {
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ \cs_generate_from_arg_count:NNnn
+ \exp_not:o \l__xtemplate_var_tl
+ \exp_not:N #1
+ { \exp_not:o \l__xtemplate_keytype_arg_tl }
+ { \exp_not:o \l__xtemplate_value_tl }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_instance:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_instance_aux:N \cs_gset_protected:Npn }
+ { \__xtemplate_assign_instance_aux:N \cs_set_protected:Npn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_instance_aux:N #1
+ {
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ \exp_not:N #1 \exp_not:o \l__xtemplate_var_tl
+ {
+ \__xtemplate_use_instance:nn
+ { \exp_not:o \l__xtemplate_keytype_arg_tl }
+ { \exp_not:o \l__xtemplate_value_tl }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_integer:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_variable:N \int_gset:Nn }
+ { \__xtemplate_assign_variable:N \int_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_length:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_variable:N \dim_gset:Nn }
+ { \__xtemplate_assign_variable:N \dim_set:Nn }
+}
+\cs_new_protected:Npn \__xtemplate_assign_muskip:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_variable:N \muskip_gset:Nn }
+ { \__xtemplate_assign_variable:N \muskip_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_real:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_variable:N \fp_gset:Nn }
+ { \__xtemplate_assign_variable:N \fp_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_skip:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_variable:N \skip_gset:Nn }
+ { \__xtemplate_assign_variable:N \skip_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_tokenlist:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_tokenlist_aux:NN \tl_gset:NV \tl_gset:Nn }
+ { \__xtemplate_assign_tokenlist_aux:NN \tl_set:NV \tl_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_tokenlist_aux:NN #1#2
+ {
+ \__xtemplate_if_key_value:oTF \l__xtemplate_value_tl
+ {
+ \__xtemplate_key_to_value:
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ #1 \exp_not:o \l__xtemplate_var_tl
+ \exp_not:o \l__xtemplate_value_tl
+ }
+ }
+ {
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ #2 \exp_not:o \l__xtemplate_var_tl
+ { \exp_not:o \l__xtemplate_value_tl }
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_commalist:
+ {
+ \bool_if:NTF \l__xtemplate_global_bool
+ { \__xtemplate_assign_tokenlist_aux:NN \clist_gset:NV \clist_gset:Nn }
+ { \__xtemplate_assign_tokenlist_aux:NN \clist_set:NV \clist_set:Nn }
+ }
+\cs_new_protected:Npn \__xtemplate_assign_variable:N #1
+ {
+ \__xtemplate_if_key_value:oT \l__xtemplate_value_tl
+ { \__xtemplate_key_to_value: }
+ \tl_put_right:Ne \l__xtemplate_assignments_tl
+ {
+ #1 \exp_not:o \l__xtemplate_var_tl
+ { \exp_not:o \l__xtemplate_value_tl }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_key_to_value:
+ { \exp_after:wN \__xtemplate_key_to_value_auxi:w \l__xtemplate_value_tl }
+\cs_new_protected:Npn \__xtemplate_key_to_value_auxi:w \KeyValue #1
+ {
+ \tl_set:Ne \l__xtemplate_tmp_tl { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
+ \prop_get:NoNTF
+ \l__xtemplate_vars_prop
+ \l__xtemplate_tmp_tl
+ \l__xtemplate_value_tl
+ {
+ \exp_after:wN \__xtemplate_key_to_value_auxii:w \l__xtemplate_value_tl
+ \s__xtemplate_mark global \q__xtemplate_nil \s__xtemplate_stop
+ }
+ {
+ \msg_error:nne { xtemplate } { unknown-attribute }
+ { \l__xtemplate_tmp_tl }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_key_to_value_auxii:w #1 global #2#3 \s__xtemplate_stop
+ {
+ \__xtemplate_quark_if_nil:NF #2
+ { \tl_set:Nn \l__xtemplate_value_tl {#2} }
+ }
+\cs_new_protected:Npn \__xtemplate_use_instance:nn #1#2
+ {
+ \__xtemplate_if_use_template:nTF {#2}
+ { \__xtemplate_use_instance_aux:nNnnn {#1} #2 }
+ { \__xtemplate_use_instance_aux:nn {#1} {#2} }
+ }
+\cs_new_protected:Npn \__xtemplate_use_instance_aux:nNnnn #1#2#3#4#5
+ {
+ \str_if_eq:nnTF {#1} {#3}
+ { \__xtemplate_use_template:nnn {#3} {#4} {#5} }
+ { \msg_error:nnee { xtemplate } { type-mismatch } {#1} {#3} }
+}
+\cs_new_protected:Npn \__xtemplate_use_instance_aux:nn #1#2
+ {
+ \__xtemplate_get_collection:n {#1}
+ \__xtemplate_if_instance_exist:nnnTF
+ {#1} { \l__xtemplate_collection_tl } {#2}
+ {
+ \use:c
+ {
+ \c__xtemplate_instances_root_tl #1 /
+ \l__xtemplate_collection_tl / #2
+ }
+ }
+ {
+ \__xtemplate_if_instance_exist:nnnTF {#1} { } {#2}
+ { \use:c { \c__xtemplate_instances_root_tl #1 / / #2 } }
+ {
+ \msg_error:nnee { xtemplate } { unknown-instance }
+ {#1} {#2}
+ }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_use_collection:nn #1#2
+ { \prop_put:Nnn \l__xtemplate_collections_prop {#1} {#2} }
+\cs_new_protected:Npn \__xtemplate_get_collection:n #1
+ {
+ \prop_get:NnNF \l__xtemplate_collections_prop {#1}
+ \l__xtemplate_collection_tl
+ { \tl_clear:N \l__xtemplate_collection_tl }
+ }
+\cs_new:Npn \__xtemplate_assignments_pop: { \l__xtemplate_assignments_tl }
+\cs_new_protected:Npn \__xtemplate_assignments_push:n #1
+ { \tl_set:Nn \l__xtemplate_assignments_tl {#1} }
+\cs_new_protected:Npn \__xtemplate_show_code:nn #1#2
+ { \cs_show:c { \c__xtemplate_code_root_tl #1 / #2 } }
+\cs_new_protected:Npn \__xtemplate_show_defaults:nn #1#2
+ {
+ \__xtemplate_if_keys_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_defaults:n { #1 / #2 }
+ \__xtemplate_show:Nnnn \l__xtemplate_values_prop
+ {#1} {#2} { default~values }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_show_keytypes:nn #1#2
+ {
+ \__xtemplate_if_keys_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_keytypes:n { #1 / #2 }
+ \__xtemplate_show:Nnnn \l__xtemplate_keytypes_prop
+ {#1} {#2} { interface }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_show_vars:nn #1#2
+ {
+ \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
+ {
+ \__xtemplate_recover_vars:n { #1 / #2 }
+ \__xtemplate_show:Nnnn \l__xtemplate_vars_prop
+ {#1} {#2} { variable~mapping }
+ }
+ }
+\cs_new_protected:Npn \__xtemplate_show:Nnnn #1#2#3#4
+ {
+ \msg_show:nneeee { xtemplate } { show-attribute }
+ { \tl_to_str:n {#2} }
+ { \tl_to_str:n {#3} }
+ { \tl_to_str:n {#4} }
+ { \prop_map_function:NN #1 \msg_show_item_unbraced:nn }
+ }
+\cs_new_protected:Npn \__xtemplate_show_values:nnn #1#2#3
+ {
+ \__xtemplate_if_instance_exist:nnnT {#1} {#2} {#3}
+ {
+ \__xtemplate_recover_values:n { #1 / #2 / #3 }
+ \msg_show:nneeee { xtemplate } { show-values }
+ { \tl_to_str:n {#1} }
+ { \tl_to_str:n {#2} }
+ { \tl_to_str:n {#3} }
+ {
+ \prop_map_function:NN \l__xtemplate_values_prop
+ \msg_show_item_unbraced:nn
+ }
+ }
+ }
+\msg_new:nnnn { xtemplate } { argument-number-mismatch }
+ { Object~type~'#1'~takes~#2~argument(s). }
+ {
+ Objects~of~type~'#1'~require~#2~argument(s).\\
+ You~have~tried~to~make~a~template~for~'#1'~
+ with~#3~argument(s),~which~is~not~possible:~
+ the~number~of~arguments~must~agree.
+ }
+\msg_new:nnnn { xtemplate } { bad-number-of-arguments }
+ { Bad~number~of~arguments~for~object~type~'#1'. }
+ {
+ An~object~may~accept~between~0~and~9~arguments.\\
+ You~asked~to~use~#2~arguments:~this~is~not~supported.
+ }
+\msg_new:nnnn { xtemplate } { bad-variable }
+ { Incorrect~variable~description~'#1'. }
+ {
+ The~argument~'#1'~is~not~of~the~form \\
+ ~~'<variable>'\\
+ ~or~\\
+ ~~'global~<variable>'.\\
+ It~must~be~given~in~one~of~these~formats~to~be~used~in~a~template.
+ }
+\msg_new:nnnn { xtemplate } { choice-not-implemented }
+ { The~choice~'#1'~has~no~implementation. }
+ {
+ Each~choice~listed~in~the~interface~for~a~template~must~
+ have~an~implementation.
+ }
+\msg_new:nnnn { xtemplate } { choice-no-code }
+ { The~choice~'#1'~requires~implementation~details. }
+ {
+ When~creating~template~code~using~\DeclareTemplateCode,~
+ each~choice~name~must~have~an~associated~implementation.\\
+ This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
+ }
+\msg_new:nnnn { xtemplate } { choice-requires-code }
+ { The~choice~'#2'~for~key~'#1'~requires~an~implementation. }
+ {
+ You~should~have~put:\\
+ \ \ #1~:~choice~{~#2 = <code> ~} \\
+ but~LaTeX~did~not~find~any~<code>.
+ }
+\msg_new:nnnn { xtemplate } { duplicate-key-interface }
+ { Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. }
+ {
+ Each~key~can~only~have~one~interface~declared~in~a~template.\\
+ LaTeX~found~two~interfaces~for~'#1'.
+ }
+\msg_new:nnnn { xtemplate } { keytype-requires-argument }
+ { The~key~type~'#1'~requires~an~argument~\msg_line_context:. }
+ {
+ You~should~have~put:\\
+ \ \ <key-name>~:~#1~{~<argument>~} \\
+ but~LaTeX~did~not~find~an~<argument>.
+ }
+\msg_new:nnnn { xtemplate } { invalid-keytype }
+ { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
+ {
+ Each~key~in~a~template~requires~a~key-type,~given~in~the~form:\\
+ \ \ <key>~:~<key-type>\\
+ LaTeX~could~not~find~a~<key-type>~in~your~input.
+ }
+\msg_new:nnnn { xtemplate } { key-no-value }
+ { The~key~'#1'~has~no~value~\msg_line_context:. }
+ {
+ When~creating~an~instance~of~a~template~
+ every~key~listed~must~include~a~value:\\
+ \ \ <key>~=~<value>
+ }
+\msg_new:nnnn { xtemplate } { key-no-variable }
+ { The~key~'#1'~requires~implementation~details~\msg_line_context:. }
+ {
+ When~creating~template~code~using~\DeclareTemplateCode,~
+ each~key~name~must~have~an~associated~implementation.\\
+ This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
+ }
+\msg_new:nnnn { xtemplate } { key-not-implemented }
+ { Key~'#1'~has~no~implementation~\msg_line_context:. }
+ {
+ The~definition~of~key~implementations~for~template~'#2'~
+ of~object~type~'#3'~does~not~include~any~details~for~key~'#1'.\\
+ The~key~was~declared~in~the~interface~definition,~
+ and~so~an~implementation~is~required.
+ }
+\msg_new:nnnn { xtemplate } { missing-keytype }
+ { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
+ {
+ Key~interface~definitions~should~be~of~the~form\\
+ \ \ #1~:~<key-type>\\
+ but~LaTeX~could~not~find~a~<key-type>.
+ }
+\msg_new:nnnn { xtemplate } { no-template-code }
+ {
+ The~template~'#2'~of~type~'#1'~is~unknown~
+ or~has~no~implementation.
+ }
+ {
+ There~is~no~code~available~for~the~template~name~given.\\
+ This~should~be~given~using~\DeclareTemplateCode.
+ }
+\msg_new:nnnn { xtemplate } { object-type-mismatch }
+ { Object~types~'#1'~and~'#2'~do~not~agree. }
+ {
+ You~are~trying~to~use~a~template~directly~with~\UseInstance
+ (or~a~similar~function),~but~the~object~types~do~not~match.
+ }
+\msg_new:nnnn { xtemplate } { unknown-attribute }
+ { The~template~attribute~'#1'~is~unknown. }
+ {
+ There~is~a~definition~in~the~current~template~reading\\
+ \ \ \token_to_str:N \KeyValue {~#1~} \\
+ but~there~is~no~key~called~'#1'.
+ }
+\msg_new:nnnn { xtemplate } { unknown-choice }
+ { The~choice~'#2'~was~not~declared~for~key~'#1'. }
+ {
+ The~key~'#1'~takes~a~fixed~list~of~choices~
+ and~this~list~does~not~include~'#2'.
+ }
+\msg_new:nnnn { xtemplate } { unknown-default-choice }
+ { The~default~choice~'#2'~was~not~declared~for~key~'#1'. }
+ {
+ The~key~'#1'~takes~a~fixed~list~of~choices~
+ and~this~list~does~not~include~'#2'.
+ }
+\msg_new:nnnn { xtemplate } { unknown-instance }
+ { The~instance~'#2'~of~type~'#1'~is~unknown. }
+ {
+ You~have~asked~to~use~an~instance~'#2',~
+ but~this~has~not~been~created.
+ }
+\msg_new:nnnn { xtemplate } { unknown-key }
+ { Unknown~template~key~'#1'. }
+ {
+ The~key~'#1'~was~not~declared~in~the~interface~
+ for~the~current~template.
+ }
+\msg_new:nnnn { xtemplate } { unknown-keytype }
+ { The~key-type~'#1'~is~unknown. }
+ {
+ Valid~key-types~are:\\
+ -~boolean;\\
+ -~choice;\\
+ -~commalist;\\
+ -~function;\\
+ -~instance;\\
+ -~integer;\\
+ -~length;\\
+ -~muskip;\\
+ -~real;\\
+ -~skip;\\
+ -~tokenlist.
+ }
+\msg_new:nnnn { xtemplate } { unknown-object-type }
+ { The~object~type~'#1'~is~unknown. }
+ {
+ An~object~type~needs~to~be~declared~with~\DeclareObjectType
+ prior~to~using~it.
+ }
+\msg_new:nnnn { xtemplate } { unknown-template }
+ { The~template~'#2'~of~type~'#1'~is~unknown. }
+ {
+ No~interface~has~been~declared~for~a~template~
+ '#2'~of~object~type~'#1'.
+ }
+\msg_new:nnn { xtemplate } { declare-object-type }
+ { Declaring~object~type~'#1'~taking~#2~argument(s)~\msg_line_context:. }
+\msg_new:nnn { xtemplate } { declare-template-code }
+ { Declaring~code~for~template~'#2'~of~object~type'#1'~\msg_line_context:. }
+\msg_new:nnn { xtemplate } { declare-template-interface }
+ {
+ Declaring~interface~for~template~'#2'~of~object~type~'#1'~
+ \msg_line_context:.
+ }
+\msg_new:nnn { xtemplate } { show-attribute }
+ {
+ The~template~'#2'~of~object~type~'#1'~has~
+ \tl_if_empty:nTF {#4} { no~#3. } { #3 : #4 }
+ }
+\msg_new:nnn { xtemplate } { show-values }
+ {
+ \tl_if_empty:nTF {#2}
+ { The~instance~'#3'~ }
+ { The~collection~ instance~'#3'~ (from~collection~'#2')~ }
+ of~object~type~'#1'~has~
+ \tl_if_empty:nTF {#4} { no~values. } { values: #4 }
+ }
+\cs_new_protected:Npn \DeclareObjectType #1#2
+ { \__xtemplate_declare_object_type:nn {#1} {#2} }
+\cs_new_protected:Npn \DeclareTemplateInterface #1#2#3#4
+ { \__xtemplate_declare_template_keys:nnnn {#1} {#2} {#3} {#4} }
+\cs_new_protected:Npn \DeclareTemplateCode #1#2#3#4#5
+ { \__xtemplate_declare_template_code:nnnnn {#1} {#2} {#3} {#4} {#5} }
+\cs_new_protected:Npn \DeclareRestrictedTemplate #1#2#3#4
+ { \__xtemplate_declare_restricted:nnnn {#1} {#2} {#3} {#4} }
+\cs_new_protected:Npn \DeclareInstance #1#2#3#4
+ { \__xtemplate_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} }
+\cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5
+ { \__xtemplate_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} }
+\cs_new_protected:Npn \DeclareInstanceCopy #1#2#3
+ { \__xtemplate_copy_instance:nnnn {#1} { } {#3} {#2} }
+\cs_new_protected:Npn \EditTemplateDefaults #1#2#3
+ { \__xtemplate_edit_defaults:nnn {#1} {#2} {#3} }
+\cs_new_protected:Npn \EditInstance #1#2#3
+ { \__xtemplate_edit_instance:nnnn {#1} { } {#2} {#3} }
+\cs_new_protected:Npn \EditCollectionInstance #1#2#3#4
+ { \__xtemplate_edit_instance:nnnn {#2} {#1} {#3} {#4} }
+\cs_new_protected:Npn \UseTemplate #1#2#3
+ { \__xtemplate_use_template:nnn {#1} {#2} {#3} }
+\cs_new_protected:Npn \UseInstance #1#2
+ { \__xtemplate_use_instance:nn {#1} {#2} }
+\cs_new_protected:Npn \UseCollection #1#2
+ { \__xtemplate_use_collection:nn {#1} {#2} }
+\cs_new_protected:Npn \ShowTemplateCode #1#2
+ { \__xtemplate_show_code:nn {#1} {#2} }
+\cs_new_protected:Npn \ShowTemplateDefaults #1#2
+ { \__xtemplate_show_defaults:nn {#1} {#2} }
+\cs_new_protected:Npn \ShowTemplateInterface #1#2
+ { \__xtemplate_show_keytypes:nn {#1} {#2} }
+\cs_new_protected:Npn \ShowTemplateVariables #1#2
+ { \__xtemplate_show_vars:nn {#1} {#2} }
+\cs_new_protected:Npn \ShowInstanceValues #1#2
+ { \__xtemplate_show_values:nnn {#1} { } {#2} }
+\cs_new_protected:Npn \ShowCollectionInstanceValues #1#2#3
+ { \__xtemplate_show_values:nnn {#1} {#2} {#3} }
+\cs_new:Npn \IfInstanceExistTF #1#2
+ { \__xtemplate_if_instance_exist:nnnTF {#1} { } {#2} }
+\cs_new:Npn \IfInstanceExistT #1#2
+ { \__xtemplate_if_instance_exist:nnnT {#1} { } {#2} }
+\cs_new:Npn \IfInstanceExistF #1#2
+ { \__xtemplate_if_instance_exist:nnnF {#1} { } {#2} }
+\cs_new_protected:Npn \KeyValue #1 {#1}
+\cs_new_protected:Npn \AssignTemplateKeys
+ { \__xtemplate_assignments_pop: }
+\cs_new_protected:Npn \SetTemplateKeys #1#2#3
+ { \keys_set_known:nnN { template / #1 / #2 } {#3} \l__xtemplate_tmp_clist }
+\cs_new_eq:NN \ShowTemplateKeytypes \ShowTemplateInterface
+%%
+%%
+%% End of file `xtemplate.sty'.
diff --git a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty
index 9d524ce8838..d3fc0172cd9 100644
--- a/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty
+++ b/Master/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty
@@ -6,7 +6,7 @@
%%
%% xtemplate.dtx (with options: `package')
%%
-%% Copyright (C) 2011-2023 The LaTeX Project
+%% Copyright (C) 2011-2024 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -19,1355 +19,23 @@
%% and all files in that bundle must be distributed together.
%%
%% File: xtemplate.dtx
-\RequirePackage{expl3}[2018/02/21]
-\@ifpackagelater{expl3}{2018/02/21}
- {}
+\@ifundefined{NewTemplateType}
{%
- \PackageError{xtemplate}{Support package l3kernel too old}
- {%
- Please install an up to date version of l3kernel\MessageBreak
- using your TeX package manager or from CTAN.\MessageBreak
- \MessageBreak
- Loading xtemplate will abort!%
- }%
+ \input{xtemplate-2023-10-10.sty}%
\endinput
}
-\ProvidesExplPackage{xtemplate}{2023-10-10}{}
- {L3 Experimental prototype document functions}
-\tl_const:Nn \c__xtemplate_code_root_tl { template~code~>~ }
-\tl_const:Nn \c__xtemplate_defaults_root_tl { template~defaults~>~ }
-\tl_const:Nn \c__xtemplate_instances_root_tl { template~instance~>~ }
-\tl_const:Nn \c__xtemplate_keytypes_root_tl { template~key~types~>~ }
-\tl_const:Nn \c__xtemplate_key_order_root_tl { template~key~order~>~ }
-\tl_const:Nn \c__xtemplate_restrict_root_tl { template~restrictions~>~ }
-\tl_const:Nn \c__xtemplate_values_root_tl { template~values~>~ }
-\tl_const:Nn \c__xtemplate_vars_root_tl { template~vars~>~ }
-\seq_const_from_clist:Nn \c__xtemplate_keytypes_arg_seq
- { choice , function , instance }
-\prop_new:N \g__xtemplate_object_type_prop
-\tl_new:N \l__xtemplate_assignments_tl
-\tl_new:N \l__xtemplate_collection_tl
-\prop_new:N \l__xtemplate_collections_prop
-\tl_new:N \l__xtemplate_default_tl
-\bool_new:N \l__xtemplate_error_bool
-\bool_new:N \l__xtemplate_global_bool
-\bool_new:N \l__xtemplate_restrict_bool
-\clist_new:N \l__xtemplate_restrict_clist
-\tl_new:N \l__xtemplate_key_name_tl
-\tl_new:N \l__xtemplate_keytype_tl
-\tl_new:N \l__xtemplate_keytype_arg_tl
-\tl_new:N \l__xtemplate_value_tl
-\tl_new:N \l__xtemplate_var_tl
-\prop_new:N \l__xtemplate_keytypes_prop
-\seq_new:N \l__xtemplate_key_order_seq
-\prop_new:N \l__xtemplate_values_prop
-\prop_new:N \l__xtemplate_vars_prop
-\clist_new:N \l__xtemplate_tmp_clist
-\dim_new:N \l__xtemplate_tmp_dim
-\int_new:N \l__xtemplate_tmp_int
-\muskip_new:N \l__xtemplate_tmp_muskip
-\skip_new:N \l__xtemplate_tmp_skip
-\tl_new:N \l__xtemplate_tmp_tl
-\scan_new:N \s__xtemplate_mark
-\scan_new:N \s__xtemplate_stop
-\quark_new:N \q__xtemplate_nil
-\__kernel_quark_new_conditional:Nn \__xtemplate_quark_if_nil:N { F }
-\cs_generate_variant:Nn \prop_get:NnNTF { No }
-\cs_generate_variant:Nn \prop_get:NnNT { No }
-\cs_generate_variant:Nn \prop_get:NnNF { No }
-\cs_new_protected:Npn \__xtemplate_execute_if_arg_agree:nnT #1#2#3
- {
- \prop_get:NnN \g__xtemplate_object_type_prop {#1} \l__xtemplate_tmp_tl
- \int_compare:nNnTF {#2} = \l__xtemplate_tmp_tl
- {#3}
- {
- \msg_error:nneee { xtemplate }
- { argument-number-mismatch } {#1} { \l__xtemplate_tmp_tl } {#2}
- }
- }
-\cs_new_protected:Npn \__xtemplate_execute_if_code_exist:nnT #1#2#3
- {
- \cs_if_exist:cTF { \c__xtemplate_code_root_tl #1 / #2 }
- {#3}
- {
- \msg_error:nnee { xtemplate } { no-template-code }
- {#1} {#2}
- }
- }
-\cs_new_protected:Npn \__xtemplate_execute_if_keytype_exist:nT #1#2
- {
- \cs_if_exist:cTF { __xtemplate_store_value_ #1 :n }
- {#2}
- { \msg_error:nne { xtemplate } { unknown-keytype } {#1} }
- }
-\cs_generate_variant:Nn \__xtemplate_execute_if_keytype_exist:nT { o }
-\cs_new_protected:Npn \__xtemplate_execute_if_type_exist:nT #1#2
- {
- \prop_if_in:NnTF \g__xtemplate_object_type_prop {#1}
- {#2}
- { \msg_error:nne { xtemplate } { unknown-object-type } {#1} }
- }
-\cs_new_protected:Npn \__xtemplate_if_keys_exist:nnT #1#2#3
- {
- \cs_if_exist:cTF { \c__xtemplate_keytypes_root_tl #1 / #2 }
- {#3}
- {
- \msg_error:nnee { xtemplate } { unknown-template }
- {#1} {#2}
- }
- }
-\prg_new_conditional:Npnn \__xtemplate_if_key_value:n #1 { T , F , TF }
- {
- \str_if_eq:noTF { \KeyValue } { \tl_head:w #1 \q_nil \q_stop }
- { \prg_return_true: }
- { \prg_return_false: }
- }
-\cs_generate_variant:Nn \__xtemplate_if_key_value:nT { o }
-\cs_generate_variant:Nn \__xtemplate_if_key_value:nF { o }
-\cs_generate_variant:Nn \__xtemplate_if_key_value:nTF { o }
-\prg_new_conditional:Npnn \__xtemplate_if_instance_exist:nnn #1#2#3
- { T, F, TF }
- {
- \cs_if_exist:cTF { \c__xtemplate_instances_root_tl #1 / #2 / #3 }
- { \prg_return_true: }
- { \prg_return_false: }
- }
-\prg_new_conditional:Npnn \__xtemplate_if_use_template:n #1 { TF }
- {
- \str_if_eq:noTF { \UseTemplate } { \tl_head:w #1 \q_nil \q_stop }
- { \prg_return_true: }
- { \prg_return_false: }
-}
-\cs_new_protected:Npn \__xtemplate_store_defaults:n #1
- {
- \prop_gclear_new:c { \c__xtemplate_defaults_root_tl #1 }
- \prop_gset_eq:cN { \c__xtemplate_defaults_root_tl #1 }
- \l__xtemplate_values_prop
- }
-\cs_new_protected:Npn \__xtemplate_store_keytypes:n #1
- {
- \prop_gclear_new:c { \c__xtemplate_keytypes_root_tl #1 }
- \prop_gset_eq:cN { \c__xtemplate_keytypes_root_tl #1 }
- \l__xtemplate_keytypes_prop
- \seq_gclear_new:c { \c__xtemplate_key_order_root_tl #1 }
- \seq_gset_eq:cN { \c__xtemplate_key_order_root_tl #1 }
- \l__xtemplate_key_order_seq
- }
-\cs_new_protected:Npn \__xtemplate_store_values:n #1
- {
- \prop_clear_new:c { \c__xtemplate_values_root_tl #1 }
- \prop_set_eq:cN { \c__xtemplate_values_root_tl #1 }
- \l__xtemplate_values_prop
- }
-\cs_new_protected:Npn \__xtemplate_store_restrictions:n #1
- {
- \clist_gclear_new:c { \c__xtemplate_restrict_root_tl #1 }
- \clist_gset_eq:cN { \c__xtemplate_restrict_root_tl #1 }
- \l__xtemplate_restrict_clist
- }
-\cs_new_protected:Npn \__xtemplate_store_vars:n #1
- {
- \prop_gclear_new:c { \c__xtemplate_vars_root_tl #1 }
- \prop_gset_eq:cN { \c__xtemplate_vars_root_tl #1 }
- \l__xtemplate_vars_prop
- }
-\cs_new_protected:Npn \__xtemplate_recover_defaults:n #1
- {
- \prop_if_exist:cTF
- { \c__xtemplate_defaults_root_tl #1 }
- {
- \prop_set_eq:Nc \l__xtemplate_values_prop
- { \c__xtemplate_defaults_root_tl #1 }
- }
- { \prop_clear:N \l__xtemplate_values_prop }
- }
-\cs_new_protected:Npn \__xtemplate_recover_keytypes:n #1
- {
- \prop_if_exist:cTF
- { \c__xtemplate_keytypes_root_tl #1 }
- {
- \prop_set_eq:Nc \l__xtemplate_keytypes_prop
- { \c__xtemplate_keytypes_root_tl #1 }
- }
- { \prop_clear:N \l__xtemplate_keytypes_prop }
- \seq_if_exist:cTF { \c__xtemplate_key_order_root_tl #1 }
- {
- \seq_set_eq:Nc \l__xtemplate_key_order_seq
- { \c__xtemplate_key_order_root_tl #1 }
- }
- { \seq_clear:N \l__xtemplate_key_order_seq }
- }
-\cs_new_protected:Npn \__xtemplate_recover_restrictions:n #1
- {
- \clist_if_exist:cTF
- { \c__xtemplate_restrict_root_tl #1 }
- {
- \clist_set_eq:Nc \l__xtemplate_restrict_clist
- { \c__xtemplate_restrict_root_tl #1 }
- }
- { \clist_clear:N \l__xtemplate_restrict_clist }
- }
-\cs_new_protected:Npn \__xtemplate_recover_values:n #1
- {
- \prop_if_exist:cTF
- { \c__xtemplate_values_root_tl #1 }
- {
- \prop_set_eq:Nc \l__xtemplate_values_prop
- { \c__xtemplate_values_root_tl #1 }
- }
- { \prop_clear:N \l__xtemplate_values_prop }
- }
-\cs_new_protected:Npn \__xtemplate_recover_vars:n #1
- {
- \prop_if_exist:cTF
- { \c__xtemplate_vars_root_tl #1 }
- {
- \prop_set_eq:Nc \l__xtemplate_vars_prop
- { \c__xtemplate_vars_root_tl #1 }
- }
- { \prop_clear:N \l__xtemplate_vars_prop }
- }
-\cs_new_protected:Npn \__xtemplate_declare_object_type:nn #1#2
- {
- \int_set:Nn \l__xtemplate_tmp_int {#2}
- \int_compare:nTF { 0 <= \l__xtemplate_tmp_int <= 9 }
- {
- \msg_info:nnnV { xtemplate } { declare-object-type }
- {#1} \l__xtemplate_tmp_int
- \prop_gput:NnV \g__xtemplate_object_type_prop {#1}
- \l__xtemplate_tmp_int
- }
- {
- \msg_error:nnee { xtemplate } { bad-number-of-arguments }
- {#1} { \exp_not:V \l__xtemplate_tmp_int }
- }
- }
-\cs_new_protected:Npn \__xtemplate_declare_template_keys:nnnn #1#2#3#4
- {
- \__xtemplate_execute_if_type_exist:nT {#1}
- {
- \__xtemplate_execute_if_arg_agree:nnT {#1} {#3}
- {
- \prop_clear:N \l__xtemplate_values_prop
- \prop_clear:N \l__xtemplate_keytypes_prop
- \seq_clear:N \l__xtemplate_key_order_seq
- \keyval_parse:NNn
- \__xtemplate_parse_keys_elt:n \__xtemplate_parse_keys_elt:nn {#4}
- \__xtemplate_store_defaults:n { #1 / #2 }
- \__xtemplate_store_keytypes:n { #1 / #2 }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_keys_elt:n #1
- {
- \__xtemplate_split_keytype:n {#1}
- \bool_if:NF \l__xtemplate_error_bool
- {
- \__xtemplate_execute_if_keytype_exist:oT \l__xtemplate_keytype_tl
- {
- \seq_map_function:NN \c__xtemplate_keytypes_arg_seq
- \__xtemplate_parse_keys_elt_aux:n
- \bool_if:NF \l__xtemplate_error_bool
- {
- \seq_if_in:NoTF \l__xtemplate_key_order_seq
- \l__xtemplate_key_name_tl
- {
- \msg_error:nne { xtemplate }
- { duplicate-key-interface }
- { \l__xtemplate_key_name_tl }
- }
- { \__xtemplate_parse_keys_elt_aux: }
- }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_keys_elt_aux:n #1
- {
- \str_if_eq:onT \l__xtemplate_keytype_tl {#1}
- {
- \tl_if_empty:NT \l__xtemplate_keytype_arg_tl
- {
- \msg_error:nne { xtemplate }
- { keytype-requires-argument } {#1}
- \bool_set_true:N \l__xtemplate_error_bool
- \seq_map_break:
- }
- }
- }
-\cs_new:Npn \__xtemplate_parse_keys_elt_aux:
- {
- \tl_set:Ne \l__xtemplate_tmp_tl
- {
- \l__xtemplate_keytype_tl
- \tl_if_empty:NF \l__xtemplate_keytype_arg_tl
- { { \l__xtemplate_keytype_arg_tl } }
- }
- \prop_put:Noo \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \seq_put_right:No \l__xtemplate_key_order_seq \l__xtemplate_key_name_tl
- \str_if_eq:onT \l__xtemplate_keytype_tl { choice }
- {
- \exp_args:No \clist_if_in:nnT \l__xtemplate_keytype_arg_tl { unknown }
- { \msg_error:nn { xtemplate } { choice-unknown-reserved } }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_keys_elt:nn #1#2
- {
- \__xtemplate_parse_keys_elt:n {#1}
- \use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#2}
- }
-\cs_new_protected:Npe \__xtemplate_split_keytype:n #1
- {
- \exp_not:N \bool_set_false:N \exp_not:N \l__xtemplate_error_bool
- \tl_set:Nn \exp_not:N \l__xtemplate_tmp_tl {#1}
- \tl_replace_all:Nnn \exp_not:N \l__xtemplate_tmp_tl { : } { \token_to_str:N : }
- \tl_if_in:onTF \exp_not:N \l__xtemplate_tmp_tl { \token_to_str:N : }
- {
- \exp_not:n
- {
- \tl_clear:N \l__xtemplate_key_name_tl
- \exp_after:wN \__xtemplate_split_keytype_aux:w
- \l__xtemplate_tmp_tl \s__xtemplate_stop
- }
- }
- {
- \exp_not:N \bool_set_true:N \exp_not:N \l__xtemplate_error_bool
- \msg_error:nne { xtemplate } { missing-keytype } {#1}
- }
- }
-\use:e
- {
- \cs_new_protected:Npn \exp_not:N \__xtemplate_split_keytype_aux:w
- #1 \token_to_str:N : #2 \s__xtemplate_stop
- {
- \tl_put_right:Ne \exp_not:N \l__xtemplate_key_name_tl
- {
- \exp_not:N \tl_trim_spaces:e
- { \exp_not:N \tl_to_str:n {#1} }
- }
- \tl_if_in:nnTF {#2} { \token_to_str:N : }
- {
- \tl_put_right:Nn \exp_not:N \l__xtemplate_key_name_tl
- { \token_to_str:N : }
- \exp_not:N \__xtemplate_split_keytype_aux:w #2 \s__xtemplate_stop
- }
- {
- \exp_not:N \tl_if_empty:NTF \exp_not:N \l__xtemplate_key_name_tl
- {
- \msg_error:nne { xtemplate } { empty-key-name }
- { \token_to_str:N : #2 }
- }
- { \exp_not:N \__xtemplate_split_keytype_arg:n {#2} }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_split_keytype_arg:n #1
- {
- \tl_set:Ne \l__xtemplate_keytype_tl { \tl_trim_spaces:n {#1} }
- \tl_clear:N \l__xtemplate_keytype_arg_tl
- \cs_set_protected:Npn \__xtemplate_split_keytype_arg_aux:n ##1
- {
- \tl_if_in:nnT {#1} {##1}
- {
- \cs_set:Npn \__xtemplate_split_keytype_arg_aux:w
- ####1 ##1 ####2 \s__xtemplate_stop
- {
- \tl_if_blank:nT {####1}
- {
- \tl_set:Ne \l__xtemplate_keytype_tl
- { \tl_trim_spaces:n {##1} }
- \tl_if_blank:nF {####2}
- {
- \tl_set:Ne \l__xtemplate_keytype_arg_tl
- { \use:n ####2 }
- }
- \seq_map_break:
- }
- }
- \__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop
- }
- }
- \seq_map_function:NN \c__xtemplate_keytypes_arg_seq
- \__xtemplate_split_keytype_arg_aux:n
- }
-\cs_generate_variant:Nn \__xtemplate_split_keytype_arg:n { o }
-\cs_new:Npn \__xtemplate_split_keytype_arg_aux:n #1 { }
-\cs_new:Npn \__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop { }
-\cs_new_protected:Npn \__xtemplate_store_value_boolean:n #1
- { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} }
-\cs_new_protected:Npn \__xtemplate_store_value:n #1
- { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} }
-\cs_new_eq:NN \__xtemplate_store_value_choice:n \__xtemplate_store_value:n
-\cs_new_eq:NN \__xtemplate_store_value_function:n \__xtemplate_store_value:n
-\cs_new_eq:NN \__xtemplate_store_value_instance:n \__xtemplate_store_value:n
-\cs_new_protected:Npn \__xtemplate_store_value_aux:Nn #1#2
- { \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#2} }
-\cs_new_protected:Npn \__xtemplate_store_value_integer:n
- { \__xtemplate_store_value_aux:Nn \int_eval:n }
-\cs_new_protected:Npn \__xtemplate_store_value_length:n
- { \__xtemplate_store_value_aux:Nn \dim_eval:n }
-\cs_new_protected:Npn \__xtemplate_store_value_muskip:n
- { \__xtemplate_store_value_aux:Nn \muskip_eval:n }
-\cs_new_protected:Npn \__xtemplate_store_value_real:n
- { \__xtemplate_store_value_aux:Nn \fp_eval:n }
-\cs_new_protected:Npn \__xtemplate_store_value_skip:n
- { \__xtemplate_store_value_aux:Nn \skip_eval:n }
-\cs_new_protected:Npn \__xtemplate_store_value_tokenlist:n
- { \__xtemplate_store_value_aux:Nn \use:n }
-\cs_new_eq:NN \__xtemplate_store_value_commalist:n \__xtemplate_store_value_tokenlist:n
-\cs_new_protected:Npn \__xtemplate_declare_template_code:nnnnn #1#2#3#4#5
- {
- \__xtemplate_execute_if_type_exist:nT {#1}
- {
- \__xtemplate_execute_if_arg_agree:nnT {#1}{#3}
- {
- \__xtemplate_if_keys_exist:nnT {#1} {#2}
- {
- \__xtemplate_store_key_implementation:nnn {#1} {#2} {#4}
- \regex_match:nnTF { \c { AssignTemplateKeys } } {#5}
- { \__xtemplate_declare_template_code:nnn { #1 / #2 } {#3} {#5} }
- {
- \__xtemplate_declare_template_code:nnn
- { #1 / #2 } {#3} { \AssignTemplateKeys #5 }
- }
- }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_declare_template_code:nnn #1#2#3
- {
- \cs_generate_from_arg_count:cNnn
- { \c__xtemplate_code_root_tl #1 }
- \cs_gset_protected:Npn {#2} {#3}
- }
-\cs_new_protected:Npn \__xtemplate_store_key_implementation:nnn #1#2#3
- {
- \__xtemplate_recover_defaults:n { #1 / #2 }
- \__xtemplate_recover_restrictions:n { #1 / #2 }
- \__xtemplate_recover_keytypes:n { #1 / #2 }
- \prop_clear:N \l__xtemplate_vars_prop
- \keyval_parse:nnn
- { \__xtemplate_parse_vars_elt:n } { \__xtemplate_parse_vars_elt:nnn { #1 / #2 } } {#3}
- \__xtemplate_store_vars:n { #1 / #2 }
- \__xtemplate_store_restrictions:n { #1 / #2 }
- \prop_map_inline:Nn \l__xtemplate_keytypes_prop
- {
- \msg_error:nneee { xtemplate } { key-not-implemented }
- {##1} {#2} {#1}
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt:n #1
- { \msg_error:nne { xtemplate } { key-no-variable } {#1} }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt:nnn #1#2#3
- {
- \tl_set:Ne \l__xtemplate_key_name_tl
- { \tl_trim_spaces:e { \tl_to_str:n {#2} } }
- \prop_get:NoNTF
- \l__xtemplate_keytypes_prop
- \l__xtemplate_key_name_tl
- \l__xtemplate_keytype_tl
- {
- \__xtemplate_split_keytype_arg:o \l__xtemplate_keytype_tl
- \__xtemplate_parse_vars_elt_aux:nn {#1} {#3}
- \prop_remove:NV \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- }
- { \msg_error:nne { xtemplate } { unknown-key } {#2} }
- }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nn #1#2
- {
- \__xtemplate_parse_vars_elt_aux:nw {#1} #2 global global \s__xtemplate_stop
- }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nw
- #1#2 global #3 global #4 \s__xtemplate_stop
- {
- \tl_if_blank:nTF {#4}
- { \__xtemplate_parse_vars_elt_aux:nnn {#1} { } {#2} }
- {
- \tl_if_blank:nTF {#2}
- {
- \exp_args:Nnne \__xtemplate_parse_vars_elt_aux:nnn
- {#1} { global } { \tl_trim_spaces:n {#3} }
- }
- { \msg_error:nnn { xtemplate } { bad-variable } { #2 global #3 } }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nnn #1#2#3
- {
- \str_case:VnF \l__xtemplate_keytype_tl
- {
- { choice } { \__xtemplate_implement_choices:nn {#1} {#3} }
- { function }
- {
- \cs_if_exist:NF #3
- { \cs_new:Npn #3 { } }
- \__xtemplate_parse_vars_elt_key:nn {#1}
- {
- .code:n =
- {
- \cs_generate_from_arg_count:NNnn
- \exp_not:N #3
- \exp_not:c
- { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
- { \exp_not:o \l__xtemplate_keytype_arg_tl }
- {##1}
- }
- }
- \prop_put:Non \l__xtemplate_vars_prop
- \l__xtemplate_key_name_tl {#2#3}
- }
- { instance }
- {
- \__xtemplate_parse_vars_elt_key:nn {#1}
- {
- .code:n =
- {
- \exp_not:c
- { cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn }
- \exp_not:N #3 { \UseInstance {##1} }
- }
- }
- \prop_put:Non \l__xtemplate_vars_prop
- \l__xtemplate_key_name_tl {#2#3}
- }
- }
- {
- \tl_if_single:nTF {#3}
- {
- \cs_if_exist:NF #3
- { \use:c { \__xtemplate_map_var_type: _new:N } #3 }
- \__xtemplate_parse_vars_elt_key:nn {#1}
- {
- . \__xtemplate_map_var_type:
- _ \str_if_eq:nnT {#1} { global } { g } set:N
- = \exp_not:N #3
- }
- \prop_put:Non \l__xtemplate_vars_prop
- \l__xtemplate_key_name_tl {#2#3}
- }
- { \msg_error:nne { xtemplate } { bad-variable } { #2#3 } }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_vars_elt_key:nn #1#2
- {
- \keys_define:ne { template / #1 }
- { \l__xtemplate_key_name_tl #2 }
- }
-\cs_new:Npn \__xtemplate_map_var_type:
- {
- \str_case:on \l__xtemplate_keytype_tl
- {
- { boolean } { bool }
- { commalist } { clist }
- { integer } { int }
- { length } { dim }
- { muskip } { muskip }
- { real } { fp }
- { skip } { skip }
- { tokenlist } { tl }
- }
- }
-\cs_new_protected:Npn \__xtemplate_implement_choices:nn #1#2
- {
- \clist_set:No \l__xtemplate_tmp_clist { \l__xtemplate_keytype_arg_tl }
- \prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_key_name_tl { }
- \keys_define:ne { template / #1 } { \l__xtemplate_key_name_tl .choice: }
- \keyval_parse:nnn
- { \__xtemplate_implement_choice_elt:n }
- { \__xtemplate_implement_choice_elt:nnn {#1} }
- {#2}
- \prop_get:NoNT \l__xtemplate_values_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- { \__xtemplate_implement_choices_default: }
- \clist_if_empty:NF \l__xtemplate_tmp_clist
- {
- \clist_map_inline:Nn \l__xtemplate_tmp_clist
- {
- \msg_error:nne { xtemplate } { choice-not-implemented }
- {##1}
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_implement_choices_default:
- {
- \tl_set:Ne \l__xtemplate_tmp_tl
- { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl }
- \prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl
- {
- \tl_set:Ne \l__xtemplate_tmp_tl
- { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl }
- \prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl
- {
- \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
- \prop_get:NoN \l__xtemplate_values_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-default-choice }
- { \l__xtemplate_key_name_tl } { \l__xtemplate_key_name_tl }
- { \l__xtemplate_keytype_arg_tl }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_implement_choice_elt:nnn #1#2#3
- {
- \clist_if_empty:NTF \l__xtemplate_tmp_clist
- {
- \str_if_eq:nnTF {#2} { unknown }
- { \__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3} }
- {
- \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l__xtemplate_key_name_tl } {#2}
- { \l__xtemplate_keytype_arg_tl }
- }
- }
- {
- \clist_if_in:NnTF \l__xtemplate_tmp_clist {#2}
- {
- \clist_remove_all:Nn \l__xtemplate_tmp_clist {#2}
- \__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3}
- }
- {
- \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l__xtemplate_key_name_tl } {#2}
- { \l__xtemplate_keytype_arg_tl }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_implement_choice_elt_aux:nnn #1#2#3
- {
- \keys_define:ne { template / #1 }
- { \l__xtemplate_key_name_tl / #2 .code:n = { \exp_not:n {#3} } }
- \tl_set:Ne \l__xtemplate_tmp_tl
- { \l__xtemplate_key_name_tl \c_space_tl #2 }
- \prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_tmp_tl {#3}
- }
-\cs_new_protected:Npn \__xtemplate_implement_choice_elt:n #1
- {
- \msg_error:nneee { xtemplate } { choice-requires-code }
- { \l__xtemplate_key_name_tl } {#1}
- }
-\cs_new_protected:Npn \__xtemplate_declare_restricted:nnnn #1#2#3#4
- {
- \__xtemplate_if_keys_exist:nnT {#1} {#2}
- {
- \__xtemplate_set_template_eq:nn { #1 / #3 } { #1 / #2 }
- \bool_set_true:N \l__xtemplate_restrict_bool
- \__xtemplate_edit_defaults_aux:nnn {#1} {#3} {#4}
- \bool_set_false:N \l__xtemplate_restrict_bool
- }
- }
-\cs_new_protected:Npn \__xtemplate_edit_defaults:nnn
- {
- \bool_set_false:N \l__xtemplate_restrict_bool
- \__xtemplate_edit_defaults_aux:nnn
- }
-\cs_new_protected:Npn \__xtemplate_edit_defaults_aux:nnn #1#2#3
- {
- \__xtemplate_if_keys_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_defaults:n { #1 / #2 }
- \__xtemplate_recover_restrictions:n { #1 / #2 }
- \__xtemplate_parse_values:nn { #1 / #2 } {#3}
- \__xtemplate_store_defaults:n { #1 / #2 }
- \__xtemplate_store_restrictions:n { #1 / #2 }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_values:nn #1#2
- {
- \clist_clear:N \l__xtemplate_restrict_clist
- \__xtemplate_parse_values_aux:nn {#1} {#2}
- }
-\cs_new_protected:Npn \__xtemplate_parse_values_aux:nn #1#2
- {
- \__xtemplate_recover_keytypes:n {#1}
- \keyval_parse:NNn
- \__xtemplate_parse_values_elt:n \__xtemplate_parse_values_elt:nn {#2}
- }
-\cs_new_protected:Npn \__xtemplate_parse_values_elt:n #1
- {
- \bool_set_true:N \l__xtemplate_error_bool
- \msg_error:nne { xtemplate } { key-no-value } {#1}
- }
-\cs_new_protected:Npn \__xtemplate_parse_values_elt:nn #1#2
- {
- \tl_set:Ne \l__xtemplate_key_name_tl
- { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
- \prop_get:NoNTF \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- {
- \bool_if:NTF \l__xtemplate_restrict_bool
- {
- \clist_if_in:NoF \l__xtemplate_restrict_clist
- \l__xtemplate_key_name_tl
- { \__xtemplate_parse_values_elt_aux:n {#2} }
- }
- { \__xtemplate_parse_values_elt_aux:n {#2} }
- }
- {
- \msg_error:nne { xtemplate } { unknown-key }
- { \l__xtemplate_key_name_tl }
- }
- }
-\cs_new_protected:Npn \__xtemplate_parse_values_elt_aux:n #1
- {
- \clist_put_right:No \l__xtemplate_restrict_clist \l__xtemplate_key_name_tl
- \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
- \use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#1}
- }
-\cs_new_protected:Npn \__xtemplate_set_template_eq:nn #1#2
- {
- \__xtemplate_recover_defaults:n {#2}
- \__xtemplate_store_defaults:n {#1}
- \__xtemplate_recover_keytypes:n {#2}
- \__xtemplate_store_keytypes:n {#1}
- \__xtemplate_recover_vars:n {#2}
- \__xtemplate_store_vars:n {#1}
- \cs_gset_eq:cc { \c__xtemplate_code_root_tl #1 }
- { \c__xtemplate_code_root_tl #2 }
- }
-\cs_new_protected:Npn \__xtemplate_declare_instance:nnnnn #1#2#3#4#5
- {
- \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_defaults:n { #1 / #2 }
- \__xtemplate_recover_restrictions:n { #1 / #2 }
- \__xtemplate_recover_vars:n { #1 / #2 }
- \__xtemplate_declare_instance_aux:nnnnn {#1} {#2} {#3} {#4} {#5}
- }
- }
-\cs_new_protected:Npn \__xtemplate_declare_instance_aux:nnnnn #1#2#3#4#5
- {
- \bool_set_false:N \l__xtemplate_error_bool
- \__xtemplate_parse_values_aux:nn { #1 / #2 } {#5}
- \bool_if:NF \l__xtemplate_error_bool
- {
- \prop_put:Nnn \l__xtemplate_values_prop { from~template } {#2}
- \__xtemplate_store_values:n { #1 / #3 / #4 }
- \__xtemplate_convert_to_assignments:
- \cs_set_protected:cpe { \c__xtemplate_instances_root_tl #1 / #3 / #4 }
- {
- \exp_not:N \__xtemplate_assignments_push:n
- { \exp_not:o \l__xtemplate_assignments_tl }
- \exp_not:c { \c__xtemplate_code_root_tl #1 / #2 }
- }
- \__xtemplate_if_instance_exist:nnnF {#1} { } {#4}
- {
- \cs_set_eq:cc
- { \c__xtemplate_instances_root_tl #1 / / #4 }
- { \c__xtemplate_instances_root_tl #1 / #3 / #4 }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_copy_instance:nnnn #1#2#3#4
- {
- \__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3}
- {
- \__xtemplate_recover_values:n { #1 / #2 / #3 }
- \__xtemplate_store_values:n { #1 / #2 / #4 }
- \cs_set_eq:cc { \c__xtemplate_instances_root_tl #1 / #2 / #4 }
- { \c__xtemplate_instances_root_tl #1 / #2 / #3 }
- }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#3}
- }
- }
-\cs_new_protected:Npn \__xtemplate_edit_instance:nnnn #1#2#3#4
- {
- \__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3}
- {
- \__xtemplate_recover_values:n { #1 / #2 / #3 }
- \prop_get:NnN \l__xtemplate_values_prop { from~template }
- \l__xtemplate_tmp_tl
- \__xtemplate_edit_instance_aux:nonnn {#1} \l__xtemplate_tmp_tl
- {#2} {#3} {#4}
- }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#3}
- }
- }
-\cs_new_protected:Npn \__xtemplate_edit_instance_aux:nnnnn #1#2
- {
- \__xtemplate_recover_vars:n { #1 / #2 }
- \__xtemplate_declare_instance_aux:nnnnn {#1} {#2}
- }
-\cs_generate_variant:Nn \__xtemplate_edit_instance_aux:nnnnn { no }
-\cs_new_protected:Npn \__xtemplate_convert_to_assignments:
- {
- \tl_clear:N \l__xtemplate_assignments_tl
- \seq_map_function:NN \l__xtemplate_key_order_seq
- \__xtemplate_convert_to_assignments_aux:n
- }
-\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:n #1
- {
- \prop_get:NnN \l__xtemplate_keytypes_prop {#1} \l__xtemplate_tmp_tl
- \__xtemplate_convert_to_assignments_aux:no {#1} \l__xtemplate_tmp_tl
- }
-\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:nn #1#2
- {
- \prop_get:NnNT \l__xtemplate_values_prop {#1} \l__xtemplate_value_tl
- {
- \prop_get:NnNTF \l__xtemplate_vars_prop {#1} \l__xtemplate_var_tl
- {
- \__xtemplate_split_keytype_arg:n {#2}
- \str_if_eq:onF \l__xtemplate_keytype_tl { choice }
- {
- \str_if_eq:onF \l__xtemplate_keytype_tl { code }
- { \__xtemplate_find_global: }
- }
- \tl_set:Nn \l__xtemplate_key_name_tl {#1}
- \use:c { __xtemplate_assign_ \l__xtemplate_keytype_tl : }
- }
- { \msg_error:nne { xtemplate } { unknown-attribute } {#1} }
- }
- }
-\cs_generate_variant:Nn \__xtemplate_convert_to_assignments_aux:nn { no }
-\cs_new_protected:Npn \__xtemplate_find_global:
- {
- \bool_set_false:N \l__xtemplate_global_bool
- \tl_if_in:onT \l__xtemplate_var_tl { global }
- {
- \exp_after:wN \__xtemplate_find_global_aux:w \l__xtemplate_var_tl \s__xtemplate_stop
- }
- }
-\cs_new_protected:Npn \__xtemplate_find_global_aux:w #1 global #2 \s__xtemplate_stop
- {
- \tl_set:Nn \l__xtemplate_var_tl {#2}
- \bool_set_true:N \l__xtemplate_global_bool
- }
-\cs_new_protected:Npn \__xtemplate_use_template:nnn #1#2#3
- {
- \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_defaults:n { #1 / #2 }
- \__xtemplate_recover_vars:n { #1 / #2 }
- \__xtemplate_parse_values:nn { #1 / #2 } {#3}
- \__xtemplate_convert_to_assignments:
- \use:c { \c__xtemplate_code_root_tl #1 / #2 }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_boolean:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_boolean_aux:n { bool_gset } }
- { \__xtemplate_assign_boolean_aux:n { bool_set } }
- }
-\cs_new_protected:Npn \__xtemplate_assign_boolean_aux:n #1
- {
- \__xtemplate_if_key_value:oTF \l__xtemplate_value_tl
- {
- \__xtemplate_key_to_value:
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- \exp_not:c { #1 _eq:NN }
- \exp_not:o \l__xtemplate_var_tl
- \exp_not:o \l__xtemplate_value_tl
- }
- }
- {
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- \exp_not:c { #1 _ \l__xtemplate_value_tl :N }
- \exp_not:o \l__xtemplate_var_tl
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_choice:
- {
- \__xtemplate_assign_choice_aux:eF
- { \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_value_tl }
- {
- \__xtemplate_assign_choice_aux:eF
- { \l__xtemplate_key_name_tl \c_space_tl unknown }
- {
- \prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl
- \l__xtemplate_tmp_tl
- \__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl
- \msg_error:nneee { xtemplate } { unknown-choice }
- { \l__xtemplate_key_name_tl } { \l__xtemplate_value_tl }
- { \l__xtemplate_keytype_arg_tl }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_choice_aux:nF #1
- {
- \prop_get:NnNTF
- \l__xtemplate_vars_prop
- {#1}
- \l__xtemplate_tmp_tl
- { \tl_put_right:No \l__xtemplate_assignments_tl \l__xtemplate_tmp_tl }
- }
-\cs_generate_variant:Nn \__xtemplate_assign_choice_aux:nF { e }
-\cs_new_protected:Npn \__xtemplate_assign_function:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_function_aux:N \cs_gset:Npn }
- { \__xtemplate_assign_function_aux:N \cs_set:Npn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_function_aux:N #1
- {
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- \cs_generate_from_arg_count:NNnn
- \exp_not:o \l__xtemplate_var_tl
- \exp_not:N #1
- { \exp_not:o \l__xtemplate_keytype_arg_tl }
- { \exp_not:o \l__xtemplate_value_tl }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_instance:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_instance_aux:N \cs_gset_protected:Npn }
- { \__xtemplate_assign_instance_aux:N \cs_set_protected:Npn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_instance_aux:N #1
- {
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- \exp_not:N #1 \exp_not:o \l__xtemplate_var_tl
- {
- \__xtemplate_use_instance:nn
- { \exp_not:o \l__xtemplate_keytype_arg_tl }
- { \exp_not:o \l__xtemplate_value_tl }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_integer:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_variable:N \int_gset:Nn }
- { \__xtemplate_assign_variable:N \int_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_length:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_variable:N \dim_gset:Nn }
- { \__xtemplate_assign_variable:N \dim_set:Nn }
-}
-\cs_new_protected:Npn \__xtemplate_assign_muskip:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_variable:N \muskip_gset:Nn }
- { \__xtemplate_assign_variable:N \muskip_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_real:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_variable:N \fp_gset:Nn }
- { \__xtemplate_assign_variable:N \fp_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_skip:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_variable:N \skip_gset:Nn }
- { \__xtemplate_assign_variable:N \skip_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_tokenlist:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_tokenlist_aux:NN \tl_gset:NV \tl_gset:Nn }
- { \__xtemplate_assign_tokenlist_aux:NN \tl_set:NV \tl_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_tokenlist_aux:NN #1#2
- {
- \__xtemplate_if_key_value:oTF \l__xtemplate_value_tl
- {
- \__xtemplate_key_to_value:
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- #1 \exp_not:o \l__xtemplate_var_tl
- \exp_not:o \l__xtemplate_value_tl
- }
- }
- {
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- #2 \exp_not:o \l__xtemplate_var_tl
- { \exp_not:o \l__xtemplate_value_tl }
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_assign_commalist:
- {
- \bool_if:NTF \l__xtemplate_global_bool
- { \__xtemplate_assign_tokenlist_aux:NN \clist_gset:NV \clist_gset:Nn }
- { \__xtemplate_assign_tokenlist_aux:NN \clist_set:NV \clist_set:Nn }
- }
-\cs_new_protected:Npn \__xtemplate_assign_variable:N #1
- {
- \__xtemplate_if_key_value:oT \l__xtemplate_value_tl
- { \__xtemplate_key_to_value: }
- \tl_put_right:Ne \l__xtemplate_assignments_tl
- {
- #1 \exp_not:o \l__xtemplate_var_tl
- { \exp_not:o \l__xtemplate_value_tl }
- }
- }
-\cs_new_protected:Npn \__xtemplate_key_to_value:
- { \exp_after:wN \__xtemplate_key_to_value_auxi:w \l__xtemplate_value_tl }
-\cs_new_protected:Npn \__xtemplate_key_to_value_auxi:w \KeyValue #1
- {
- \tl_set:Ne \l__xtemplate_tmp_tl { \tl_trim_spaces:e { \tl_to_str:n {#1} } }
- \prop_get:NoNTF
- \l__xtemplate_vars_prop
- \l__xtemplate_tmp_tl
- \l__xtemplate_value_tl
- {
- \exp_after:wN \__xtemplate_key_to_value_auxii:w \l__xtemplate_value_tl
- \s__xtemplate_mark global \q__xtemplate_nil \s__xtemplate_stop
- }
- {
- \msg_error:nne { xtemplate } { unknown-attribute }
- { \l__xtemplate_tmp_tl }
- }
- }
-\cs_new_protected:Npn \__xtemplate_key_to_value_auxii:w #1 global #2#3 \s__xtemplate_stop
- {
- \__xtemplate_quark_if_nil:NF #2
- { \tl_set:Nn \l__xtemplate_value_tl {#2} }
- }
-\cs_new_protected:Npn \__xtemplate_use_instance:nn #1#2
- {
- \__xtemplate_if_use_template:nTF {#2}
- { \__xtemplate_use_instance_aux:nNnnn {#1} #2 }
- { \__xtemplate_use_instance_aux:nn {#1} {#2} }
- }
-\cs_new_protected:Npn \__xtemplate_use_instance_aux:nNnnn #1#2#3#4#5
- {
- \str_if_eq:nnTF {#1} {#3}
- { \__xtemplate_use_template:nnn {#3} {#4} {#5} }
- { \msg_error:nnee { xtemplate } { type-mismatch } {#1} {#3} }
-}
-\cs_new_protected:Npn \__xtemplate_use_instance_aux:nn #1#2
- {
- \__xtemplate_get_collection:n {#1}
- \__xtemplate_if_instance_exist:nnnTF
- {#1} { \l__xtemplate_collection_tl } {#2}
- {
- \use:c
- {
- \c__xtemplate_instances_root_tl #1 /
- \l__xtemplate_collection_tl / #2
- }
- }
- {
- \__xtemplate_if_instance_exist:nnnTF {#1} { } {#2}
- { \use:c { \c__xtemplate_instances_root_tl #1 / / #2 } }
- {
- \msg_error:nnee { xtemplate } { unknown-instance }
- {#1} {#2}
- }
- }
- }
-\cs_new_protected:Npn \__xtemplate_use_collection:nn #1#2
- { \prop_put:Nnn \l__xtemplate_collections_prop {#1} {#2} }
-\cs_new_protected:Npn \__xtemplate_get_collection:n #1
- {
- \prop_get:NnNF \l__xtemplate_collections_prop {#1}
- \l__xtemplate_collection_tl
- { \tl_clear:N \l__xtemplate_collection_tl }
- }
-\cs_new:Npn \__xtemplate_assignments_pop: { \l__xtemplate_assignments_tl }
-\cs_new_protected:Npn \__xtemplate_assignments_push:n #1
- { \tl_set:Nn \l__xtemplate_assignments_tl {#1} }
-\cs_new_protected:Npn \__xtemplate_show_code:nn #1#2
- { \cs_show:c { \c__xtemplate_code_root_tl #1 / #2 } }
-\cs_new_protected:Npn \__xtemplate_show_defaults:nn #1#2
- {
- \__xtemplate_if_keys_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_defaults:n { #1 / #2 }
- \__xtemplate_show:Nnnn \l__xtemplate_values_prop
- {#1} {#2} { default~values }
- }
- }
-\cs_new_protected:Npn \__xtemplate_show_keytypes:nn #1#2
- {
- \__xtemplate_if_keys_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_keytypes:n { #1 / #2 }
- \__xtemplate_show:Nnnn \l__xtemplate_keytypes_prop
- {#1} {#2} { interface }
- }
- }
-\cs_new_protected:Npn \__xtemplate_show_vars:nn #1#2
- {
- \__xtemplate_execute_if_code_exist:nnT {#1} {#2}
- {
- \__xtemplate_recover_vars:n { #1 / #2 }
- \__xtemplate_show:Nnnn \l__xtemplate_vars_prop
- {#1} {#2} { variable~mapping }
- }
- }
-\cs_new_protected:Npn \__xtemplate_show:Nnnn #1#2#3#4
- {
- \msg_show:nneeee { xtemplate } { show-attribute }
- { \tl_to_str:n {#2} }
- { \tl_to_str:n {#3} }
- { \tl_to_str:n {#4} }
- { \prop_map_function:NN #1 \msg_show_item_unbraced:nn }
- }
-\cs_new_protected:Npn \__xtemplate_show_values:nnn #1#2#3
- {
- \__xtemplate_if_instance_exist:nnnT {#1} {#2} {#3}
- {
- \__xtemplate_recover_values:n { #1 / #2 / #3 }
- \msg_show:nneeee { xtemplate } { show-values }
- { \tl_to_str:n {#1} }
- { \tl_to_str:n {#2} }
- { \tl_to_str:n {#3} }
- {
- \prop_map_function:NN \l__xtemplate_values_prop
- \msg_show_item_unbraced:nn
- }
- }
- }
-\msg_new:nnnn { xtemplate } { argument-number-mismatch }
- { Object~type~'#1'~takes~#2~argument(s). }
- {
- Objects~of~type~'#1'~require~#2~argument(s).\\
- You~have~tried~to~make~a~template~for~'#1'~
- with~#3~argument(s),~which~is~not~possible:~
- the~number~of~arguments~must~agree.
- }
-\msg_new:nnnn { xtemplate } { bad-number-of-arguments }
- { Bad~number~of~arguments~for~object~type~'#1'. }
- {
- An~object~may~accept~between~0~and~9~arguments.\\
- You~asked~to~use~#2~arguments:~this~is~not~supported.
- }
-\msg_new:nnnn { xtemplate } { bad-variable }
- { Incorrect~variable~description~'#1'. }
- {
- The~argument~'#1'~is~not~of~the~form \\
- ~~'<variable>'\\
- ~or~\\
- ~~'global~<variable>'.\\
- It~must~be~given~in~one~of~these~formats~to~be~used~in~a~template.
- }
-\msg_new:nnnn { xtemplate } { choice-not-implemented }
- { The~choice~'#1'~has~no~implementation. }
- {
- Each~choice~listed~in~the~interface~for~a~template~must~
- have~an~implementation.
- }
-\msg_new:nnnn { xtemplate } { choice-no-code }
- { The~choice~'#1'~requires~implementation~details. }
- {
- When~creating~template~code~using~\DeclareTemplateCode,~
- each~choice~name~must~have~an~associated~implementation.\\
- This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
- }
-\msg_new:nnnn { xtemplate } { choice-requires-code }
- { The~choice~'#2'~for~key~'#1'~requires~an~implementation. }
- {
- You~should~have~put:\\
- \ \ #1~:~choice~{~#2 = <code> ~} \\
- but~LaTeX~did~not~find~any~<code>.
- }
-\msg_new:nnnn { xtemplate } { duplicate-key-interface }
- { Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. }
- {
- Each~key~can~only~have~one~interface~declared~in~a~template.\\
- LaTeX~found~two~interfaces~for~'#1'.
- }
-\msg_new:nnnn { xtemplate } { keytype-requires-argument }
- { The~key~type~'#1'~requires~an~argument~\msg_line_context:. }
- {
- You~should~have~put:\\
- \ \ <key-name>~:~#1~{~<argument>~} \\
- but~LaTeX~did~not~find~an~<argument>.
- }
-\msg_new:nnnn { xtemplate } { invalid-keytype }
- { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
- {
- Each~key~in~a~template~requires~a~key-type,~given~in~the~form:\\
- \ \ <key>~:~<key-type>\\
- LaTeX~could~not~find~a~<key-type>~in~your~input.
- }
-\msg_new:nnnn { xtemplate } { key-no-value }
- { The~key~'#1'~has~no~value~\msg_line_context:. }
- {
- When~creating~an~instance~of~a~template~
- every~key~listed~must~include~a~value:\\
- \ \ <key>~=~<value>
- }
-\msg_new:nnnn { xtemplate } { key-no-variable }
- { The~key~'#1'~requires~implementation~details~\msg_line_context:. }
- {
- When~creating~template~code~using~\DeclareTemplateCode,~
- each~key~name~must~have~an~associated~implementation.\\
- This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one.
- }
-\msg_new:nnnn { xtemplate } { key-not-implemented }
- { Key~'#1'~has~no~implementation~\msg_line_context:. }
- {
- The~definition~of~key~implementations~for~template~'#2'~
- of~object~type~'#3'~does~not~include~any~details~for~key~'#1'.\\
- The~key~was~declared~in~the~interface~definition,~
- and~so~an~implementation~is~required.
- }
-\msg_new:nnnn { xtemplate } { missing-keytype }
- { The~key~'#1'~is~missing~a~key-type~\msg_line_context:. }
- {
- Key~interface~definitions~should~be~of~the~form\\
- \ \ #1~:~<key-type>\\
- but~LaTeX~could~not~find~a~<key-type>.
- }
-\msg_new:nnnn { xtemplate } { no-template-code }
- {
- The~template~'#2'~of~type~'#1'~is~unknown~
- or~has~no~implementation.
- }
- {
- There~is~no~code~available~for~the~template~name~given.\\
- This~should~be~given~using~\DeclareTemplateCode.
- }
-\msg_new:nnnn { xtemplate } { object-type-mismatch }
- { Object~types~'#1'~and~'#2'~do~not~agree. }
- {
- You~are~trying~to~use~a~template~directly~with~\UseInstance
- (or~a~similar~function),~but~the~object~types~do~not~match.
- }
-\msg_new:nnnn { xtemplate } { unknown-attribute }
- { The~template~attribute~'#1'~is~unknown. }
- {
- There~is~a~definition~in~the~current~template~reading\\
- \ \ \token_to_str:N \KeyValue {~#1~} \\
- but~there~is~no~key~called~'#1'.
- }
-\msg_new:nnnn { xtemplate } { unknown-choice }
- { The~choice~'#2'~was~not~declared~for~key~'#1'. }
- {
- The~key~'#1'~takes~a~fixed~list~of~choices~
- and~this~list~does~not~include~'#2'.
- }
-\msg_new:nnnn { xtemplate } { unknown-default-choice }
- { The~default~choice~'#2'~was~not~declared~for~key~'#1'. }
- {
- The~key~'#1'~takes~a~fixed~list~of~choices~
- and~this~list~does~not~include~'#2'.
- }
-\msg_new:nnnn { xtemplate } { unknown-instance }
- { The~instance~'#2'~of~type~'#1'~is~unknown. }
- {
- You~have~asked~to~use~an~instance~'#2',~
- but~this~has~not~been~created.
- }
-\msg_new:nnnn { xtemplate } { unknown-key }
- { Unknown~template~key~'#1'. }
- {
- The~key~'#1'~was~not~declared~in~the~interface~
- for~the~current~template.
- }
-\msg_new:nnnn { xtemplate } { unknown-keytype }
- { The~key-type~'#1'~is~unknown. }
- {
- Valid~key-types~are:\\
- -~boolean;\\
- -~choice;\\
- -~commalist;\\
- -~function;\\
- -~instance;\\
- -~integer;\\
- -~length;\\
- -~muskip;\\
- -~real;\\
- -~skip;\\
- -~tokenlist.
- }
-\msg_new:nnnn { xtemplate } { unknown-object-type }
- { The~object~type~'#1'~is~unknown. }
- {
- An~object~type~needs~to~be~declared~with~\DeclareObjectType
- prior~to~using~it.
- }
-\msg_new:nnnn { xtemplate } { unknown-template }
- { The~template~'#2'~of~type~'#1'~is~unknown. }
- {
- No~interface~has~been~declared~for~a~template~
- '#2'~of~object~type~'#1'.
- }
-\msg_new:nnn { xtemplate } { declare-object-type }
- { Declaring~object~type~'#1'~taking~#2~argument(s)~\msg_line_context:. }
-\msg_new:nnn { xtemplate } { declare-template-code }
- { Declaring~code~for~template~'#2'~of~object~type'#1'~\msg_line_context:. }
-\msg_new:nnn { xtemplate } { declare-template-interface }
- {
- Declaring~interface~for~template~'#2'~of~object~type~'#1'~
- \msg_line_context:.
- }
-\msg_new:nnn { xtemplate } { show-attribute }
- {
- The~template~'#2'~of~object~type~'#1'~has~
- \tl_if_empty:nTF {#4} { no~#3. } { #3 : #4 }
- }
-\msg_new:nnn { xtemplate } { show-values }
- {
- \tl_if_empty:nTF {#2}
- { The~instance~'#3'~ }
- { The~collection~ instance~'#3'~ (from~collection~'#2')~ }
- of~object~type~'#1'~has~
- \tl_if_empty:nTF {#4} { no~values. } { values: #4 }
+ {%
+ \ProvidesExplPackage{xtemplate}{2023-10-10}{}
+ {L3 Experimental prototype document functions}
+ \long\protected\def\DeclareRestrictedTemplate#1#2#3#4{%
+ \DeclareTemplateCopy{#1}{#3}{#2}%
+ \EditTemplateDefaults{#1}{#3}{#4}%
+ }%
}
+\ExplSyntaxOn
\cs_new_protected:Npn \DeclareObjectType #1#2
- { \__xtemplate_declare_object_type:nn {#1} {#2} }
-\cs_new_protected:Npn \DeclareTemplateInterface #1#2#3#4
- { \__xtemplate_declare_template_keys:nnnn {#1} {#2} {#3} {#4} }
-\cs_new_protected:Npn \DeclareTemplateCode #1#2#3#4#5
- { \__xtemplate_declare_template_code:nnnnn {#1} {#2} {#3} {#4} {#5} }
-\cs_new_protected:Npn \DeclareRestrictedTemplate #1#2#3#4
- { \__xtemplate_declare_restricted:nnnn {#1} {#2} {#3} {#4} }
-\cs_new_protected:Npn \DeclareInstance #1#2#3#4
- { \__xtemplate_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} }
-\cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5
- { \__xtemplate_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} }
-\cs_new_protected:Npn \DeclareInstanceCopy #1#2#3
- { \__xtemplate_copy_instance:nnnn {#1} { } {#3} {#2} }
-\cs_new_protected:Npn \EditTemplateDefaults #1#2#3
- { \__xtemplate_edit_defaults:nnn {#1} {#2} {#3} }
-\cs_new_protected:Npn \EditInstance #1#2#3
- { \__xtemplate_edit_instance:nnnn {#1} { } {#2} {#3} }
-\cs_new_protected:Npn \EditCollectionInstance #1#2#3#4
- { \__xtemplate_edit_instance:nnnn {#2} {#1} {#3} {#4} }
-\cs_new_protected:Npn \UseTemplate #1#2#3
- { \__xtemplate_use_template:nnn {#1} {#2} {#3} }
-\cs_new_protected:Npn \UseInstance #1#2
- { \__xtemplate_use_instance:nn {#1} {#2} }
-\cs_new_protected:Npn \UseCollection #1#2
- { \__xtemplate_use_collection:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateCode #1#2
- { \__xtemplate_show_code:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateDefaults #1#2
- { \__xtemplate_show_defaults:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateInterface #1#2
- { \__xtemplate_show_keytypes:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowTemplateVariables #1#2
- { \__xtemplate_show_vars:nn {#1} {#2} }
-\cs_new_protected:Npn \ShowInstanceValues #1#2
- { \__xtemplate_show_values:nnn {#1} { } {#2} }
-\cs_new_protected:Npn \ShowCollectionInstanceValues #1#2#3
- { \__xtemplate_show_values:nnn {#1} {#2} {#3} }
-\cs_new:Npn \IfInstanceExistTF #1#2
- { \__xtemplate_if_instance_exist:nnnTF {#1} { } {#2} }
-\cs_new:Npn \IfInstanceExistT #1#2
- { \__xtemplate_if_instance_exist:nnnT {#1} { } {#2} }
-\cs_new:Npn \IfInstanceExistF #1#2
- { \__xtemplate_if_instance_exist:nnnF {#1} { } {#2} }
-\cs_new_protected:Npn \KeyValue #1 {#1}
-\cs_new_protected:Npn \AssignTemplateKeys
- { \__xtemplate_assignments_pop: }
-\cs_new_protected:Npn \SetTemplateKeys #1#2#3
- { \keys_set_known:nnN { template / #1 / #2 } {#3} \l__xtemplate_tmp_clist }
-\cs_new_eq:NN \ShowTemplateKeytypes \ShowTemplateInterface
+ { \__template_declare_type:nn {#1} {#2} }
+\ExplSyntaxOff
%%
%%
%% End of file `xtemplate.sty'.