diff options
author | Karl Berry <karl@freefriends.org> | 2023-03-21 20:51:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-03-21 20:51:05 +0000 |
commit | 8581c3ea62b08305b6e6ea2b355aedc17b91494c (patch) | |
tree | 8d1b6db1fd6a091f44cc9e8842042c7d2ed7ffc8 | |
parent | 552c2f99479d2f8c84a188cc03d22adad630de0e (diff) |
stex (21mar23)
git-svn-id: svn://tug.org/texlive/trunk@66640 c570f23f-e606-0410-a88d-b1316a301751
100 files changed, 20986 insertions, 24299 deletions
diff --git a/Master/texmf-dist/doc/latex/stex/Makefile b/Master/texmf-dist/doc/latex/stex/Makefile index 7544a3c2fdc..6b1efc4862c 100644 --- a/Master/texmf-dist/doc/latex/stex/Makefile +++ b/Master/texmf-dist/doc/latex/stex/Makefile @@ -1,8 +1,8 @@ -STY = stex extensions +STY = . SPATH = $(STY:%=../source/%) DTX = $(shell ls $(SPATH:%=%/*.dtx)) INS = $(shell ls $(SPATH:%=%/*.ins)) -DOC = stex-doc.pdf stex-manual.pdf stex-ide.pdf +DOC = stex-doc.pdf TEXDIR = ../tex TEXINPUTS = $(TEXDIR)//: @@ -20,6 +20,7 @@ pack: $(DTX) $(INS) $(DOC): %.pdf: %.tex pack $(PDFLATEX) $< biber -q $(basename $<) + makeindex -s gind.ist -o $(basename $<).ind $(basename $<).idx $(PDFLATEX) $< echo: diff --git a/Master/texmf-dist/doc/latex/stex/Makefile.top b/Master/texmf-dist/doc/latex/stex/Makefile.top index ff0fca84513..43942d6051b 100644 --- a/Master/texmf-dist/doc/latex/stex/Makefile.top +++ b/Master/texmf-dist/doc/latex/stex/Makefile.top @@ -1,5 +1,8 @@ +TEST = test.tex # recurse into the directories. MAKEDIRS = source doc all package doc: @for d in $(MAKEDIRS); do (cd $$d && $(MAKE) -$(MAKEFLAGS) $@) || exit $$?; done + ls + pdflatex test.en.tex diff --git a/Master/texmf-dist/doc/latex/stex/img/vsc1.png b/Master/texmf-dist/doc/latex/stex/img/vsc1.png Binary files differdeleted file mode 100644 index c6c3847f692..00000000000 --- a/Master/texmf-dist/doc/latex/stex/img/vsc1.png +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/stex/img/vsc2.png b/Master/texmf-dist/doc/latex/stex/img/vsc2.png Binary files differdeleted file mode 100644 index e6365ad8024..00000000000 --- a/Master/texmf-dist/doc/latex/stex/img/vsc2.png +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/stex/img/vsc3.png b/Master/texmf-dist/doc/latex/stex/img/vsc3.png Binary files differdeleted file mode 100644 index d7b67ae278b..00000000000 --- a/Master/texmf-dist/doc/latex/stex/img/vsc3.png +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-basics.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-basics.tex deleted file mode 100644 index f766b9b22f1..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-basics.tex +++ /dev/null @@ -1,41 +0,0 @@ -We can use \sTeX by simply including the package with |\usepackage{stex}|, -or -- primarily for individual fragments to be included in other -documents -- by using the \sTeX document class with |\documentclass{stex}| -which combines the \pkg{standalone} document class with the \pkg{stex} -package. - -Both the \pkg{stex} package and document class offer the following -options: - -\begin{description} - \item[\texttt{lang}] (\meta{language}$\ast$) Languages - to load with the \pkg{babel} package. - \item[\texttt{mathhub}] (\meta{directory}) MathHub folder - to search for repositories -- this is not necessary if the - |MATHHUB| system variable is set. - \item[\texttt{writesms}] (\meta{boolean}) with this package - option, \sTeX will write the contents of all external - modules imported via \stexcode"\importmodule" or \stexcode"\usemodule" - into a file \stexcode"\jobname.sms" (analogously to - the table of contents \stexcode".toc"-file). - \item[\texttt{usems}] (\meta{boolean}) subsequently tells - \sTeX to read the generated sms-file at the beginning of the - document. This allows for e.g. collaborating on documents - without all authors having to have all used archives and - modules available -- one author can load the modules - with \texttt{writesms}, and the rest can use the - the modules with \texttt{usesms}. Furthermore, the sms - file can be submitted alongside a \texttt{tex}-file, - effectively making it ``standalone''. - \item[\texttt{image}] (\meta{boolean}) passed on to - \pkg{tikzinput}. - \item[\texttt{debug}] (\meta{log-prefix}$\ast$) Logs debugging - information with the given prefixes to the terminal, - or all if |all| is given. Largely irrelevant for the - majority of users. -\end{description} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex deleted file mode 100644 index f2cabec6c08..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-document-structure.tex +++ /dev/null @@ -1,167 +0,0 @@ -\begin{sfragment}[id=sec:ds:intro]{Introduction} -The \pkg{document-structure} package supplies an infrastructure for writing {\omdoc} documents in {\LaTeX}. -This includes a simple structure sharing mechanism for \sTeX that allows to to move from -a copy-and-paste document development model to a copy-and-reference model, which -conserves space and simplifies document management. The augmented structure can be used -by MKM systems for added-value services, either directly from the \sTeX sources, or -after translation. - - - The \pkg{document-structure} package supplies macros and environments that allow to label document - fragments and to reference them later in the same document or in other documents. In - essence, this enhances the document-as-trees model to - documents-as-directed-acyclic-graphs (DAG) model. This structure can be used by MKM - systems for added-value services, either directly from the \sTeX sources, or after - translation. Currently, trans-document referencing provided by this package can only be - used in the \sTeX collection. - - DAG models of documents allow to replace the ``Copy and Paste'' in the source document - with a label-and-reference model where document are shared in the document source and the - formatter does the copying during document formatting/presentation. -\end{sfragment} - -\begin{sfragment}{Package Options} -The \pkg{document-structure} package accepts the following options: -\begin{center} - \begin{tabular}{|l|p{10cm}|}\hline - \texttt{class=\meta{name}} & load \meta{name}|.cls| instead of |article.cls|\\\hline - \texttt{topsect=\meta{sect}} & The top-level sectioning level; the default for - \meta{sect} is \texttt{section}\\\hline - \end{tabular} -\end{center} -\end{sfragment} - -\begin{sfragment}{Document Fragments} -\begin{environment}{sfragment} - The structure of the document is given by nested |sfragment| environments. In the - {\LaTeX} route, the |sfragment| environment is flexibly mapped to sectioning commands, - inducing the proper sectioning level from the nesting of |sfragment| - environments. Correspondingly, the |sfragment| environment takes an optional key/value - argument for metadata followed by a regular argument for the (section) title of the - sfragment. The optional metadata argument has the keys |id| for an identifier, - |creators| and |contributors| for the Dublin Core metadata~\cite{DCMI:dmt03}. The option - |short| allows to give a short title for the generated section. If the title contains - semantic macros, we need to give the |loadmodules| key (it needs no value). For instance - we would have -\begin{latexcode} -\begin{smodule}{foo} - \symdef{bar}{B^a_r} - ... - \begin{sfragment}[id=sec.barderiv,loadmodules] - {Introducing $\protect\bar$ Derivations} -\end{latexcode} - -\sTeX automatically computes the sectioning level, from the nesting of |sfragment| -environments. -\end{environment} - -But sometimes, we want to skip levels (e.g. to use a |\subsection*| as an introduction for -a chapter). - -\begin{environment}{blindfragment} - Therefore the \pkg{document-structure} package provides a variant |blindfragment| that - does not produce markup, but increments the sectioning level and logically groups - document parts that belong together, but where traditional document markup relies on - convention rather than explicit markup. The |blindfragment| environment is useful - e.g. for creating frontmatter at the correct level. The example below shows a typical - setup for the outer document structure of a book with parts and chapters. - -\begin{latexcode} -\begin{document} -\begin{blindfragment} -\begin{blindfragment} -\begin{frontmatter} -\maketitle\newpage -\begin{sfragment}{Preface} -... <<preface>> ... -\end{sfragment} -\clearpage\setcounter{tocdepth}{4}\tableofcontents\clearpage -\end{frontmatter} -\end{blindfragment} -... <<introductory remarks>> ... -\end{blindfragment} -\begin{sfragment}{Introduction} -... <<intro>> ... -\end{sfragment} -... <<more chapters>> ... -\bibliographystyle{alpha}\bibliography{kwarc} -\end{document} -\end{latexcode} - -Here we use two levels of |blindfragment|: -\begin{itemize} -\item The outer one groups the introductory parts of the book (which we assume to have a - sectioning hierarchy topping at the part level). This |blindfragment| makes sure that - the introductory remarks become a ``chapter'' instead of a ``part''. -\item The inner one groups the frontmatter\footnote{We shied away from redefining the - |frontmatter| to induce a blindfragment, but this may be the ``right'' way to go in - the future.} and makes the preface of the book a section-level construct. The - |frontmatter| environment also suppresses numbering as is traditional for prefaces. -\end{itemize} -\end{environment} - -\begin{function}{\skipfragment} - The |\skipfragment| ``skips an |sfragment|'', i.e. it just steps the respective sectioning - counter. This macro is useful, when we want to keep two documents in sync structurally, - so that section numbers match up: Any section that is left out in one becomes a - |\skipfragment|. -\end{function} - -\begin{function}{\currentsectionlevel,\CurrentSectionLevel} - The |\currentsectionlevel| macro supplies the name of the current sectioning level, - e.g. ``chapter'', or ``subsection''. |\CurrentSectionLevel| is the capitalized - variant. They are useful to write something like ``In this |\currentsectionlevel|, we - will\ldots'' in an |sfragment| environment, where we do not know which sectioning level we - will end up. -\end{function} -\end{sfragment} - -\begin{sfragment}{Ending Documents Prematurely} -\begin{function}{\prematurestop,\afterprematurestop} - For prematurely stopping the formatting of a document, \sTeX provides the - |\prematurestop| macro. It can be used everywhere in a document and ignores all input - after that -- backing out of the |sfragment| environments as needed. After that -- and - before the implicit |\end{document}| it calls the internal |\afterprematurestop|, which - can be customized to do additional cleanup or e.g. print the bibliography. - - |\prematurestop| is useful when one has a driver file, e.g. for a course taught multiple - years and wants to generate course notes up to the current point in the lecture. Instead - of commenting out the remaining parts, one can just move the |\prematurestop| macro. - This is especially useful, if we need the rest of the file for processing, e.g. to - generate a theory graph of the whole course with the already-covered parts marked up as - an overview over the progress; see |import_graph.py| from the |lmhtools| - utilities~\cite{lmhtools:github:on}. -\end{function} - -Text fragments and modules can be made more re-usable by the use of global variables. For -instance, the admin section of a course can be made course-independent (and therefore -re-usable) by using variables (actually token registers) |courseAcronym| and |courseTitle| -instead of the text itself. The variables can then be set in the \sTeX preamble of the -course notes file. -\end{sfragment} - -\begin{sfragment}{Global Document Variables} - To make document fragments more reusable, we sometimes want to make the content depend - on the context. We use \defemph{document variables} for that. - -\begin{function}{\setSGvar,\useSGvar} - |\setSGvar{|\meta{vname}|}{|\meta{text}|}| to set the global variable \meta{vname} to - \meta{text} and |\useSGvar{|\meta{vname}|}| to reference it. -\end{function} - -\begin{function}{\ifSGvar} - With|\ifSGvar| we can test for the contents of a global variable: the macro call - |\ifSGvar{|\meta{vname}|}{|\meta{val}|}{|\meta{ctext}|}| tests the content of the global - variable \meta{vname}, only if (after expansion) it is equal to \meta{val}, the - conditional text \meta{ctext} is formatted. -\end{function} -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: article.cls topsect DCMI:dmt03 loadmodules lmhtools -% LocalWords: prematurestop afterprematurestop import_graph.py STRlabel STRcopy vname -% LocalWords: STRsemantics setSGvar ifSGvar ctext diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex deleted file mode 100644 index 4e0cd214576..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-features.tex +++ /dev/null @@ -1,246 +0,0 @@ -\begin{sfragment}{The \texttt{mathstructure} Environment} -\begin{smodule}[ns=https://github.com/slatex/sTeX/doc]{MathStructures} - A common occurence in mathematics is bundling several - interrelated ``declarations'' together into \emph{structures}. - For example: - \begin{itemize} - \item A \emph{monoid} is a structure $\mathstruct{M,\circ,e}$ - with $\circ:M\times M\to M$ and $e\in M$ such that... - \item A \emph{topological space} is a structure - $\mathstruct{X,\mathcal T}$ where $X$ is a set and - $\mathcal T$ is a topology on $X$ - \item A \emph{partial order} is a structure $\mathstruct{S,\leq}$ - where $\leq$ is a binary relation on $S$ such that... - \end{itemize} - - This phenomenon is important and common enough to warrant special - support, in particular because it requires being able - to \emph{instantiate} such structures (or, rather, - structure \emph{signatures}) in order to talk about (concrete - or variable) \emph{particular} monoids, topological spaces, - partial orders etc. - - \begin{environment}{mathstructure} - The \stexcode"mathstructure" environment allows us to do - exactly that. It behaves exactly like the - \stexcode"smodule" environment, but is itself only allowed - inside an \stexcode"smodule" environment, and allows - for instantiation later on. - \end{environment} - - How this works is again best demonstrated by example: - \symdef{funtype}[args=ai]{#1 \comp\to #2}{##1 \comp\times ##2} - \symdef{fun}[args=bi]{#1 \comp\mapsto #2} - \symdef{set}{\comp{\texttt{Set}}} - - \stexexample{% -\begin{mathstructure}{monoid} - \symdef{universe}[type=\set]{\comp{U}} - \symdef{op}[ - args=2, - type=\funtype{\universe,\universe}{\universe}, - op=\circ - ]{#1 \comp{\circ} #2} - \symdef{unit}[type=\universe]{\comp{e}} -\end{mathstructure} - -A \symname{monoid} is... - } - Note that the \stexcode"\symname{monoid}" is appropriately - highlighted and (depending on your pdf viewer) - shows a URI on hovering -- implying that the \stexcode"mathstructure" - environment has generated a \emph{symbol} |monoid| for us. - It has not generated a semantic macro though, since - we can not use the |monoid|-symbol \emph{directly}. Instead, - we can instantiate it, for example for integers: - - \stexexample{% -\symdef{Int}[type=\set]{\comp{\mathbb Z}} -\symdef{addition}[ - type=\funtype{\Int,\Int}{\Int}, - args=2, - op=+ -]{##1 \comp{+} ##2} -\symdef{zero}[type=\Int]{\comp{0}} - -$\mathstruct{\Int,\addition!,\zero}$ is a \symname{monoid}. - } - - So far, we have not actually instantiated |monoid|, but now - that we have all the symbols to do so, we can: - - \stexexample{% -\instantiate{intmonoid}{monoid}{\mathbb{Z}_{+,0}}[ - universe = Int , - op = addition , - unit = zero -] - -$\intmonoid{universe}$, $\intmonoid{unit}$ and $\intmonoid{op}{a}{b}$. - -Also: $\intmonoid!$ - } - \begin{function}{\instantiate} - So summarizing: - \stexcode"\instantiate" takes four arguments: The - (macro-)name of the instance, a key-value pair assigning - declarations in the corresponding \stexcode"mathstructure" - to symbols currently in scope, the name of the \stexcode"mathstructure" - to instantiate, and lastly a notation for the instance itself. - - It then generates a semantic macro that takes as argument - the name of a declaration in the instantiated \stexcode"mathstructure" - and resolves it to the corresponding instance of that particular declaration. - \end{function} - - \begin{mmtbox} - \stexcode"\instantiate" and \stexcode"mathstructure" make use of the - \emph{Theories-as-Types} paradigm (see \cite{MueRabKoh:tat18}): - - \stexcode"mathstructure{<name>}" simply creates a nested theory with name - |<name>-structure|. The \emph{constant} |<name>| is defined as - |Mod(<name>-structure)| -- a \emph{dependent record type with manifest fields}, - the fields of which are generated from (and correspond to) the constants in - |<name>-structure|. - - \stexcode"\instantiate" generates a constant whose definiens is a record term of - type |Mod(<name>-structure)|, with the fields assigned based on the respective - key-value-list. - \end{mmtbox} - - Notably, \stexcode"\instantiate" throws an error if not \emph{every} - declaration in the instantiated \stexcode"mathstructure" is being assigned. - - You might consequently ask what the usefulness of \stexcode"mathstructure" - even is. - - \begin{function}{\varinstantiate} - The answer is that we can also instantiate a - \stexcode"mathstructure" with a \emph{variable}. - The syntax of \stexcode"\varianstantiate" is equivalent - to that of \stexcode"\instantiate", but all of the key-value-pairs - are optional, and if not explicitly assigned (to a symbol \emph{or} - a variable declared with \stexcode"\vardef") inherit their notation - from the one in the \stexcode"mathstructure" environment. - \end{function} - - This allows us to do things like: - - \stexexample{% -\varinstantiate{varM}{monoid}{M} - -A \symname{monoid} is a structure -$\varM!:=\mathstruct{\varM{universe},\varM{op}!,\varM{unit}}$ -such that -$\varM{op}!:\funtype{\varM{universe},\varM{universe}}{\varM{universe}}$ ... -} - -and - -\stexexample{% - \varinstantiate{varMb}{monoid}{M_2}[universe = Int] - - Let $\varMb!:=\mathstruct{\varMb{universe},\varMb{op}!,\varMb{unit}}$ -be a \symname{monoid} on $\Int$ ... - } - - -We will return to these two example later, when we also know how to handle the -\emph{axioms} of a monoid. - -\begin{environment}{usestructure} - The |usestructure{<struct>}| environment is used in multilingual settings as a parallel - to the |mathstructure|. It opens a group and then issues a - |\usemodule{.../<struct>-structure}| that gives the body access to all the semantic - macros in the referenced structure. -\end{environment} -\end{smodule} -\end{sfragment} - -\begin{sfragment}{The \texttt{copymodule} Environment} - - \textcolor{red}{TODO: explain} - -Given modules: - -\stexexample{% -\begin{smodule}{magma} - \symdef{universe}{\comp{\mathcal U}} - \symdef{operation}[args=2,op=\circ]{#1 \comp\circ #2} -\end{smodule} -\begin{smodule}{monoid} - \importmodule{magma} - \symdef{unit}{\comp e} -\end{smodule} -\begin{smodule}{group} - \importmodule{monoid} - \symdef{inverse}[args=1]{{#1}^{\comp{-1}}} -\end{smodule} -} - -We can form a module for \emph{rings} by ``cloning'' -an instance of |group| (for addition) and |monoid| (for multiplication), -respectively, and ``glueing them together'' to ensure they share the -same universe: - -\stexexample{% -\begin{smodule}{ring} - \begin{copymodule}{group}{addition} - \renamedecl[name=universe]{universe}{runiverse} - \renamedecl[name=plus]{operation}{rplus} - \renamedecl[name=zero]{unit}{rzero} - \renamedecl[name=uminus]{inverse}{ruminus} - \end{copymodule} - \notation*{rplus}[plus,op=+,prec=60]{#1 \comp+ #2} -%\setnotation{rplus}{plus} - \notation*{rzero}[zero]{\comp0} -%\setnotation{rzero}{zero} - \notation*{ruminus}[uminus,op=-]{\comp- #1} -%\setnotation{ruminus}{uminus} - \begin{copymodule}{monoid}{multiplication} - \assign{universe}{\runiverse} - \renamedecl[name=times]{operation}{rtimes} - \renamedecl[name=one]{unit}{rone} - \end{copymodule} - \notation*{rtimes}[cdot,op=\cdot,prec=50]{#1 \comp\cdot #2} -%\setnotation{rtimes}{cdot} - \notation*{rone}[one]{\comp1} -%\setnotation{rone}{one} - Test: $\rtimes a{\rplus c{\rtimes de}}$ -\end{smodule} -} - -\textcolor{red}{TODO: explain donotclone} - -\end{sfragment} - -\begin{sfragment}{The \texttt{interpretmodule} Environment} - - \textcolor{red}{TODO: explain} - -\stexexample{% -\begin{smodule}{int} - \symdef{Integers}{\comp{\mathbb Z}} - \symdef{plus}[args=2,op=+]{#1 \comp+ #2} - \symdef{zero}{\comp0} - \symdef{uminus}[args=1,op=-]{\comp-#1} - - \begin{interpretmodule}{group}{intisgroup} - \assign{universe}{\Integers} - \assign{operation}{\plus!} - \assign{unit}{\zero} - \assign{inverse}{\uminus!} - \end{interpretmodule} -\end{smodule} -} - -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: circ,e intmonoid MueRabKoh:tat18 varinstantiate 2,op runiverse rplus prec -% LocalWords: rzero uminus ruminus plus,op uminus,op rtimes cdot,op cdot,prec 1,op -% LocalWords: donotclone intisgroup diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex index a3679d0d948..1d95d35f7b5 100644 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex +++ b/Master/texmf-dist/doc/latex/stex/packages/stex-hwexam.tex @@ -54,24 +54,24 @@ duration of the test, \DescribeMacro{min}|min| specifies the equivalent in numbe minutes, and \DescribeMacro{reqpts}|reqpts| the points that are required for a perfect grade. -\begin{latexcode} +\begin{stexcode} \title{320101 General Computer Science (Fall 2010)} \begin{testheading}[duration=one hour,min=60,reqpts=27] Good luck to all students! \end{testheading} -\end{latexcode} +\end{stexcode} Will result in \begin{center} \begin{minipage}{.9\textwidth} \makeatletter -\@problem{1.1}{4}{10} -\@problem{2.1}{4}{8} -\@problem{2.2}{6}{10} -\@problem{2.3}{6}{10} -\@problem{3.1}{4}{8} -\@problem{3.2}{4}{8} -\@problem{3.3}{2}{4} +%^^A\@problem{1.1}{4}{10} +%^^A\@problem{2.1}{4}{8} +%^^A\@problem{2.2}{6}{10} +%^^A\@problem{2.3}{6}{10} +%^^A\@problem{3.1}{4}{8} +%^^A\@problem{3.2}{4}{8} +%^^A\@problem{3.3}{2}{4} \makeatother \title{320101 General Computer Science (Fall 2010)} \begin{testheading}[duration=one hour,min=60,reqpts=27] @@ -79,7 +79,7 @@ Will result in \end{testheading} \end{minipage} \end{center} -\ednote{MK: The first three ``problems'' come from the stex examples above, how do we get rid +\footnote{MK: The first three ``problems'' come from the stex examples above, how do we get rid of this?} \end{sfragment} diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex deleted file mode 100644 index b4d495b6281..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-idesetup.tex +++ /dev/null @@ -1,61 +0,0 @@ -\begin{sfragment}{Setting up the \sTeX IDE} - - The \sTeX IDE consists of two components using the - \emph{Language Server Protocol (LSP)}: A \emph{client} - in the form of a VSCode extension, and a \emph{server} - included in the \mmt system. Installing the extension will - open up a setup routine that will guide you through the rest. - - \begin{sfragment}{The \sTeX VSCode Extension} - - If you have not already, you should first install the VSCode editor - available at \url{https://code.visualstudio.com/}. - - Next, open VSCode and install the \sTeX extension by clicking on - the \emph{extensions} menu on the very left of the VSCode window - and searching for ``sTeX'' in the - \emph{``Search Extensions in Marketplace''} field, as in - \autoref{fig:install}, and clicking the \emph{Install}-button - of the \sTeX extension by KWARC. - - \begin{figure} - \begin{center} - \includegraphics[width=0.6\textwidth]{img/vsc1.png} - \end{center} - \caption{Installing the \sTeX extension for VSCode}\label{fig:install} - \end{figure} - - \end{sfragment} - - \begin{sfragment}{Setting up \mmt} - - Next, open any directory (\texttt{File $\to$ Open Folder...}) that contains - a \verb|.tex|-file, and a setup window as in \autoref{fig:setup} - will pop up. Clik on the highlighted link `\emph{here}' and download - the latest version of the \texttt{MMT.jar} file (at least version 23.0.0) - anywhere you like. Then click the \emph{``Browse...''}-button - and select your freshly downloaded \texttt{MMT.jar}. - - If you have already set a system variable for your MathHub-directory, - you are now done and can click \emph{``Finish''}. If you have not, - you can now also enter a directory path in the lower text field, - and the VSCode extension will attempt to globally set one up - for you, depending on your operating system. - - \begin{figure} - \begin{center} - \includegraphics[width=\textwidth]{img/vsc2.png} - \end{center} - \caption{\sTeX Setup Routine}\label{fig:setup} - \end{figure} - - Once you click \emph{``Finish''}, the client will connect - to \url{https://stexmmt.mathhub.info/:sTeX}, query for - available archives, download the core libraries required - for all (or most) semantic services (\texttt{MMT/urtheories} - and \texttt{sTeX/meta-inf}) and set up \RusTeX for you - automatically. - - \end{sfragment} - - \end{sfragment}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-inheritance.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-inheritance.tex deleted file mode 100644 index be7c4e68ec0..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-inheritance.tex +++ /dev/null @@ -1,131 +0,0 @@ -\begin{sfragment}{Simple Inheritance and Namespaces} - - \begin{function}{\importmodule,\usemodule} - \stexcode"\importmodule[Some/Archive]{path?ModuleName}" is only allowed within an - \stexcode"smodule"-environment and makes the symbols declared in |ModuleName| - available therein. Additionally the symbols of |ModuleName| will be exported if the - current module is imported somewhere else via \stexcode"\importmodule". - - \stexcode"\usemodule" behaves the same way, but without exporting the content of the - used module. - \end{function} - - It is worth going into some detail how exactly \stexcode"\importmodule" - and \stexcode"\usemodule" resolve their arguments to find - the desired module -- which is closely related to the - \emph{namespace} generated for a module, that is used to generate - its URI. - - \begin{dangerbox} - Ideally, \sTeX would use arbitrary URIs for modules, with no - forced relationships between the \emph{logical} namespace - of a module and the \emph{physical} location of the file - declaring the module -- like \mmt does things. - - Unfortunately, \TeX\ only provides very restricted access to - the file system, so we are forced to generate namespaces - systematically in such a way that they reflect the physical - location of the associated files, so that \sTeX can resolve - them accordingly. Largely, users need not concern themselves - with namespaces at all, but for completenesses sake, we describe - how they are constructed: - - \begin{itemize} - \item If \stexcode"\begin{smodule}{Foo}" - \iffalse\end{smodule}\fi occurs in a file - |/path/to/file/Foo[.|\meta{lang}|].tex| which does not belong - to an archive, the namespace is |file://path/to/file|. - \item If the same statement occurs in a file - |/path/to/file/bar[.|\meta{lang}|].tex|, the namespace is - |file://path/to/file/bar|. - \end{itemize} - - In other words: outside of archives, the namespace corresponds to - the file URI with the filename dropped iff it is equal to the - module name, and ignoring the (optional) language suffix. - - If the current file is in an archive, the procedure is the same - except that the initial segment of the file path up to the archive's - |source|-folder is replaced by the archive's namespace URI. -\end{dangerbox} - -\begin{dangerbox} - Conversely, here is how namespaces/URIs and file paths are computed - in import statements, examplary \stexcode"\importmodule": - - \begin{itemize} - \item \stexcode"\importmodule{Foo}" outside of an archive refers - to module |Foo| in the current namespace. Consequently, |Foo| - must have been declared earlier in the same document or, if not, - in a file |Foo[.|\meta{lang}|].tex| in the same directory. - \item The same statement \emph{within} an archive refers to either - the module |Foo| declared earlier in the same document, or - otherwise to the module |Foo| in the archive's top-level namespace. - In the latter case, is has to be declared in a file |Foo[.|\meta{lang}|].tex| - directly in the archive's |source|-folder. - \item Similarly, in \stexcode"\importmodule{some/path?Foo}" the path - |some/path| refers to either the sub-directory and relative - namespace path of the current directory and namespace outside of an archive, - or relative to the current archive's top-level namespace and |source|-folder, - respectively. - - The module |Foo| must either be declared in the file - \meta{top-directory}|/some/path/Foo[.|\meta{lang}|].tex|, or in - \meta{top-directory}|/some/path[.|\meta{lang}|].tex| (which are - checked in that order). - \item Similarly, \stexcode"\importmodule[Some/Archive]{some/path?Foo}" - is resolved like the previous cases, but relative to the archive - |Some/Archive| in the mathhub-directory. - \item Finally, \stexcode"\importmodule{full://uri?Foo}" naturally refers to the - module |Foo| in the namespace |full://uri|. Since the file this module - is declared in can not be determined directly from the URI, the module - must be in memory already, e.g. by being referenced earlier in the - same document. - - Since this is less compatible with a modular development, using full - URIs directly is strongly discouraged, unless the module is delared in - the current file directly. - \end{itemize} - - \end{dangerbox} - - \begin{function}{\STEXexport} - \stexcode"\importmodule" and \stexcode"\usemodule" import all symbols, notations, - semantic macros and (recursively) \stexcode"\importmodule"s. If you want to - additionally export e.g. convenience macros and other (\sTeX) code from a module, you - can use the command \stexcode"\STEXexport{<code>}" in your module. Then |<code>| is - executed (both immediately and) every time the current module is opened via - \stexcode"\importmodule" or \stexcode"\usemodule". - \end{function} - - \begin{dangerbox} - For persistency reasons, everything in an \stexcode"\STEXexport" - is digested by \TeX in the \LaTeX3-category code scheme. - This means that the characters \stexcode"_" and \stexcode":" - are considered \emph{letters} and valid parts of - control sequence names, and space characters are ignored entirely. - For spaces, use the character \stexcode"~" instead, and - keep in mind, that if you want to use subscripts, you - should use \stexcode"\c_math_subscript_token" instead - of \stexcode"_"! - - - Also note, that \stexcode"\newcommand" defines macros \emph{globally} - and throws an error if the macro already exists, - potentially leading to low-level \LaTeX\xspace errors if - we put a \stexcode"\newcommand" in an \stexcode"\STEXexport" - and the |<code>| is executed more than once in a document - -- which can happen easily. - - A safer alternative is to use macro definition principles, - that are safe to use even if the macro being defined already - exists, and ideally are local to the current \TeX\xspace group, - such as \stexcode"\def" or \stexcode"\let". - \end{dangerbox} - -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex deleted file mode 100644 index eb09414ac74..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-mathhub.tex +++ /dev/null @@ -1,203 +0,0 @@ -\begin{sfragment}[id=sec:localmh]{The Local MathHub-Directory} - \stexcode"\usemodule", \stexcode"\importmodule", - \stexcode"\inputref" etc. allow for - including content modularly without having to specify absolute - paths, which would differ between users and machines. Instead, - \sTeX uses \emph{archives} that determine the global - namespaces for symbols and statements and make it possible - for \sTeX to find content referenced via such URIs. - - All \sTeX archives need to exist in the local |MathHub|-directory. - \sTeX knows where this folder is via one of four means: - - \begin{enumerate} - \item If the \sTeX package is loaded with the option |mathhub=/path/to/mathhub|, then - \sTeX will consider |/path/to/mathhub| as the local |MathHub|-directory. - \item If the |mathhub| package option is \emph{not} set, but the macro |\mathhub| - exists when the \sTeX-package is loaded, then this macro is assumed to point to the - local |MathHub|-directory; i.e. - \stexcode"\def\mathhub{/path/to/mathhub}\usepackage{stex}" will set the - |MathHub|-directory as |path/to/mathhub|. - \item Otherwise, \sTeX will attempt to retrieve the system variable |MATHHUB|, - assuming it will point to the local |MathHub|-directory. Since this variant needs - setting up only \emph{once} and is machine-specific (rather than defined in tex - code), it is compatible with collaborating and sharing tex content, and hence - recommended. - \item Finally, if all else fails, \sTeX will look for a file - |~/.stex/mathhub.path|. If this file exists, \sTeX will assume that it contains the - path to the local |MathHub|-directory. This method is recommended on systems where - it is difficult to set environment variables. - \end{enumerate} -\end{sfragment} - -\begin{sfragment}{The Structure of \sTeX Archives} - An \sTeX archive |group/name| is stored in the - directory |/path/to/mathhub/group/name|; e.g. assuming your - local |MathHub|-directory is set as |/user/foo/MathHub|, then - in order for the |smglom/calculus|-archive to be found by the - \sTeX system, it needs to be in |/user/foo/MathHub/smglom/calculus|. - - Each such archive needs two subdirectories: - \begin{itemize} - \item |/source| -- this is where all your tex files go. - \item |/META-INF| -- a directory containing a single file - |MANIFEST.MF|, the content of which we will consider shortly - \end{itemize} - An additional |lib|-directory is optional, and is where \sTeX will - look for files included via \stexcode"\libinput". - - Additionally a \emph{group} of archives |group/name| may have - an additional archive |group/meta-inf|. If this |meta-inf|-archive - has a |/lib|-subdirectory, it too will be searched by \stexcode"\libinput" - from all tex files in any archive in the |group/*|-group. - - \paragraph{} We recommend the following additional directory structure in the - |source|-folder of an \sTeX archive: - \begin{itemize} - \item |/source/mod/| -- individual \sTeX modules, containing - symbol declarations, notations, and - \stexcode"\begin{sparagraph}[type=symdoc,for=...]" - environments for ``encyclopaedic'' symbol documentations - \iffalse\end{sparagraph}\fi - \item |/source/def/| -- definitions - \item |/source/ex/| -- examples - \item |/source/thm/| -- theorems, lemmata and proofs; preferably - proofs in separate files to allow for multiple proofs for the - same statement - \item |/source/snip/| -- individual text snippets such as remarks, - explanations etc. - \item |/source/frag/| -- individual document fragments, - ideally only \stexcode"\inputref"ing snippets, definitions, - examples etc. in some desirable order - \item |/source/tikz/| -- tikz images, as individual |.tex|-files - \item |/source/PIC/| -- image files. - \end{itemize} - -\end{sfragment} - -\begin{sfragment}{MANIFEST.MF-Files} - The |MANIFEST.MF| in the |META-INF|-directory consists of key-value-pairs, informing - \sTeX (and associated software) of various properties of an archive. For example, the - |MANIFEST.MF| of the |smglom/calculus|-archive looks like this: - - \begin{framed} - \begin{verbatim} - id: smglom/calculus - source-base: http://mathhub.info/smglom/calculus - narration-base: http://mathhub.info/smglom/calculus - dependencies: smglom/arithmetics,smglom/sets,smglom/topology, - smglom/mv,smglom/linear-algebra,smglom/algebra - responsible: Michael.Kohlhase@FAU.de - title: Elementary Calculus - teaser: Terminology for the mathematical study of change. - description: desc.html - \end{verbatim} - \end{framed} - - Many of these are in fact ignored by \sTeX, but some are important: - \begin{itemize} - \item[|id|:] The name of the archive, including its group (e.g. |smglom/calculus|), - \item[|source-base|] or - \item[|ns|:] The namespace from which all symbol and module URIs - in this repository are formed, see (\textcolor{red}{TODO}), - \item[|narration-base:|] The namespace from which all document - URIs in this repository are formed, see (\textcolor{red}{TODO}), - \item[|url-base|:] The URL that is formed as a basis for \emph{external references}, - see (\textcolor{red}{TODO}), - \item[|dependencies|:] All archives that this archive depends on. \sTeX ignores - this field, but \mmt can pick up on them to resolve dependencies, - e.g. for |lmh install|. - \end{itemize} - -\end{sfragment} - -\begin{sfragment}{Using Files in \sTeX Archives Directly} - Several macros provided by \sTeX allow for directly including - files in repositories. These are: - \begin{function}{\mhinput} - \stexcode"\mhinput[Some/Archive]{some/file}" directly - inputs the file |some/file| in the |source|-folder of - |Some/Archive|. - \end{function} - \begin{function}{\inputref} - \stexcode"\inputref[Some/Archive]{some/file}" behaves like \stexcode"\mhinput", but - wraps the input in a |\begingroup ... \endgroup|. When converting to |xhtml|, the - file is not input at all, and instead an |html|-annotation is inserted that - references the file, e.g. for lazy loading. - - In the majority of practical cases \stexcode"\inputref" is likely to be preferred - over \stexcode"\mhinput" because it leads to less duplication in the generated - |xhtml|. - \end{function} - \begin{function}{\ifinput} - Both \stexcode"\mhinput" and \stexcode"\inputref" - set \stexcode"\ifinput" to ``true'' during input. This allows - for selectively including e.g. bibliographies only if the - current file is not being currently included in a larger document. - \end{function} - \begin{function}{\addmhbibresource} - \stexcode"\addmhbibresource[Some/Archive]{some/file}" searches for a file like - \stexcode"\mhinput" does, but calls |\addbibresource| to the result and looks for - the file in the archive root directory directly, rather than the |source| - directory. Typical invocations are - \begin{itemize} - \item |\addmhbibresource{lib/refs.bib}|, which specifies a bibliography in the |lib| - folder in the local archive or - \item |\addmhbibresource[HW/meta-inf]{lib/refs.bib}| in another. - \end{itemize} - \end{function} - \begin{function}{\libinput} - \stexcode"\libinput{some/file}" - searches for a file |some/file| in - \begin{itemize} - \item the |lib|-directory of the current archive, and - \item the |lib|-directory of a |meta-inf|-archive in - (any of) the archive groups containing the current archive - \end{itemize} - and include all found files in reverse order; - e.g. \stexcode"\libinput{preamble}" in a |.tex|-file in - |smglom/calculus| will \emph{first} input |.../smglom/meta-inf/lib/preamble.tex| - and then |../smglom/calculus/lib/preamble.tex|. - - \stexcode|\libinput| will throw an error if \emph{no} candidate for |some/file| - is found. - \end{function} - \begin{function}{\libusepackage} - \stexcode"\libusepackage[package-options]{some/file}" searches for a file - |some/file.sty| in the same way that \stexcode"\libinput" does, but will - call\\ - |\usepackage[package-options]{path/to/some/file}| instead of |\input|. - - \stexcode|\libusepackage| throws an error if not \emph{exactly one} candidate for - |some/file| is found. - \end{function} - - \begin{remark} - A good practice is to have individual \sTeX fragments - follow basically this document frame: - \begin{latexcode}[gobble=12] - \documentclass{stex} - \libinput{preamble} - \begin{document} - ... - \ifinputref \else \libinput{postamble} \fi - \end{document} - \end{latexcode} - Then the |preamble.tex| files can take care of loading the generally required - packages, setting presentation customizations etc. (per archive or archive group - or both), and |postamble.tex| can e.g. print the bibliography, index etc. - - \stexcode|\libusepackage| is particularly useful in |preamble.tex| when we want to - use custom packages that are not part of {\TeX}Live. In this case we commit the - respective packages in one of the |lib| folders and use \stexcode|\libusepackage| - to load them. - \end{remark} -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -%%% LocalWords: mathhub symdoc,for lmh subdirs arithmetics,smglom sets,smglom mv,smglom -%%% LocalWords: linear-algebra,smglom diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex deleted file mode 100644 index 7a653186b3e..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-mathhubsetup.tex +++ /dev/null @@ -1,25 +0,0 @@ - \begin{sfragment}{Setting your MathHub Directory} - One of \sTeX's features is a proper \emph{module system} - of interconnected document snippets for mathematical - content. Analogously to \emph{object-oriented programming}, - it allows for ``object-oriented mathematics'' via individual - combinable and, importantly, \emph{reusable} modules, developed - collaboratively. - - To make use of such modules, the \sTeX system needs to be told - where to find them. There are several ways to do so (see - \sref[file=stex-mathhub]{sec:localmh}[in=../stex-manual, - title={\href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}}]), - but the most convenient way to do so is via a system variable. - - To do so, create a directory \texttt{MathHub} somewhere on - your local file system and set the environment - variable \texttt{MATHHUB} to the file path to that directory. - - In linux, you can do so by writing - \begin{lstlisting}[language=bash] - export MATHHUB="/path/to/your/MathHub" - \end{lstlisting} - in your \verb|~/.profile| (for all shells) or \verb|~/.bashrc| - (for the bash terminal only) file. - \end{sfragment}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-metatheory.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-metatheory.tex deleted file mode 100644 index 4feb646eb9f..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-metatheory.tex +++ /dev/null @@ -1,30 +0,0 @@ -The \pkg{stex-metatheory} package contains \sTeX symbols so ubiquitous, that it is -virtually impossible to describe any flexiformal content without them, or that are -required to annotate even the most primitive symbols with meaningful -(foundation-independent) ``type''-annotations, or required for basic structuring -principles (theorems, definitions). As such, it serves as the default meta theory for any -\sTeX module. - -We can also see the \pkg{stex-metatheory} as a foundation of mathematics in the sense of -\cite{rabe:future:15}, albeit an informal one (the ones discussed there are all formal -foundations). The state of the \pkg{stex-metatheory} is necessarily incomplete, and will -stay so for a long while: It arises as a collection of empirically useful symbols that are -collected as more and more mathematics are encoded in \sTeX and are classified as -foundational. - -Formal foundations should ideally instantiate these symbols with their formal counterparts, -e.g. |isa| corresponds to a typing operation in typed setting, or the $\in$-operator in -set-theoretic contexts; |bind| corresponds to a universal quantifier in ($n$th-order) -logic, or a $\Pi$ in dependent type theories. - -We make this theory part of the \sTeX collection due to the obiquity -of the symbols involved. Note however, that the metatheory is -for all practical purposes a ``normal'' \sTeX module, and the -symbols contained ``normal'' \sTeX symbols. - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: stex-metatheory th-order diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-modules.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-modules.tex deleted file mode 100644 index 424c2200e85..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-modules.tex +++ /dev/null @@ -1,73 +0,0 @@ -\begin{sfragment}{The \texttt{smodule}-Environment} - \begin{environment}{smodule} - A new module is declared using the basic syntax - \begin{center} - \stexcode"\begin{smodule}[options]{ModuleName}...\end{smodule}". - \end{center} - A module is required to declare any new formal content such as symbols or - notations (but not variables, which may be introduced anywhere). - - The |smodule|-environment takes several keyword arguments, all of which are - optional: - - \begin{itemize} - \item[|title|] (\meta{token list}) to display in customizations. - \item[|type|] (\meta{string}$\ast$) for use in customizations. - \item[|deprecate|] (\meta{module}) if set, will throw a warning - when loaded, urging to use \meta{module} instead. - \item[|id|] (\meta{string}) for cross-referencing. - \item[|ns|] (\meta{URI}) the namespace to use. \emph{Should not be used, - unless you know precisely what you're doing}. If not explicitly set, is - computed using \cs{stex_modules_current_namespace:}. - \item[|lang|] (\meta{language}) if not set, computed from the current file name (e.g. |foo.en.tex|). - \item[|sig|] (\meta{language}) if the current file is a translation of a file with the same base name - but a different language suffix, setting |sig=<lang>| will preload the module - from that language file. This helps ensuring that the (formal) content of both modules - is (almost) identical across languages and avoids duplication. - \item[|creators|] (\meta{string}$\ast$) names of the creators. - \item[|contributors|] (\meta{string}$\ast$) names of contributors. - \item[|srccite|] (\meta{string}) a source citation for the content of this module. - \end{itemize} - \end{environment} - - \begin{mmtbox} - An \sTeX module corresponds to an \mmt/\omdoc \emph{theory}. - As such it gets assigned a module URI (\emph{universal resource identifier}) - of the form |<namespace>?<module-name>|. - \end{mmtbox} - - By default, opening a module will produce no output whatsoever, - e.g.: - \stexexample{% -\begin{smodule}[title={This is Some Module}]{SomeModule} - Hello World -\end{smodule} - } - - \begin{function}{\stexpatchmodule} - We can customize this behavior either for all modules or - only for modules with a specific |type| using the command - \stexcode"\stexpatchmodule[optional-type]{begin-code}{end-code}". - Some optional parameters are then available in |\smodule*|-macros, - specifically |\smoduletitle|, |\smoduletype| and |\smoduleid|. - \end{function} - For example: - - \stexexample{% -\stexpatchmodule[display] - {\textbf{Module (\smoduletitle)}\par} - {\par\noindent\textbf{End of Module (\smoduletitle)}} - -\begin{smodule}[type=display,title={Some New Module}]{SomeModule2} - Hello World -\end{smodule} - } -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: srccite mmtbox stexexample stexpatchmodule smoduletitle smoduleid -% LocalWords: display,title diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex index 75fd9ee9e8e..f7738938a15 100644 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex +++ b/Master/texmf-dist/doc/latex/stex/packages/stex-notesslides.tex @@ -4,7 +4,7 @@ it adds a ``notes version'' for course notes that is more suited to printing tha supplied by |beamer.cls|. The \pkg{notesslides} class takes the notion of a slide frame from Till Tantau's excellent -\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \omdoc. To +\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \OMDoc. To support semantic course notes, it extends the notion of mixing frames and explanatory text, but rather than treating the frames as images (or integrating their contents into the flowing text), the \pkg{notesslides} package displays the slides as such in the course @@ -56,7 +56,7 @@ study. To achieve this, the \pkg{notesslides} class has two modes: \emph{slides By interleaving the |frame| and |note| environments, we can build course notes as shown here: -\begin{latexcode} +\begin{stexcode} \ifnotes\maketitle\else \frame[noframenumbering]\maketitle\fi @@ -77,7 +77,7 @@ here: ... \end{frame} ... -\end{latexcode} +\end{stexcode} \begin{function}{\ifnotes} Note the use of the |\ifnotes| conditional, which allows different treatment between @@ -119,7 +119,7 @@ here: The result in |notes| mode (which is like the |slides| version except that the slide hight is variable) is - \includegraphics[width=.95\textwidth]{\libfolder{img/notes-frame}} + \includegraphics[width=.95\textwidth]{\stexdocpath/../lib/img/notes-frame} The footer line can be customized. In particular the logos. @@ -156,13 +156,13 @@ have a PowerPoint presentation, to which we want to add \sTeX notes. The |\mhframeimage| macro is a variant of |\frameimage| with repository support. Instead of writing -\begin{latexcode} +\begin{stexcode} \frameimage{\MathHub{fooMH/bar/source/baz/foobar}} -\end{latexcode} +\end{stexcode} we can simply write (assuming that |\MathHub| is defined as above) -\begin{latexcode} +\begin{stexcode} \mhframeimage[fooMH/bar]{baz/foobar} -\end{latexcode} +\end{stexcode} Note that the |\mhframeimage| form is more semantic, which allows more advanced document management features in \textsf{MathHub}. \end{function} @@ -170,26 +170,69 @@ management features in \textsf{MathHub}. If |baz/foobar| is the ``current module'', i.e. if we are on the \textsf{MathHub} path \ldots|MathHub/fooMH/bar|\ldots, then stating the repository in the first optional argument is redundant, so we can just use -\begin{latexcode} +\begin{stexcode} \mhframeimage{baz/foobar} -\end{latexcode} +\end{stexcode} \end{sfragment} \begin{function}{\textwarning} The |\textwarning| macro generates a warning sign: \textwarning \end{function} + +\begin{sfragment}{Ending Documents Prematurely} + \begin{function}{\prematurestop,\afterprematurestop} + For prematurely stopping the formatting of a document, \sTeX provides the + |\prematurestop| macro. It can be used everywhere in a document and ignores all input + after that -- backing out of the |sfragment| environments as needed. After that -- and + before the implicit |\end{document}| it calls the internal |\afterprematurestop|, which + can be customized to do additional cleanup or e.g. print the bibliography. + + |\prematurestop| is useful when one has a driver file, e.g. for a course taught multiple + years and wants to generate course notes up to the current point in the lecture. Instead + of commenting out the remaining parts, one can just move the |\prematurestop| macro. + This is especially useful, if we need the rest of the file for processing, e.g. to + generate a theory graph of the whole course with the already-covered parts marked up as + an overview over the progress; see |import_graph.py| from the |lmhtools| + utilities~\cite{lmhtools:github:on}. + \end{function} + + Text fragments and modules can be made more re-usable by the use of global variables. For + instance, the admin section of a course can be made course-independent (and therefore + re-usable) by using variables (actually token registers) |courseAcronym| and |courseTitle| + instead of the text itself. The variables can then be set in the \sTeX preamble of the + course notes file. +\end{sfragment} + + +\begin{sfragment}{Global Document Variables} + To make document fragments more reusable, we sometimes want to make the content depend + on the context. We use \defemph{document variables} for that. + +\begin{function}{\setSGvar,\useSGvar} + |\setSGvar{|\meta{vname}|}{|\meta{text}|}| to set the global variable \meta{vname} to + \meta{text} and |\useSGvar{|\meta{vname}|}| to reference it. +\end{function} + +\begin{function}{\ifSGvar} + With|\ifSGvar| we can test for the contents of a global variable: the macro call + |\ifSGvar{|\meta{vname}|}{|\meta{val}|}{|\meta{ctext}|}| tests the content of the global + variable \meta{vname}, only if (after expansion) it is equal to \meta{val}, the + conditional text \meta{ctext} is formatted. +\end{function} +\end{sfragment} + \begin{sfragment}[id=sec:user:excursions]{Excursions} In course notes, we sometimes want to point to an ``excursion'' -- material that is either presupposed or tangential to the course at the moment -- e.g. in an appendix. The typical setup is the following: -\begin{latexcode} +\begin{stexcode} \excursion{founif}{../fragments/founif.en} {We will cover first-order unification in} ... \begin{appendix}\printexcursions\end{appendix} -\end{latexcode} +\end{stexcode} It generates a paragraph that references the excursion whose source is in the file |../fragments/founif.en.tex| and automatically books the file for the |\printexcursions| @@ -198,12 +241,12 @@ command that is used here to put it into the appendix. We will look at the mecha \begin{function}{\excursion} The |\excursion{|\meta{ref}|}{|\meta{path}|}{|\meta{text}|}| is syntactic sugar for -\begin{latexcode} +\begin{stexcode} \begin{nparagraph}[title=Excursion] \activateexcursion{founif}{../ex/founif} We will cover first-order unification in \sref{founif}. \end{nparagraph} -\end{latexcode} +\end{stexcode} \end{function} \begin{function}{\activateexcursion,\printexcursion,\excursionref} @@ -219,14 +262,14 @@ command that is used here to put it into the appendix. We will look at the mecha Finally, we usually want to put the excursions into an |sfragment| environment and add an introduction, therefore we provide the a variant of the |\printexcursions| macro: |\excursiongroup[id=|\meta{id}|,intro=|\meta{path}|]| is equivalent to -\begin{latexcode} +\begin{stexcode} \begin{note} \begin{sfragment}[id=<id>]{Excursions} \inputref{<path>} \printexcursions \end{sfragment} \end{note} -\end{latexcode} +\end{stexcode} \end{function} \end{sfragment} diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex index 53316b28bc8..81315415a41 100644 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex +++ b/Master/texmf-dist/doc/latex/stex/packages/stex-problem.tex @@ -154,12 +154,11 @@ The next simplest situation, where we can implement auto-grading is the case whe have fill-in-the-blanks \begin{function}{\fillinsol} - The |\fillinsol| macro takes\Ednote{for now; more to come} an a single argument, which - contains a concrete solution (i.e. a number, a string, \ldots), which generates a - fill-in-box in test mode: -\stexexample{% - \stopsolutions - \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants] + The |\fillinsol| macro takes a single argument, which contains a concrete solution + (i.e. a number, a string, \ldots), which generates a fill-in-box in test mode: + \stexexample{% + \stopsolutions + \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants] How many Elefants can you fit into a Volkswagen beetle? \fillinsol{4} \end{sproblem}} and the actual solution in solutions mode: @@ -174,7 +173,7 @@ also give |\fillinsol| an optional argument with a size: |\fillinsol[3cm]{12}| m Obviously, the required argument of |\fillinsol| can be used for auto-grading. For concrete data like numbers, this is immediate, for more complex data like strings ``soft - comparisons'' might be in order. \ednote{For the moment we only assume a single concrete + comparisons'' might be in order. \footnote{For the moment we only assume a single concrete value as correct. In the future we will almost certainly want to extend the functionality to multiple answer classes that allow different feedback like im MCQ. This still needs a bit of design. Also we want to make the formatting of the diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex deleted file mode 100644 index 9e6e44f5ca2..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-proofs.tex +++ /dev/null @@ -1,387 +0,0 @@ -\begin{sfragment}{Proofs} - -The \pkg{stex-proof} package supplies macros and environment that allow to annotate the -structure of mathematical proofs in \sTeX document. This structure can be used by MKM -systems for added-value services, either directly from the \sTeX sources, or after -translation. - -Its central component is the |sproof|-environment, whose body consists -of: -\begin{itemize} - \item \emph{subproofs} via the |subproof|-environment, - \item \emph{proof steps} via the |\spfstep|, |\eqstep| - |\assumption|, and |\conclude| macros, and - \item \emph{comments}, via normal text without special markup. -\end{itemize} - -|sproof|, |subproof| and the various proof step macros take the following -optional arguments: -\begin{itemize} - \item[|id|] (\meta{string}) for referencing, - \item[|method|] (\meta{string}) the proof method (e.g. contradiction, induction,...) - \item[|term|] (\meta{token list}) the (ideally semantically-marked up) - proposition that is derived/proven by this proof/subproof/proof step. -\end{itemize} -Additionally, they take one mandatory argument for the document text -to be annotated, or (in the case of the environments) -as an introductory description of the proof itself. Since -the latter often contains the |term| to be derived -as text, alternatively to providing it as -an optional argument, the mandatory argument can use the -|\yield|-macro to mark it up in the text. - -The |sproof| and |subproof| environments additionally take -two optional arguments: -\begin{itemize} - \item[|for|] the symbol identifier/name corresponding to the |sassertion| - to be proven. This too subsumes |\yield| and the |term|-argument. - \item[|hide|] In the pdf, this only shows the mandatory argument text - and hides the body of the environment. In the HTML (as served by \mmt), - the bodies of all |proof| and |subproof| environments are \emph{collapsible}, - and |hide| collapses the body by default. -\end{itemize} - -\begin{smodule}{sproofs} - \symdef{coprime}[args=2]{#1 \comp\bot #2} - \symdef{realroot}[args=1]{\sqrt{#1}} - \symdecl{irrational}[args=1] - \symdecl{rational}[args=1] - \symdef{eq}[args=2]{#1 \comp= #2} - \symdef{ratfrac}[args=2,prec=1]{\frac{#1}{#2}} - \symdef{intpow}[args=2,prec=-1]{{#1}^{#2}} - \symdef{ratpow}[args=2]{{#1}^{#2}} - \symdef{inset}[args=ai]{#1\comp\in#2}{##1\comp,##2} - \symdef{Int}{\comp{\mathbb Z}} - \symdef{PosInt}{\comp{{\mathbb Z}^+}} - \symdef{inttimes}[args=2]{#1 #2} - \symdef{divides}[args=2]{#1\comp\|#2} - - \vardef{vara}{\comp a} - \vardef{varb}{\comp b} - \vardef{varc}{\comp c} - - \def\contradiction{} - -\begin{latexcode} - \begin{sassertion}[type=theorem,name=sqrt2irr] - \conclusion{\irrational{$\arg{\realroot{2}}$ is \comp{irrational}}}. -\end{sassertion} - -\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} - \assumption{Assume \yield{\rational{$\arg{\realroot{2}}$ is - \comp{rational}}}} - \begin{subproof}[method=straightforward]{Then - \yield{$\eq{\ratfrac{\intpow{\vara}{2}}{\intpow{\varb}2}}{2}$ - for some $\inset{\vara,\varb}\PosInt$ with - \coprime{$\arg{\vara},\arg{\varb}$ \comp{coprime}}}} - \assumption{By assumption, \yield{there are - $\inset{\vara,\varb}\PosInt $ with - $\realroot{2}=\ratfrac{\vara}{\varb}$}} - \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ - to be \comp{coprime}}} - % a comment: - If not, reduce the fraction until numerator and denominator - are coprime, and let the resulting components be - $\vara $ and $\varb $ - \spfstep{Then \yield{$\eq{\intpow{\ratfrac{\vara}{\varb}}2}2$}} - \eqstep{\ratfrac{\intpow{\vara}2}{\intpow{\varb}2}} - \end{subproof} - \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{ - Then $\vara $ is even} - \spfstep{Multiplying the equation by $\intpow{\varb}2$ yields - $\yield{\eq{\intpow{\vara}2}{\inttimes{2}{\intpow{\varb}2}}}$} - \spfstep[term=\divides{2}{\intpow{\vara}2}]{Hence - $\intpow{\vara}2$ is even} - \conclude[term=\divides{2}{\vara}]{Hence $\vara $ is even as well} - % another comment: - Hint: Think about the prime factorizations of $\vara $ and - $\intpow{\vara}2$ - \end{subproof} - \begin{subproof}[term=\divides{2}{\varb},method=straightforward,]{ - Then $\varb $ is also even} - \spfstep{Since $\vara $ is even, we have \yield{some $\varc $ - such that $\eq{\inttimes{2}{\varc}}{\vara}$}} - \spfstep{Plugging into the above, we get - \yield{$\eq{\intpow{\inttimes{2}{\vara}}2} - {\inttimes{2}{\intpow{\varb}2}}$}} - \eqstep{\inttimes{4}{\intpow{\vara}2}} - \spfstep{Dividing both sides by $2$ yields - \yield{$\eq{\intpow{\varb}2}{\inttimes{2}{\intpow{\vara}2}}$}} - \spfstep[term=\divides{2}{\intpow{\varb}2}]{Hence - $\intpow{\varb}2$ is even} - \conclude[term=\divides{2}{\varb}]{Hence $\varb $ is even} - % one more comment: - By the same argument as above - \end{subproof} - \conclude[term=\contradiction]{Contradiction to $\vara,\varb $ being - \symname{coprime}.} -\end{sproof} -\end{latexcode} - -which will produce: - -\begin{mdframed} -\begin{sassertion}[type=theorem,name=sqrt2irr] - \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}. -\end{sassertion} - -\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} - \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}} - \begin{subproof}[method=straightforward]% - {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}} - \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}} - \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}} - If not, reduce the fraction until numerator and denominator are - coprime, and let the resulting components be $\vara$ and $\varb$ - \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}} - \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}} - \end{subproof} - \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even} - \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$} - \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even} - \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well} - Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$ - \end{subproof} - \begin{subproof}[term=\divides{2}{\varb},method=straightforward]{Then $\varb$ is also even} - \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}} - \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}} - \eqstep{\inttimes4{\intpow\vara2}} - \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}} - \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even} - \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even} - By the same argument as above - \end{subproof} - \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.} -\end{sproof} -\end{mdframed} - -If we mark all subproofs with |hide|, we will obtain the following -instead: - -\begin{mdframed} - \begin{sassertion}[type=theorem,name=sqrt2irr] - \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}. - \end{sassertion} - - \begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} - \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}} - \begin{subproof}[hide,method=straightforward]% - {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}} - \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}} - \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}} - If not, reduce the fraction until numerator and denominator are - coprime, and let the resulting components be $\vara$ and $\varb$ - \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}} - \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}} - \end{subproof} - \begin{subproof}[hide,term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even} - \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$} - \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even} - \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well} - Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$ - \end{subproof} - \begin{subproof}[hide,term=\divides{2}{\varb},method=straightforward,]{Then $\varb$ is also even} - \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}} - \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}} - \eqstep{\inttimes4{\intpow\vara2}} - \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}} - \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even} - \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even} - By the same argument as above - \end{subproof} - \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.} - \end{sproof} - \end{mdframed} - - However, the hidden subproofs will still be shown in the HTML, - only in an expandable section which is collapsed by default. - - -The above style of writing proofs is usually called \emph{structured proofs}. -They have a huge advantage over the traditional purely prosaic style, -in that (as the name suggests) the actual \emph{structure} of the proof -is made explicit, which almost always makes it considerably more -comprehensible. We, among many others, encourage the general use of -structured proofs. - -Alas, most proofs are not written in this style, and we would -do users a disservice by insisting on this style. For that reason, -the |spfblock| environment turns all subproofs and proof step -macros into presentationally neutral \emph{inline} annotations, -as in the induction step of the following example: - -\begin{latexcode} -\begin{sproof}[id=simple-proof,method=induction] - {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$} - For the induction we have to consider three cases: % <- a comment - \begin{subproof}{$n=1$} - \spfstep*{then we compute $1=1^2$} - \end{subproof} - \begin{subproof}{$n=2$} - This case is not really necessary, but we do it for the - fun of it (and to get more intuition). - \spfstep*{We compute $1+3=2^{2}=4$.} - \end{subproof} - \begin{subproof}{$n>1$}\begin{spfblock} - \assumption[id=ind-hyp]{ - Now, we assume that the assertion is true for a certain $k\geq 1$, - i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}. - } - - We have to show that we can derive the assertion for $n=k+1$ from - this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$. - - \spfstep{ - We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}= - \sum_{i=1}^k{2i-1}+2(k+1)-1}$ - \spfjust{by \splitsum{\comp{splitting the sum} - \arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}. - } - \spfstep{ - Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$ - \spfjust{by \symname{induction-hypothesis}}. - } - \conclude{ - We can \spfjust{\simplification{\comp{simplify} the right-hand side - \arg*{k^2+2k+1}}} to - ${k+1}^2$, which proves the assertion. - } - \end{spfblock}\end{subproof} - \conclude{ - We have considered all the cases, so we have proven the assertion. - } -\end{sproof} -\end{latexcode} - - -\symdecl{splitsum}[args=1] -\symdecl{inducthypothesis}[name=induction-hypothesis] -\symdecl{simplification}[args=1] - -This yields the following result: - -\begin{mdframed} - \begin{sproof}[id=simple-proof,method=induction] - {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$} - For the induction we have to consider three cases: % <- a comment - \begin{subproof}{$n=1$} - \spfstep*{then we compute $1=1^2$} - \end{subproof} - \begin{subproof}{$n=2$} - This case is not really necessary, but we do it for the - fun of it (and to get more intuition). - \spfstep*{We compute $1+3=2^{2}=4$.} - \end{subproof} - \begin{subproof}{$n>1$}\begin{spfblock} - \assumption[id=ind-hyp]{ - Now, we assume that the assertion is true for a certain $k\geq 1$, - i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}. - } - - We have to show that we can derive the assertion for $n=k+1$ from - this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$. - - \spfstep{ - We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}=\sum_{i=1}^k{2i-1}+2(k+1)-1}$ - \spfjust{by \splitsum{\comp{splitting the sum}\arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}. - } - \spfstep{ - Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$ - \spfjust{by \symname{induction-hypothesis}}. - } - \conclude{ - We can \spfjust{\simplification{\comp{simplify} the right-hand side - \arg*{k^2+2k+1}}} to - ${k+1}^2$, which proves the assertion. - } - \end{spfblock}\end{subproof} - \conclude{ - We have considered all the cases, so we have proven the assertion. - } - \end{sproof} -\end{mdframed} - -\end{smodule} - -\begin{environment}{sproof} - The |sproof| environment is the main container for proofs. It takes an optional |KeyVal| - argument that allows to specify the |id| (identifier) and |for| (for which assertion is - this a proof) keys. The regular argument of the |proof| environment contains an - introductory comment, that may be used to announce the proof style. The |proof| - environment contains a sequence of |spfstep|, |spfcomment|, and |spfcases| environments - that are used to markup the proof steps. -\end{environment} - -\begin{function}{\spfidea} - The |\spfidea| macro allows to give a one-paragraph description of the proof idea. -\end{function} - -\begin{function}{\spfsketch} - For one-line proof sketches, we use the |\spfsketch| macro, which takes the same - optional argument as |sproof| and another one: a natural language text that sketches - the proof. -\end{function} - -\begin{function}{\spfstep} - Regular proof steps are marked up with the |\spfstep| macro, which takes an optional - |KeyVal| argument for annotations. A proof step usually contains a local assertion - (the text of the step) together with some kind of evidence that this can be derived - from already established assertions. -\end{function} - -\begin{function}{\yield} - See above -\end{function} - -\begin{function}{\spfjust} - This evidence is marked up with the |\spfjust| macro in the \pkg{stex-proofs} - package. This environment totally invisible to the formatted result; it wraps the text - in the proof step that corresponds to the evidence (ideally, a - semantically marked-up term). -\end{function} - -\begin{function}{\assumption} - The |\assumption| macro allows to mark up a (justified) assumption. -\end{function} - -\begin{function}{\justarg} -\end{function} - -\begin{environment}{subproof} - The |subproof| environment is used to mark up a subproof. This environment takes an - optional |KeyVal| argument for semantic annotations and a second argument that allows - to specify an introductory comment (just like in the |proof| environment). The - |method| key can be used to give the name of the proof method - executed to make this subproof. -\end{environment} - -\begin{function}{\sproofend} - Traditionally, the end of a mathematical proof is marked with a little box at the end of - the last line of the proof (if there is space and on the end of the next line if there - isn't), like so:\sproofend - - The \pkg{stex-proofs} package provides the |\sproofend| macro for this. -\end{function} - -\begin{variable}{\sProofEndSymbol} - If a different symbol for the proof end is to be used (e.g. {\sl{q.e.d}}), then this can - be obtained by specifying it using the |\sProofEndSymbol| configuration macro (e.g. by - specifying |\sProofEndSymbol{q.e.d}|). -\end{variable} - -Some of the proof structuring macros above will insert proof end symbols for sub-proofs, -in most cases, this is desirable to make the proof structure explicit, but sometimes this -wastes space (especially, if a proof ends in a case analysis which will supply its own -proof end marker). To suppress it locally, just set |proofend={}| in them or use use -|\sProofEndSymbol{}|. -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: hypothesis,id geq splitit arith:split-sum byindhyp rhs proofend eqstep -% LocalWords: sproofs coprime ratfrac 2,prec intpow ratpow inttimes varb varc sqrt2irr -% LocalWords: theorem,name sqrt2irr,method wlog hide,method hide,term spfblock splitsum -% LocalWords: simple-proof,method inducthypothesis diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex deleted file mode 100644 index 3850d644ee7..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-references.tex +++ /dev/null @@ -1,92 +0,0 @@ -If we take features like \stexcode"\inputref" and \stexcode"\mhinput" -(and the \stexcode"sfragment"-environment, see -\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]) seriously, -and build large documents modularly from individually compiling documents for sections, chapters -and so on, cross-referencing becomes an interesting problem. - -Say, we have a document |main.tex|, which \stexcode"\inputref"s a section -|section1.tex|, which references a definition with label |some_definition| in -|section2.tex| (subsequently also inputted in |main.tex|). -Then the numbering of the definition will depend on the \emph{document context} -in which the document fragment |section2.tex| occurs - in |section2.tex| itself -(as a standalone document), it might be \emph{Definition 1}, in |main.tex| it might -be \emph{Definition 3.1}, and in |section1.tex|, the definition \emph{does not even occur}, so -it needs to be referenced by some other text. - -What we would want in that instance is an equivalent of \stexcode"\autoref", that takes -the document context into account to yield something like \emph{Definition 1}, \emph{Definition 3.1} -or ``\emph{Definition 1 in the section on Foo}'' respectively. - -The \stexcode"\sref" command attempts to do precisely that. Unlike plain \stexcode"\ref", \stexcode"\autoref" -etc., \stexcode"\sref" refers to not just a \emph{label}, but instead a pair consisting of a \emph{label} -and the \emph{document} in whose context we want to refer to it. Conversely, every \emph{document} -(i.e. standalone compilable |.tex|-file) keeps track of the ``names'' (\emph{Definition 3.1} etc.) for every -label as determined in the context of the document, and stores them in a dedicated file |\jobname.sref|. -Additionally, every document has a ``\emph{reference name}'' (e.g. ``\emph{the section on Foo}''). -This allows us to refer to ``label $x$ in document $D$'' to yield ``\emph{Definition 1 in the section on Foo}''. -And of course, \sTeX can decide based on the current document to either refer to the label by its -``full name'' or directly as e.g. \emph{Definition 3.1} depending on whether the label occurs in -the current document anyway (and link to it accordingly). - -\paragraph{} For that to work, we need to supply (up to) three pieces -of information: -\begin{itemize} - \item The \emph{label} of the reference target (e.g. |some_definition|), - \item (optionally) the \emph{file}/document containing the reference target - (e.g. |section2|). - This is not strictly necessary, but allows for additional disambiguation - between possibly duplicate labels across files, and - \item (optionally) the document context, in which we want to - refer to the reference target (e.g. |main|). -\end{itemize} -Additionally, the document in which we want to reference a label needs -a title for external references. - - -\begin{function}{\sref} - \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|% - \Arg{label}|[archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|]| \end{syntax} - This command references \meta{label} (declared in \meta{file} in \meta{archive1}). - If the object (section, figure, etc.) with that label occurs ultimately - in the same document, \cs{sref} will ignore the second set of optional arguments - and simply defer to \cs{autoref} if that command exists, or \cs{ref} if the \pkg{hyperref} - package is not included. - - If the referenced object does \emph{not} occur in the current document however, - \cs{sref} will refer to it by the object's name as it occurs in - the file \meta{document-context} in \meta{archive2}. - -For example, the reference to the \stexcode"sfragment"-environment above -will appear as ``subsection 7.2.1 (Introduction) in the \sTeX{}3 manual'' -if you are reading this in the package documentation for |stex-references| -directly, but as a linked ``subsection 7.2.1'' in the full documentation -or manual. This is achieved using - -\stexcode"\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]". - -\end{function} - -For a further example, the following: -\begin{center} - \sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}] -\end{center} -will say ``Part III'' (and link accordingly) in the full documentation, -and ``Part III (Extensions) in the full \sTeX{}3 documentation'' -everywhere else. This is achieved using - -\stexcode"\sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}]". - -\begin{function}{\extref} - \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|% - \Arg{label}|{archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|}| \end{syntax} - The \cs{extref}-command behaves exactly like \cs{sref}, but takes - \emph{required} the document context argument and will always use it - for generating the document text, regardless of whether the label - occurs in the current document. -\end{function} - - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex deleted file mode 100644 index 7e0e1fe4a44..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-setup.tex +++ /dev/null @@ -1,34 +0,0 @@ -\begin{sfragment}{Setting up the \sTeX Package} - - \begin{sfragment}[id=sec.minimal-setup]{Minimal Setup for the \sTeX Package} - In the best of all worlds, there is no setup, as you already have a new version of - {\TeX}Live on your system as a {\LaTeX} enthusiast. If not now is the time to - install it; see \cite{TeXLive:on}. You can usually update {\TeX}Live via a package - manager or the {\TeX}Live manager \textbf{tlmgr}. - \sTeX requires a \TeX{} kernel newer than February 2022. - - Alternatively, you can install \sTeX from CTAN, the Comprehensive {\TeX} Archive - Network; see \cite{stexCTAN:on} for details. We - assume you have the \sTeX package in at least version 3.2 (September 2022). - \end{sfragment} - - \begin{sfragment}[id=sec.git-setup]{GIT-based Setup for the \sTeX Development Version} - If you want use the latest and greatest \sTeX packages - that have not even been released to CTAN, - then you can directly clone them from the \sTeX development - repository \cite{sTeX:github:on} by the following command-line instructions: - \begin{lstlisting}[language=bash] - cd <stexdir> - git clone https://github.com/slatex/sTeX.git - \end{lstlisting} - and keep it updated by pulling updates via \lstinline|git pull| in the cloned \sTeX - directory. - Make sure to either clone the \sTeX repository into a local texmf-tree or to update your \lstinline|TEXINPUTS| environment variable, e.g. by placing the following line in your \lstinline|.bashrc|: - \begin{lstlisting}[language=bash] - export TEXINPUTS="$(TEXINPUTS):<sTeXDIR>//:" - \end{lstlisting} - \end{sfragment} - - \input{packages/stex-mathhubsetup} - -\end{sfragment}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-statements.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-statements.tex deleted file mode 100644 index 6a2478fa7d1..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-statements.tex +++ /dev/null @@ -1,145 +0,0 @@ -\begin{sfragment}{Definitions, Theorems, Examples, Paragraphs} -\begin{smodule}{Statements} - As mentioned earlier, we can semantically mark-up - \emph{statements} such as definitions, theorems, lemmata, examples, etc. - - The corresponding environments for that are: - \begin{itemize} - \item \stexcode"sdefinition" for definitions, - \item \stexcode"sassertion" for assertions, i.e. - propositions that are declared to be \emph{true}, - such as theorems, lemmata, axioms, - \item \stexcode"sexample" for examples and counterexamples, and - \item \stexcode"sparagraph" for ``other'' semantic paragraphs, - such as comments, remarks, conjectures, etc. - \end{itemize} - - The \emph{presentation} of these environments can be customized - to use e.g. predefined |theorem|-environments, see \sref{sec.customhighlight} - for details. - - All of these environments take optional arguments in the form of - |key=value|-pairs. Common to all of them are the keys |id=| (for cross-referencing, - see \sref{sec.references}), |type=| for customization (see \sref{sec.customhighlight}) - and additional information (e.g. definition principles, ``difficulty'' etc), as well - as |title=| (for giving the paragraph a title), and finally |for=|. - - The |for=| key expects a comma-separated list of existing - symbols, allowing for e.g. things like - \symdef{addition}[args=a,prec=100]{#1}{##1 \comp+ ##2} - \symdef{multiplication}[args=a,prec=50]{#1}{##1 \comp\cdot ##2} - \stexexample{% -\begin{sexample}[ - id=additionandmultiplication.ex, - for={addition,multiplication}, - type={trivial,boring}, - title={An Example} -] - $\addition{2,3}$ is $5$, $\multiplication{2,3}$ is $6$. -\end{sexample} - } - - \begin{function}{\definiendum,\definame,\Definame} - \stexcode"sdefinition" (and \stexcode"sparagraph" with - |type=symdoc|) introduce three new macros: - \stexcode"definiendum" behaves like \stexcode"symref" - (and \stexcode"definame"/\stexcode"Definame" - like \stexcode"symname"/\stexcode"Symname", respectively), - but highlights the referenced symbol as \emph{being defined} - in the current definition. - \end{function} - - \begin{mmtbox} - The special |type=symdoc| for \stexcode"sparagraph" is intended to be used for - ``informal definitions'', or encyclopedia-style descriptions for symbols. - - The \mmt system can use those (in lieu of an actual \stexcode"sdefinition" in scope) - to present to users, e.g. when hovering over symbols. - \end{mmtbox} - - \begin{function}{\definiens} - Additionally, \stexcode"sdefinition" (and \stexcode"sparagraph" with - |type=symdoc|) introduces \stexcode"\definiens[<optional symbolname>]{<code>}" - which marks up |<code>| as being the explicit \emph{definiens} - of |<optional symbolname>| (in case |for=| has multiple symbols). - \end{function} - - All four statement environments -- i.e. \stexcode|sdefinition|, - \stexcode|sassertion|, \stexcode|sexample|, and \stexcode|sparagraph| -- also take an - optional parameter |name=| -- if this one is given a value, the environment will - generate a \emph{symbol} by that name (but with no semantic macro). Not only does this - allow for \stexcode"\symref" et al, it allows us to resume our earlier example for - monoids much more nicely:\ednote{MK: we should reference the example explicitly here.} - - \symdef{set}{\comp{\texttt{Set}}} - \symdef{equal}[args=2]{#1 \comp= #2} - \symdef{inset}[args=2]{#1 \comp\in #2} - \symdef{funtype}[args=ai]{#1 \comp\to #2}{##1 \comp\times ##2} - - \stexexample{% -\begin{mathstructure}{monoid} - \symdef{universe}[type=\set]{\comp{U}} - \symdef{op}[ - args=2, - type=\funtype{\universe,\universe}{\universe}, - op=\circ - ]{#1 \comp{\circ} #2} - \symdef{unit}[type=\universe]{\comp{e}} - - \begin{sparagraph}[type=symdoc,for=monoid] - A \definame{monoid} is a structure - $\mathstruct{\universe,\op!,\unit}$ - where $\op!:\funtype{\universe}{\universe}$ and - $\inset{\unit}{\universe}$ such that - - \begin{sassertion}[name=associative, - type=axiom, - title=Associativity] - $\op!$ is associative - \end{sassertion} - \begin{sassertion}[name=isunit, - type=axiom, - title=Unit] - $\equal{\op{\svar{x}}{\unit}}{\svar{x}}$ - for all $\inset{\svar{x}}{\universe}$ - \end{sassertion} - \end{sparagraph} -\end{mathstructure} - -An example for a \symname{monoid} is... - } - - The main difference to before\ednote{MK: reference} is that the two - \stexcode|sassertion|s now have |name=| attributes. Thus the \stexcode"mathstructure" - \symname{monoid} now contains two additional symbols, namely the axioms for - associativity and that $e$ is a unit. Note that both symbols do not represent the mere - \emph{propositions} that e.g. $\circ$ is associative, but \emph{the assertion that it - is actually true} that $\circ$ is associative. - - If we now want to instantiate |monoid| (unless with a variable, - of course), we also need to assign |associative| and |neutral| - to analogous assertions. So the earlier example - \begin{latexcode}[gobble=8] - \instantiate{intmonoid}{monoid}{\mathbb{Z}_{+,0}}[ - universe = Int , - op = addition , - unit = zero - ] - \end{latexcode} - ...will not work anymore. We now need to give assertions that - |addition| is associative and that |zero| is a unit with respect - to addition.\footnote{Of course, \sTeX can not check that - the assertions are the ``correct'' ones -- but if - the assertions (both in |monoid| as well as those for addition and - zero) are properly marked up, \mmt can. \textcolor{red}{TODO: should}} - -\end{smodule} -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: sec.customhighlight a,prec additionandmultiplication.ex trivial,boring -% LocalWords: addition,multiplication symdoc symdoc,for isunit diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex deleted file mode 100644 index 67e9a32e704..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-symbols.tex +++ /dev/null @@ -1,587 +0,0 @@ -\begin{smodule}[ns=https://github.com/slatex/sTeX/doc]{SymbolsAndNotations} -\begin{sfragment}{Declaring New Symbols and Notations} - Inside an \stexcode"smodule" environment, we can declare new \sTeX symbols. - -\begin{function}{\symdecl} - The most basic command for doing so is using \stexcode"\symdecl{symbolname}". This - introduces a new symbol with name |symbolname|, arity $0$ and semantic macro - \stexcode"\symbolname". - - The starred variant \stexcode"\symdecl*{symbolname}" will declare a symbol, but not - introduce a semantic macro. If we don't want to supply a notation (for example to - introduce concepts like ``abelian'', which is not something that has a notation), the - starred variant is likely to be what we want. -\end{function} -\begin{mmtbox} - \stexcode"\symdecl" introduces a new \omdoc/\mmt constant in the current module - (=\omdoc/\mmt theory). Correspondingly, they get assigned the URI - |<module-URI>?<constant-name>|. -\end{mmtbox} - -Without a semantic macro or a notation, the only meaningful way to reference a symbol is -via \stexcode"\symref",\stexcode"\symname" etc. - -\stexexample{% -\symdecl*{foo} -Given a \symname{foo}, we can... -} - -Obviously, most semantic macros should take actual \emph{arguments}, implying that the -symbol we introduce is an \emph{operator} or \emph{function}. We can let -\stexcode"\symdecl" know the \emph{arity} (i.e. number of arguments) of a symbol like -this: - -\stexexample{% -\symdecl{binarysymbol}[args=2] -\symref{binarysymbol}{this} is a symbol taking two arguments. -} - -So far we have gained exactly \ldots nothing by adding the arity information: we cannot do -anything with the arguments in the text. - -We will now see what we can gain with more machinery. - -\begin{function}{\notation} - We probably want to supply a notation as well, in which case we can finally actually use - the semantic macro in math mode. We can do so using the \stexcode"\notation" command, - like this: - -\stexexample{% -\notation{binarysymbol}{\text{First: }#1\text{; Second: }#2} -$\binarysymbol{a}{b}$ } -\end{function} - -\begin{mmtbox} - Applications of semantic macros, such as \stexcode"\binarysymbol{a}{b}" are translated - to \mmt/\omdoc as |OMA|-terms with head |<OMS name="...?binarysymbol"/>|. - - Semantic macros with no arguments correspond to |OMS| directly. -\end{mmtbox} - -\begin{function}{\comp} - For many semantic services e.g. semantic highlighting or \defemph{wikification} (linking - user-visible notation components to the definition of the respective symbol they come - from), we need to specify the notation components. Unfortunately, there is currently no - way the \sTeX engine can infer this by itself, so we have to specify it manually in the - notation specification. We can do so with the \stexcode"\comp" command. -\end{function} - -We can introduce a new notation |highlight| for \stexcode"\binarysymbol" that fixes this -flaw, which we can subsequently use with \stexcode"\binarysymbol[highlight]": - -\stexexample{% -\notation{binarysymbol}[highlight] - {\comp{\text{First: }}#1\comp{\text{; Second: }}#2} -$\binarysymbol[highlight]{a}{b}$ -} - -\begin{dangerbox} - Ideally, \stexcode"\comp" would not be necessary: Everything in a notation that is - \emph{not} an argument should be a notation component. Unfortunately, it is - computationally expensive to determine where an argument begins and ends, and the - argument markers |#n| may themselves be nested in other macro applications or - \TeX\xspace groups, making it ultimately almost impossible to determine them - automatically while also remaining compatible with arbitrary highlighting customizations - (such as tooltips, hyperlinks, colors) that users might employ, and that are ultimately - invoked by \stexcode"\comp". -\end{dangerbox} - -\begin{dangerbox} - Note that it is required that - \begin{enumerate} - \item the argument markers |#n| never occur inside a \stexcode"\comp", and - \item no semantic arguments may ever occur inside a notation. - \end{enumerate} - Both criteria are not just required for technical reasons, but conceptionally - meaningful: - - The underlying principle is that the arguments to a semantic macro represent - \emph{arguments to the mathematical operation} represented by a symbol. For example, a - semantic macro \stexcode"\addition{a}{b}" taking two arguments would represent \emph{the - actual addition of (mathematical objects) $a$ and $b$}. It should therefore be - impossible for $a$ or $b$ to be part of a notation component of \stexcode"\addition". - - Similarly, a semantic macro can not conceptually be part of the notation of - \stexcode"\addition", since a semantic macro represents a \emph{distinct mathematical - concept} with \emph{its own semantics}, whereas notations are syntactic - representations of the very symbol to which the notation belongs. - - If you want an argument to a semantic macro to be a purely syntactic parameter, then you - are likely somewhat confused with respect to the distinction between the precise - \emph{syntax} and \emph{semantics} of the symbol you are trying to declare (which - happens quite often even to experienced \sTeX users), and might want to give those - another thought - quite likely, the macro you aim to implement does not actually - represent a semantically meaningful mathematical concept, and you will want to use - \stexcode"\def" and similar native \LaTeX\xspace macro definitions rather than semantic - macros. -\end{dangerbox} - -\begin{function}{\symdef} - In the vast majority of cases where a symbol declaration should come with a semantic - macro, we will want to supply a notation immediately. For that reason, the - \stexcode"\symdef" command combines the functionality of both \stexcode"\symdecl" and - \stexcode"\notation" with the optional arguments of both: -\end{function} - -\stexexample{% -\symdef{newbinarysymbol}[hl,args=2] - {\comp{\text{1.: }}#1\comp{\text{; 2.: }}#2} -$\newbinarysymbol{a}{b}$ -} - -We just declared a new symbol |newbinarysymbol| with |args=2| and immediately provided it -with a notation with identifier |hl|. Since |hl| is the \emph{first} (and so far, only) -notation supplied for |newbinarysymbol|, using \stexcode"\newbinarysymbol" without -optional argument defaults to this notation.\bigskip - -But one man's meat is another man's poison: it is very subjective what the ``default -notation'' of an operator should be. Different communities have different practices. For -instance, the complex unit is written as $i$ in Mathematics and as $j$ in electrical -engineering. So to allow modular specification and facilitate re-use of document fragments -\sTeX allows to re-set notation defaults. - -\begin{function}{\setnotation} - The first notation provided will stay the default notation unless explicitly changed -- - this is enabled by the \stexcode"\setnotation" command: - \stexcode"\setnotation{symbolname}{notation-id}" sets the default notation of - \stexcode"\symbolname" to |notation-id|, i.e. henceforth, \stexcode"\symbolname" behaves - like \stexcode"\symbolname[notation-id]" from now on. -\end{function} - -Often, a default notation is set right after the corresponding notation is introduced -- -the starred version \stexcode"\notation*" for that reason introduces a new notation and -immediately sets it to be the new default notation. So expressed differently, the -\emph{first} \stexcode"\notation" for a symbol behaves exactly like \stexcode"\notation*", -and \stexcode"\notation*{foo}[bar]{...}" behaves exactly like -\stexcode"\notation{foo}[bar]{...}\setnotation{foo}{bar}". - -\begin{function}{\textsymdecl} - In the less mathematical settings where we want a symbol and - semantic macro for some concept with a notation \emph{beyond} - its mere name, but which should also be available in \TeX's text - mode, the command \stexcode"\textsymdecl" is useful. - For example, we can declare a symbol \stexcode"openmath" - with the notation \stexcode"\textsc{OpenMath}" using - \textsymdecl{openmath}[name=OpenMath]{\textsc{OpenMath}} - \stexcode"\textsymdecl{openmath}[name=OpenMath]{\textsc{OpenMath}}". - The \stexcode"\openmath" yields \openmath both in text and math - mode. -\end{function} - -\begin{sfragment}{Operator Notations} - Once we have a semantic macro with arguments, such as \stexcode"\newbinarysymbol", the - semantic macro represents the \emph{application} of the symbol to a list of - arguments. What if we want to refer to the operator \emph{itself}, though? - - We can do so by supplying the \stexcode"\notation" (or \stexcode"\symdef") with an - \emph{operator notation}, indicated with the optional argument |op=|. We can then - invoke the operator notation using \stexcode"\symbolname![notation-identifier]". Since - operator notations never take arguments, we do not need to use \stexcode"\comp" in it, - the whole notation is wrapped in a \stexcode"\comp" automatically: - - \stexexample{% - \notation{newbinarysymbol}[ab, op={\text{a:}\cdot\text{; b:}\cdot}] - {\comp{\text{a:}}#1\comp{\text{; b:}}#2} \symname{newbinarysymbol} is also - occasionally written $\newbinarysymbol![ab]$ - } - - \begin{mmtbox} - \stexcode"\symbolname!" is translated to \omdoc/\mmt as |<OMS name="...?symbolname"/>| - directly. - \end{mmtbox} - -\end{sfragment} -\end{sfragment} - -\begin{sfragment}{Argument Modes} - The notations so far used \emph{simple} arguments which we call \emph{mode}-|i| - arguments. Declaring a new symbol with \stexcode"\symdecl{foo}[args=3]" is equivalent to - writing \stexcode"\symdecl{foo}[args=iii]", indicating that the semantic macro takes - three mode-|i| arguments. However, there are three more argument modes which we will - investigate now, namely mode-|b|, mode-|a| and mode-|B| arguments. - -\begin{sfragment}{Mode-\texttt b Arguments} - -A mode-|b| argument represents a \emph{variable} that is \emph{bound} by the symbol in -its application, making the symbol a \emph{binding operator}. Typical examples of -binding operators are e.g. sums $\sum$, products $\prod$, integrals $\int$, quantifiers -like $\forall$ and $\exists$, that $\lambda$-operator, etc. - -\begin{mmtbox} - Mode-|b| arguments behave exactly like mode-|i| arguments within \TeX, but applications - of binding operators, i.e. symbols with mode-|b| arguments, are translated to - |OMBIND|-terms in \omdoc/\mmt, rather than |OMA|. -\end{mmtbox} - -For example, we can implement a summation operator binding an index variable and taking -lower and upper index bounds and the expression to sum over like this: - -\stexexample{% -\symdef{summation}[args=biii] - {\mathop{\comp{\sum}}_{#1\comp{=}#2}^{#3}#4} - $\summation{\svar{x}}{1}{\svar{n}}{\svar{x}}^2$ -} - -where the variable $\svar{x}$ is now \emph{bound} by the \stexcode"\summation"-symbol in -the expression. -\end{sfragment} - -\begin{sfragment}{Mode-\texttt a Arguments} - Mode-|a| arguments represent a \emph{flexary argument sequence}, i.e. a sequence of - arguments of arbitrary length. Formally, operators that take arbitrarily many arguments - don't ``exist'', but in informal mathematics, they are ubiquitous. Mode-|a| arguments - allow us to write e.g. \stexcode"\addition{a,b,c,d,e}" rather than having to write - something like \stexcode"\addition{a}{\addition{b}{\addition{c}{\addition{d}{e}}}}"! - - \stexcode"\notation" (and consequently \stexcode"\symdef", too) take one additional - argument for each mode-|a| argument that indicates how to ``accumulate'' a - comma-separated sequence of arguments. This is best demonstrated on an example. - - Let's say we want an operator representing quantification over an ascending chain of - elements in some set, i.e. \stexcode"\ascendingchain{S}{a,b,c,d,e}{t}" should yield - $\forall a{<_S}b{<_S}c{<_S}d{<_S}e.\,t$. The ``base''-notation for this operator is - simply\\ \stexcode"{\comp{\forall} #2\comp{.\,}#3}", where |#2| represents the full - notation fragment \emph{accumulated} from |{a,b,c,d,e}|. - - The \emph{additional} argument to \stexcode"\notation" (or \stexcode"\symdef") takes the - same arguments as the base notation and two \emph{additional} arguments |##1| and |##2| - representing successive pairs in the mode-|a| argument, and accumulates them into |#2|, - i.e. to produce $a<_Sb<_Sc<_Sd<_Se$, we do \stexcode"{##1 \comp{<}_{#1} ##2}": - - \stexexample{% -\symdef{ascendingchain}[args=iai] - {\comp{\forall} #2\comp{.\,}#3} - {##1 \comp{<}_{#1} ##2} - -Tadaa: $\ascendingchain{S}{a,b,c,d,e}{t}$ -} - -If this seems overkill, keep in mind that you will rarely need the single-hash arguments -|#1|,|#2| etc. in the |a|-notation-argument. For a much more representative and simpler -example, we can introduce flexary addition via: -\stexexample{% - \symdef{addition}[args=a]{#1}{##1 \comp{+} ##2} - -Tadaa: $\addition{a,b,c,d,e}$ -} - -\begin{sfragment}{The \texttt{assoc}-key} - We mentioned earlier that ``formally'', flexary arguments don't really - ``exist''. Indeed, formally, addition is usually defined as a binary operation, - quantifiers bind a single variable etc. - - Consequently, we can tell \sTeX (or, rather, \mmt/\omdoc) how to ``resolve'' flexary - arguments by providing \stexcode"\symdecl" or \stexcode"\symdef" with an optional - |assoc|-argument, as in \stexcode"\symdecl{addition}[args=a,assoc=bin]". The possible - values for the |assoc|-key are: - \begin{itemize} - \item[|bin|:] A binary, associative argument, e.g. as in \stexcode"\addition" - \item[|binl|:] A binary, left-associative argument, e.g. - $a^{\scriptstyle b^{\scriptstyle c^d}}$, which stands for $((a^b)^c)^d$ - \item[|binr|:] A binary, right-associative argument, e.g. as in $A\to B\to C\to D$, - which stands for $A \to (B \to (C \to D))$ - \item[|pre|:] Successively prefixed, e.g. as in $\forall x,y,z.\,P$, which stands for - $\forall x.\, \forall y.\, \forall z.\,P$ - \item[|conj|:] Conjunctive, e.g. as in $a=b=c=d$ or $a,b,c,d\in A$, which stand for - $a=d\wedge b=d\wedge c=d$ and $a\in A\wedge b\in A \wedge c\in A\wedge d\in A$, - respectively - \item[|pwconj|:] Pairwise conjunctive, e.g. as in $a\neq b\neq c\neq d$, which stands - for $a\neq b\wedge a\neq c\wedge a\neq d\wedge b\neq c\wedge b\neq d\wedge c\neq d$ - \end{itemize} - As before, at the PDF level, this annotation is invisible (and without effect), but at - the level of the generated OMDoc/MMT this leads to more semantical expressions. -\end{sfragment} -\end{sfragment} - -\begin{sfragment}{Mode-\texttt B Arguments} - Finally, mode-|B| arguments simply combine the functionality of both |a| and |b| - - i.e. they represent an arbitrarily long sequence of variables to be bound, e.g. for - implementing quantifiers: - - \stexexample{% -\symdef{quantforall}[args=Bi] - {\comp{\forall}#1\comp{.}#2} - {##1\comp,##2} - -$\quantforall{\svar{x},\svar{y},\svar{z}}{P}$ -} -\end{sfragment} -\end{sfragment} - -\begin{sfragment}{Type and Definiens Components} - \stexcode"\symdecl" and \stexcode"\symdef" take two more optional arguments. \TeX\xspace - largely ignores them (except for special situations we will talk about later), but \mmt - can pick up on them for additional services. These are the |type| and |def| keys, which - expect expressions in math-mode (ideally using semantic macros, of course!) - - \begin{mmtbox} - The |type| and |def| keys correspond to the |type| and |definiens| components of - \omdoc/\mmt constants. - - Correspondingly, the name ``type'' should be taken with a grain of salt, since - \omdoc/\mmt -- being foundation-independent -- does not a priori implement a fixed - typing system. - \end{mmtbox} - - \symdef{funtype}[args=ai]{#1 \comp\to #2}{##1 \comp\times ##2} - \symdef{fun}[args=bi]{#1 \comp\mapsto #2} - \symdef{set}{\comp{\texttt{Set}}} - - The |type|-key allows us to provide additional information - (given the necessary \sTeX symbols), e.g. for - addition on natural numbers: - - \stexexample{% -\symdef{Nat}[type=\set]{\comp{\mathbb N}} -\symdef{addition}[ - type=\funtype{\Nat,\Nat}{\Nat}, - op=+, - args=a -]{#1}{##1 \comp+ ##2} - -\symname{addition} is an operation $\funtype{\Nat,\Nat}{\Nat}$ -} - -The |def|-key allows for declaring symbols as abbreviations: -\stexexample{% -\symdef{successor}[ - type=\funtype{\Nat}{\Nat}, - def=\fun{\svar{x}}{\addition{\svar{x},1}}, - op=\mathtt{succ}, - args=1 -]{\comp{\mathtt{succ(}#1\comp{)}}} - -The \symname{successor} operation $\funtype{\Nat}{\Nat}$ -is defined as $\fun{\svar{x}}{\addition{\svar{x},1}}$ -} -\end{sfragment} - -\begin{sfragment}{Precedences and Automated Bracketing} - Having done \stexcode"\addition", the obvious next thing to implement is - \stexcode"\multiplication". This is straight-forward in theory: - - \stexexample{% -\symdef{multiplication}[ - type=\funtype{\Nat,\Nat}{\Nat}, - op=\cdot, - args=a -]{#1}{##1 \comp\cdot ##2} - -\symname{multiplication} is an operation $\funtype{\Nat,\Nat}{\Nat}$ -} - -However, if we \emph{combine} \stexcode"\addition" and \stexcode"\multiplication", we -notice a problem: - -\stexexample{% -$\addition{a,\multiplication{b,\addition{c,\multiplication{d,e}}}}$ -} - -We all know that $\multiplication!$ binds stronger than $\addition!$, so the output -$\addition{a,\multiplication{b,\addition{c,\multiplication{d,e}}}}$ does not actually -reflect the term we wrote. We can of course insert parentheses manually - -\stexexample{% -$\addition{a,\multiplication{b,(\addition{c,\multiplication{d,e}})}}$ -} -but we can also do better by supplying \emph{precedences} and -have \sTeX insert parentheses automatically. - -For that purpose, \stexcode"\notation" (and hence \stexcode"\symdef") take an optional -argument |prec=<opprec>;<argprec1>x...x<argprec n>|. - -We will investigate the precise meaning of |<opprec>| and the |<argprec>|s shortly -- in -the vast majority of cases, it is perfectly sufficient to think of |prec=| taking a single -number and having that be \emph{the} precedence of the notation, where lower precedences -(somewhat counterintuitively) bind stronger than higher precedences. So fixing our -notations for \stexcode"\addition" and \stexcode"\multiplication", we get: - -\stexexample{% -\notation{multiplication}[ - op=\cdot, - prec=50 -]{#1}{##1 \comp\cdot ##2} -\notation{addition}[ - op=+, - prec=100 -]{#1}{##1 \comp+ ##2} - -$\addition{a,\multiplication{b,\addition{c,\multiplication{d,e}}}}$ -} - -Note that the precise numbers used for precedences are pretty arbitrary - what matters is -which precedences are higher than which other precedences when used in conjunction. -\begin{variable}{\infprec,\neginfprec} - It is occasionally useful to have ``infinitely'' high or low precedences to enforce or - forbid automated bracketing entirely, e.g. for bracket-like notations such as intervals - -- for those purposes, \stexcode"\infprec" and \stexcode"\neginfprec" exist (which are - implemented as the maximal and minimal integer values accordingly).g -\end{variable} - -\begin{dangerbox} - More precisely, each notation takes - \begin{enumerate} - \item One \emph{operator precedence} and - \item one \emph{argument precedence} for each argument. - \end{enumerate} - By default, all precedences are $0$, unless the symbol takes no argument, in which case - the operator precedence is \stexcode"\neginfprec" (negative infinity). If we only - provide a single number, this is taken as both the operator precedence and all argument - precedences. - - \sTeX decides whether to insert parentheses by comparing operator precedences to a - \emph{downward precedence} $p_d$ with initial value \stexcode"\infprec". When - encountering a semantic macro, \sTeX takes the operator precedence $p_{op}$ of the - notation used and checks whether $p_{op}>p_d$. If so, \sTeX insert parentheses. - - When \sTeX steps into an argument of a semantic macro, it sets $p_d$ to the respective - argument precedence of the notation used. - - In the example above: - \begin{enumerate} - \item \sTeX starts out with $p_d=$\stexcode"\infprec". - \item \sTeX encounters \stexcode"\addition" with $p_{op}=100$. Since - $100\not>$\stexcode"\infprec", it inserts no parentheses. - \item Next, \sTeX encounters the two arguments for \stexcode"\addition". Both have no - specifically provided argument precedence, so \sTeX uses $p_d=p_{op}=100$ for both and - recurses. - \item Next, \sTeX encounters \stexcode"\multiplication{b,...}", whose notation has - $p_{op}=50$. - \item We compare to the current downward precedence $p_d$ set by \stexcode"\addition", - arriving at $p_{op}=50\not>100=p_d$, so \sTeX again inserts no parentheses. - \item Since the notation of \stexcode"\multiplication" has no explicitly set argument - precedences, \sTeX uses the operator precedence for all arguments of - \stexcode"\multiplication", hence sets $p_d=p_{op}=50$ and recurses. - \item Next, \sTeX encounters the inner \stexcode"\addition{c,...}" whose notation has - $p_{op}=100$. - \item We compare to the current downward precedence $p_d$ set by - \stexcode"\multiplication", arriving at $p_{op}=100>50=p_d$ -- which finally prompts - \sTeX to insert parentheses, and we proceed as before. - \end{enumerate} -\end{dangerbox} -\end{sfragment} - -\begin{sfragment}{Variables} - All symbol and notation declarations require a module with which they are associated, - hence the commands \stexcode"\symdecl", \stexcode"\notation", \stexcode"\symdef" - etc. are disabled outside of |smodule|-environments. - - Variables are different -- variables are allowed everywhere, are not exported when the - current module (if one exists) is imported (via \stexcode"\importmodule" or - \stexcode"\usemodule") and (also unlike symbol declarations) ``disappear'' at the end of - the current \TeX\xspace group. - - \begin{function}{\svar} - So far, we have always used variables using \stexcode"\svar{n}", which marks-up $n$ as - a variable with name |n|. More generally, \stexcode"\svar[foo]{<texcode>}" marks-up - the arbitrary |<texcode>| as representing a variable with name |foo|. - \end{function} - - Of course, this makes it difficult to reuse variables, or introduce ``functional'' - variables with arities $>0$, or provide them with a type or definiens. - - \begin{function}{\vardef} - For that, we can use the \stexcode"\vardef" command. Its syntax is largely the same as - that of \stexcode"\symdef", but unlike symbols, variables have only one notation - (\textcolor{red}{TODO: so far?}), hence there is only \stexcode"\vardef" and no - \stexcode"\vardecl". - \end{function} - -\stexexample{% -\vardef{varf}[ - name=f, - type=\funtype{\Nat}{\Nat}, - op=f, - args=1, - prec=0;\neginfprec -]{\comp{f}#1} -\vardef{varn}[name=n,type=\Nat]{\comp{n}} -\vardef{varx}[name=x,type=\Nat]{\comp{x}} - -Given a function $\varf!:\funtype{\Nat}{\Nat}$, -by $\addition{\varf!,\varn}$ we mean the function\rustexBREAK -$\fun{\varx}{\varf{\addition{\varx,\varn}}}$ -} - -(of course, ``lifting'' addition in the way described in the previous example is an -operation that deserves its own symbol rather than abusing \stexcode"\addition", -but... well.) - -\textcolor{red}{TODO: bind=forall/exists} -\end{sfragment} - -\begin{sfragment}{Variable Sequences} - Variable \emph{sequences} occur quite frequently in informal mathematics, hence they - deserve special support. Variable sequences behave like variables in that they disappear - at the end of the current \TeX\xspace group and are not exported from modules, but their - declaration is quite different. - - \begin{function}{\varseq} - A variable sequence is introduced via the command \stexcode"\varseq", which takes the - usual optional arguments |name| and |type|. It then takes a starting index, an end - index and a \emph{notation} for the individual elements of the sequence parametric in - an index. Note that both the starting as well as the ending index may be variables. - \end{function} - - This is best shown by example: - \stexexample{% -\vardef{varn}[name=n,type=\Nat]{\comp{n}} -\varseq{seqa}[name=a,type=\Nat]{1}{\varn}{\comp{a}_{#1}} - -The $i$th index of $\seqa!$ is $\seqa{i}$. -} - -Note that the syntax |\seqa!| now automatically generates a presentation based on the -starting and ending index. - -\textcolor{red}{TODO: more notations for invoking sequences}. - -\vardef{varn}[name=n,type=\Nat]{\comp{n}} -\varseq{seqa}[name=a]{1}{\varn}{\comp{a}_{#1}} - -Notably, variable sequences are nicely compatible with |a|-type arguments, so we can do -the following: - -\stexexample{% -$\addition{\seqa}$ -} - -Sequences can be \emph{multidimensional} using the |args|-key, in which case the -notation's arity increases and starting and ending indices have to be provided as a -comma-separated list: - -\stexexample{% -\vardef{varm}[name=m,type=\Nat]{\comp{m}} -\varseq{seqa}[ - name=a, - args=2, - type=\Nat, -]{1,1}{\varn,\varm}{\comp{a}_{#1}^{#2}} - -$\seqa!$ and $\addition{\seqa}$ -} -\vardef{varm}[name=m,type=\Nat]{\comp{m}} - -We can also explicitly provide a ``middle'' segment to be used, like such: - -\stexexample{% -\varseq{seqa}[ - name=a, - type=\Nat, - args=2, - mid={\comp{a}_{\varn}^1,\comp{a}_1^2,\ellipses,\comp{a}_{1}^{\varm}} -]{1,1}{\varn,\varm}{\comp{a}_{#1}^{#2}} - -$\seqa!$ and $\addition{\seqa}$ -} -\end{sfragment} -\end{smodule} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: binarysymbol newbinarysymbol hl,args a,b,c,d,e ascendingchain assoc binl -% LocalWords: a,assoc binr x,y,z conj a,b,c,d pwconj funtype succ prec opprec argprec1 -% LocalWords: argprec texcode varf varn n,type varx x,type varseq seqa a,type th m,type diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-terms.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-terms.tex deleted file mode 100644 index 759b3f5fdd8..00000000000 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-terms.tex +++ /dev/null @@ -1,177 +0,0 @@ -\begin{smodule}{SymbolsInText} - \symdef{set}{\comp{\texttt{Set}}} - - Given a symbol declaration \stexcode"\symdecl{symbolname}", - we obtain a semantic macro \stexcode"\symbolname". - We can use this semantic macro in math mode to use its notation(s), - and we can use \stexcode"\symbolname!" - in math mode to use its operator notation(s). - What else can we do? - -\begin{sfragment}{\texttt{\textbackslash symref} and its variants} - - \begin{function}{\symref,\symname} - We have already seen \stexcode"\symname" and - \stexcode"\symref", the latter being the more general. - - \stexcode"\symref{<symbolname>}{<code>}" marks-up |<code>| - as referencing |<symbolname>|. Since quite often, the |<code>| - should be (a variant of) the name of the symbol anyway, - we also have \stexcode"\symname{<symbolname>}". - \end{function} - - Note that \stexcode"\symname" uses the \emph{name} - of a symbol, not its macroname. More precisely, - \stexcode"\symname" will insert the name of the symbol - with ``|-|'' replaced by spaces. - If a symbol does not have - an explicit |name=| given, the two are equal -- but - for \stexcode"\symname" it often makes sense to make the - two explicitly distinct. For example: - \stexexample{% -\symdef{Nat}[ - name=natural-number, - type=\set -]{\comp{\mathbb{N}}} - -A \symname{Nat} is... - } - - \stexcode"\symname" takes two additional optional - arguments, |pre=| and |post=| that get prepended or appended - respectively to the symbol name. - - \begin{function}{\Symname} - Additionally, \stexcode"\Symname" behaves exactly - like \stexcode"\symname", but will capitalize the first - letter of the name: - \end{function} - \stexexample{% -\Symname[post=s]{Nat} are... - } - - \begin{dangerbox} - This is as good a place as any other to explain how - \sTeX resolves a string |symbolname| to an actual symbol. - - If \stexcode"\symbolname" is a semantic macro, then - \sTeX has no trouble resolving |symbolname| to the full - URI of the symbol that is being invoked. - - However, especially in \stexcode"\symname" (or if a symbol - was introduced using \stexcode"\symdecl*" without - generating a semantic macro), we might - prefer to use the \emph{name} of a symbol directly for - readability -- e.g. we would want to write - \stexcode"A \symname{natural-number} is..." rather than - \stexcode"A \symname{Nat} is...". \sTeX attempts to handle - this case thusly: - - If |string| does \emph{not} correspond to a semantic - macro \stexcode"\string" and does \emph{not} - contain a |?|, then \sTeX checks - all symbols currently in scope until it finds one, - whose name is |string|. If |string| is of the - form |pre?name|, \sTeX first looks through all modules - currently in scope, whose full URI ends with |pre|, - and then looks for a symbol with name |name| in those. - This allows - for disambiguating more precisely, e.g. by - saying \stexcode"\symname{Integers?addition}" - or \stexcode"\symname{RealNumbers?addition}" in the - case where several |addition|s are in scope. - \end{dangerbox} -\end{sfragment} - -\symdef{addition}[op=+,prec=100,args=2]{#1 \comp+ #2} -\symdef{multiplication}[op=\cdot,prec=50,args=a]{#1}{##1 \comp\cdot ##2} - -\begin{sfragment}{Marking Up Text and On-the-Fly Notations} - We can also use semantic macros outside of text mode though, - which allows us to annotate arbitrary text fragments. - - Let us assume again, that we have - \stexcode"\symdef{addition}[args=2]{#1 \comp+ #2}". Then we - can do - \stexexample{% -\addition{\comp{The sum of} \arg{$\svar{n}$} \comp{ and }\arg{$\svar{m}$}} -is... - } - ...which marks up the text fragment as representing - an \emph{application} of the |addition|-symbol to two - argument $\svar{n}$ and $\svar{m}$. - - \begin{mmtbox} - As expected, the above example is translated to \omdoc/\mmt - as an |OMA| with |<OMS name="...?addition"/>| as head and - |<OMV name="n"/>| and |<OMV name="m"/>| as arguments. - \end{mmtbox} - - \begin{dangerbox} - Note the difference in treating ``arguments'' between math mode and text mode. In - math mode the (in this case two) tokens/groups following the \stexcode|\addition| - macro are treated as arguments to the addition function, whereas in text mode the - group following \stexcode|\addition| is taken to be the ad-hoc presentation. We - drill in on this now. - \end{dangerbox} - - \begin{function}{\arg} - In text mode, every semantic macro takes exactly one - argument, namely the text-fragment to be annotated. - The \stexcode"\arg" command is only valid within the - argument to a semantic macro and marks up the - \emph{individual arguments} for the symbol. - \end{function} - - We can also use semantic macros in text mode to invoke - an operator itself instead of its application, with the - usual syntax using |!|: - \stexexample{% -\addition!{Addition} is... - } - - Indeed, \stexcode"\symbolname!{<code>}" is exactly equivalent to - \stexcode"\symref{symbolname}{<code>}" (the latter is in fact implemented in terms of - the former). - - \stexcode"\arg" also allows us to switch the order of arguments - around and ``hide'' arguments: For example, \stexcode"\arg[3]{<code>}" - signifies that |<code>| represents the \emph{third} - argument to the current operator, and \stexcode"\arg*[i]{<code>}" - signifies that |<code>| represents the $i$th argument, but it - should not produce any output (it is exported in the |xhtml| - however, so that \mmt and other systems can pick up on it).\ednote{MK: I do not - understand why we have to/want to give the second arg*; I think this must be - elaborated on.} - \stexexample{% -\addition{\comp{adding} - \arg[2]{$\svar{k}$} - \arg*{$\addition{\svar{n}}{\svar{m}}$}} yields... - } - Note that since the second \stexcode"\arg" has no explicit argument - number, it automatically represents the first not-yet-given - argument -- i.e. in this case the first one.\ednote{MK: I do not understand this at - all. } - - \paragraph{} The same syntax can be used in math mod as well. This allows us to - spontaneously introduce new notations on the fly. We can activate it using the starred - variants of semantic macros: - - \stexexample{% -Given $\addition{\svar{n}}{\svar{m}}$, then -$\addition*{ - \arg*{\addition{\svar{n}}{\svar{m}}} - \comp{+} - \arg{\svar{k}} -}$ yields... - } - -\end{sfragment} -\end{smodule} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: - -% LocalWords: prec cdot,prec 50,args th diff --git a/Master/texmf-dist/doc/latex/stex/packages/stex-tikzinput.tex b/Master/texmf-dist/doc/latex/stex/packages/stex-tikzinput.tex index ac321f129cd..8539ab4e5d7 100644 --- a/Master/texmf-dist/doc/latex/stex/packages/stex-tikzinput.tex +++ b/Master/texmf-dist/doc/latex/stex/packages/stex-tikzinput.tex @@ -9,7 +9,7 @@ The selective input functionality of the \pkg{tikzinput} package assumes that the TIKZ pictures are externalized into a standalone picture file, such as the following one -\begin{latexcode} +\begin{stexcode} \documentclass{standalone} \usepackage{tikz} \usetikzpackage{...} @@ -18,7 +18,7 @@ pictures are externalized into a standalone picture file, such as the following ... \end{tikzpicture} \end{document} -\end{latexcode} +\end{stexcode} The \pkg{standalone} class is a minimal {\LaTeX} class that when loaded in a document that uses the \pkg{standalone} package: the preamble and the |documenat| environment @@ -43,7 +43,7 @@ pictures are externalized into a standalone picture file, such as the following \begin{function}{\mhtikzinput,\cmhtikzinput} |\mhtizkinput| is a variant of |\tikzinput| that treats its file path argument as a - relative path in a math archive in analogy to \stexcode|\inputref|. To give the archive + relative path in a math archive in analogy to \stexcodeinline|\inputref|. To give the archive path, we use the |mhrepos=| key. Again, |\cmhtizkinput| is a version of |\mhtikzinput| that is centered. \end{function} @@ -51,8 +51,8 @@ pictures are externalized into a standalone picture file, such as the following \begin{function}{\libusetikzlibrary} Sometimes, we want to supply archive-specific TIKZ libraries in the |lib| folder of the archive or the |meta-inf/lib| of the archive group. Then we need an analogon to - \stexcode|\libinput| for \stexcode|\usetikzlibrary|. The \pkg{stex-tikzinput} package - provides the \stexcode|libusetikzlibrary| for this purpose. + \stexcodeinline|\libinput| for \stexcodeinline|\usetikzlibrary|. The \pkg{stex-tikzinput} package + provides the \stexcodeinline|libusetikzlibrary| for this purpose. \end{function} %%% Local Variables: diff --git a/Master/texmf-dist/doc/latex/stex/stex-abstract.tex b/Master/texmf-dist/doc/latex/stex/stex-abstract.tex deleted file mode 100644 index f342bbf9075..00000000000 --- a/Master/texmf-dist/doc/latex/stex/stex-abstract.tex +++ /dev/null @@ -1,26 +0,0 @@ -\begin{abstract} - \sTeX is a collection of {\LaTeX} packages that allow to markup documents semantically - without leaving the document format. - - Running `pdflatex` over sTeX-annotated documents formats them into normal-looking - PDF. But sTeX also comes with a conversion pipeline into semantically annotated HTML5, - which can host semantic added-value services that make the documents active - (i.e. interactive and user-adaptive) and essentially turning {\LaTeX} into a document - format for (mathematical) knowledge management (MKM). - - \sTeX augments {\LaTeX} with - \begin{itemize} - \item \emph{semantic macros} that denote and distinguish between mathematical concepts, - operators, etc. independent of their notational presentation, - \item a powerful \emph{module system} that allows for authoring and importing individual - fragments containing document text and/or semantic macros, independent of -- and - without hard coding -- directory paths relative to the current document, and - \item a mechanism for exporting \sTeX documents to (modular) XHTML, preserving all the - semantic information for semantically informed knowledge management services. - \end{itemize} -\end{abstract} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "stex-manual" -%%% End: diff --git a/Master/texmf-dist/doc/latex/stex/stex-devel.tex b/Master/texmf-dist/doc/latex/stex/stex-devel.tex new file mode 100644 index 00000000000..972775ad129 --- /dev/null +++ b/Master/texmf-dist/doc/latex/stex/stex-devel.tex @@ -0,0 +1,1799 @@ +\begin{smodule}{Aux Macros} + + \begin{dangerbox} + Keeping the implementation properly up-to-date is pretty much + incompatible with the kinds of workflows systemically enforced + in academia. Any of the following may be out of date. + \end{dangerbox} + + \STEXexport{ + \stex_sms_allow_escape:N \stexmacro + \protected\def\stexmacro#1{ + \stex_execute_in_module:x{\tl_set:cn{l_stex_stexmacro_\tl_to_str:n{#1}_path}{\l_stex_current_module_str?\tl_to_str:n{#1}}} + \exp_args:NNx\symdecl*{\tl_to_str:n{#1}} + \exp_args:Nx\notation{\tl_to_str:n{#1}}{\comp{\texttt{\textbackslash\detokenize{#1}}}} + } + \protected\def\stexvarmacro#1{ + \tl_set:cx{l_stex_stexvarmacro_\tl_to_str:n{#1}_var}{\tl_to_str:n{#1}} + \exp_args:Nnx\use:nn{\vardef}{ + {\tl_to_str:n{varmacro_#1}}[name={\tl_to_str:n{#1}}]{ + \noexpand\comp{\hbox{\noexpand\texttt{\noexpand\textbackslash\noexpand\detokenize{#1}}}} + } + } + } + \stex_sms_allow_escape:N \stexenv + \protected\def\stexenv#1{ + \stex_execute_in_module:x{\tl_set:cn{l_stex_stexenv_\tl_to_str:n{#1}_path}{\l_stex_current_module_str?\tl_to_str:n{#1}}} + \exp_args:NNx\symdecl*{\tl_to_str:n{#1}} + \exp_args:Nx\notation{\tl_to_str:n{#1}}{\noexpand\texttt{\noexpand\detokenize{#1}}} + } + + \cs_set_nopar:Nn \_stexdoc_do_cs:nn { + \tl_if_exist:cTF{l_stex_stexvarmacro_\tl_to_str:n{#1}_var}{ + \exp_args:Nx \varref{\use:c{l_stex_stexvarmacro_\tl_to_str:n{#1}_var}}{#2} + }{ + \tl_if_exist:cTF{l_stex_stexmacro_\tl_to_str:n{#1}_path}{ + \exp_args:Nx \symref{\use:c{l_stex_stexmacro_\tl_to_str:n{#1}_path}}{#2} + }{#2} + } + } + + \RenewDocumentCommand\cmd { O{} m } + { \_stexdoc_do_cs:nn{#2}{\__codedoc_cmd:no {#1} { \token_to_str:N #2 }} } + \RenewDocumentCommand \cs { O{} m } + { \_stexdoc_do_cs:nn{#2}{\__codedoc_cmd:no {#1} { \c_backslash_str #2 }} } + \RenewDocumentCommand \tn { O{} m } + { \_stexdoc_do_cs:nn{#2}{ + \@@_cmd:no + { module = TeX , replace = false , #1 } + { \c_backslash_str #2 } + }} + \protected\def\env#1{ + \tl_if_exist:cTF{l_stex_stexenv_\tl_to_str:n{#1}_path}{ + \exp_args:Nx \symref{\use:c{l_stex_stexenv_\tl_to_str:n{#1}_path}}{\texttt{\tl_to_str:n{#1}}} + }{\texttt{\tl_to_str:n{#1}}} + } + + \cs_set_protected:Nn \_stexdoc_dcs: { + \peek_charcode:NTF [ { + \_stexdoc_dcs:w + }{ + \exp_args:NNe \use:nn \_stexdoc_dcs:w {[\seq_item:Nn \_stexdoc_sfunction_seq 1]} + } + } + + \cs_set_protected:Npn \_stexdoc_dcs:w [#1] { + \exp_args:Ne \definiendum{\tl_to_str:n{#1}}{\exp_args:Nne \__codedoc_cmd:nn {} { \c_backslash_str \tl_to_str:n{ #1 } }} + \xspace + } + + \ProvideDocumentEnvironment {sfunction}{m O{} +v}{ + \seq_set_split:Nnn \_stexdoc_sfunction_seq , {#1} + \seq_map_inline:Nn \_stexdoc_sfunction_seq { + \stex_pseudogroup_with:nn{\stex_smsmode_do:}{\def\stex_smsmode_do:{}\stexmacro{##1}} + } + \cs_set_eq:NN \dcs \_stexdoc_dcs: + \ifstexhtml + \def\box_move_up:nn##1##2{\tex_raise:D\__box_dim_eval:n{0pt}##2} + \renewenvironment{syntax}{\noindent}{\par} + \fi + \begin{sparagraph}[style=symdoc,for={#1}] + \__codedoc_function:nnw{#2}{#3} + }{ + \stex_if_smsmode:F{\__codedoc_function_end:} + \end{sparagraph} + } + \stex_sms_allow_env:n{sfunction} + + \ProvideDocumentEnvironment { svariable } { m +v } + { + \seq_set_split:Nnn \_stexdoc_sfunction_seq , {#1} + \seq_map_inline:Nn \_stexdoc_sfunction_seq { + \stex_pseudogroup_with:nn{\stex_smsmode_do:}{\def\stex_smsmode_do:{}\stexmacro{##1}} + } + \cs_set_eq:NN \dcs \_stexdoc_dcs: + \ifstexhtml + \def\box_move_up:nn##1##2{\tex_raise:D\__box_dim_eval:n{0pt}##2} + \renewenvironment{syntax}{\noindent}{\par} + \fi + \begin{sparagraph}[style=symdoc,for={#1}] + \bool_if:NTF \l__codedoc_in_implementation_bool + { \__codedoc_macro:nnw { var , } {#2} } + { \__codedoc_function:nnw {} {#2} } + } + { + \bool_if:NTF \l__codedoc_in_implementation_bool + { \__codedoc_macro_end: } + { \__codedoc_function_end: } + \end{sparagraph} + } + \stex_sms_allow_env:n{svariable} + + \ProvideDocumentEnvironment {senv} {m} { + \def\denv{\exp_args:Ne\definiendum{\tl_to_str:n{#1}}{\texttt{\tl_to_str:n{#1}}}} + \stex_pseudogroup_with:nn{\stex_smsmode_do:}{\def\stex_smsmode_do:{}\stexenv{#1}} + \begin{sparagraph}[style=symdoc,for={#1}] + \exp_args:Ne\DescribeEnv{\tl_to_str:n{#1}} + }{ + \end{sparagraph}\par\smallskip + } + \stex_sms_allow_env:n{senv} + } + + \CodedocExplain + + %^^A\CodedocExplainEXP + %^^A\CodedocExplainREXP + %^^A\CodedocExplainTF + + \begin{sfunction}{stex_debug:nn}{\stex_debug:nn} + \begin{syntax} + \dcs \marg{prefix} \marg{msg} + \end{syntax} + Logs the debug message \marg{msg} under the prefix + \marg{prefix}. A message is shown if its prefix + is in a list of prefixes given either via the + package option |debug=|\meta{prefixes} or + the environment variable |STEX_DEBUG=|\meta{prefixes}, + where the latter overrides the former. + \end{sfunction} + + \begin{sfunction}{_stex_do_deprecation:n}{\_stex_do_deprecation:n} + TODO \dcs + \end{sfunction} + +\begin{sfragment}{Documents} + + \begin{svariable}{l_stex_docheader_sect}{\l_stex_docheader_sect} + integer register keeping track of the current sectioning level: + \begin{itemize} + \item[0] part + \item[1] chapter + \item[2] section + \item[3] subsection + \item[4] subsubsection + \item[5] paragraph + \item[$>5$] subparagraph + \end{itemize} + \cs{setsectionlevel} sets \cs{l_stex_docheader_sect} to the corresponding + integer value. + \end{svariable} + + \begin{sfunction}{stex_ref_new_doc_target:n}{\stex_ref_new_doc_target:n} + internal variant of \cs{sreflabel}. If the argument is empty, + the label is determined to be |REF|\meta{counter} + and \meta{counter} is increased. + \end{sfunction} + + \begin{sfunction}{stex_ref_new_symbol:n}{\stex_ref_new_symbol:n} + registers a new link target for the symbol with the given full uri + (as string), using the |url-base|-field of the current + archive's manifest file to link the symbol to + \meta{url-base}|/symbol?|\meta{uri}. + \end{sfunction} + + \begin{sfunction}{stex_ref_new_sym_target:n}{\stex_ref_new_sym_target:n} + sets a new label for the symbol with the given full uri (as string). + If called in sms-mode, defers to \cs{stex_ref_new_symbol:n}, + if not already registered. + Otherwise, sets a \cs{label} for the symbol. + \end{sfunction} + + \begin{sfunction}{stex_ref_new_sym_target:nn}{\stex_ref_new_sym_target:nn} + \begin{syntax}\dcs\marg{symbol}\marg{target} + \end{syntax} + redirects links for \meta{symbol} to the one for the symbol + \meta{target}. Useful for e.g. symbols elaborated from + structural features. Note that this acts as a \emph{default}, + in that previous or subsequent + calls of \cs{stex_ref_new_sym_target:n}\marg{symbol} + are prioritized. + + Requires that either \cs{stex_ref_new_sym_target:n}\marg{target} + or + \cs{stex_ref_new_sym_target:nn}\marg{target}\marg{other-target} + have been called previously. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Modules} + + \stexmacro{stex_module_add_symbol:nnnnnnN} + \stexmacro{stex_add_module_notation:nnnnn} + \stexmacro{stex_module_add_morphism:nnn} + + The contents of a module with full URI + \meta{uri} are represented as four macros: + \begin{itemize} + \item |\c_stex_module_|\meta{uri}|_code|: code to be executed + every time the module is \emph{activated}; e.g. the contents + of \cs{STEXexport}, defines semantic macros and macros for + notations, activates dependency modules, etc. + \item |\c_stex_module_|\meta{uri}|_morphisms_prop|: property list + containing all module dependencies of this module + (see \cs{stex_module_add_morphism:nnn}). + \item |\c_stex_module_|\meta{uri}|symbols_prop|: property list + containing all declarations in this module (see \cs{stex_module_add_symbol:nnnnnnN}). + \item |\c_stex_module_|\meta{uri}|_notations_prop|: property list + containing all notations introduced in this module + (see \cs{stex_add_module_notation:nnnnn}). + \end{itemize} + + \begin{svariable}{l_stex_current_module_str}{\l_stex_current_module_str} + contains the full URI of the current module. + \end{svariable} + + \begin{svariable}{l_stex_all_modules_seq}{\l_stex_all_modules_seq} + contains the full URIs of all modules currently in scope. + \end{svariable} + + \stexvarmacro{l_stex_key_sig_str} + \begin{sfunction}{stex_module_setup:n}{\stex_module_setup:n} + \begin{syntax} \dcs\marg{name} \end{syntax} + Computes the full URI of a new module with name \meta{name} + in the current namespace, initializes the + four macros above and sets \cs{l_stex_current_module_str} + accordingly. Also takes care of correct naming for nested + modules, activates the meta theory and loads the signature module + if |sig=| was provided (according to \cs{l_stex_key_sig_str}). + \end{sfunction} + + \stexmacro{stex_persist:n} + \begin{sfunction}{stex_close_module:}{\stex_close_module:} + closes the current module; checks whether we are currently in + sms mode, and if so, calls \cs{stex_persist:n} + to write the module contents to the sms-file. + \end{sfunction} + + \begin{sfunction}{stex_every_module:n}{\stex_every_module:n} + \begin{syntax}\dcs\marg{code}\end{syntax} + executes \meta{code} every time a new module is opened. + \end{sfunction} + + \begin{sfunction}{stex_if_in_module:}[pTF]{\stex_if_in_module:} + tests whether we are currently in a module. + \end{sfunction} + + \begin{sfunction}{stex_if_module_exists:n}[pTF]{\stex_if_module_exists:n} + tests whether a module with the given full URI exists, in the sense + of \emph{has been parsed at some point in the current document}. + \end{sfunction} + + \begin{sfunction}{stex_activate_module:n}{\stex_activate_module:n,\stex_activate_module:o,\stex_activate_module:x} + activates the module with the given full URI \emph{if and only if} + it has not already been activated in the current scope. + \end{sfunction} + + \stexmacro{stex_metagroup_do_in:nn} + + \begin{sfunction}{stex_execute_in_module:n}{\stex_execute_in_module:n,\stex_execute_in_module:x} + executes the provided code, adds it to the current module + activation code, and makes + sure the macros defined in it are valid in the current module + \TeX\ group level. + \end{sfunction} + + This macro is a combination of the following two macros: + + \begin{sfunction}{stex_do_up_to_module:n}{\stex_do_up_to_module:n,\stex_do_up_to_module:x} + executes the provided code such that all definitions in it + are valid in the current module regardless of \TeX\ group level + (using \cs{stex_metagroup_do_in:nn}). + \end{sfunction} + + \begin{sfunction}{stex_module_add_code:n}{\stex_module_add_code:n,\stex_module_add_code:x} + adds the provided code to the module's + |\c_stex_module_|\meta{uri}|_code|-macro. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Symbols} + + A symbol in \stex is represented as a tuple of several components: + + \stexvarmacro{id} + \stexvarmacro{invokation_macro} + \stexmacro{_stex_invoke_symbol:nnnnnnnN} + + \begin{sfunction}{stex_module_add_symbol:nnnnnnnN}{\stex_module_add_symbol:nnnnnnnN} + \begin{arguments} + \item \meta{id}: An \emph{identifier} (possibly empty) that determines its + semantic macro name, or e.g. in \env{mathstructure} its + accessor-identifier (if empty, the name is used for that), + \item \meta{name} a unique \emph{name}, which in combination with the + containing module determines its URI as \meta{module-URI}|?|\meta{name}, + \item \meta{arity} a numeric string in the range |0..9|, + \item \meta{args} a list of argument specifiers of the form + \meta{i}\meta{mode}|{|\meta{argname}|}| (the length of \meta{args} + must be $3\cdot$\meta{arity}), + \item \meta{definiens} (or empty), + \item \meta{type} (or empty), + \item \meta{return code} (or empty), and + \item \meta{\cs{invokation_macro}}. + \end{arguments} + + the arguments are stored in the property list + \cs{c_stex_module_}\meta{\cs{l_stex_current_module}}|_symbols_prop| + under key \meta{name}. + + If the identifier \meta{id} is non-empty, the macro + \cs{id} is defined as |{|\cs{_stex_invoke_symbol:nnnnnnnN}|}| + with the arguments described there. + + \begin{texnote} \cs{invokation_macro} must be \cs{protected}. + \end{texnote} + \end{sfunction} + + \begin{sfunction}{stex_iterate_symbols:n,stex_iterate_break:,stex_iterate_break:n}{\stex_iterate_symbols:n,\stex_iterate_break:,\stex_iterate_break:n} + \begin{syntax}\dcs\marg{code}\end{syntax} + iterates over all symbols currently in scope and calls + \meta{code} for all of them with arguments + \marg{module}\marg{name}\marg{arity}\meta{args}\marg{definiens} + \marg{type}\marg{return code}\marg{\cs{invokation_macro}}. + + Iteration can be stopped prematurely with + \dcs[stex_iterate_break:] and can stop and return code + with \dcs[stex_iterate_break:n]. + \end{sfunction} + + \begin{sfunction}{stex_iterate_symbols:nn}{\stex_iterate_symbols:nn} + \begin{syntax}\dcs\marg{csl}\marg{code}\end{syntax} + iterates over all symbols in the provided \meta{csl} + of full module URIs. \meta{code} + receives the same arguments as \cs{stex_iterate_symbols:n}, + but iteration can not be stopped early. + \end{sfunction} + + \begin{sfunction}{ + stex_get_symbol:n, + l_stex_get_symbol_mod_str, + l_stex_get_symbol_name_str, + l_stex_get_symbol_arity_int, + l_stex_get_symbol_args_tl, + l_stex_get_symbol_def_tl, + l_stex_get_symbol_type_tl, + l_stex_get_symbol_return_tl, + l_stex_get_symbol_invoke_cs + }{\stex_get_symbol:n, + \l_stex_get_symbol_mod_str, + \l_stex_get_symbol_name_str, + \l_stex_get_symbol_arity_int, + \l_stex_get_symbol_args_tl, + \l_stex_get_symbol_def_tl, + \l_stex_get_symbol_type_tl, + \l_stex_get_symbol_return_tl, + \l_stex_get_symbol_invoke_cs + } + \dcs attemps to find a symbol with the given name or id + that is currently in scope. + A name may be prefixed with a module name/path separated by |?|. + + Throws an error if no such symbol is found; otherwise, sets the + listed |\l_stex_get_symbol_...|-macros to the components of the + found symbol. + \end{sfunction} + + \begin{sfunction}{stex_if_check_terms:}[pTF]{\stex_if_check_terms:} + whether to typeset declaration components (notations, types, + definientia etc.) in a throwaway box. Is true iff + the backend is |pdflatex| and + either the |STEX_CHECKTERMS| environment variable + or |checkterms| package option is set. + \end{sfunction} + + \begin{sfunction}{stex_check_term:n}{\stex_check_term:n} + typesets the argument in a throwaway box in math mode + iff \cs{stex_if_check_terms:} is true. + + Is deactivated in sms-mode. + \end{sfunction} + + \begin{sfunction}{ + stex_symdecl_do:, + l_stex_key_name_str, + l_stex_key_args_str, + l_stex_key_argnames_clist, + l_stex_assoc_args_count, + l_stex_argnames_seq + }{\stex_symdecl_do:, + \l_stex_key_name_str, + \l_stex_key_args_str, + \l_stex_key_argnames_clist, + \l_stex_assoc_args_count, + \l_stex_argnames_seq + } + \dcs processes the shared (mandatory and optional) arguments + of e.g. \cs{symdecl}, \cs{symdef}, \cs{vardef} etc. + + Requires the following macros to be set + \begin{itemize} + \item \dcs[l_stex_key_name_str]: the name of the symbol, + \item \dcs[l_stex_key_args_str]: the |args|-string (e.g. + |3| or |ai|) + \item \dcs[l_stex_key_argnames_clist]: a list of \emph{names} + for the arguments, the length of which should be $\leq$ the + arity of the symbol + \end{itemize} + + and will generate the following macros: + \begin{itemize} + \item \cs{l_stex_get_symbol_arity_int}: the arity of the symbol, + \item \dcs[l_stex_key_args_str]: the args string as a + definite sequence of argument-mode characters, whose + length is the arity of the symbol; e.g. + |3| is turned into |iii|, + \item \dcs[l_stex_assoc_args_count]: the number of + sequence arguments (i.e. |a| or |B| mode), + \item \dcs[l_stex_argnames_seq]: the full sequence of + argument names; those not provided by + \cs{l_stex_key_argnames_clist} are set to be + |$j|\iffalse$\fi, where |j| is the index of the + argument, + \item \cs{l_stex_get_symbol_args_tl}: a token list of + triples |jm{|\meta{argname}|}|, where |j| is the index and + |m| the respective argument mode character (i.e. |i|, |a|, + |b| or |B|). + \end{itemize} + \end{sfunction} + + \begin{sfunction}{_stex_symdecl_check_terms:, + l_stex_key_type_tl,l_stex_key_def_tl}{\_stex_symdecl_check_terms:} + calls \cs{stex_check_term:n} for + the type and definiens stored in \cs{l_stex_key_type_tl} and + \cs{l_stex_key_def_tl} + \end{sfunction} + + \stexmacro{stex_invoke_symbol:} + \begin{sfunction}{stex_symdecl_top:n,l_stex_macroname_str}{\stex_symdecl_top:n} + \begin{syntax}\dcs\marg{maybename}\end{syntax} + checks whether \cs{l_stex_key_name_str} is empty, + and if so, sets it to be \meta{maybename}. + Then calls \cs{stex_symdecl_do:} and + \cs{_stex_symdecl_check_terms:}, writes the components to the HTML + (if applicable) and adds the symbol to the current module + with invokation macro \cs{stex_invoke_symbol:} and id/macroname + \cs{l_stex_macroname_str}. + \end{sfunction}\bigskip + + Variables work very similar to symbols, except that their declarations + are local to the current \TeX-group rather than the + current module, and they are not exported in modules. + + \begin{svariable}{l_stex_variables_prop}{\l_stex_variables_prop} + stores all variables currently in scope as a property list + with key \meta{name} and value + \marg{id}\marg{name}\marg{arity}\meta{args}\marg{definiens} + \marg{type}\marg{return code}\marg{\cs{invokation_macro}}. + + The invokation macro for ``normal'' variables declared with + \cs{vardef} is \cs{stex_invoke_symbol:}. + \end{svariable} + + \begin{sfunction}{_stex_vardecl_notation_macro:}{\_stex_vardecl_notation_macro:} + generates the notation macro for a variable, based on the + values of the |\l_stex_key|-macros und \cs{l_stex_notation_macrocode_cs}. + \end{sfunction} + + \begin{sfunction}{stex_get_var:n}{\stex_get_var:n} + like \cs{stex_get_symbol:n}, but attempts to retrieve a + variables and throws an error if none is found. + \end{sfunction} + + \begin{sfunction}{stex_get_symbol_or_var:n}{\stex_get_symbol_or_var:n} + like \cs{stex_get_symbol:n}, but first attempts + to find a \emph{variable}, and if none is found, + defers to \cs{stex_get_symbol:n}. + \end{sfunction} + +\end{sfragment} + + +\begin{sfragment}{Notations} + + \stexmacro{stex_set_notation_macro:nnnnn} + \begin{sfunction}{stex_module_add_notation:nnnnn}{\stex_module_add_notation:nnnnn, \stex_module_add_notation:eoexo} + \begin{syntax}\dcs + \marg{symboluri}\marg{id}\marg{arity}\meta{code}\meta{op code} + \end{syntax} + stores the arguments in the property list + \cs{c_stex_module_}\meta{\cs{l_stex_current_module}}|_notations_prop| + under key \meta{symboluri}|!|\meta{id} and calls + \cs{stex_set_notation_macro:nnnnn}. + \end{sfunction} + + \begin{sfunction}{stex_set_notation_macro:nnnnn}{\stex_set_notation_macro:nnnnn,\stex_set_notation_macro:eoexo} + \begin{syntax}\dcs + \marg{symboluri}\marg{id}\marg{arity}\meta{code}\meta{op code} + \end{syntax} + Declares the following macros: + + An active notation for a symbol with uri \meta{symboluri} and id + \meta{id} is represented as + a macro \cs{l_stex_notation_}\meta{symboluri}|_|\meta{id}|_cs|, + that takes \meta{arity} many argument + and expands to \meta{code}, + and (if nonempty) an \emph{operator} notation as + a macro \cs{l_stex_notation_}\meta{symboluri}|_op_|\meta{id}|_cs| + that expands to \meta{op code}. + + The default notation is represented as the \emph{empty} id. + If the correponding macros + \cs{l_stex_notation_}\meta{symboluri}|__cs|, + and \cs{l_stex_notation_}\meta{symboluri}|_op__cs| do not yet exist, + they are now defined as \meta{id}. + \end{sfunction} + + \begin{sfunction}{stex_iterate_notations:nn}{\stex_iterate_notations:nn} + \begin{syntax}\dcs\marg{csl}\marg{code}\end{syntax} + iterates over all notations in the provided \meta{csl} + of full module URIs and calls \meta{code} on each of them with + arguments + \marg{symboluri}\marg{id}\marg{arity}\meta{code}\meta{op code}. + \end{sfunction} + + \begin{sfunction}{ + stex_notation_parse_and_then:nw, + l_stex_key_prec_str, + l_stex_key_variant_str, + l_stex_notation_macrocode_cs + }{\stex_notation_parse_and_then:nw, + \l_stex_key_prec_str, + \l_stex_key_variant_str, + \l_stex_notation_macrocode_cs + } + \begin{syntax}\dcs\marg{code}\meta{notations} + \end{syntax} + + parses a notation (which may consist of multiple + braced components, depending on the argument modes) + and subsequently calls \meta{code}. + + Requires the following macros to be set: + \begin{itemize} + \item \cs{l_stex_get_symbol_arity_int}, + \item \cs{l_stex_get_symbol_args_tl}, + \item \dcs[l_stex_key_prec_str]: The precedence string + as provided by a user in the optional |precs|-argument, + \item \dcs[l_stex_key_variant_str]: the id of the + notation variant. + \end{itemize} + + Stores the final notation in the macro + \dcs[l_stex_notation_macrocode_cs] taking + \cs{l_stex_get_symbol_arity_int} many arguments. + \end{sfunction}\bigskip + + + Some thing to consider when we generate a notation macro: + \begin{itemize} + \item The notation macro generated by the \cs{notation}-command + should contain the variant identifier and the precedences, + as these are intrinsic parts of the notation. + \item It should + \emph{not} contain the symbol itself however, so that + notations can be copied between symbols. + \item Notations as provided by users will largely adhere + to the standard \LaTeX\ category code scheme, and + \item notations need to be ``persistable'' in |.deps|-files. + \end{itemize} + + We therefore want to augment the simple code provided by + a user by various ``annotations'' that contain the + relevant information (such as precedences) and to mark + the argument positions for semantic extractions, but we should + adhere to the default \LaTeX\ category code scheme in doing + so. + + \begin{sfunction}{ + STEXInternalTermMathArgiii, + STEXInternalTermMathOMSOrOMViii, + STEXInternalTermMathAssocArgiiiii, + STEXInternalAssocArgMarkerI, + STEXInternalAssocArgMarkerII, + STEXInternalTermMathOMAiii, + STEXInternalTermMathOMBiii, + STEXInternalSymbolAfterInvokationTL + }{ + \STEXInternalTermMathArgiii, + \STEXInternalTermMathAssocArgiiiii, + \STEXInternalAssocArgMarkerI, + \STEXInternalAssocArgMarkerII, + \STEXInternalTermMathOMSOrOMViii, + \STEXInternalTermMathOMAiii, + \STEXInternalTermMathOMBiii, + \STEXInternalSymbolAfterInvokationTL + } + + In \openmath/\OMDoc, there are (for our purposes) + three kinds of expressions that an application of a semantic macro + -- and hence a notation macro -- can represent, each of which + corresponds to a macro taking care of the semantic annotations: + \begin{itemize} + \item |OMS/OMV|: a simple symbol (arity 0) (\dcs[STEXInternalTermMathOMSOrOMViii]) + \item |OMA|: an application of a symbol to argument (arity $>0$, + \dcs[STEXInternalTermMathOMAiii]) + \item |OMB|: a binding application of a symbol that + binds/declares one or more variables (argument string contains + |b| or |B|, \dcs[STEXInternalTermMathOMBiii]). + \end{itemize} + + The arguments are marked with \dcs[STEXInternalTermMathArgiii] + (|i| or |b|) or \dcs[STEXInternalTermMathAssocArgiiiii] (|a| + or |B|). Finally, the notation is closed with + \dcs[STEXInternalSymbolAfterInvokationTL]. + + How this works is best explained by example. + \end{sfunction} + + + \begin{sexample} + Assume we have a symbol and notation: + \begin{stexcode} +\symdecl{somesymbol}[args=iai] +\notation{somesymbol}[prec=10;20x30x40,variant=foo] +{First: #1; Second: #2; Third: #3; End} +{(#1 -- ##1 split ##2 -- #3)} + \end{stexcode} + + Since the symbol corresponds to an |OMA|, the whole notation + is wrapped in \cs{STEXInternalTermMathOMAiii}, taking as + arguments the variant identifier (|foo|), + the operator precedence (|10|) and the body of the notation. + + The second argument in the notation, being associative, + is wrapped in a \cs{STEXInternalTermMathAssocArgiiiii}, + taking as arguments the argument number (|2|), the + precedence (|30|), the \TeX\ parameter token (|#2|) + the notation body (|(#1 -- ##1 split ##2 -- #3)|), and finally + the argument mode (|a|). Additionally, the markers |##1| + and |##2| are replaced by \cs{STEXInternalAssocArgMarkerI} + and \cs{STEXInternalAssocArgMarkerII}, respectively. + + Subsequently, the non-sequence parameter tokens + are wrapped in \cs{STEXInternalTermMathArgiii} with + arguments |mj| (where |m| is the mode und |j| the index), + the precedence (|20| or |40| respectively), and the + parameter token. + + Finally, a \cs{STEXInternalSymbolAfterInvokationTL} + is inserted. + + The final expansion of \cs{l_stex_notation_macrocode_cs} + is thus: + \begin{stexcode} +\STEXInternalTermMathOMAiii{foo}{10}{ + First: \STEXInternalTermMathArgiii{i1}{20}{#1}; + Second: \STEXInternalTermMathAssocArgiiiii{2}{30}{#2}{ + (\STEXInternalTermMathArgiii{i1}{20}{##1} -- + \STEXInternalAssocArgMarkerI split + \STEXInternalAssocArgMarkerII -- + \STEXInternalTermMathArgiii{i3}{40}{##3}) + }{a}; + Third: \STEXInternalTermMathArgiii {i3}{40}{#3}; End +}\STEXInternalSymbolAfterInvokationTL + \end{stexcode} + \end{sexample} + + \begin{sfunction}{stex_notation_top:nnw}{\stex_notation_top:nnw} + \begin{syntax}\dcs\marg{symboluri}\marg{code}\end{syntax} + calls \cs{stex_notation_parse_and_then:nw}\marg{code} + and, adds the notation for the symbol with + URI \meta{symboluri} to the current module and + exports it to the HTML (if applicable). + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Structural Features} + + \begin{sfunction}{stex_structural_feature_module:nn, + stex_structural_feature_module_end:, + g_stex_last_feature_str + }{\stex_structural_feature_module:nn, + \stex_structural_feature_module_end:, + \g_stex_last_feature_str + } + \begin{syntax}\dcs\marg{name}\marg{typeid}\end{syntax} + opens a new module-like structural feature of type \meta{typeid} + with name \meta{name}, which needs to be closed with + \dcs[stex_structural_feature_module_end:]. + + Its body behaves like a nested module with name + \meta{modulename}|/|\meta{name}, the full URI of which is + stored in \dcs[g_stex_last_feature_str] for + subsequent elaboration. + \end{sfunction} + + \begin{sfunction}{ + stex_structural_feature_morphism:nnnnn, + stex_structural_feature_morphism_end:, + l_stex_current_domain_str, + l_stex_feature_name_str, + l_stex_morphism_symbols_prop, + l_stex_morphism_renames_prop, + l_stex_morphism_morphisms_seq + }{ + \stex_structural_feature_morphism:nnnnn, + \stex_structural_feature_morphism_end:, + \l_stex_current_domain_str, + \l_stex_feature_name_str, + \l_stex_morphism_symbols_prop, + \l_stex_morphism_renames_prop, + \l_stex_morphism_morphisms_seq + } + \begin{syntax}\dcs\marg{moprhismname}\marg{typeid}\marg{archive}\marg{domain}\marg{annotations}\end{syntax} + opens a new morphism-like structural feature of type \meta{typeid} + with name \meta{morphismname} and the module + |[|\meta{archive}|]|\marg{domain} as domain, which needs to be closed with + \dcs[stex_structural_feature_morphism_end:]. + + Deactivates \cs{symdecl}, \cs{textsymdecl}, + \cs{symdef}, \cs{notation} and \env{smodule}, and activates + \cs{assign}, \cs{assignMorphism} and \cs{renamedecl}. + + Defines the following macros: + \begin{itemize} + \item \dcs[l_stex_feature_name_str]|=|\marg{name}. + \item \dcs[l_stex_current_domain_str]|=| the full uri of \meta{domain}. + \item \dcs[l_stex_morphism_symbols_prop]: This property list is + initialized as follows: For every symbol + transitively included in \meta{domain} with data + \meta{module}, \meta{name}, \meta{id}, \meta{arity}, \meta{args}, + \meta{definiens}, \meta{type}, and \meta{return code}, + the property list contains an entry with key + |[|\meta{module}|]/[|\meta{name}|]| + and value \marg{id}\marg{arity}\marg{args}\marg{definiens} + \marg{type}\marg{return code}. + \item \dcs[l_stex_morphism_renames_prop]: An initially empty + property list. + \item \dcs[l_stex_morphism_morphisms_seq]: TODO + \end{itemize} + + At \dcs[stex_structural_feature_morphism_end:], the elaboration + is computed from the above data thusly: + + For every entry in \dcs[l_stex_morphism_symbols_prop], + a new symbol is created with the values \meta{arity}, \meta{args}, + \meta{definiens}, \meta{type} and \meta{return code} from that + property list, and either: + \begin{itemize} + \item if \dcs[l_stex_morphism_renames_prop] does \emph{not} + contain an entry with key \meta{module}|?|\meta{name}, + then the elaborated name is \meta{morphismname}|/|\meta{name} + and its \meta{id} is empty (no semantic macro is generated), or + \item if \dcs[l_stex_morphism_renames_prop] contains an + entry with key \meta{module}|?|\meta{name}, then its value + needs to be of the form \marg{id}\marg{name}, which are + used for the elaborated symbol. + \end{itemize} + All notations of the symbols transitively included in the domain + are copied over to their elaborations. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Imports and Morphisms} + + \begin{sfunction}{stex_module_add_morphism:nnnn}{\stex_module_add_morphism:nnnn, \stex_module_add_morphism:nonn, \stex_module_add_morphism:ooox} + adds a new module morphism (i.e. inheritance, possibly with + modification) to the current module + \begin{arguments} + \item The name of the morphism (may be empty for e.g. \cs{importmodule}, + but may be named for e.g. \env{copymodule}), + \item the URI of the module being ``imported'', + \item the ``type'' of the morphism (e.g. |import| or |copymodule|), + \item a list of assignments as pairs + |{|\meta{source}|}{|\meta{target}|}| that signify that + the symbol with full URI \meta{source} is being mapped or elaborated to + the new symbol with name \meta{target} in the current module. + May be empty for e.g. \cs{importmodule}. + \end{arguments} + The provided arguments are stored in + |\c_stex_module_|\meta{uri}|_morphisms_prop| + with key |#1| (if non-empty) or |[#2]| (if |#1| is empty) + and value |{#1}{#2}{#3}{#4}| + \end{sfunction}\bigskip + + Import-like statements in \sTeX are usually given + as pairs |[|\meta{archive}|]{|\meta{path}|?|\meta{module}|}|, + which be relative to the current archive and/or + file path. For persistence and sms-mode, these + pairs first need to be resolved into an \emph{absolute} + specification: + + \begin{sfunction}{ + stex_import_module_uri:nn, + l_stex_import_archive_str, + l_stex_import_name_str, + l_stex_import_uri_str, + l_stex_import_path_str + }{ + \stex_import_module_uri:nn, + \l_stex_import_archive_str, + \l_stex_import_name_str, + \l_stex_import_uri_str, + \l_stex_import_path_str + } + \begin{syntax}\dcs\marg{archive}\marg{pathstring}\end{syntax} + (where \meta{archive} may be empty) resolves the given arguments + into: + \begin{itemize} + \item \dcs[l_stex_import_archive_str] the given archive id + (in which case \cs{stex_require_archive:n} is called), + or the id of the current archive (if existent and \meta{archive} + empty), or empty, + \item \dcs[l_stex_import_uri_str] if an archive id is given, + or we currently are in an archive, its corresponding + namespace; otherwise |{file:}|, + \item \dcs[l_stex_import_path_str] the path of the URI + relative to the given (or current) archive, or (if not existent) + the absolute path of \meta{pathstring} (without a module name) + resolved relative to the current file's parent directory, and + \item \dcs[l_stex_import_name_str] the name of the module. + \end{itemize} + If \meta{pathstring} does not contain the character |?|, + the whole pathstring is assumed to be the name of the module + and the path is empty (or the current file's parent directory, + depending on the above). + \end{sfunction} + + \begin{sfunction}{stex_import_require_module:nnn}{\stex_import_require_module:nnn} + takes as arguments values + \cs{l_stex_import_archive_str}, \cs{l_stex_import_path_str} + and \cs{l_stex_import_name_str} as computed by + \cs{stex_import_module_uri:nn} and + (optionally loads and) activates the corresponding + module (or throws an error if it does not exist). + \end{sfunction}\bigskip + + Most complex morphisms (\env{copymodule} et al) are implemented + as structural features + using \cs{stex_structural_feature_morphism:nnnn}. + + \begin{sfunction}{stex_get_in_morphism:n, + l_stex_get_symbol_macro_str}{\stex_get_in_morphism:n, + \l_stex_get_symbol_macro_str} + finds a symbol with the provided name or id in the domain + of the current morphism. Sets the same macros as + \cs{stex_get_symbol:n}, and additionaly + \dcs[l_stex_get_symbol_macro_str] to the \meta{id} + of the symbol. Throws an error if no such symbol is found. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Expressions and Semantic Macros} + + \begin{sfunction}{_stex_invoke_symbol:nnnnnnnN, + l_stex_current_symbol_str, + l_stex_current_arity_str, + l_stex_current_args_tl, + l_stex_current_return_tl, + l_stex_current_type_tl + }{\_stex_invoke_symbol:nnnnnnnN + \l_stex_current_symbol_str, + \l_stex_current_arity_str, + \l_stex_current_args_tl, + \l_stex_current_return_tl, + \l_stex_current_type_tl + } + \begin{syntax}\dcs + \marg{module}\marg{name}\marg{arity}\marg{args}\marg{definiens} + \marg{type} + \marg{return code} + \marg{\cs{invokation_macro}} + \end{syntax} + is how a semantic macro is/should be defined. + \dcs first checks whether semantic macros are currently allowed, + and throws an error if not. Otherwise, it + sets the \cs{comp}-controlled highlighting to \cs{compemph@uri}, + initializes \cs{STEXInternalSymbolAfterInvokationTL}, + defines the following macros for all of its arguments, and subsequently + calls the \cs{invokation_macro}: + \begin{itemize} + \item \dcs[l_stex_current_symbol_str]|={|\meta{module}|?|\meta{name}|}| + \item \dcs[l_stex_current_arity_str]|=|\marg{arity} + \item \dcs[l_stex_current_args_tl]|=|\marg{args} + \item \dcs[l_stex_current_type_tl]|=|\marg{type} + \item \dcs[l_stex_current_return_tl]|=|\marg{return code} + \end{itemize} + + The simplest example for an \cs{invokation_macro} is + \cs{stex_invoke_symbol:}. + \end{sfunction} + + \begin{sfunction}{_stex_invoke_variable:nnnnnnN}{\_stex_invoke_variable:nnnnnnN} + analogous to \cs{_stex_invoke_symbol:nnnnnnnN}, but for variables; + sets the \cs{comp}-controlled highlighting to \cs{varemph@uri}. + \end{sfunction} + + \begin{sfunction}{stex_invoke_symbol:}{\stex_invoke_symbol:} + branches based on the mode and following characters: + \begin{itemize} + \item If math, check next character: + \begin{itemize} + \item[!] operator; defer to operator notation + \item[else] defer to notation and check the value of + \cs{l_stex_current_return_tl}=\meta{return}. + \begin{itemize} + \item If \meta{return} is empty, call the notation macro, + \item otherwise, call \meta{return}|{|\cs{stex_invoke_symbol}|!}|. + \end{itemize} + \end{itemize} + \item If text: + \end{itemize} + \end{sfunction} + + \begin{sfunction}{stex_invoke_sequence_range:, + stex_invoke_sequence_in: + }{ + \stex_invoke_sequence_range:, + \stex_invoke_sequence_in: + } + TODO + \end{sfunction} + +\end{sfragment} + + +\begin{sfragment}{Optional (Key-Value) Argument Handling} + \LaTeX3 is surprisingly weak when it comes to handling + optional (key-val) arguments in such a manner that + \emph{only} the freshly set macros are defined, and to modularly + build up sets of argument keys. The following macros attempt + to fix that: + + \begin{sfunction}{stex_keys_define:nnnn,stex_keys_set:nn}{\stex_keys_define:nnnn,\stex_keys_set:nn} + \begin{syntax} + \dcs\marg{id}\marg{setup code} + \marg{keyval setup code}\marg{parents} + \end{syntax} + Defines a set of keys and their allowed values with + identifier |stex/|\meta{id}, that inherits from + the sets with identifiers in \meta{parents}. + + \dcs[stex_keys_set:nn]\marg{id}\marg{CSL} first executes + \meta{setup code} (e.g. to empty the macros holding the values) + and then sets the keys in + set \meta{id} with the values provided in \meta{CSL}. + \end{sfunction} + + \stexvarmacro{l_stex_key_id_str} + + \begin{sfunction}{_stex_do_id:}{\_stex_do_id:} + should be called whenever a macro or environment has a label id, + i.e. calls \cs{stex_keys_set:nn}|{id}{...}|, after + the title has been typeset. Sets a \cs{label} by calling + \cs{stex_ref_new_doc_target:n}\marg{id}. + \end{sfunction} + + \begin{sexample} + If we define a set of keys with: + \stexvarmacro{l_stex_key_archive_str} + \stexvarmacro{l_stex_key_file_str} + \begin{stexcode}[gobble=6] + |\cs{stex_keys_define:nnnn}|{archive file}{ + \str_clear:N |\cs{l_stex_key_archive_str}| + \str_clear:N |\cs{l_stex_key_file_str}| + }{ + archive .str_set_x:N = |\cs{l_stex_key_archive_str}| , + file .str_set_x:N = |\cs{l_stex_key_file_str}| + }{id} + \end{stexcode} + then calling \cs{stex_keys_set:nn}|{archive file}{id=foo,file=bar}| + sets \cs{l_stex_key_file_str}|={bar}|, assures that + \cs{l_stex_key_archive_str} is empty, and executes the + code associated with |id|, i.e. it sets + \cs{l_stex_key_id_str}|={foo}|. + \end{sexample} + +\end{sfragment} + +\begin{sfragment}{Stylable Commands and Environments} + + \stexmacro{stex_style_apply:} + + \begin{sfunction}{stex_new_stylable_cmd:nnnn,l_stex_key_style_clist}{\stex_new_stylable_cmd:nnnn} + \begin{syntax} + \dcs\marg{name}\marg{arity}\marg{code} + \marg{default} + \end{syntax} + Creates a new macro \cs{}\meta{name} with expansion \meta{code} taking + \meta{arity} many arguments, that is customizable in presentation + by a user by calling \cs{stexstyle}\meta{name}. + On calling + \cs{stex_style_apply:} executes the presentation code provided + by a user. + + \meta{code} should: + \begin{itemize} + \item Call \cs{stex_keys_set:nn}|{style}{...}| (or a keyset inheriting + from |style|), + \item set macros with prefix |\this...| that a user might want + to use for presentation (e.g. \cs{thistitle}), + \item call \cs{stex_style_apply:} at some point. + \end{itemize} + \end{sfunction} + + \begin{sfunction}{stex_new_stylable_env:nnnnnnn}{\stex_new_stylable_env:nnnnnnn} + \begin{syntax} + \dcs\marg{name}\marg{arity}\marg{begincode} + \marg{endcode}\marg{default begin}\marg{default end}\marg{prefix} + \end{syntax} + + Like \cs{stex_new_stylable_cmd:nnnn}, but defines a new environment + |{|\meta{prefix}\meta{name}|}| stylable via + \cs{stexstyle}\meta{name}. Should call \cs{stex_style_apply:} twice; + once in the \meta{begincode} and once in \meta{endcode}. + \end{sfunction} + + \begin{sfunction}{stex_style_apply:}{\stex_style_apply:} + Sets \cs{thisstyle} to be the head of the CSL + \cs{l_stex_key_style_clist} and checks whether a style + for the current stylable macro/environment has been defined; + if not, executes the code for the default style. + \end{sfunction} + + \begin{sexample} + \cs{importmodule} is defined something like the following: + \begin{stexcode}[gobble=6] + |\cs{stex_new_stylable_cmd:nnnn}|{importmodule}{O{} m}{ + ... + \def|\cs{thismoduleuri}|{...} + \def|\cs{thismodulename}|{...} + |\cs{stex_style_apply:}| + ... + }{} + \end{stexcode} + A user can then customize the output generated by \cs{importmodule} + (by default none) via + \cs{stexstyleimportmodule}|{...|\cs{thismodulename}|...}|. + \end{sexample} + + \begin{sexample} + \env{smodule} does something like + \begin{stexcode}[gobble=6] + |\cs{stex_new_stylable_env:nnnnnnn}|{module}{O{} m}{ + ... + \def|\cs{thismoduleuri}|{...} + \def|\cs{thismodulename}|{...} + |\cs{stex_style_apply:}| + ... + }{ + ... + |\cs{stex_style_apply:}| + ... + }{}{}{s} + \end{stexcode} + which defines the environment name to be \env{smodule} and + generates \cs{stexstylemodule}. + \end{sexample} + +\end{sfragment} + +\begin{sfragment}{Math Archives} + Math archives are represented as \LaTeX3 property lists, + the keys/values of which correspond to the entries in the + archive's manifest file. The most important fields are + \begin{itemize} + \item |id|, + \item |narr| the document namespace, + \item |ns| the content namespace, and + \item |docurl| the document URL base. + \end{itemize} + + \stexvarmacro{target} + \begin{sfunction}{stex_resolve_path_pair:Nnn}{\stex_resolve_path_pair:Nnn,\stex_resolve_path_pair:Nxx} + \begin{syntax}\dcs\marg{\cs{target}}\marg{archive-id}\marg{pathstring} + \end{syntax} + computes the absolute file path of + \meta{pathstring} relative + to the |source|-folder of \meta{archive-id} (if non-empty), + or the current archive (if existent) or the parent working + directory (otherwise), and stores the result in \cs{target}. + \end{sfunction} + + \begin{svariable}{l_stex_current_archive_prop}{\l_stex_current_archive_prop} + \dcs always points to the current math archive or is \cs{undefined}, + if the current file is not part of a math archive. + \end{svariable} + + \begin{svariable}{c_stex_main_archive_prop}{\c_stex_main_archive_prop} + \dcs represents the math archive in which the main file + resides (if existent). + \end{svariable} + + \begin{sfunction}{stex_require_archive:n}{\stex_require_archive:n,\stex_require_archive:o} + \begin{syntax}\dcs\marg{id} + \end{syntax} + looks for a math archive \meta{id} in the MathHub directory, + parses its manifest file, creates the corresponding property + list |\c_stex_mathhub_|\meta{id}|_manifest_prop|, + and throws a fatal error if the archive is not found. + + If the archive has been found and parsed before, does nothing, + so it is cheap and safe to call repeatedly for the same id. + \end{sfunction} + + \begin{sfunction}{stex_set_current_archive:n}{\stex_set_current_archive:n} + \begin{syntax}\dcs\marg{id} + \end{syntax} + Calls \cs{stex_require_archive:n}\marg{id} and sets + \cs{l_stex_current_archive_prop}. + \end{sfunction} + + \begin{sfunction}{stex_in_archive:nn}{\stex_in_archive:nn} + \begin{syntax}\dcs\marg{opt-id}\marg{code} + \end{syntax} + Executes \meta{code} in the context of math archive \meta{opt-id} + (using \cs{stex_require_archive:n}), i.e. + iff \meta{opt-id} is non-empty, changes the current archive + to the one with id \meta{opt-id}, + call \meta{code} with \meta{opt-id} as argument (in |#1|) and changes + it back afterwards. + + If \meta{opt-id} is empty, \meta{code} is called with the id + of the \emph{current} math archive as |#1|, or with |#1| empty + if there is no current math archive. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{SMS-Mode} + \stex has to extract formal content (i.e. modules and their symbols) + from \LaTeX-files, that may otherwise contain arbitrary + code, including macros that may not be defined unless + the file is fully processed by \TeX. Those + modules and symbols also may depend on other modules that have not yet + been loaded. The naive way to achieve this, which would + be to just suppress output (e.g. by storing it in a box register) + and then \cs{input} the required file, does not work thanks to + \TeX's limited \emph{file stack}, which would overflow quickly + for modules that have a deeply nested list of dependencies. + + To solve those problems, \sTeX reads dependencies in what we call + \emph{sms mode}, which can be summarized thusly: + \begin{itemize} + \item In a first pass, we parse the file token by token, ignoring everything + other than a select list of macros and environments that + introduce dependencies (such as \cs{importmodule} and + \cs{begin}|{|\env{smodule}|}[sig=...]|). Instead of loading + those, we remember them for later. + \item After the file as been fully parsed thusly, the + dependencies found are loaded, again in sms-mode. + \item In a second pass, we parse the file \emph{again} in the same way, but + this time execute all macros that are explicitly allowed + in sms mode, such as \cs{importmodule}, \cs{symdecl}, + \cs{notation}, \cs{symdef}, etc. + \item all this parsing happens additionally in a + \cs{setbox}\cs{throwaway}\cs{vbox}|{...}|-block to + suppress any accidental output. + \end{itemize} + This means that \TeX's input stack never grows by more + than $+1$, but still behaves \emph{as if} the dependencies + were loaded recursively, at the detriment of being somewhat slow. + + \begin{sfunction}{stex_if_smsmode:}[pTF]{\stex_if_smsmode:} + tests for whether we are currently in sms-mode. + \end{sfunction} + + \begin{sfunction}{stex_file_in_smsmode:nn}{\stex_file_in_smsmode:nn,\stex_file_in_smsmode:on} + \begin{syntax}\dcs\marg{filestring}\marg{setup-code}\end{syntax} + sets up sms-mode and internal grouping, calls + \meta{setup-code} and subsequently processes the file + \meta{filestring} in sms-mode as described above. + \end{sfunction} + + \begin{sfragment}{Second Pass} + + \stexvarmacro{macro} + + \begin{sfunction}{stex_sms_allow:N}{\stex_sms_allow:N} + \begin{syntax}\dcs\marg{\cs{macro}}\end{syntax} + registers the \cs{macro}-command to be allowed in sms mode. + + This only works, if \cs{macro} takes no arguments and/or + does not touch the subsequent tokens. + \end{sfunction} + + For macros taking arguments, we can use + + \stexmacro{stex_smsmode_do:} + + \begin{sfunction}{stex_sms_allow_escape:N}{\stex_sms_allow_escape:N} + \begin{syntax}\dcs\marg{\cs{macro}}\end{syntax} + registers the \cs{macro}-command to be allowed in sms mode. + + If \cs{macro} is subsequently encountered in sms-mode, + parsing is halted and \cs{macro} can process arguments as desired. + It then needs to continue parsing manually though, by calling + \cs{stex_smsmode_do:} as (usually) its last token. + \end{sfunction} + + \begin{sfunction}{stex_sms_allow_env:n}{\stex_sms_allow_env:n} + \begin{syntax}\dcs\marg{envname}\end{syntax} + registers the environment \meta{envname} to be allowed in sms mode. + + As with \cs{stex_sms_allow_escape:N}, the \cs{begin}|{|\meta{envname}|}| + is escaped, hence the begin-code of the environment needs to call + \cs{stex_smsmode_do:}. Since + \cs{end}|{|\meta{envname}|}| never takes arguments, it does not + need to be escaped. + \end{sfunction} + + \begin{sfunction}{stex_smsmode_do:}{\stex_smsmode_do:} + continues with sms-mode-style parsing. Does nothing if not in + sms-mode, and is therefore safe to be called ``just in case''. + \end{sfunction} + + \end{sfragment} + \begin{sfragment}{First Pass} + + \stexmacro{g_stex_sms_import_code} + \begin{sfunction}{stex_sms_allow_import:Nn,stex_sms_allow_import_env:nn}{\stex_sms_allow_import:Nn,\stex_sms_allow_import_env:nn} + behave like \cs{stex_sms_allow_escape:N} and + \cs{stex_sms_allow_env:n} respectively, but the macro or environment + provided is now allowed in the \emph{first} pass of sms-mode. + + This macro should process arguments, add content to + \cs{g_stex_sms_import_code}, and finally call \cs{stex_smsmode_do:}. + + The code provided in the \emph{second} argument is called + before the first pass of sms-mode, as to set up functionality + for these macros. For example, \cs{importmodule} + provides code that redefines \cs{importmodule} to + store the identified dependency in + \cs{g_stex_sms_import_code} instead of activating it directly. + \end{sfunction} + + \begin{svariable}{g_stex_sms_import_code}{\g_stex_sms_import_code} + is built up in the first pass of sms mode and called subsequently; + before the second pass. + + Code in this token list should load and activate dependencies + found in the first pass. + \end{svariable} + + \end{sfragment} + +\end{sfragment} + +\begin{sfragment}{Strings, File Paths, URIs} + + \begin{sfunction}{stex_str_if_starts_with:nn}[pTF]{\stex_str_if_starts_with:nn} + \begin{syntax}\dcs\marg{first}\marg{second} + \end{syntax} + Checks whether the string \meta{first} starts with the string + \meta{second} (i.e. \meta{second} is a prefix of \meta{first}). + \end{sfunction} + + \begin{sfunction}{stex_str_if_ends_with:nn}[pTF]{\stex_str_if_ends_with:nn} + \begin{syntax}\dcs\marg{first}\marg{second} + \end{syntax} + Checks whether the string \meta{first} ends with the string + \meta{second} (i.e. \meta{second} is a suffix of \meta{first}). + \end{sfunction} + + \begin{sfragment}{File Paths} + + \emph{File paths} are represented as \LaTeX3 sequences. The following + methods make sure to + \begin{itemize} + \item canonicalize paths, i.e. resolve |..| and |.| segments, + \item set all category codes to 12 (other), and + \item tranform windows file paths containing |\| uniformly to |/|. + \end{itemize} + + \stexvarmacro{macro} + \begin{sfunction}{stex_file_resolve:Nn}{\stex_file_resolve:Nn, \stex_file_resolve:No, \stex_file_resolve:Nx} + \begin{syntax}\dcs\marg{\cs{macro}}\marg{string} + \end{syntax} + resolves and canonicalizes the file path string \meta{string} and + stores the result in \cs{macro}. + \end{sfunction} + + \begin{sfunction}{stex_file_set:Nn}{\stex_file_set:Nn, \stex_file_set:No, \stex_file_set:Nx} + \begin{syntax}\dcs\marg{\cs{macro}}\marg{string} + \end{syntax} + represents an already canonicalized file path string as a + \LaTeX3 sequence and stores it in \cs{macro}. + \end{sfunction} + + \begin{sfunction}{stex_if_file_absolute:N}[pTF]{\stex_if_file_absolute:N} + \dcs tests whether the given file path (represented as a canonicalized + \LaTeX3 sequence) is an absolute file path. + \end{sfunction} + + \begin{sfunction}{stex_file_use:N}[EXP]{\stex_file_use:N} + \dcs expands to a string representation of the given file path. + \end{sfunction} + + \stexvarmacro{first} + \stexvarmacro{second} + \begin{sfunction}{stex_if_file_starts_with:NN}[TF]{\stex_if_file_starts_with:NN} + \begin{syntax}\dcs\marg{\cs{first}}\marg{\cs{second}} + \end{syntax} + tests whether the file path \cs{first} is a child of \cs{second}. + \emph{(Not expandable)} + \end{sfunction} + + \stexvarmacro{source} + \stexvarmacro{target} + \begin{sfunction}{stex_file_split_off_ext:NN}{\stex_file_split_off_ext:NN} + \begin{syntax}\dcs\marg{\cs{target}}\marg{\cs{source}} + \end{syntax} + splits off the file extension of \cs{source} and stores the resulting + file path in \cs{target} + \end{sfunction} + + \begin{sfunction}{stex_file_split_off_lang:NN}{\stex_file_split_off_lang:NN} + \begin{syntax}\dcs\marg{\cs{target}}\marg{\cs{source}} + \end{syntax} + checks whether the file path \cs{source} ends with a language + abbreviation (e.g. |.en|), if so removes it, and stores the result + in \cs{target}. + \end{sfunction} + + The following are primarily used in file hooks, + but might occasionally be useful to call manually: + + \stexmacro{g_stex_current_file} + \stexmacro{c_stex_main_file} + + \begin{sfunction}{stex_filestack_push:n}{\stex_filestack_push:n} + pushes the given file to the file stack, recomputing + \cs{g_stex_current_file}, the current language, + document URI and namespace. + \end{sfunction} + + \begin{sfunction}{stex_filestack_pop:}{\stex_filestack_pop:} + pops the current top entry of the file stack. If the file stack + is empty, resets to \cs{c_stex_main_file}. + \end{sfunction} + + \begin{sfragment}{File Path Constants and Variables} + + \begin{svariable}{c_stex_pwd_file,c_stex_main_file}{\c_stex_pwd_file,\c_stex_main_file} + store the parent working directory and + the absolute path of the main file being processed + (with guessed file extension |.tex|). + \end{svariable} + + \begin{svariable}{c_stex_home_file}{\c_stex_home_file} + stores the user's home directory. + \end{svariable} + + \begin{svariable}{c_stex_mathhub_file}{\c_stex_mathhub_file} + stores the user's MathHub directory; + its string representation is stored in \cs{mathhub}. + \end{svariable} + + \begin{svariable}{g_stex_current_file}{\g_stex_current_file} + always points to the \emph{current} file. + \end{svariable} + + \end{sfragment} + + \end{sfragment} + + \begin{sfragment}{URIs} + + \stexmacro{__stex_path_auth:n} + \stexmacro{__stex_path_path:n} + \stexmacro{__stex_path_module:n} + \stexmacro{__stex_path_name:n} + \stexmacro{stex_uri_resolve:Nn} + \begin{sparagraph}[style=symdoc,for={__stex_path_auth:n,% + __stex_path_path:n,__stex_path_module:n,__stex_path_name:n}] + \mmt URIs are represented + as token lists of the form + + |{|\cs{__stex_path_auth:n}\marg{authority} + \cs{__stex_path_path:n}\marg{path} + \cs{__stex_path_module:n}\marg{modulename} + \cs{__stex_path_name:n}\marg{declname}|}|, + + all of which may be empty. Largely, URIs are used as strings only, + but the above representation is used in \cs{stex_uri_resolve:Nn} + to canonicalize URIs when they are computed the first time. + + \end{sparagraph} + + \stexvarmacro{uri} + \begin{sfunction}{stex_map_uri:Nnnnn}{\stex_map_uri:Nnnnn} + \begin{syntax} + \dcs\marg{\cs{uri}}\marg{authority code} + \marg{path code}\marg{modulename code}\marg{declname code} + \end{syntax} + executes the provided \meta{code}s with the components + of the \cs{uri} as arguments. + \end{sfunction} + + \begin{sfunction}{stex_uri_resolve:Nn}{\stex_uri_resolve:Nn, \stex_uri_resolve:No, \stex_uri_resolve:Nx} + behaves analogously to \cs{stex_file_resolve:Nn}. + \end{sfunction} + + \begin{sfunction}{stex_uri_set:Nn}{\stex_uri_set:Nn, \stex_uri_set:No, \stex_uri_set:Nx} + behaves analogously to \cs{stex_file_set:Nn}. + \end{sfunction} + + \begin{sfunction}{stex_uri_use:N}[EXP]{\stex_uri_use:N} + behaves analogously to \cs{stex_file_use:N}. + \end{sfunction} + + A common usage of URIs is computing the namespace of content + elements (modules or documents) from the namespace of a math + archive and some relative file path within that archive. + + \stexvarmacro{target} + \stexvarmacro{repo_prop} + \stexvarmacro{filepath} + \begin{sfunction}{stex_uri_from_repo_file:NNNn}{\stex_uri_from_repo_file:NNNn} + \begin{syntax} + \dcs\marg{\cs{target}}\marg{\cs{repo_prop}}\marg{\cs{filepath}} + \marg{ns\_field} + \end{syntax} + computes the namespace URI from the property list + \cs{repo_prop} of some math archive, the file path + \cs{filepath} and the archive field \marg{ns\_field} + (|narr| or |ns|), and stores the result in \cs{target}. + \end{sfunction} + + \begin{sfunction}{stex_uri_from_repo_file_nolang:NNNn}{\stex_uri_from_repo_file_nolang:NNNn} + behaves like \cs{stex_uri_from_repo_file:NNNn}, but makes + sure + to split off language abbreviations from the file name + (e.g. |.en|). + \end{sfunction} + + \begin{sfunction}{stex_uri_from_current_file:Nn, stex_uri_from_current_file_nolang:Nn}{\stex_uri_from_current_file:Nn, \stex_uri_from_current_file_nolang:Nn} + Special cases for \cs{stex_uri_from_repo_file}|[_nolang]:NNNn|, + for \cs{repo_prop}|=|\cs{l_stex_current_archive_prop} and + \cs{filepath}|=|\cs{g_stex_current_file}. + \end{sfunction} + + \stexmacro{l_stex_current_doc_uri} + \begin{sfunction}{stex_set_document_uri:}{\stex_set_document_uri:} + sets the current value of \cs{l_stex_current_doc_uri} based + on the current file and archive. + \end{sfunction} + + \stexmacro{l_stex_current_ns_uri} + \begin{sfunction}{stex_set_current_namespace:}{\stex_set_current_namespace:} + sets the current value of \cs{l_stex_current_ns_uri} based + on the current file and archive. + \end{sfunction} + + \begin{sfunction}{stex_uri_add_module:NNn}{\stex_uri_add_module:NNn, \stex_uri_add_module:NNo} + \begin{syntax} + \dcs\marg{\cs{target}}\marg{\cs{uri}} + \marg{name} + \end{syntax} + Checks that URI \cs{uri} has no module name, adds the provided + \meta{name} and stores the result in \cs{target}. + \end{sfunction} + + \begin{sfragment}{URI Constants and Variables} + + \begin{svariable}{l_stex_current_doc_uri}{\l_stex_current_doc_uri} + always points to the current document URI. + \end{svariable} + + \begin{svariable}{l_stex_current_ns_uri}{\l_stex_current_ns_uri} + always points to the current content namespace. + \end{svariable} + + \end{sfragment} + + \end{sfragment} + +\end{sfragment} + +\begin{sfragment}{Language Handling} + \begin{svariable}{c_stex_languages_prop,c_stex_language_abbrevs_prop}{\c_stex_languages_prop,\c_stex_language_abbrevs_prop} + Property lists converting babel languages to/from their abreviations; + e.g. + \begin{itemize} + \item |\prop_item:Nn |\cs{c_stex_languages_prop}| {de}| yields |ngerman|, and + \item \cs{c_stex_language_abbrevs_prop}| {ngerman}| yields |de|. + \end{itemize} + \end{svariable} + + \begin{svariable}{l_stex_current_language_str}{\l_stex_current_language_str} + always stores the current language. + \end{svariable} + + \begin{sfunction}{stex_set_language:n}{\stex_set_language:n, \stex_set_language:x, \stex_set_language:o} + \begin{syntax}\dcs\marg{abbrev}\end{syntax} + Sets \cs{l_stex_current_language_str}, and, if the \pkg{babel} + package is loaded, calls \cs{selectlanguage} on the + language corresponding to \marg{abbrev}. + + Note that the package option |lang=| automatically loads the + \pkg{babel} package. + + If \meta{abbrev}|=tr|, additionally call \cs{selectlanguage} + with the option |shorthands=:!|. + + Throws |error/unknownlanguage| if no language with abbreviation + \marg{abbrev} is known. + \end{sfunction} + + \begin{sfunction}{stex_language_from_file:}{\stex_language_from_file:} + infers the current language from file ending (e.g. |.en.tex|) + and sets it appropriately. + + Is called in a file hook, i.e. always switches language when inputting + a file |.<lang>.<ext>|. + \end{sfunction} + +\end{sfragment} + +\begin{sfragment}{Inserting Annotations} + \stex can be used to produce either \HTML or \PDF. In \HTML-mode, + multiple macros exist to insert annotations. The same macros + are also valid in \PDF mode but implemented as null operations. + + \begin{sfunction}{stex_suppress_html:n}{\stex_suppress_html:n} + \begin{syntax}\dcs\marg{code}\end{syntax} + turns annotations off temporarily in \meta{code} (e.g. as to not + generate additional annotations for elaborated declarations, + or in sms-mode). + \end{sfunction} + + For that to work, code that inserts annotations should use + \begin{sfunction}{stex_if_do_html:}[pTF]{\stex_if_do_html:} + tests whether to generate \HTML annotations. + \end{sfunction} + + \begin{sfunction}{stex@backend}{\stex@backend} + should be set by a backend engine, such that a file + |stex-backend-|\dcs{}|.cfg| exists. + \end{sfunction} + + \begin{sfragment}{Backend macros} + + Such a backend config file should provide the following: + + \begin{sfunction}{stex_if_html_backend:}[pTF]{\stex_if_html_backend:} + can be used to determine whether the backend produces \HTML (e.g. + \rustex or \LaTeXML) or not (e.g. |pdflatex|). + + \cs{ifstexhtml} is set accordingly. + \end{sfunction} + + \begin{sfunction}{stex_annotate:nnn}{\stex_annotate:nnn} + \begin{syntax} \dcs\marg{attr}\marg{value}\marg{code} + \end{syntax} + In \HTML mode, annotates the output of \meta{code} with the + \XML-attribute \meta{attr}|="|\meta{value}|"|. In \PDF mode, just + calls \meta{code}. + \end{sfunction} + + \begin{sfunction}{stex_annotate_invisible:nnn,stex_annotate_invisible:n}{\stex_annotate_invisible:nnn,\stex_annotate_invisible:n} + \begin{syntax} \dcs[stex_annotate_invisible:n]\marg{code} + \end{syntax} + + Should annotate \meta{code} with + |shtml:visible="false" style="display:none;"|. In \PDF mode, does + nothing. + + \dcs combines \cs{stex_annotate_invisible:n} + and \cs{stex_annotate:nnn}. + \end{sfunction} + + + \begin{senv}{stex_annotate_env} + \cs{begin}|{|\denv|}|\marg{attr}\marg{value} + \meta{code} + \cs{end}|{|\denv|}| should behave + like \cs{stex_annotate:nnn}\marg{attr}\marg{value}\marg{code} + \end{senv} + + \begin{sfunction}{stex_mathml_intent:nn,stex_mathml_arg:nn}{\stex_mathml_intent:nn,\stex_mathml_arg:nn} + MathML Intent (TODO) + \end{sfunction} + + \end{sfragment} + +\end{sfragment} + +\begin{sfragment}{Persisting Content from Math Archives in sms-Files} + + \begin{sfunction}{stex_persist:n}{\stex_persist:n,\stex_persist:e} + \begin{syntax}\dcs\marg{code}\end{syntax} + writes \meta{code} to the \cs{jobname}|.sms|-file, if + |writesms| is active. + + \begin{texnote} + \meta{code} is being read with \pkg{expl3} category + codes (except for spaces having catcode 10), + but not pretokenized; i.e. \meta{code} can safely + change the current catcode scheme. + \end{texnote} + \end{sfunction} + + + \begin{svariable}{c_stex_persist_mode_bool,c_stex_persist_write_mode_bool}{ + \c_stex_persist_mode_bool,\c_stex_persist_write_mode_bool + } + whether |usesms| or |writesms| are active. + \end{svariable} + +\end{sfragment} + + +\begin{sfragment}{Utility Methods} + + \stexvarmacro{foo} + \begin{sfunction}{stex_macro_body:N}[EXP]{\stex_macro_body:N} + expands to the \emph{expansion} of the provided macro, + including parameter tokens, with the original category codes intact; + e.g. if \cs{def}\cs{foo}|#1{First #1}|, + then \dcs\cs{foo} expands to + |First #1|. + \end{sfunction} + + \begin{sfunction}{stex_macro_definition:N}[EXP]{\stex_macro_definition:N} + expands to the token list \emph{defining} the provided macro, + including parameters, command attributes (i.e. \cs{long}, + \cs{protected}), with the original category codes intact; + e.g. if \cs{protected}\cs{def}\cs{foo}|#1{First #1}|, + then \dcs\cs{foo} expands to + \cs{protected}\cs{def}\cs{foo}|#1{First #1}|. + + \begin{texnote} Does not work with ``higher'' parameter + tokens, i.e. |##1|, |####1| etc.\end{texnote} + \end{sfunction} + + \stexvarmacro{macro} + \begin{sfunction}{stex_deactivate_macro:Nn, stex_reactivate_macro:N}{\stex_deactivate_macro:Nn, \stex_reactivate_macro:N} + \begin{syntax}\dcs \marg{\cs{macro}} \marg{msg} + \end{syntax} + Makes \cs{macro} throw an error message |error/deactivated-macro|\marg{msg}, + notifying an author that the macro is only allowed in certain environments. + + \dcs[stex_reactivate_macro:N] restores the functionality of the macro. + \end{sfunction} + + \begin{sfunction}{stex_kpsewhich:Nn}{\stex_kpsewhich:Nn} + \begin{syntax} + \dcs \marg{\cs{macro}} \marg{args} + \end{syntax} + Calls ``|kpsewhich| \meta{args}'' and stores the result + in \cs{macro}, +%^^A Foo + \begin{texnote} + Does not require |shell-escape| + \end{texnote} +%^^A +%^^A +%^^A \begin{arguments} +%^^A \item Narf? +%^^A \end{arguments} +%^^A + \end{sfunction} + + \begin{sfunction}{stex_get_env:Nn}{\stex_get_env:Nn} + \begin{syntax} + \dcs \marg{\cs{macro}} \marg{envvar} + \end{syntax} + Stores the value of the environment variable \meta{envvar} + in \cs{macro}. + \end{sfunction} + + \begin{sfunction}{stex_fatal_error:n}{\stex_fatal_error:n,\stex_fatal_error:nnn,\stex_fatal_error:nxx} + Mimic the \cs{msg_error:}-macros, but make sure that \TeX\ stops + processing. + \begin{texnote} + Calls |\input{non-existent file}|. + \end{texnote} + \end{sfunction} + + \begin{sfunction}{stex_ignore_spaces_and_pars:}{\stex_ignore_spaces_and_pars:} + As the name suggests, ignores all subsequent spaces and \cs{par}s + until the first non-expandable macro is encountered. + + Useful for e.g. ending \cs{symdecl} and related macros with, + so that formatting sources with empty lines does not cause + paragraph breaks. + \end{sfunction} + + \begin{sfragment}{Group-like Behaviours} + + \begin{sfunction}{stex_pseudogroup_with:nn}{\stex_pseudogroup_with:nn} + \begin{syntax}\dcs\marg{macros}\marg{code} + \end{syntax} + Calls \meta{code} and subsequently restores the values of the + \meta{macros} given. + \begin{texnote} + Does \emph{not} work recursively! + \end{texnote} + \end{sfunction} + + \stexmacro{stex_pseudogroup_restore:N} + + \begin{sfunction}{stex_pseudogroup:nn}{\stex_pseudogroup:nn} + \begin{syntax}\dcs\marg{code1}\marg{code2} + \end{syntax} + Expands \meta{code2}, and inserts the result after \meta{code1}. + Works recursively and + allows for restoring the values of macros in combination with + \cs{stex_pseudogroup_restore:N}, but \emph{only for macros + that take no arguments}: + \end{sfunction} + + \begin{sfunction}{stex_pseudogroup_restore:N}[EXP]{\stex_pseudogroup_restore:N} + \begin{syntax}\dcs\marg{\cs{macro}} + \end{syntax} + \end{sfunction} + + \begin{sexample} + \stexvarmacro{foo} + \stexvarmacro{num} + \begin{stexcode}[gobble=8] + |\cs{stex_pseudogroup:nn}|{ + something changing |\cs{foo}| + something changing |\cs{num}| + }{ + |\cs{stex_pseudogroup_restore:N}\cs{foo}| + \int_set:Nn |\cs{num}| {\int_use:N |\cs{num}|} + } + \end{stexcode} + restores the values of macro \cs{foo} and register \cs{num} + after calling the first block. + \end{sexample} + + Commands like \cs{symdecl} and \cs{importmodule} that generate + (semantic) macros should be local \emph{to the current module}, + e.g. \env{smodule}. For that purpose, we open a new ``metagroup'' + with some identifier (e.g. \cs{l_stex_current_module_str}) + and then execute the relevant code \emph{in the metagroup with that + identifier}: + + \begin{sfunction}{stex_metagroup_new:n}{\stex_metagroup_new:n, \stex_metagroup_new:o} + \begin{syntax}\dcs \marg{id}\end{syntax} + Opens a new metagroup at the current \TeX\ group level with + identifier \meta{id}. + \end{sfunction} + + \begin{sfunction}{stex_metagroup_do_in:nn}{\stex_metagroup_do_in:nn, \stex_metagroup_do_in:nx} + \begin{syntax}\dcs \marg{id}\marg{code}\end{syntax} + Executes \meta{code} and adds its content to \cs{aftergroup} up + until the \TeX\ group level of the metagroup with identifier + \meta{id}. + \end{sfunction} + + \end{sfragment} + +\end{sfragment} + +\end{smodule} + +%^^A^^A \begin{TemplateInterfaceDescription}{foo} +%^^A^^A \TemplateArgument{1}{Something Here} +%^^A^^A \TemplateSemantics{Some Narf Here} +%^^A^^A \end{TemplateInterfaceDescription} +%^^A^^A \begin{TemplateDescription}{foo}{bar} +%^^A^^A \TemplateKey{narf}{Something Here} +%^^A^^A \TemplateSemantics{Some Narf Here} +%^^A^^A \end{TemplateDescription} +%^^A^^A \begin{InstanceDescription}{foo}{newinst}{bar} +%^^A^^A \InstanceKey{narf}{Something Here} +%^^A^^A \InstanceSemantics{Some Narf Here} +%^^A^^A \end{InstanceDescription} +%^^A^^A \cs{stex_kpsewhich:Nn} +%^^A \begin{function}{\stex_kpsewhich:Nn} +%^^A Foo +%^^A \begin{texnote} Foo! \end{texnote} +%^^A +%^^A \begin{syntax} \cs{stex_kpsewhich:Nn} \meta{something} \Arg{argh} +%^^A \end{syntax} +%^^A +%^^A \begin{arguments} +%^^A \item Narf? +%^^A \end{arguments} +%^^A +%^^A \end{function}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/stex/stex-doc.pdf b/Master/texmf-dist/doc/latex/stex/stex-doc.pdf Binary files differindex e53c98213ac..a978cbb2e7a 100644 --- a/Master/texmf-dist/doc/latex/stex/stex-doc.pdf +++ b/Master/texmf-dist/doc/latex/stex/stex-doc.pdf diff --git a/Master/texmf-dist/doc/latex/stex/stex-doc.tex b/Master/texmf-dist/doc/latex/stex/stex-doc.tex index d2ff005554c..6dbf566c2ce 100644 --- a/Master/texmf-dist/doc/latex/stex/stex-doc.tex +++ b/Master/texmf-dist/doc/latex/stex/stex-doc.tex @@ -1,218 +1,85 @@ -\def\libfolder#1{../lib/#1} -\newif\ifinidedoc\inidedocfalse -\newif\ifinfulldoc\inidedocfalse - \input{stex-docheader} -\infulldoctrue -\ExplSyntaxOn -\def\OmitDocInput#1{ -\clist_gput_right:Nn \g_docinput_clist - { #1 } -} -\ExplSyntaxOff +\stextoptitle{The {\protect\stex{3}} Package Collection}{} \begin{document} - \title{ - The {\stex{3}} Package Collection - \thanks{Version {\fileversion} (last revised {\filedate})} - } - \author{Michael Kohlhase, Dennis Müller\\ - FAU Erlangen-Nürnberg\\ - \url{http://kwarc.info/} - } - \pagenumbering{roman} - \maketitle - - \input{stex-abstract}\bigskip - - This is the full documentation of \sTeX. It - consists of four parts: - \begin{itemize} - \item \autoref{part:manual} is a general manual - for the \sTeX package and associated software. - It is primarily directed at end-users who - want to use \sTeX to author semantically - enriched documents. - \item \autoref{part:documentation} - documents the macros provided - by the \sTeX package. It is primarily directed - at package authors who want to build on - \sTeX, but can also serve as a reference manual - for end-users. - \item \autoref{part:extensions} documents additional - packages that build on \sTeX, primarily its - module system. These are not part of the - \sTeX package itself, but useful additions - enabled by \sTeX package functionality. - \item \autoref{part:implementation} is the - detailled documentation of the \sTeX package - implementation. - \end{itemize} - - \makeatletter - \renewcommand\part{% - \clearpage - \thispagestyle{plain}% - \@tempswafalse - \null\vfil - \secdef\@part\@spart% - } - \newcounter{chapter} - \numberwithin{section}{chapter} - \renewcommand\thechapter{\@arabic\c@chapter} - \renewcommand\thesection{\thechapter.\@arabic\c@section} - \newcommand*\chaptermark[1]{} - \setcounter{secnumdepth}{2} - \newcommand\@chapapp{\chaptername} - %\newcommand\chaptername{Chapter} - \def\ps@headings{% - \let\@oddfoot\@empty - \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% - \let\@mkboth\markboth - \def\chaptermark##1{% - \markright{\MakeUppercase{% - \ifnum \c@secnumdepth >\m@ne - \@chapapp\ \thechapter. \ % - \fi - ##1}}% - }% - } - \newcommand\chapter{\clearpage - \thispagestyle{plain}% - \global\@topnum\z@ - \@afterindentfalse - \secdef\@chapter\@schapter% - } - \def\@chapter[#1]#2{\refstepcounter{chapter}% - \typeout{\@chapapp\space\thechapter.}% - \addcontentsline{toc}{chapter}% - {\protect\numberline{\thechapter}#1}% - \chaptermark{#1}% - \addtocontents{lof}{\protect\addvspace{10\p@}}% - \addtocontents{lot}{\protect\addvspace{10\p@}}% - \@makechapterhead{#2}% - \@afterheading% - } - \def\@makechapterhead#1{% - \vspace*{50\p@}% - {\parindent \z@ \raggedright \normalfont - \huge\bfseries \@chapapp\space \thechapter - \par\nobreak - \vskip 20\p@ - \interlinepenalty\@M - \Huge \bfseries #1\par\nobreak - \vskip 40\p@ - }% - } -\newcommand*\l@chapter[2]{% - \ifnum \c@tocdepth >\m@ne - \addpenalty{-\@highpenalty}% - \vskip 1.0em \@plus\p@ - \setlength\@tempdima{1.5em}% - \begingroup - \parindent \z@ \rightskip \@pnumwidth - \parfillskip -\@pnumwidth - \leavevmode \bfseries - \advance\leftskip\@tempdima - \hskip -\leftskip - #1\nobreak\hfil - \nobreak\hb@xt@\@pnumwidth{\hss #2% - \kern-\p@\kern\p@}\par - \penalty\@highpenalty - \endgroup - \fi} -\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}} -\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} -\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} -\def\partname{Part} -\def\toclevel@part{-1} -\def\maketitle{\chapter{\@title}} -\let\thanks\@gobble -\let\DelayPrintIndex\PrintIndex -\let\PrintIndex\@empty -\providecommand*{\hexnum}[1]{\text{\texttt{\char`\"}#1}} -\makeatother - -\ExplSyntaxOn -\int_set:Nn \l_document_structure_section_level_int {1} -\ExplSyntaxOff - -\clearpage - -{% - \def\\{:}% fix "newlines" in the ToC - \tableofcontents -} - -\clearpage -\pagenumbering{arabic} - -\part{Manual}\label{part:manual} - -%\let\oldsubsubsection\subsubsection -%\let\subsubsection\section -%\let\subsection\section -%\let\section\chapter - -\input{stex-manual} - -%\let\section\subsection -%\let\subsection\subsubsection -%\let\subsubsection\oldsubsubsection - -\part{Documentation}\label{part:documentation} - -\ExplSyntaxOn -\int_set:Nn \l_document_structure_section_level_int {2} -\ExplSyntaxOff - - -%\errmessage{\expandafter\meaning\csname comment \endcsname} +\usemodule[sTeX/Documentation]{common} +\maketitle + +\libinput[sTeX/Documentation]{docparts} + +\tableofcontents + +\begin{experimental} + \stex is -- by now -- relatively stable and ready to use for the + general public. However, it is also actively being developed further + and subject to ongoing research. Some of the features described in + here might not fully work as expected, + some are still experimental, there might occasionally be cryptic + error messages, and in general bugs are expected. + + We welcome all kinds of issues you might encounter at + \url{https://github.com/slatex/sTeX}. +\end{experimental} +\edef\stexmatrixlink{\noexpand\url{https://matrix.to/\#/\#stex:fau.de}} +\begin{center}\emph{ + If you have questions or problems with \stex, you can talk to us + directly at \stexmatrixlink. +}\end{center} + +\EnableManual +\DisableDocumentation \DisableImplementation +\begin{blindfragment} + \inputref[sTeX/Documentation]{setup} +\end{blindfragment} -\DocInput{../source/stex/stex-basics.dtx} -\DocInput{../source/stex/stex-mathhub.dtx} -\DocInput{../source/stex/stex-references.dtx} -\DocInput{../source/stex/stex-modules.dtx} -\DocInput{../source/stex/stex-inheritance.dtx} -\DocInput{../source/stex/stex-symbols.dtx} -\DocInput{../source/stex/stex-terms.dtx} -\DocInput{../source/stex/stex-features.dtx} -\DocInput{../source/stex/stex-statements.dtx} -\DocInput{../source/stex/stex-proofs.dtx} - -\OmitDocInput{../source/stex/stex-others.dtx} -\DocInput{../source/stex/stex-metatheory.dtx} +\begin{sfragment}{Tutorial} + \inputref[sTeX/Documentation]{tutorial.en} +\end{sfragment} -\part{Extensions}\label{part:extensions}\slabel{part:extends} +\begin{sfragment}{User Manual} + \inputref[sTeX/Documentation]{manual} -\DocInput{../source/extensions/tikzinput.dtx} -\DocInput{../source/extensions/document-structure.dtx} -\DocInput{../source/extensions/notesslides.dtx} -\DocInput{../source/extensions/problem.dtx} -\DocInput{../source/extensions/hwexam.dtx} + \begin{sfragment}{Additional Packages} + \DocInput{../source/notesslides.dtx} + \DocInput{../source/problem.dtx} + \DocInput{../source/hwexam.dtx} + \DocInput{../source/tikzinput.dtx} + \end{sfragment} +\end{sfragment} +\DisableManual +\EnableDocumentation +\DisableImplementation -\part{Implementation}\label{part:implementation} +\begin{sfragment}{Documentation} + \DocInput{../source/stex.dtx} -\def\maketitle{} -\let\subsubsection\section -\let\subsection\section -\let\section\chapter + \begin{sfragment}{Additional Packages} + \DocInput{../source/notesslides.dtx} + \DocInput{../source/problem.dtx} + \DocInput{../source/hwexam.dtx} + \DocInput{../source/tikzinput.dtx} + \end{sfragment} +\end{sfragment} \EnableImplementation \DisableDocumentation -\DocInputAgain +\begin{sfragment}{Implementation} + %\DocInputAgain + \DocInput{../source/stex.dtx} -\begin{sfragment}{References}\ednote{we need an un-numbered version {sfragment*}} - \printbibliography[heading=none] + \begin{sfragment}{Additional Packages} + \DocInput{../source/notesslides.dtx} + \DocInput{../source/problem.dtx} + \DocInput{../source/hwexam.dtx} + \DocInput{../source/tikzinput.dtx} + \end{sfragment} \end{sfragment} -\end{document} -%%% Local Variables: -%%% mode: latex -%%% TeX-master: t -%%% End: +\DelayPrintIndex + +\end{document} diff --git a/Master/texmf-dist/doc/latex/stex/stex-docheader.tex b/Master/texmf-dist/doc/latex/stex/stex-docheader.tex index c6bea9b3da5..b8b6313be8d 100644 --- a/Master/texmf-dist/doc/latex/stex/stex-docheader.tex +++ b/Master/texmf-dist/doc/latex/stex/stex-docheader.tex @@ -1,164 +1,168 @@ \RequirePackage{paralist} -\ifcsname libfolder\endcsname\else\def\libfolder#1{../lib/#1}\fi -\documentclass[full,kernel]{l3doc} -\usepackage[dvipsnames]{xcolor} -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\RequirePackage{morewrites} -\RequirePackage{tikzinput} -\usetikzlibrary{fit} - -\usepackage[lang=en, mathhub=./tests,debug=sref]{stex} -\usepackage{url,array,float} -\usepackage[show]{ed} +\ifcsname stexdocpath\endcsname\else\def\stexdocpath{.}\fi +\documentclass[full]{l3doc} +%\RequirePackage{document-structure} \usepackage[hyperref=auto,style=alphabetic]{biblatex} -\addbibresource{\libfolder{bib/kwarcpubs.bib}} -\addbibresource{\libfolder{bib/extpubs.bib}} -\addbibresource{\libfolder{bib/kwarccrossrefs.bib}} -\addbibresource{\libfolder{bib/extcrossrefs.bib}} -\usepackage{amssymb} -\usepackage{amsfonts} -\usepackage{xspace} -\usepackage{hyperref} - -\makeindex -\floatstyle{boxed} -\newfloat{exfig}{thp}{lop} -\floatname{exfig}{Example} - -\usepackage{listings} -\usepackage{lststex} - -\lstdefinelanguage{sTeX}{ - sensitive=true, - numbers=left, - numbersep=3pt, - xleftmargin=3pt, - alsodigit={\$}, - %gobble=4, - alsoletter={\\}, - %moredelim = [s][\itshape]{$}{$}, - %moredelim = [s][\itshape\bfseries]{\\[}{\\]}, - classoffset=0,keywordstyle=\bfseries,morekeywords={ - \\begin,\\end,\\ExplSyntaxOn,\\ExplSyntaxOff,\\documentclass, - \\usepackage,\\def,\\[,\\],\\else,\\fi,$\iffalse$\fi, - \\newcommand, \\renewcommand, \\let - }, - classoffset=1,keywordstyle=\itshape\color{OliveGreen},morekeywords={ - \\defeq,\\geometricSeries,\\infinitesum,\\realdivide, - \\realpower, - \\symbolname,\\binarysymbol,\\newbinarysymbol,\\addition, - \\summation,\\ascendingchain,\\quantforall,\\set,\\funtype, - \\Nat,\\successor,\\multiplication,\\Int,\\zero,\\uminus, - \\intmonoid,\\divides,\\intpow,\\ratfrac,\\ratpow,\\inttimes, - \\inset,\\eq,\\rational,\\irrational,\\coprime,\\PosInt, - \\realroot - }, - classoffset=2,keywordstyle=\color{blue},morekeywords={ - \\symdecl,\\symdef,\\notation,\\vardef,\\varseq,\\instantiate, - \\varinstantiate, \\renamedecl, \\assign, \\setnotation, - \\STEXexport - }, - classoffset=3,keywordstyle=\color{BurntOrange},morekeywords={ - \\importmodule,\\usemodule,\\libinput,\\inputref,\\mhinput, - \\libusepackage,\\addmhbibresource,\\ifinputref - }, - classoffset=4,keywordstyle=\color{Purple},morekeywords={ - \\definiendum,\\definame,\\symref,\\symname,\\comp, - \\compemph,\\definiens,\\svar,\\infprec,\\neginfprec,\\ellipses, - \\Symname,\\arg,\\yield,\\assumption,\\spfstep,\\eqstep,\\conclude - }, - classoffset=5,keywordstyle=\color{magenta},morekeywords={ - smodule,sdefinition,sassertion,sparagraph,sexample, - sproof,subproof,spfcases,spfcase,spfstep,spfcomment,spfblock, - \\spfidea,\\spfsketch,\\spfcasesketch,\\sproofend, - \\spfjust,\\premise,\\justarg, - copymodule,interpretmodule,mathstructure,sexample - }, - classoffset=6,keywordstyle=\color{cyan},morekeywords={ - sfragment,blindfragment,\\skipfragment, - \\currentsectionlevel,\\Currentsectionlevel - \\prematurestop,\\afterprematurestop, - \\setSGvar,\\useSGvar,\\ifSGvar - }, - classoffset=7,keywordstyle=\color{brown},morekeywords={ - frame,note,\\ifnotes,\\setslidelogo,\\setsource,\\setlicensing - slides,notes,sectocframes,frameimages,fiboxed, - nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion, - \\frameimage,\\mhframeimage,\\textwarning, - \\activateexcursion,\\printexcursion,\\excursionref,\\excursiongroup - }, - classoffset=8,keywordstyle=\color{red},morekeywords={ - frame,note - }, - classoffset=9,keywordstyle=\color{gray},morekeywords={ - \\vara,\\varb,\\varc - } -} +%\usepackage[mathhub=\stexdocpath/mh,usedeps]{stex} +\usepackage[lang={en,de}]{stex} -\lstnewenvironment{latexcode}[1][]{\lstset{language=sTeX,#1}}{} +\usepackage{rustex} +\usepackage{stex-highlighting,stexthm} -\def\stexcode{\lstinline[language=sTeX]} +\srefsetin[sTeX/Documentation]{documentation}{the \stex Documentation} -\usepackage{mdframed,realboxes} -\usepackage[most]{tcolorbox} -\usepackage{caption} +\makeatletter +\providecommand{\HTML}{\textsc{html}\xspace}% +\providecommand{\XML}{\textsc{xml}\xspace}% +\providecommand{\PDF}{\textsc{pdf}\xspace}% +\providecommand\openmath{\textsc{OpenMath}\xspace} +\providecommand\OMDoc{\textsc{OMDoc}\xspace} +\DeclareRobustCommand\LaTeXML{L\kern-.36em% + {\sbox\z@ T% + \vbox to\ht\z@{\hbox{\check@mathfonts + \fontsize\sf@size\z@ + \math@fontsfalse\selectfont + A}% + \vss}% + }% + \kern-.15em% +% T\kern-.1667em\lower.5ex\hbox{E}\kern-.125em\relax +% {\tt XML}} + T\kern-.1667em\lower.4ex\hbox{E}\kern-0.05em\relax + {\scshape xml}\xspace}% +\def\mmt{\textsc{Mmt}\xspace} +\makeatother -\newenvironment{framed}{\begin{mdframed}\begin{center}}{\end{center}\end{mdframed}} -\newcommand{\scaled}[2][0.9\hsize]{\begin{center}\resizebox{#1}{!}{\begin{minipage}{\textwidth} #2 \end{minipage}}\end{center}} -\newenvironment{stextest@output} -{ - \begin{mdframed}[linewidth=1pt,backgroundcolor=white]\small -} -{\end{mdframed}} +\newif\ifhadtitle\hadtitlefalse -\newenvironment{stextest@input} -{ - \begin{mdframed}[linewidth=1pt,backgroundcolor=white]\small +\def\stexversion{3.3.0} +\def\changedate{\today} +\def\stextoptitle#1#2{\title{#1\thanks{Version {\stexversion} (last revised {\changedate})} }\def\thispkg{#2}} + +\author{Michael Kohlhase, Dennis Müller\\ + FAU Erlangen-Nürnberg\\ + \url{http://kwarc.info/} } -{\end{mdframed}} -\makeatletter +\def\stexmaketitle{\ifhadtitle\else\hadtitletrue\maketitle\fi} -\newcount\test@counter\test@counter=0 -\newcount\example@counter\example@counter=0 +\ExplSyntaxOn -\newtcolorbox{exampleborderbox}{ - empty, - title={Example \the\example@counter}, - attach boxed title to top left, - minipage boxed title, - boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}}, - coltitle=blue,fonttitle=\bfseries, - parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm, - before upper=\csname @totalleftmargin\endcsname0pt, - overlay unbroken={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, - overlay first={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, - overlay middle={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, - overlay last={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, - outer arc=4pt + \def\docmodule{ + \begin{document} + \EnableManual + \EnableDocumentation + \EnableImplementation + \stexmaketitle + \tableofcontents + \int_gincr:N \l_stex_docheader_sect + \exp_args:Ne \__stex_mathhub_find_manifest:n {\stex_file_use:N \c_stex_mathhub_file / sTeX / Documentation} + \str_if_empty:NF \l__stex_mathhub_manifest_str { + \usemodule[sTeX/Documentation]{macros?AllMacros} + } + \DocInput{\jobname.dtx} + \clearpage + \PrintIndex + \printbibliography + \end{document} + } + + \bool_new:N \g_stexdoc_typeset_manual_bool + \NewDocumentCommand \EnableManual {}{ + \bool_gset_true:N \g_stexdoc_typeset_manual_bool + } + \NewDocumentCommand \DisableManual {}{ + \bool_gset_false:N \g_stexdoc_typeset_manual_bool + } + \NewDocumentEnvironment {stexmanual} {} { + \bool_if:NTF \g_stexdoc_typeset_manual_bool + {\bool_set_false:N \l__codedoc_in_implementation_bool} + {\comment} + }{ + \bool_if:NF \g_stexdoc_typeset_manual_bool {\endcomment} + } +\ExplSyntaxOff + +%\usepackage{makeidx} +%\makeindex + +%\usepackage{document-structure} + + +\usepackage{lststex,mdframed} +\usepackage[most]{tcolorbox} + +\lstset{literate=% + {Ö}{{\"O}}1 + {Ä}{{\"A}}1 + {Ü}{{\"U}}1 + {ß}{{\ss}}1 + {ü}{{\"u}}1 + {ä}{{\"a}}1 + {ö}{{\"o}}1 + {~}{{\textasciitilde}}1 } -\newenvironment{example@border} -{ - \global\advance\example@counter by 1 -%^^A\refstepcounter{remark} -\begin{exampleborderbox} +\newenvironment{framed}[1][]{ + \ifstexhtml\par\vbox\bgroup + \csname exp_args:Nne\endcsname\begin{stex_annotate_env}{% + style:border=solid 1px black,% + style:width=var(--this-width),% + style:min-width=var(--this-width),% + style:--this-width=calc(var(--current-width) - 6px),% + style:padding=3px,% + style:margin-top=5px,% + style:margin-bottom=5px% + } + \csname stex_annotate_invisible:n\endcsname{ }% + \begin{stex_annotate_env}{% + style:--current-width=var(--this-width);% + }\csname stex_annotate_invisible:n\endcsname{ } + \else\begin{mdframed}[#1]\fi + %\begin{center}% +}{% + %\end{center}% + \ifstexhtml + \end{stex_annotate_env}\end{stex_annotate_env}\egroup\par + \else\end{mdframed}\fi } -{\end{exampleborderbox}} +\newcommand{\scaled}[2][0.9\hsize]{\begin{center}\resizebox{#1}{!}{\begin{minipage}{\textwidth} #2 \end{minipage}}\end{center}} - \makeatother - -\def\present#1{\texttt{>>\meaning#1<<}} -\def\printltx#1{\texttt{\detokenize{#1}}} +\makeatletter +\ExplSyntaxOn -\newwrite\testoutfile -\def\testfile{0} +\def\doc_exbox:nnn#1#2#3{ + \begin{sexample}[#3] + Input: + \begin{framed}[linewidth=1pt,backgroundcolor=white]\small + #1 + \end{framed} + Output: + \begin{framed}[linewidth=1pt,backgroundcolor=white]\small + #2 + \end{framed} + \end{sexample} +} -\ExplSyntaxOn -\def\stexexample{ +\NewDocumentCommand\stexexamplefile{O{} m O{} O{}}{ + \stex_resolve_path_pair:Nxx \l_@@_filepath_str {\tl_to_str:n{#1}} {\tl_to_str:n{#2}} + \doc_exbox:nnn{ + \hfill File~\str_if_empty:nTF{#1}{ + \prop_if_exist:NT \l_stex_current_archive_prop { + [\texttt{\prop_item:Nn \l_stex_current_archive_prop {id}}] + } + }{[#1]}\texttt{\tl_to_str:n{#2}} + \_lststex_parse_args:n{#3} + \exp_args:Nno \use:nn{\lstinputlisting[} \l_lststex_return_tl ]{\l_@@_filepath_str} + }{ + \inputref[#1]{#2} + }{#4} +} + +\newwrite\testoutfile +\NewDocumentCommand\stexexample{O{} O{}}{ \begingroup \catcode`\\=12\relax \catcode`\#=12\relax @@ -171,38 +175,65 @@ \endlinechar=`^^J \newlinechar=-1 %^^A \everyeof{\noexpand} - \example_a:n + \example_a:nnn{#1}{#2} } -\long\def\example_a:n #1 { +\long\def\example_a:nnn #1 #2 #3 { \endgroup - \begin{example@border} - \immediate\openout\testoutfile=stextest.tex - \immediate\write\testoutfile{ - \c_backslash_str begin{latexcode} - \detokenize{^^J}#1 - \c_backslash_str end{latexcode} - } + \immediate\openout\testoutfile=\jobname.exmpl + \immediate\write\testoutfile{ + \c_backslash_str begin{stexcode}[#1] + \detokenize{^^J}#3 + \c_backslash_str end{stexcode} + } + \immediate\closeout\testoutfile + \doc_exbox:nnn{ + \catcode`\#=12\relax + \csname @ @ input\endcsname{\jobname.exmpl} + }{ + \immediate\openout\testoutfile=\jobname.exmpl + \immediate\write\testoutfile{#3} \immediate\closeout\testoutfile + \csname @ @ input\endcsname \jobname.exmpl\relax + }{#2} + \peek_charcode_remove:NT ^^J +} - Input: +\ExplSyntaxOff +\makeatother - \begin{stextest@input} - \catcode`\#=12\relax - \input{stextest.tex} - \end{stextest@input} - \immediate\openout\testoutfile=stextest.tex - \immediate\write\testoutfile{#1} - \immediate\closeout\testoutfile +\makeatletter +\newcount\example@counter\example@counter=0 +\newtcolorbox{exampleborderbox}[1][]{ + empty, + title={Example \the\example@counter #1}, + attach boxed title to top left, + minipage boxed title, + boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}}, + coltitle=blue,fonttitle=\bfseries, + parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm, + before upper=\csname @totalleftmargin\endcsname0pt, + overlay unbroken={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, + overlay first={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, + overlay middle={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, + overlay last={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, + outer arc=4pt% +} - Output: - - \begin{stextest@output} - \csname @ @ input\endcsname{stextest.tex} - \end{stextest@output} - \end{example@border} +\ExplSyntaxOn +\stexstyleexample{ + \global\advance\example@counter by 1 + \tl_if_empty:NTF\thistitle{ + \begin{exampleborderbox} + }{ + \begin{exampleborderbox}[ (\thistitle)] + } +}{ + \end{exampleborderbox} } -\ExplSyntaxOff +\ExplSyntaxOff\makeatother + +\usetikzlibrary{calc} \def\textwarning{\includegraphics[width=1.2em]{stex-dangerous-bend}\xspace} \newtcolorbox{dangerbox}{ @@ -226,6 +257,62 @@ {\includegraphics[width=1cm,height=1cm]{stex-dangerous-bend}};} } +\protected\def\TODO#1{\textcolor{red}{TODO}\footnote{\textcolor{red}{TODO: #1}}} + +\definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0} + +\usepackage[solutions]{problem} +\usepackage{hwexam} +\newtcolorbox{problemborderbox}[1][]{ + empty, + title={Exercise #1}, + attach boxed title to top left, + minipage boxed title, + boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}}, + coltitle=darkgreen,fonttitle=\bfseries, + parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm, + before upper=\csname @totalleftmargin\endcsname0pt, + overlay unbroken={\draw[darkgreen,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, + overlay first={\draw[darkgreen,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, + overlay middle={\draw[darkgreen,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, + overlay last={\draw[darkgreen,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, + outer arc=4pt% +} + +\ExplSyntaxOn +\stexstyleproblem{ + \tl_if_empty:NTF\thistitle{ + \begin{problemborderbox} + }{ + \begin{problemborderbox}[ (\thistitle)] + } +}{ + \end{problemborderbox} +} +\ExplSyntaxOff + +\newtcolorbox{experimental}{ + breakable, + enhanced, + left=0pt, + right=0pt, + top=8pt, + bottom=8pt, + colback=white, + colframe=gray, + width=\textwidth, + enlarge left by=0mm, + boxsep=5pt, + fontupper=\small, + arc=4pt, + outer arc=4pt, + leftupper=1.5cm, + overlay={ + \node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$) + {\includegraphics[height=1cm]{stex-experimental}};} +} + + \usetikzlibrary{decorations.pathmorphing,shapes,arrows,calc} % Taken from pgflibrarytikzmmt.code.tex \newcommand{\mmtarrowtip}{angle 45} @@ -239,6 +326,7 @@ post=lineto,post length=5pt}, thick] \tikzstyle{view}=[preview,-\mmtarrowtip] + % TIKZ RULES \def\mmtlogo{ \begin{tikzpicture} @@ -287,98 +375,31 @@ {\mmtlogo};} } - -\MakeShortVerb{\|} - -\def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}\xspace} -\def\mmt{\textsc{Mmt}\xspace} -\def\xml{\scsys{Xml}} -\def\mathml{\scsys{MathML}} -\def\omdoc{\scsys{OMDoc}} -\def\openmath{\scsys{OpenMath}} -\def\latexml{\scsys{LaTeXML}} -\def\perl{\scsys{Perl}} -\def\cmathml{Content-{\sc MathML}\index{Content {\sc MathML}}\index{MathML@{\sc MathML}!content}} -\def\activemath{\scsys{ActiveMath}} -\def\twin#1#2{\index{#1!#2}\index{#2!#1}} -\def\twintoo#1#2{{#1 #2}\twin{#1}{#2}} -\def\atwin#1#2#3{\index{#1!#2!#3}\index{#3!#2 (#1)}} -\def\atwintoo#1#2#3{{#1 #2 #3}\atwin{#1}{#2}{#3}} -\def\cT{\mathcal{T}}\def\cD{\mathcal{D}} - -\def\fileversion{3.2} -\def\filedate{\today} - -\RequirePackage{pdfcomment} - -\ExplSyntaxOn\makeatletter -\cs_set_protected:Npn \@comp #1 #2 { - \pdftooltip { - \textcolor{blue}{#1} - } { #2 } -} - -\cs_set_protected:Npn \@defemph #1 #2 { - \pdftooltip { - \textbf{\textcolor{magenta}{#1}} - } { #2 } -} - -\def\__omtext_lec#1{#1} -\cs_new_protected:Npn \lec #1 { - \strut\hfil\strut\null\hfill\__omtext_lec{#1} +\newtcolorbox{defibox}{ + breakable, + enhanced, + left=0pt, + right=0pt, + top=8pt, + bottom=8pt, + colback=white, + colframe=orange, + width=\textwidth, + enlarge left by=0mm, + boxsep=5pt, + fontupper=\small, + leftupper=1.5cm, + arc=4pt, + outer arc=4pt, + overlay={\node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$) + {\textcolor{orange}{\Large\sTeX}};} } -\makeatother\ExplSyntaxOff - -\makeatletter -\let\@stex@oldcomment\comment -\let\@stex@oldendcomment\endcomment - -%\RequirePackage{comment} -\RequirePackage{document-structure} -\RequirePackage[hints,solutions,notes]{problem} -\RequirePackage{hwexam} - -\let\comment\@stex@oldcomment -\let\endcomment\@stex@oldendcomment - -\newif\ifinfulldoc\infulldocfalse -\makeatother - -\def\basedocurl{https://github.com/slatex/sTeX/blob/main/doc} -\newcounter{module} -\NewDocumentEnvironment {module}{}{ - \stepcounter{module} - \textbf{Module \themodule: \smoduletitle} +\stexstyleparagraph[defibox]{ + \begin{defibox} }{ - + \end{defibox} } -\stexpatchmodule[visible]{\begin{module}}{\end{module}} - -\usepackage{stexthm} - -\newtcolorbox{remarkbox}[1][]{ - empty, - title={Remark \theremark: #1}, - attach boxed title to top left, - minipage boxed title, - boxed title style={empty,size=minimal,toprule=0pt,top=4pt,left=3mm,overlay={}}, - fonttitle=\bfseries,coltitle=black, - before=\par\medskip\noindent,parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm, - before upper=\csname @totalleftmargin\endcsname0pt, - overlay unbroken={\draw[black,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, - overlay first={\draw[black,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); }, - overlay middle={\draw[black,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, - overlay last={\draw[black,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); }, -} - -\renewenvironment{remark}[1][]{ - \refstepcounter{remark}\begin{remarkbox}[#1] - \begin{mdframed}[linewidth=1pt,backgroundcolor=lightgray!33!white] -}{ -\end{mdframed}\end{remarkbox}\endlist -} -\usepackage{rustex}
\ No newline at end of file +\AtBeginDocument{\catcode`_=8}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/stex/stex-ide.pdf b/Master/texmf-dist/doc/latex/stex/stex-ide.pdf Binary files differdeleted file mode 100644 index a04d7ddd606..00000000000 --- a/Master/texmf-dist/doc/latex/stex/stex-ide.pdf +++ /dev/null diff --git a/Master/texmf-dist/doc/latex/stex/stex-ide.tex b/Master/texmf-dist/doc/latex/stex/stex-ide.tex deleted file mode 100644 index a563d277fbd..00000000000 --- a/Master/texmf-dist/doc/latex/stex/stex-ide.tex +++ /dev/null @@ -1,155 +0,0 @@ -\ifcsname ifinfulldoc\endcsname\else - \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse -\fi -\ifcsname ifinidedoc\endcsname\else - \expandafter\newif\csname ifinidedoc\endcsname\inidedoctrue -\fi - -\ifinidedoc -\input{stex-docheader} - - -\begin{document} - - \title{ - The {\stex} VSCode IDE - \thanks{Version {\fileversion} (last revised {\filedate})} - } - \author{Michael Kohlhase, Dennis Müller\\ - FAU Erlangen-Nürnberg\\ - \url{http://kwarc.info/} - } - \pagenumbering{roman} - \maketitle - - This is the user manual for the \sTeX Plugin for VSCode, available at - \url{https://marketplace.visualstudio.com/items?itemName=kwarc.stexide}. - For the manual for the \sTeX package itself, see \href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}. - - \makeatletter - \renewcommand\part{% - \clearpage - \thispagestyle{plain}% - \@tempswafalse - \null\vfil - \secdef\@part\@spart% - } - \newcounter{chapter} - \numberwithin{section}{chapter} - \renewcommand\thechapter{\@arabic\c@chapter} - \renewcommand\thesection{\thechapter.\@arabic\c@section} - \newcommand*\chaptermark[1]{} - \setcounter{secnumdepth}{2} - \newcommand\@chapapp{\chaptername} - %\newcommand\chaptername{Chapter} - \def\ps@headings{% - \let\@oddfoot\@empty - \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% - \let\@mkboth\markboth - \def\chaptermark##1{% - \markright{\MakeUppercase{% - \ifnum \c@secnumdepth >\m@ne - \@chapapp\ \thechapter. \ % - \fi - ##1}}% - }% - } - \newcommand\chapter{\clearpage - \thispagestyle{plain}% - \global\@topnum\z@ - \@afterindentfalse - \secdef\@chapter\@schapter% - } - \def\@chapter[#1]#2{\refstepcounter{chapter}% - \typeout{\@chapapp\space\thechapter.}% - \addcontentsline{toc}{chapter}% - {\protect\numberline{\thechapter}#1}% - \chaptermark{#1}% - \addtocontents{lof}{\protect\addvspace{10\p@}}% - \addtocontents{lot}{\protect\addvspace{10\p@}}% - \@makechapterhead{#2}% - \@afterheading% - } - \def\@makechapterhead#1{% - \vspace*{50\p@}% - {\parindent \z@ \raggedright \normalfont - \huge\bfseries \@chapapp\space \thechapter - \par\nobreak - \vskip 20\p@ - \interlinepenalty\@M - \Huge \bfseries #1\par\nobreak - \vskip 40\p@ - }% - } -\newcommand*\l@chapter[2]{% - \ifnum \c@tocdepth >\m@ne - \addpenalty{-\@highpenalty}% - \vskip 1.0em \@plus\p@ - \setlength\@tempdima{1.5em}% - \begingroup - \parindent \z@ \rightskip \@pnumwidth - \parfillskip -\@pnumwidth - \leavevmode \bfseries - \advance\leftskip\@tempdima - \hskip -\leftskip - #1\nobreak\hfil - \nobreak\hb@xt@\@pnumwidth{\hss #2% - \kern-\p@\kern\p@}\par - \penalty\@highpenalty - \endgroup - \fi} -\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}} -\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} -\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} -\def\partname{Part} -\def\toclevel@part{-1} -\def\maketitle{\chapter{\@title}} -\let\thanks\@gobble -\let\DelayPrintIndex\PrintIndex -\let\PrintIndex\@empty -\providecommand*{\hexnum}[1]{\text{\texttt{\char`\"}#1}} -\makeatother - -\ExplSyntaxOn -\int_set:Nn \l_document_structure_section_level_int {1} -\ExplSyntaxOff - -\clearpage - -{% - \def\\{:}% fix "newlines" in the ToC - \tableofcontents -} - -\clearpage -\pagenumbering{arabic} - -\long\def\ignore#1{} - -\input{packages/stex-setup} -\input{packages/stex-idesetup} - -\fi - - - - -\ifinidedoc -\newpage -\printbibliography -\end{document} -\fi - - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: t -%%% End: - -% LocalWords: stex-docheader infulldoctrue l@subsubsection toclevel@part ExplSyntaxOff -% LocalWords: l_document_structure_section_level_int dangerbox mmtbox omdoc OBJref lmh -% LocalWords: own:fifom MueRabRot:rslffml20 sec.stexarchives stex-mathhub ngerman a,b -% LocalWords: Metatheory sec.customhighlight sproof stexthm xspace stexpatchmodule -% LocalWords: stexpatchexample stexpatchparagraph sexampleid amsthm sassertiontitle -% LocalWords: sdefinitiontitle compemph varemph srefsymuri stex-hwexam TeXLive:on tlmgr -% LocalWords: stexls:on,stexls-vscode-plugin:on diff --git a/Master/texmf-dist/doc/latex/stex/stex-manual.pdf b/Master/texmf-dist/doc/latex/stex/stex-manual.pdf Binary files differindex 2facc41ad11..dcc5371fada 100644 --- a/Master/texmf-dist/doc/latex/stex/stex-manual.pdf +++ b/Master/texmf-dist/doc/latex/stex/stex-manual.pdf diff --git a/Master/texmf-dist/doc/latex/stex/stex-manual.tex b/Master/texmf-dist/doc/latex/stex/stex-manual.tex deleted file mode 100644 index 547e238f540..00000000000 --- a/Master/texmf-dist/doc/latex/stex/stex-manual.tex +++ /dev/null @@ -1,563 +0,0 @@ - -\ifcsname ifinfulldoc\endcsname\else - \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse -\fi -\ifcsname ifinidedoc\endcsname\else - \expandafter\newif\csname ifinidedoc\endcsname\inidedocfalse -\fi - -\ifinfulldoc\else - \input{stex-docheader} - -\begin{document} - \title{ - The {\stex{3}} Manual - \thanks{Version {\fileversion} (last revised {\filedate})} - } - \author{Michael Kohlhase, Dennis Müller\\ - FAU Erlangen-Nürnberg\\ - \url{http://kwarc.info/} - } - \pagenumbering{roman} - \maketitle - - \input{stex-abstract}\bigskip - - This is the user manual for the \sTeX package and - associated software. It is primarily directed at end-users - who want to use \sTeX to author semantically - enriched documents. For the full documentation, see - \href{\basedocurl/stex-doc.pdf}{the \sTeX documentation}. - - \makeatletter - \renewcommand\part{% - \clearpage - \thispagestyle{plain}% - \@tempswafalse - \null\vfil - \secdef\@part\@spart% - } - \newcounter{chapter} - \numberwithin{section}{chapter} - \renewcommand\thechapter{\@arabic\c@chapter} - \renewcommand\thesection{\thechapter.\@arabic\c@section} - \newcommand*\chaptermark[1]{} - \setcounter{secnumdepth}{2} - \newcommand\@chapapp{\chaptername} - %\newcommand\chaptername{Chapter} - \def\ps@headings{% - \let\@oddfoot\@empty - \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% - \let\@mkboth\markboth - \def\chaptermark##1{% - \markright{\MakeUppercase{% - \ifnum \c@secnumdepth >\m@ne - \@chapapp\ \thechapter. \ % - \fi - ##1}}% - }% - } - \newcommand\chapter{\clearpage - \thispagestyle{plain}% - \global\@topnum\z@ - \@afterindentfalse - \secdef\@chapter\@schapter% - } - \def\@chapter[#1]#2{\refstepcounter{chapter}% - \typeout{\@chapapp\space\thechapter.}% - \addcontentsline{toc}{chapter}% - {\protect\numberline{\thechapter}#1}% - \chaptermark{#1}% - \addtocontents{lof}{\protect\addvspace{10\p@}}% - \addtocontents{lot}{\protect\addvspace{10\p@}}% - \@makechapterhead{#2}% - \@afterheading% - } - \def\@makechapterhead#1{% - \vspace*{50\p@}% - {\parindent \z@ \raggedright \normalfont - \huge\bfseries \@chapapp\space \thechapter - \par\nobreak - \vskip 20\p@ - \interlinepenalty\@M - \Huge \bfseries #1\par\nobreak - \vskip 40\p@ - }% - } -\newcommand*\l@chapter[2]{% - \ifnum \c@tocdepth >\m@ne - \addpenalty{-\@highpenalty}% - \vskip 1.0em \@plus\p@ - \setlength\@tempdima{1.5em}% - \begingroup - \parindent \z@ \rightskip \@pnumwidth - \parfillskip -\@pnumwidth - \leavevmode \bfseries - \advance\leftskip\@tempdima - \hskip -\leftskip - #1\nobreak\hfil - \nobreak\hb@xt@\@pnumwidth{\hss #2% - \kern-\p@\kern\p@}\par - \penalty\@highpenalty - \endgroup - \fi} -\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}} -\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} -\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} -\def\partname{Part} -\def\toclevel@part{-1} -\def\maketitle{\chapter{\@title}} -\let\thanks\@gobble -\let\DelayPrintIndex\PrintIndex -\let\PrintIndex\@empty -\providecommand*{\hexnum}[1]{\text{\texttt{\char`\"}#1}} -\makeatother - -\ExplSyntaxOn -\int_set:Nn \l_document_structure_section_level_int {1} -\ExplSyntaxOff - -\clearpage - -{% - \def\\{:}% fix "newlines" in the ToC - \tableofcontents -} - -\clearpage -\pagenumbering{arabic} - -\fi - -\long\def\ignore#1{} - -\begin{dangerbox} - Boxes like this one contain implementation details that are - mostly relevant for more advanced use cases, might be useful - to know when debugging, or might be good to know to better understand - how something works. They can easily be skipped on a first read. -\end{dangerbox} - -\begin{mmtbox} - Boxes like this one explain how some \sTeX concept relates to the \mmt/\omdoc system, - philosophy or language; see \cite{uniformal:on,Kohlhase:OMDoc1.2} for introductions. -\end{mmtbox} - - -\begin{sfragment}{What is \sTeX?} - -Formal systems for mathematics (such as interactive theorem provers) -have the potential to significantly increase both the accessibility -of published knowledge, as well as the confidence in its veracity, -by rendering the precise semantics of statements machine actionable. -This allows for a plurality of added-value services, from semantic -search up to verification and automated theorem proving. -Unfortunately, their usefulness is hidden behind severe barriers -to accessibility; primarily related to their surface languages -reminiscent of programming languages and very unlike informal -standards of presentation. - -\sTeX minimizes this gap between informal and formal -mathematics by integrating formal methods into established -and widespread authoring workflows, primarily \LaTeX, via -non-intrusive semantic -annotations of arbitrary informal document fragments. That way -formal knowledge management services become available for informal -documents, accessible via an IDE for authors and via generated -\emph{active} documents for readers, while remaining fully compatible -with existing authoring workflows and publishing systems. - -Additionally, an extensible library of reusable -document fragments is being developed, that serve as reference targets -for global disambiguation, intermediaries for content exchange -between systems and other services. - -Every component of the system is designed modularly and extensibly, -and thus lay the groundwork for a potential full integration of -interactive theorem proving systems into established informal document -authoring workflows. - -\paragraph{} The general \sTeX workflow combines functionalities -provided by several pieces of software: -\begin{itemize} -\item The \sTeX package collection to use semantic annotations in {\LaTeX} documents, -\item \RusTeX \cite{RusTeX:on} to convert |tex| sources to (semantically enriched) |xhtml|, -\item The \mmt system~\cite{uniformal:on}, that extracts semantic information from the - thus generated |xhtml| and provides semantically informed added value services. - Notably, \mmt integrates the \RusTeX system already. -\end{itemize} - -\end{sfragment} - -\begin{sfragment}{Setup} - There are two ways of using \sTeX: as a - \begin{enumerate} - \item way of writing {\LaTeX} more modularly (object-oriented Math) for creating PDF - documents or - \item foundation for authoring active documents in HTML5 instrumented with knowledge - management services. - \end{enumerate} - Both are legitimate and useful. The first requires a significantly smaller - tool-chain, so we describe it first. The second requires a much more substantial - toolchain of knowledge management systems. - - Luckily, the \sTeX-IDE will take care of much of the setup required - for the full toolchain, if you are willing to use it. - - \input{packages/stex-setup} - - \input{packages/stex-idesetup} - - \begin{sfragment}{Manual Setup} - - In lieu of using the \sTeX IDE, we can do the following: - - \begin{sfragment}[id=sec.stex-archives]{\sTeX Archives (Manual Setup)} - Writing semantically annotated \sTeX becomes much easier, if we can use - well-designed libraries of already annotated content. \sTeX provides such - libraries as \sTeX archives -- i.e. GIT repositories at - \url{https://gl.mathhub.info} -- most prominently the SMGLoM libraries at - \url{https://gl.mathhub.info/smglom}. - - To do so, we set up a \textbf{local MathHub} by creating a MathHub directory - \lstinline|<mhdir>|. Every \sTeX archive as an \textbf{archive path} - \lstinline|<apath>| and a name \lstinline|<archive>|. We can clone the \sTeX - archive by the following command-line instructions: -\begin{lstlisting}[language=bash] -cd <mhdir>/<apath> -git clone https://gl.mathhub.info/smglom/<archive>.git -\end{lstlisting} - Note that \sTeX archives often depend on other archives, thus you should be - prepared to clone these as well -- e.g. if \texttt{pdflatex} reports missing - files. - To make sure that \sTeX too knows where to find its archives, we need to set a global - system variable |MATHHUB|, that points to your local |MathHub|-directory (see - \sref{sec.stexarchives}). -\begin{lstlisting}[language=bash] -export MATHHUB="<mhdir>" -\end{lstlisting} - \end{sfragment} - - \begin{sfragment}{Manual Setup for Active Documents and Knowledge Management Services} - Foregoing on the \sTeX IDE, we will need several additional (on top of the minimal - setup above) pieces of software; namely: - \begin{itemize} - \item \textbf{The \mmt System} available - \href{https://github.com/uniformal/MMT/tree/sTeX}{here}. - We recommend following - the setup routine documented - \href{https://uniformal.github.io//doc/setup/}{here}. - - Following the setup routine (Step 3) will entail designating - a |MathHub|-directory on your local file system, where - the \mmt system will look for \sTeX/\mmt content archives. - - \item \textbf{\sTeX Archives} If we only care about {\LaTeX} and generating - |pdf|s, we do not technically need \mmt at all; however, we still need the - |MATHHUB| system variable to be set. Furthermore, \mmt can make downloading - content archives we might want to use significantly easier, since it makes sure - that all dependencies of (often highly interrelated) \sTeX archives are cloned - as well. - - Once set up, we can run |mmt| in a shell and download an archive along with all - of its dependencies like this: |lmh install <name-of-repository>|, or a whole - \emph{group} of archives; for example, |lmh install smglom| will download all - smglom archives. - \item \textbf{\RusTeX} The \mmt system will also set up \RusTeX for you, which is - used to generate (semantically annotated) |xhtml| from tex sources. In lieu of - using \mmt, you can also download and use \RusTeX directly - \href{https://github.com/slatex/RusTeX}{here}. - \end{itemize} - \end{sfragment} - \end{sfragment} -\end{sfragment} - -\begin{sfragment}[id=sec.sTeX-IDE]{The \sTeX IDE} - \input{stex-ide} -\end{sfragment} - -\input{stex-tutorial} - - -\begin{sfragment}{Creating \sTeX Content} - - \input{packages/stex-basics} - - \begin{sfragment}{How Knowledge is Organized in \sTeX} - - \sTeX content is organized on multiple levels: - \begin{enumerate} - \item \sTeX \textbf{archives} (see \sref{sec.stexarchives}) - contain individual |.tex|-files. - \item These may contain \sTeX \textbf{modules}, introduced via - \stexcode"\begin{smodule}{ModuleName}".\iffalse\end{smodule}\fi - \item Modules contain \sTeX \textbf{symbol declarations}, introduced via - \stexcode"\symdecl{symbolname}", \stexcode"\symdef{symbolname}" and some other - constructions. Most symbols have a \emph{notation} that can - be used via a \emph{semantic macro} \stexcode"\symbolname" generated - by symbol declarations. - \item \sTeX \textbf{expressions} finally are built up from - usages of semantic macros. - \end{enumerate} - - \begin{mmtbox} - \begin{itemize} - \item \sTeX archives are simultaneously \mmt archives, and the same directory - structure is consequently used. - \item \sTeX modules correspond to \omdoc/\mmt \emph{theories}. - \stexcode"\importmodule"s (and similar constructions) induce \mmt |include|s and - other \emph{theory morphisms}, thus giving rise to a \emph{theory graph} in the - \omdoc sense~\cite{RabKoh:WSMSML13}. - \item Symbol declarations induce \omdoc/\mmt \emph{constants}, with optional - (formal) \emph{type} and \emph{definiens} components. - \item Finally, \sTeX expressions are converted to \omdoc/\mmt terms, which use the - abstract syntax (and XML encoding) of \openmath \cite{BusCapCar:2oms04}. - \end{itemize} - \end{mmtbox} - \end{sfragment} - - \begin{sfragment}[id=sec.stexarchives]{\sTeX Archives} - \input{packages/stex-mathhub} - \end{sfragment} - - \begin{sfragment}[id=sec.decls]{Module, Symbol and Notation Declarations} - \input{packages/stex-modules} - \input{packages/stex-symbols} - \end{sfragment} - - \begin{sfragment}{Module Inheritance and Structures} - The \sTeX features for modular document management are inherited from the OMDoc/MMT - model that organizes knowledge into a graph, where the nodes are theories (called - modules in \sTeX) and the edges are truth-preserving mappings (called theory - morphismes in MMT). We have already seen modules/theories above. - - Before we get into theory morphisms in \sTeX we will see a very simple application of - modules: managing multilinguality modularly. - - \begin{sfragment}{Multilinguality and Translations} - - If we load the \sTeX document class or package with the option |lang=<lang>|, \sTeX - will load the appropriate \pkg{babel} language for you -- e.g. |lang=de| will load - the babel language |ngerman|. Additionally, it makes \sTeX aware of the current - document being set in (in this example) \emph{german}. This matters for reasons - other than mere \pkg{babel}-purposes, though: - - Every \emph{module} is assigned a language. If no \sTeX - package option is set that allows for inferring a language, - \sTeX will check whether the current file name ends in - e.g. |.en.tex| (or |.de.tex| or |.fr.tex|, or...) and - set the language accordingly. Alternatively, a language - can be explicitly assigned via - \stexcode"\begin{smodule}[lang=<language>]{Foo}". - \iffalse\end{smodule}\fi - - \begin{mmtbox} - Technically, each |smodule|-environment induces \emph{two} - \omdoc/\mmt theories: - \stexcode"\begin{smodule}[lang=<lang>]{Foo}" - \iffalse\end{smodule}\fi - generates a theory |some/namespace?Foo| that only contains - the ``formal'' part of the module -- i.e. exactly the - content that is exported when using \stexcode"\importmodule". - - Additionally, \mmt generates a \emph{language theory} - |some/namespace/Foo?<lang>| that includes |some/namespace?Foo| - and contains all the other document content -- variable - declarations, includes for each \stexcode"\usemodule", etc. - \end{mmtbox} - - Notably, the language suffix in a filename is ignored - for \stexcode"\usemodule", \stexcode"\importmodule" - and in generating/computing URIs for modules. This however - allows for providing \emph{translations} for modules - between languages without needing to duplicate content: - - If a module |Foo| exists in e.g. english in a file |Foo.en.tex|, - we can provide a file |Foo.de.tex| right next to it, and write - \stexcode"\begin{smodule}[sig=en]{Foo}". - \iffalse\end{smodule}\fi - The |sig|-key then signifies, that the ``signature'' of the - module is contained in the \emph{english} version of the module, - which is immediately imported from there, just like - \stexcode"\importmodule" would. - - Additionally to translating the informal content of a module - file to different languages, it also allows for customizing - notations between languages. For example, - the \emph{least common multiple} of two numbers is often - denoted as $\mathtt{lcm}(a,b)$ in english, but is - called \emph{kleinstes gemeinsames Vielfaches} in german - and consequently denoted as $\mathtt{kgV}(a,b)$ there. - - We can therefore imagine a german version of an lcm-module - looking something like this: - - \begin{latexcode}[gobble=8] - \begin{smodule}[sig=en]{lcm} - \notation*{lcm}[de]{\comp{\mathtt{kgV}}(#1,#2)} - - Das \symref{lcm}{kleinste gemeinsame Vielfache} - $\lcm{a,b}$ von zwei Zahlen $a,b$ ist... - \end{smodule} - \end{latexcode} - - If we now do \stexcode"\importmodule{lcm}" - (or \stexcode"\usemodule{lcm}") within a \emph{german} document, - it will also load the content of the german translation, - including the |de|-notation for \stexcode"\lcm". - - \end{sfragment} - - \input{packages/stex-inheritance} - \input{packages/stex-features} - \end{sfragment} - - \begin{sfragment}{Primitive Symbols (The \sTeX Metatheory)} - \input{packages/stex-metatheory} - \end{sfragment} - -\end{sfragment} - -\begin{sfragment}[id=sec.textsymbols]{Using \sTeX Symbols} - \input{packages/stex-terms} - \input{packages/stex-references} -\end{sfragment} - -\begin{sfragment}{\sTeX Statements} - \input{packages/stex-statements} - \input{packages/stex-proofs} - -\begin{sfragment}[id=sec.customhighlight]{Highlighting and Presentation Customizations} - - The environments starting with |s| (i.e. \stexcode"smodule", \stexcode"sassertion", - \stexcode"sexample", \stexcode"sdefinition", \stexcode"sparagraph" and - \stexcode"sproof") by default produce no additional output whatsoever (except for the - environment content of course). Instead, the document that uses them (whether directly - or e.g. via \stexcode"\inputref") can decide how these environments are supposed to look - like. - - The \pkg{stexthm} package defines some default customizations that can be used, but of - course many existing \LaTeX\xspace templates come with their own |definition|, |theorem| - and similar environments that authors are supposed (or even required) to use. Their - concrete syntax however is usually not compatible with all the additional arguments that - \sTeX allows for semantic information. - - Therefore we introduced the separate environments \stexcode"sdefinition" etc. instead of - using \stexcode"definition" directly. We allow authors to specify how these environments - should be styled via the commands \stexcode"stexpatch*". - - \begin{function}{\stexpatchmodule,\stexpatchdefinition, - \stexpatchassertion,\stexpatchexample,\stexpatchparagraph, - \stexpatchproof} - All of these commands take one optional and two proper arguments, i.e.\\ - \stexcode"\stexpatch*[<type>]{<begin-code>}{<end-code>}". - - After \stex reads and processes the optional arguments for these environments, (some - of) their values are stored in the macros \stexcode"\s*<field>" - (i.e. \stexcode"sexampleid", \stexcode"\sassertionname", etc.). It then checks for all - the values |<type>| in the |type=|-list, whether an \stexcode"\stexpatch*[<type>]" for - the current environment has been called. If it finds one, it uses the patches - |<begin-code>| and |<end-code>| to mark up the current environment. If no patch for - (any of) the type(s) is found, it checks whether and \stexcode"\stexpatch*" was called - without optional argument. - \end{function} - - For example, if we want to use a predefined |theorem| environment for - \stexcode"sassertion"s with |type=theorem|, we can do -\begin{latexcode} -\stexpatchassertion[theorem]{\begin{theorem}}{\end{theorem}} -\end{latexcode} - ...or, rather, since e.g. |theorem|-like environments defined using \pkg{amsthm} take an - optional title as argument, we can do: -\begin{latexcode} -\stexpatchassertion[theorem] - {\ifx\sassertiontitle\@empty - \begin{theorem} - \else - \begin{theorem}[\sassertiontitle] - \fi} - {\end{theorem}} -\end{latexcode} - - Or, if we want \emph{all kinds of} \stexcode"sdefinition"s to use a predefined - |definition|-environment irrespective of their |type=|, then we can issue the following - customization patch: -\begin{latexcode} -\stexpatchdefinition - {\ifx\sdefinitiontitle\@empty - \begin{definition} - \else - \begin{definition}[\sdefinitiontitle] - \fi} - {\end{definition}} -\end{latexcode} - - \begin{function}{\compemph,\varemph,\symrefemph,\defemph} - Apart from the environments, we can control how \sTeX highlights variables, notation - components, \stexcode"\symref"s and \stexcode"\definiendum"s, respectively. - - To do so, we simply redefine these four macros. For example, to highlight notation - components (i.e. everything in a \stexcode"\comp") in blue, as in this document, we - can do \stexcode"\def\compemph#1{\textcolor{blue}{#1}}". By default, |\compemph| et - al do nothing. - \end{function} - - \begin{function}{\compemph@uri,\varemph@uri,\symrefemph@uri,\defemph@uri} - For each of the four macros, there exists an additional macro that takes the full URI - of the relevant symbol currently being highlighted as a second argument. That allows - us to e.g. use pdf tooltips and links. For example, this document uses\Ednote{MK: why - |protected|, ... if we show that, then we should explain.} -\begin{latexcode} -\protected\def\symrefemph@uri#1#2{ - \pdftooltip{ - \symrefemph{#1} - }{ - URI:~\detokenize{#2} - } -} -\end{latexcode} - By default, |\compemph@uri| is simply defined as |\compemph{#1}| (analogously for the - other three commands). -\end{function} -\end{sfragment} -\end{sfragment} -\begin{sfragment}[id=sec.references]{Cross References} - \input{packages/stex-references} -\end{sfragment} - -\begin{sfragment}{Additional Packages} - \begin{sfragment}{Tikzinput: Treating TIKZ code as images} - \input{packages/stex-tikzinput} - \end{sfragment} - \begin{sfragment}{Modular Document Structuring} - \input{packages/stex-document-structure} - \end{sfragment} - \begin{sfragment}{Slides and Course Notes} - \input{packages/stex-notesslides} - \end{sfragment} - \begin{sfragment}{Representing Problems and Solutions} - \input{packages/stex-problem} - \end{sfragment} - \begin{sfragment}{Homeworks, Quizzes and Exams} - \input{packages/stex-hwexam} - \end{sfragment} -\end{sfragment} - -\ifinfulldoc\else -\newpage -\printbibliography -\end{document} -\fi - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: t -%%% End: - -% LocalWords: stex-docheader infulldoctrue l@subsubsection toclevel@part ExplSyntaxOff -% LocalWords: l_document_structure_section_level_int dangerbox mmtbox omdoc OBJref lmh -% LocalWords: own:fifom MueRabRot:rslffml20 sec.stexarchives stex-mathhub ngerman a,b -% LocalWords: Metatheory sec.customhighlight sproof stexthm xspace stexpatchmodule -% LocalWords: stexpatchexample stexpatchparagraph sexampleid amsthm sassertiontitle -% LocalWords: sdefinitiontitle compemph varemph srefsymuri stex-hwexam TeXLive:on tlmgr -% LocalWords: stexls:on,stexls-vscode-plugin:on diff --git a/Master/texmf-dist/doc/latex/stex/stex-tutorial.pdf b/Master/texmf-dist/doc/latex/stex/stex-tutorial.pdf Binary files differnew file mode 100644 index 00000000000..1c380faddef --- /dev/null +++ b/Master/texmf-dist/doc/latex/stex/stex-tutorial.pdf diff --git a/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex b/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex deleted file mode 100644 index 7b3b723826e..00000000000 --- a/Master/texmf-dist/doc/latex/stex/stex-tutorial.tex +++ /dev/null @@ -1,354 +0,0 @@ - \begin{sfragment}{A First \sTeX Document} - Having set everything up, we can write a first - \sTeX document. As an example, we will use the - |smglom/calculus| and |smglom/arithmetics| archives, - which should be present in the designated |MathHub|-folder, - and write a small fragment defining the \emph{geometric series}: - - % \textcolor{red}{TODO: use some sTeX-archive instead of smglom, - % use a convergence-notion that includes the limit, - % mark-up the theorem properly} - - \begin{framed}\begin{latexcode}[gobble=8] - \documentclass{article} - \usepackage{stex,xcolor,stexthm} - - \begin{document} - \begin{smodule}{GeometricSeries} - \importmodule[smglom/calculus]{series} - \importmodule[smglom/arithmetics]{realarith} - - \symdef{geometricSeries}[name=geometric-series]{\comp{S}} - - \begin{sdefinition}[for=geometricSeries] - The \definame{geometricSeries} is the \symname{series} - \[\defeq{\geometricSeries}{\definiens{ - \infinitesum{\svar{n}}{1}{ - \realdivide[frac]{1}{ - \realpower{2}{\svar{n}} - }} - }}.\] - \end{sdefinition} - - \begin{sassertion}[name=geometricSeriesConverges,type=theorem] - The \symname{geometricSeries} \symname{converges} towards $1$. - \end{sassertion} - \end{smodule} - \end{document} - \end{latexcode}\end{framed} - - Compiling this document with |pdflatex| should yield - the output - - \begin{mdframed} - \noindent\textbf{Definition 0.1. }\ The - \pdftooltip{\textcolor{blue}{\textbf{geometric series}}}{URI: file://your/file/name/here?GeometricSeries?geometric-series} - is the - \pdftooltip{\textcolor{blue}{series}}{URI: http://mathhub.info/smglom/calculus?series?series} - \[ - \pdftooltip{\textcolor{blue}S}{URI: file://your/file/name/here?GeometricSeries?geometric-series} - \pdftooltip{\textcolor{blue}{:=}}{URI: http://mathhub.info/smglom/mv?defeq?definitional-equation} - \mathop{\pdftooltip{\textcolor{blue}{\sum}}{URI: http://mathhub.info/smglom/calculus?series?infinitesum} - }_{ - \pdftooltip{\textcolor{gray}{n}}{Variable var://n}=1 - }^{ - \pdftooltip{\textcolor{blue}\infty}{URI: http://mathhub.info/smglom/calculus?series?infinitesum} - } \frac{1}{2^{\pdftooltip{\textcolor{gray}{n}}{Variable var://n}}} - .\] - \noindent\textbf{Theorem 0.2. }\ The - \pdftooltip{\textcolor{blue}{geometric series}}{URI: file://your/file/name/here?GeometricSeries?geometric-series} - \pdftooltip{\textcolor{blue}{converges}}{URI: http://mathhub.info/smglom/calculus?sequenceConvergence?converges} towards $1$. - \end{mdframed} - - Move your cursor over the various highlighted parts of the document -- depending on - your pdf viewer, this should yield some interesting (but possibly for now cryptic) - information. - - \begin{sparagraph}[type=remark] - Note that all of the highlighting, tooltips, coloring and the environment headers - come from \pkg{stexthm} -- by default, the amount of additional packages loaded - is kept to a minimum and all the presentations can be customized, - see \sref{sec.customhighlight}. - \end{sparagraph} - - Let's investigate this document in detail to understand the respective parts of the - \sTeX markup infrastructure:\bigskip - - \begin{environment}{smodule} - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=8] - \begin{smodule}{GeometricSeries} - ... - \end{smodule} - \end{latexcode} - First, we open a new \emph{module} called |GeometricSeries|. The main purpose of - the |smodule| environment is to group the contents and associate it with a - \emph{globally unique} identifier (URI), which is computed from the name - |GeometricSeries| and the document context. - - (Depending on your pdf viewer), the URI should pop up in a tooltip if you hover over - the word \pdftooltip{\textcolor{blue}{\textbf{geometric series}}}{URI: - file://your/file/name/here?GeometricSeries?geometric-series}. - \end{environment}\bigskip - - \begin{function}{\importmodule} - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=8] - \importmodule[smglom/calculus]{series} - \importmodule[smglom/arithmetics]{realarith} - \end{latexcode} - Next, we \emph{import} two modules -- |series| from the \sTeX archive - |smglom/calculus|, and |realarith| from the \sTeX archive |smglom/arithmetics|. If - we investigate these archives, we find the files |series.en.tex| and - |realarith.en.tex| (respectively) in their respective |source|-folders, which - contain the statements \stexcode"\begin{smodule}{series}" and - \stexcode"\begin{smodule}{realarith}" (respectively). - \iffalse\end{smodule}\end{smodule}\fi - - The \stexcode"\importmodule"-statements make all \stex symbols and associated - semantic macros (e.g. \stexcode"\infinitesum", \stexcode"\realdivide", - \stexcode"\realpower") in the imported module available to the current module - |GeometricSeries|. The module |GeometricSeries| ``exports'' all of these symbols to - all modules imports it via an \stexcode"\importmodule{GeometricSeries}" - instruction. Additionally it exports the local symbol \stexcode"\geometricSeries". - \end{function} - - \begin{function}{\usemodule} - If we only want to \emph{use} the content of some module |Foo|, - e.g. in remarks or examples, but none - of the symbols in our current module actually \emph{depend} on - the content of |Foo|, we can use \stexcode"\usemodule" instead -- like - \stexcode"\importmodule", this will make the module content available, - but will \emph{not} export it to other modules. - \end{function}\bigskip - - \begin{function}{\symdef} - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=6] - \symdef{GeometricSeries}[name=geometric-series]{\comp{S}} - \end{latexcode} - Next, we introduce a new \emph{symbol} with name - |geometric-series| and assign it the semantic macro - \stexcode"\geometricSeries". - \stexcode"\symdef" also immediately assigns this symbol a \emph{notation}, - namely $S$. - \end{function} - - \begin{function}{\comp} - The macro \stexcode"\comp" marks the $S$ in the notation as a - \emph{notational component}, as opposed to e.g. arguments - to \stexcode"\geometricSeries". - It is the notational components that get highlighted - and associated with the corresponding symbol (i.e. in this - case |geometricSeries|). Since \stexcode"\geometricSeries" takes - no arguments, we can wrap the whole notation in a \stexcode"\comp". - \end{function}\bigskip - - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=8] - \begin{sdefinition}[for=geometricSeries] - ... - \end{sdefinition} - \begin{sassertion}[name=geometricSeriesConverges,type=theorem] - ... - \end{sassertion} - \end{latexcode} - What follows are two \sTeX-\emph{statements} (e.g. definitions, - theorems, examples, proofs, ...). These are semantically marked-up - variants of the usual environments, which take additional optional - arguments (e.g. |for=|, |type=|, |name=|). Since many \LaTeX\xspace templates - predefine environments like |definition| or |theorem| with - different syntax, we use \stexcode"sdefinition", - \stexcode"sassertion", \stexcode"sexample" - etc. instead. You can customize these environments to e.g. - simply wrap around some predefined |theorem|-environment. - That way, we can still use \stexcode"sassertion" to provide semantic - information, while being fully compatible with (and using - the document presentation of) predefined environments. - - In our case, the \pkg{stexthm}-package patches - e.g. \stexcode"\begin{sassertion}[type=theorem]" to use - a |theorem|-environment defined (as usual) using the \pkg{amsthm} package. - \bigskip \iffalse \end{sassertion}\fi - - \begin{function}{\symname} - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=6] - ... is the \symname{?series} - \end{latexcode} - The \stexcode"\symname"-command prints the name of a symbol, - highlights it (based on customizable settings) - and associates the text printed with the corresponding - symbol. - - Note that the argument of \stexcode"\symref" can be - an imported symbol - (here the |series| symbol is imported from the |series| module). \sTeX tries to - determine the full symbol URI from the argument. If there are name clashes in or - with the imported symbols, the name of the exporting module can be prepended to the - symbol name before the |?| character. - - If you hover over the word - \pdftooltip{\textcolor{blue}{series}}{URI: http://mathhub.info/smglom/calculus?series?series} - in the pdf output, you should see a tooltip showing the full URI - of the symbol used. - \end{function} - \begin{function}{\symref} - The \stexcode"\symname"-command is a special case of the more general - \stexcode"\symref"-command, which allows customizing the precise text associated - with a symbol. \stexcode"\symref" takes two arguments: the first ist the symbol - name (or macro name), and the second a variant verbalization of the symbol, e.g. an inflection - variant, a different language or a synonym. In our example - \stexcode"\symname{?series}" abbreviates \stexcode|\symref{?series}{series}|. - - \end{function} - \begin{function}{\definame,\definiendum} - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=6] - The \definame{geometricSeries} ... - \end{latexcode} - The \stexcode"sdefinition"-environment provides two additional - macros, \stexcode"\definame" and \stexcode"\definiendum" which behave - similarly to \stexcode"\symname" and \stexcode"\symref", but explicitly mark - the symbols as \emph{being defined} in this environment, - to allow for special highlighting. - \end{function}\bigskip - - \begin{latexcode}[numbers=none,aboveskip=0pt,belowskip=0pt,gobble=8] - \[\defeq{\geometricSeries}{\definiens{ - \infinitesum{\svar{n}}{1}{ - \realdivide[frac]{1}{ - \realpower{2}{\svar{n}} - }} - }}.\] - \end{latexcode} - The next snippet -- set in a math environment -- uses - several semantic macros imported from (or recursively via) - |series| and |realarithmetics|, such as \stexcode"\defeq", - \stexcode"\infinitesum", - etc. In math mode, using a semantic macro inserts its (default) - definition. A semantic macro can have several notations -- in - that case, we can explicitly choose a specific notation by - providing its identifier as an optional argument; e.g. - \stexcode"\realdivide[frac]{a}{b}" will use the explicit notation named |frac| - of the semantic macro \stexcode"\realdivide", which yields $\frac ab$ - instead of $a/b$. - \begin{function}{\svar} - The \stexcode"\svar{n}" command marks up the |n| as a variable - with name |n| and notation |n|. - \end{function} - \begin{function}{\definiens} - The \stexcode"sdefinition"-environment additionally provides the - \stexcode"\definiens"-command, which allows for explicitly - marking up its argument as the \emph{definiens} of the - symbol currently being defined. - \end{function} - - \begin{sfragment}{\omdoc/xhtml Conversion} - So, if we run |pdflatex| on our document, then \sTeX yields pretty colors and - tooltips\footnote{...and hyperlinks for symbols, and indices, and allows reusing - document fragments modularly, and...}. But \sTeX becomes a lot more powerful if - we additionally convert our document to |xhtml| while preserving all the \sTeX - markup in the result. - - \textcolor{red}{TODO VSCode Plugin} - - Using \rustex \cite{RusTeX:on}, we can convert the document to |xhtml| - using the command |rustex -i /path/to/file.tex -o /path/to/outfile.xhtml|. - Investigating the resulting file, we notice additional semantic - information resulting from our usage of semantic macros, - \stexcode"\symref" etc. Below is the (abbreviated) snippet inside - our \stexcode"\definiens" block: - -\begin{lstlisting}[escapechar=!, -morekeywords={property,resource,stex:comp,stex:arg,stex:OMA,stex:OMV}] -<mrow resource="" property="stex:definiens"> - <mrow resource="...?series?infinitesum" property="stex:OMBIND"> - <munderover displaystyle="true"> - <mo resource="...?series?infinitesum" property="stex:comp">!$\Sigma$!</mo> - <mrow> - <mrow resource="1" property="stex:arg"> - <mi resource="var://n" property="stex:OMV">n</mi> - </mrow> - <mo resource="...?series?infinitesum" property="stex:comp">=</mo> - <mi resource="2" property="stex:arg">1</mi> - </mrow> - <mi resource="...?series?infinitesum" property="stex:comp">!$\infty$!</mi> - </munderover> - <mrow resource="3" property="stex:arg"> - <mfrac resource="...?realarith?division#frac#" property="stex:OMA"> - <mi resource="1" property="stex:arg">1</mi> - <mrow resource="2" property="stex:arg"> - <msup resource="...realarith?exponentiation" property="stex:OMA"> - <mi resource="1" property="stex:arg">2</mi> - <mrow resource="2" property="stex:arg"> - <mi resource="var://n" property="stex:OMV">n</mi> - </mrow> - </msup> - </mrow> - </mfrac> - </mrow> - </mrow> -</mrow> - \end{lstlisting} - ...containing all the semantic information. The \mmt system - can extract from this the following \openmath snippet: - - \begin{lstlisting}[escapechar=!] -<OMBIND> - <OMID name="...?series?infinitesum"/> - <OMV name="n"/> - <OMLIT name="1"/> - <OMA> - <OMS name="...?realarith?division"/> - <OMLIT name="1"/> - <OMA> - <OMS name="...realarith?exponentiation"/> - <OMLIT name="2"/> - <OMV name="n"/> - </OMA> - </OMA> -</OMBIND> - \end{lstlisting} - ...giving us the full semantics of the snippet, allowing for - a plurality of knowledge management services -- in particular - when serving the |xhtml|. - - \begin{remark} - Note that the |html| when opened in a browser will - look slightly different than the |pdf| when it comes - to highlighting semantic content -- that is because - naturally |html| allows for much more powerful - features than |pdf| does. Consequently, the |html| - is intended to be served by a system like \mmt, - which can pick up on the semantic information and - offer much more powerful highlighting, linking - and similar features, and being customizable by - \emph{readers} rather than being prescribed by an author. - - Additionally, not all browsers (most notably Chrome) - support \mathml natively, and might require - additional external JavaScript libraries such as - MathJax to render mathematical formulas properly. - \end{remark} - \end{sfragment} - - - \begin{sfragment}{\mmt/\omdoc Conversion} - Another way to convert our document to \emph{actual} - \mmt/\omdoc is to put it in an \sTeX \textbf{archive} - (see \sref{sec.stexarchives}) and have \mmt take care of - everything. - - Assuming the above file is |source/demo.tex| in - an \sTeX archive |MyTest|, you can run \mmt and - do - |build MyTest stex-omdoc demo.tex| to convert the - document to both |xhtml| (which you will find in - |xhtml/demo.xhtml| in the archive) and formal - \mmt/\omdoc, which you can subsequently view in - the \mmt browser (see \url{https://uniformal.github.io//doc/applications/server.html#the-mmt-web-site} - for details). - \end{sfragment} -\end{sfragment} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "stex-manual" -%%% End: - -% LocalWords: coloring sec.customhighlight realarith infinitesum realarithmetics diff --git a/Master/texmf-dist/source/latex/stex/Makefile b/Master/texmf-dist/source/latex/stex/Makefile index c4af5ba15dc..b01a820b338 100644 --- a/Master/texmf-dist/source/latex/stex/Makefile +++ b/Master/texmf-dist/source/latex/stex/Makefile @@ -1,5 +1,24 @@ -# recurse into the directories. -MAKEDIRS = stex extensions +DTX = $(shell ls *.dtx) +DOC = $(DTX:%.dtx=%.pdf) +INS = stex.ins -all package doc: - @for d in $(MAKEDIRS); do (cd $$d && $(MAKE) -$(MAKEFLAGS) $@) || exit $$?; done +PDFLATEX = pdflatex -interaction=batchmode +TEXDIR = ../tex +TEXINPUTS = $(TEXDIR)//: + +all: package doc + +doc: $(DOC) + +package: $(DTX) $(INS) + $(PDFLATEX) $(INS) + mv *.sty *.cls $(TEXDIR) + +$(DOC): %.pdf: %.dtx + $(PDFLATEX) $< + biber -q $(basename $<) + makeindex -s gind.ist -o $(basename $<).ind $(basename $<).idx + $(PDFLATEX) $< + +echo: + @echo $(TEXINPUTS) diff --git a/Master/texmf-dist/source/latex/stex/extensions/Makefile b/Master/texmf-dist/source/latex/stex/extensions/Makefile deleted file mode 100644 index 67f13569539..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -DTX = $(shell ls *.dtx) -DOC = $(DTX:%.dtx=%.pdf) -INS = stex-extensions.ins - -PDFLATEX = pdflatex -interaction=batchmode -TEXDIR = ../../tex -TEXINPUTS = $(TEXDIR)//: - -all: package doc - -doc: $(DOC) - -package: $(DTX) $(INS) - $(PDFLATEX) $(INS) - mv *.sty *.cls $(TEXDIR) - -$(DOC): %.pdf: %.dtx - $(PDFLATEX) $< - biber -q $(basename $<) - $(PDFLATEX) $< - - -echo: - @echo $(DTX) diff --git a/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx b/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx deleted file mode 100644 index a73e0fd8561..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/document-structure.dtx +++ /dev/null @@ -1,513 +0,0 @@ -% \iffalse meta-comment -% A LaTeX Class and Package for OMDoc Document Structures -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{document-structure: Semantic Markup for Open Mathematical Documents in {\LaTeX} -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -% \ifinfulldoc\else -% \begin{abstract} -% This is the documentation for the \pkg{document-structure} package from \sTeX -% collection, a version of {\TeX/\LaTeX} that allows to markup {\TeX/\LaTeX} documents -% semantically without leaving the document format, essentially turning {\TeX/\LaTeX} -% into a document format for mathematical knowledge management (MKM). -% -% For a more high-level introduction, see \href{\basedocurl/manual.pdf}{the \sTeX -% Manual} or the \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \end{abstract} -% -% \tableofcontents -% -% \begin{documentation}\label{pkg:documentstructure:doc} -% \begin{sfragment}{The User Interface} -% \input{../../doc/packages/stex-document-structure} -% \end{sfragment} -% \end{documentation} -% -% \fi -% -% \begin{implementation}\label{pkg:documentstructure:impl} -% -% \begin{sfragment}{document-structure.sty Implementation} -% -% \begin{macrocode} -%<*package> -%<@@=document_structure> -\ProvidesExplPackage{document-structure}{2022/09/14}{3.2.0}{Modular Document Structure} -\RequirePackage{l3keys2e} -% \end{macrocode} -% -% \begin{sfragment}[id=sec:impl:options]{Package Options} -% -% We declare some switches which will modify the behavior according to the package -% options. Generally, an option |xxx| will just set the appropriate switches to true -% (otherwise they stay false). -% -% -% \begin{macrocode} - -\keys_define:nn{ document-structure }{ - class .str_set_x:N = \c_document_structure_class_str, - topsect .str_set_x:N = \c_document_structure_topsect_str, - unknown .code:n = { - \PassOptionsToClass{\CurrentOption}{stex} - \PassOptionsToClass{\CurrentOption}{tikzinput} - } -% showignores .bool_set:N = \c_document_structure_showignores_bool, -} -\ProcessKeysOptions{ document-structure } -\str_if_empty:NT \c_document_structure_class_str { - \str_set:Nn \c_document_structure_class_str {article} -} -\str_if_empty:NT \c_document_structure_topsect_str { - \str_set:Nn \c_document_structure_topsect_str {section} -} -% \end{macrocode} -% -% Then we need to set up the packages by requiring the |sref| package to be loaded, -% and set up triggers for other languages -% -% \begin{macrocode} -\RequirePackage{xspace} -\RequirePackage{comment} -\RequirePackage{stex} -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{babel}{ - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ - \makeatletter\input{document-structure-ngerman.ldf}\makeatother - } - }{} -} -% \end{macrocode} -% -% Finally, we set the \DescribeMacro{\section@level}|\section@level| macro that governs -% sectioning. The default is two (corresponding to the |article| class), then we set the -% defaults for the standard classes |book| and |report| and then we take care of the -% levels passed in via the |topsect| option. -% -% \begin{macrocode} -\int_new:N \l_document_structure_section_level_int -\str_case:VnF \c_document_structure_topsect_str { - {part}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - {chapter}{ - \int_set:Nn \l_document_structure_section_level_int {1} - } -}{ - \str_case:VnF \c_document_structure_class_str { - {book}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - {report}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - }{ - \int_set:Nn \l_document_structure_section_level_int {2} - } -} -% \end{macrocode} -% -% \end{sfragment} -% -% \begin{sfragment}[id=sec:impl:struct]{Document Structure} -% -% The structure of the document is given by the |sfragment| environment. The hierarchy -% is adjusted automatically according to the {\LaTeX} class in effect. -% \begin{macro}{\currentsectionlevel} -% For the |\currentsectionlevel| and |\Currentsectionlevel| macros we use an internal -% macro |\current@section@level| that only contains the keyword (no markup). We -% initialize it with ``document'' as a default. In the generated OMDoc, we only generate -% a text element of class |omdoc_currentsectionlevel|, wich will be instantiated by CSS -% later.\ednote{MK: we may have to experiment with the more powerful uppercasing macro -% from \texttt{mfirstuc.sty} once we internationalize.} -% \begin{macrocode} -\def\current@section@level{document}% -\newcommand\currentsectionlevel{\lowercase\expandafter{\current@section@level}\xspace}% -\newcommand\Currentsectionlevel{\expandafter\MakeUppercase\current@section@level\xspace}% -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\skipfragment} -% \begin{macrocode} -\cs_new_protected:Npn \skipfragment { - \ifcase\l_document_structure_section_level_int - \or\stepcounter{part} - \or\stepcounter{chapter} - \or\stepcounter{section} - \or\stepcounter{subsection} - \or\stepcounter{subsubsection} - \or\stepcounter{paragraph} - \or\stepcounter{subparagraph} - \fi -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{blindfragment} -% \begin{macrocode} -\newcommand\at@begin@blindsfragment[1]{} -\newenvironment{blindfragment} -{ - \int_incr:N\l_document_structure_section_level_int - \at@begin@blindsfragment\l_document_structure_section_level_int -}{} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\sfragment@nonum} -% convenience macro: |\sfragment@nonum{|\meta{level}|}{|\meta{title}|}| makes an unnumbered -% sectioning with title \meta{title} at level \meta{level}. -% \begin{macrocode} -\newcommand\sfragment@nonum[2]{ - \ifx\hyper@anchor\@undefined\else\phantomsection\fi - \addcontentsline{toc}{#1}{#2}\@nameuse{#1}*{#2} -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\sfragment@num} -% convenience macro: |\sfragment@nonum{|\meta{level}|}{|\meta{title}|}| makes numbered -% sectioning with title \meta{title} at level \meta{level}. We have to check the |short| -% key was given in the |sfragment| environment and -- if it is use it. But how to do that -% depends on whether the |rdfmeta| package has been loaded. In the end we call -% |\sref@label@id| to enable crossreferencing. -% \begin{macrocode} -\newcommand\sfragment@num[2]{ - \tl_if_empty:NTF \l_@@_sfragment_short_tl { - \@nameuse{#1}{#2} - }{ - \cs_if_exist:NTF\rdfmeta@sectioning{ - \@nameuse{rdfmeta@#1@old}[\l_@@_sfragment_short_tl]{#2} - }{ - \@nameuse{#1}[\l_@@_sfragment_short_tl]{#2} - } - } -%\sref@label@id@arg{\omdoc@sect@name~\@nameuse{the#1}}\sfragment@id -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{sfragment} -% \begin{macrocode} -\keys_define:nn { document-structure / sfragment }{ - id .str_set_x:N = \l_@@_sfragment_id_str, - date .str_set_x:N = \l_@@_sfragment_date_str, - creators .clist_set:N = \l_@@_sfragment_creators_clist, - contributors .clist_set:N = \l_@@_sfragment_contributors_clist, - srccite .tl_set:N = \l_@@_sfragment_srccite_tl, - type .tl_set:N = \l_@@_sfragment_type_tl, - short .tl_set:N = \l_@@_sfragment_short_tl, - intro .tl_set:N = \l_@@_sfragment_intro_tl, - imports .tl_set:N = \l_@@_sfragment_imports_tl, - loadmodules .bool_set:N = \l_@@_sfragment_loadmodules_bool -} -\cs_new_protected:Nn \_@@_sfragment_args:n { - \str_clear:N \l_@@_sfragment_id_str - \str_clear:N \l_@@_sfragment_date_str - \clist_clear:N \l_@@_sfragment_creators_clist - \clist_clear:N \l_@@_sfragment_contributors_clist - \tl_clear:N \l_@@_sfragment_srccite_tl - \tl_clear:N \l_@@_sfragment_type_tl - \tl_clear:N \l_@@_sfragment_short_tl - \tl_clear:N \l_@@_sfragment_imports_tl - \tl_clear:N \l_@@_sfragment_intro_tl - \bool_set_false:N \l_@@_sfragment_loadmodules_bool - \keys_set:nn { document-structure / sfragment } { #1 } -} -% \end{macrocode} -% we define a switch for numbering lines and a hook for the beginning of groups: The -% \DescribeMacro{\at@begin@sfragment}|\at@begin@sfragment| macro allows customization. It is -% run at the beginning of the |sfragment|, i.e. after the section heading. -% \begin{macrocode} -\newif\if@mainmatter\@mainmattertrue -\newcommand\at@begin@sfragment[3][]{} -% \end{macrocode} -% -% Then we define a helper macro that takes care of the sectioning magic. It comes with its -% own key/value interface for customization. -% -% \begin{macrocode} -\keys_define:nn { document-structure / sectioning }{ - name .str_set_x:N = \l_@@_sect_name_str , - ref .str_set_x:N = \l_@@_sect_ref_str , - clear .bool_set:N = \l_@@_sect_clear_bool , - clear .default:n = {true} , - num .bool_set:N = \l_@@_sect_num_bool , - num .default:n = {true} -} -\cs_new_protected:Nn \_@@_sect_args:n { - \str_clear:N \l_@@_sect_name_str - \str_clear:N \l_@@_sect_ref_str - \bool_set_false:N \l_@@_sect_clear_bool - \bool_set_false:N \l_@@_sect_num_bool - \keys_set:nn { document-structure / sectioning } { #1 } -} -\newcommand\omdoc@sectioning[3][]{ - \_@@_sect_args:n {#1 } - \let\omdoc@sect@name\l_@@_sect_name_str - \bool_if:NT \l_@@_sect_clear_bool { \cleardoublepage } - \if@mainmatter% numbering not overridden by frontmatter, etc. - \bool_if:NTF \l_@@_sect_num_bool { - \sfragment@num{#2}{#3} - }{ - \sfragment@nonum{#2}{#3} - } - \def\current@section@level{\omdoc@sect@name} - \else - \sfragment@nonum{#2}{#3} - \fi -}% if@mainmatter -% \end{macrocode} -% and another one, if redefines the |\addtocontentsline| macro of {\LaTeX} to import the -% respective macros. It takes as an argument a list of module names. -% \begin{macrocode} -\newcommand\sfragment@redefine@addtocontents[1]{% -%\edef\@@import{#1}% -%\@for\@I:=\@@import\do{% -%\edef\@path{\csname module@\@I @path\endcsname}% -%\@ifundefined{tf@toc}\relax% -% {\protected@write\tf@toc{}{\string\@requiremodules{\@path}}}} -%\ifx\hyper@anchor\@undefined% hyperref.sty loaded? -%\def\addcontentsline##1##2##3{% -%\addtocontents{##1}{\protect\contentsline{##2}{\string\withusedmodules{#1}{##3}}{\thepage}}} -%\else% hyperref.sty not loaded -%\def\addcontentsline##1##2##3{% -%\addtocontents{##1}{\protect\contentsline{##2}{\string\withusedmodules{#1}{##3}}{\thepage}{\@currentHref}}}% -%\fi -}% hypreref.sty loaded? -% \end{macrocode} -% now the |sfragment| environment itself. This takes care of the table of contents via the -% helper macro above and then selects the appropriate sectioning command from -% |article.cls|. It also registeres the current level of sfragments in the |\sfragment@level| -% counter. -% \begin{macrocode} -\newenvironment{sfragment}[2][]% keys, title -{ - \_@@_sfragment_args:n { #1 }%\sref@target% -% \end{macrocode} -% If the |loadmodules| key is set on |\begin{sfragment}|, we redefine the |\addcontetsline| -% macro that determines how the sectioning commands below construct the entries for the -% table of contents. -% \begin{macrocode} - \stex_csl_to_imports:No \usemodule \l_@@_sfragment_imports_tl - - \bool_if:NT \l_@@_sfragment_loadmodules_bool { - \sfragment@redefine@addtocontents{ - %\@ifundefined{module@id}\used@modules% - %{\@ifundefined{module@\module@id @path}{\used@modules}\module@id} - } - } -% \end{macrocode} -% now we only need to construct the right sectioning depending on the value of -% |\section@level|. -% \begin{macrocode} - - \stex_document_title:n { #2 } - - \int_incr:N\l_document_structure_section_level_int - \ifcase\l_document_structure_section_level_int - \or\omdoc@sectioning[name=\omdoc@part@kw,clear,num]{part}{#2} - \or\omdoc@sectioning[name=\omdoc@chapter@kw,clear,num]{chapter}{#2} - \or\omdoc@sectioning[name=\omdoc@section@kw,num]{section}{#2} - \or\omdoc@sectioning[name=\omdoc@subsection@kw,num]{subsection}{#2} - \or\omdoc@sectioning[name=\omdoc@subsubsection@kw,num]{subsubsection}{#2} - \or\omdoc@sectioning[name=\omdoc@paragraph@kw,ref=this \omdoc@paragraph@kw]{paragraph}{#2} - \or\omdoc@sectioning[name=\omdoc@subparagraph@kw,ref=this \omdoc@subparagraph@kw]{paragraph}{#2} - \fi - \at@begin@sfragment[#1]\l_document_structure_section_level_int{#2} - \str_if_empty:NF \l_@@_sfragment_id_str { - \stex_ref_new_doc_target:n\l_@@_sfragment_id_str - } -}% for customization -{} -% \end{macrocode} -% \end{environment} -% -% and finally, we localize the sections -% \begin{macrocode} -\newcommand\omdoc@part@kw{Part} -\newcommand\omdoc@chapter@kw{Chapter} -\newcommand\omdoc@section@kw{Section} -\newcommand\omdoc@subsection@kw{Subsection} -\newcommand\omdoc@subsubsection@kw{Subsubsection} -\newcommand\omdoc@paragraph@kw{paragraph} -\newcommand\omdoc@subparagraph@kw{subparagraph} -% \end{macrocode} -% -% \end{sfragment} -% -% \begin{sfragment}[id=sec:user:docmatter]{Front and Backmatter} -% -% Index markup is provided by the |omtext| package~\cite{Kohlhase:smmtf:git}, so in the -% |document-structure| package we only need to supply the corresponding |\printindex| command, if it -% is not already defined -% \begin{macro}{\printindex} -% \begin{macrocode} -\providecommand\printindex{\IfFileExists{\jobname.ind}{\input{\jobname.ind}}{}} -% \end{macrocode} -% \end{macro} -% -% some classes (e.g. |book.cls|) already have |\frontmatter|, |\mainmatter|, and -% |\backmatter| macros. As we want to define |frontmatter| and |backmatter| environments, -% we save their behavior (possibly defining it) in |orig@*matter| macros and make them -% undefined (so that we can define the environments). -% \begin{macrocode} -\cs_if_exist:NTF\frontmatter{ - \let\_@@_orig_frontmatter\frontmatter - \let\frontmatter\relax -}{ - \tl_set:Nn\_@@_orig_frontmatter{ - \clearpage - \@mainmatterfalse - \pagenumbering{roman} - } -} -\cs_if_exist:NTF\backmatter{ - \let\_@@_orig_backmatter\backmatter - \let\backmatter\relax -}{ - \tl_set:Nn\_@@_orig_backmatter{ - \clearpage - \@mainmatterfalse - \pagenumbering{roman} - } -} -% \end{macrocode} -% -% Using these, we can now define the |frontmatter| and |backmatter| environments -% -% \begin{environment}{frontmatter} -% we use the |\orig@frontmatter| macro defined above and |\mainmatter| if it exists, -% otherwise we define it. -% \begin{macrocode} -\newenvironment{frontmatter}{ - \_@@_orig_frontmatter -}{ - \cs_if_exist:NTF\mainmatter{ - \mainmatter - }{ - \clearpage - \@mainmattertrue - \pagenumbering{arabic} - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{backmatter} -% As backmatter is at the end of the document, we do nothing for |\endbackmatter|. -% \begin{macrocode} -\newenvironment{backmatter}{ - \_@@_orig_backmatter -}{ - \cs_if_exist:NTF\mainmatter{ - \mainmatter - }{ - \clearpage - \@mainmattertrue - \pagenumbering{arabic} - } -} -% \end{macrocode} -% -% finally, we make sure that page numbering is arabic and we have main matter as the default -% -% \begin{macrocode} -\@mainmattertrue\pagenumbering{arabic} -% \end{macrocode} -% \end{environment} -% \end{sfragment} -% -% \begin{macro}{\prematurestop} -% We initialize |\afterprematurestop|, and provide -% |\prematurestop@endsfragment| which looks up |\sfragment@level| and recursively ends -% enough |{sfragment}|s. -% \begin{macrocode} -\def \c_@@_document_str{document} -\newcommand\afterprematurestop{} -\def\prematurestop@endsfragment{ - \unless\ifx\@currenvir\c_@@_document_str - \expandafter\expandafter\expandafter\end\expandafter\expandafter\expandafter{\expandafter\@currenvir\expandafter} - \expandafter\prematurestop@endsfragment - \fi -} -\providecommand\prematurestop{ - \message{Stopping~sTeX~processing~prematurely} - \prematurestop@endsfragment - \afterprematurestop - \end{document} -} -% \end{macrocode} -% \end{macro} -% -% \begin{sfragment}[id=sec:impl:gvars]{Global Variables} -% -% \begin{macro}{\setSGvar} -% set a global variable -% \begin{macrocode} -\RequirePackage{etoolbox} -\newcommand\setSGvar[1]{\@namedef{sTeX@Gvar@#1}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\useSGvar} -% use a global variable -% \begin{macrocode} -\newrobustcmd\useSGvar[1]{% - \@ifundefined{sTeX@Gvar@#1} - {\PackageError{document-structure} - {The sTeX Global variable #1 is undefined} - {set it with \protect\setSGvar}} -\@nameuse{sTeX@Gvar@#1}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\ifSGvar} -% execute something conditionally based on the state of the global variable. -% \begin{macrocode} -\newrobustcmd\ifSGvar[3]{\def\@test{#2}% - \@ifundefined{sTeX@Gvar@#1} - {\PackageError{document-structure} - {The sTeX Global variable #1 is undefined} - {set it with \protect\setSGvar}} - {\expandafter\ifx\csname sTeX@Gvar@#1\endcsname\@test #3\fi}} -% \end{macrocode} -% \end{macro} -% -% \end{sfragment} -% \end{sfragment} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -\endinput - -%%% Local Variables: -%%% mode: doctex -%%% TeX-master: t -%%% End: diff --git a/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx b/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx deleted file mode 100644 index de3538d53f4..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/hwexam.dtx +++ /dev/null @@ -1,513 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for marking up Assignments -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% \fi -% -% \iffalse -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \GetFileInfo{hwexam.sty} -% -% \MakeShortVerb{\|} -% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}} -% \def\latexml{\scsys{LaTeXML}} -% -% \title{\texttt{hwexam.sty/cls}: An Infrastructure for formatting Assignments -% and Exams\thanks{Version {\fileversion} (last revised {\filedate})}} -% \author{Michael Kohlhase\\ -% FAU Erlangen-N\"urnberg\\ -% \url{http://kwarc.info/kohlhase}} -% \maketitle -% -% \begin{documentation} -%\ifinfulldoc\else -% -%\begin{abstract}{} -% The |hwexam| package and class allows individual course assignment sheets and compound -% assignment documents using problem files marked up with the |problem| package. -% -% This is the documentation for the \pkg{hwexam} package. For a more high-level -% introduction, see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \end{abstract} -% -% \tableofcontents -% \begin{sfragment}{The User Intterface} -% \input{../../doc/packages/stex-hwexam} -% \end{sfragment} -% \fi -% -% \end{documentation} -% -%\begin{implementation} -% -% \section{Implementation: The hwexam Package} -% -% \subsection{Package Options} -% -% The first step is to declare (a few) package options that handle whether certain -% information is printed or not. Some come with their own conditionals that are set by the -% options, the rest is just passed on to the |problems| package. -% -% \begin{macrocode} -%<*package> -\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams} -\RequirePackage{l3keys2e} - -\newif\iftest\testfalse -\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}} -\newif\ifmultiple\multiplefalse -\DeclareOption{multiple}{\multipletrue} -\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}} -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}} -\ProcessOptions -% \end{macrocode} -% Then we make sure that the necessary packages are loaded (in the right versions). -% \begin{macrocode} -\RequirePackage{keyval}[1997/11/10] -\RequirePackage{problem} -% \end{macrocode} -% -% \begin{macro}{\hwexam@*@kw} -% For multilinguality, we define internal macros for keywords that can be specialized in -% |*.ldf| files. -% \begin{macrocode} -\newcommand\hwexam@assignment@kw{Assignment} -\newcommand\hwexam@given@kw{Given} -\newcommand\hwexam@due@kw{Due} -\newcommand\hwexam@testemptypage@kw{This~page~was~intentionally~left~blank~for~extra~space} -\newcommand\hwexam@minutes@kw{minutes} -\newcommand\correction@probs@kw{prob.} -\newcommand\correction@pts@kw{total} -\newcommand\correction@reached@kw{reached} -\newcommand\correction@sum@kw{Sum} -\newcommand\correction@grade@kw{grade} -\newcommand\correction@forgrading@kw{To~be~used~for~grading,~do~not~write~here} -% \end{macrocode} -% \end{macro} -% -% For the other languages, we set up triggers -% \begin{macrocode} -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{babel}{ - \makeatletter - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ - \input{hwexam-ngerman.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ - \input{hwexam-finnish.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ - \input{hwexam-french.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ - \input{hwexam-russian.ldf} - } - \makeatother - }{} -} - -% \end{macrocode} -% \subsection{Assignments} -% -% Then we set up a counter for problems and make the problem counter inherited from -% |problem.sty| depend on it. Furthermore, we specialize the |\prob@label| macro to take -% the assignment counter into account. -% \begin{macrocode} -\newcounter{assignment} -%\numberproblemsin{assignment} -% \end{macrocode} -% -% We will prepare the keyval support for the |assignment| environment. -% -% \begin{macrocode} -\keys_define:nn { hwexam / assignment } { - id .str_set_x:N = \l_@@_assign_id_str, - number .int_set:N = \l_@@_assign_number_int, - title .tl_set:N = \l_@@_assign_title_tl, - type .tl_set:N = \l_@@_assign_type_tl, - given .tl_set:N = \l_@@_assign_given_tl, - due .tl_set:N = \l_@@_assign_due_tl, - loadmodules .code:n = { - \bool_set_true:N \l_@@_assign_loadmodules_bool - } -} -\cs_new_protected:Nn \_@@_assignment_args:n { - \str_clear:N \l_@@_assign_id_str - \int_set:Nn \l_@@_assign_number_int {-1} - \tl_clear:N \l_@@_assign_title_tl - \tl_clear:N \l_@@_assign_type_tl - \tl_clear:N \l_@@_assign_given_tl - \tl_clear:N \l_@@_assign_due_tl - \bool_set_false:N \l_@@_assign_loadmodules_bool - \keys_set:nn { hwexam / assignment }{ #1 } -} -% \end{macrocode} -% -% The next three macros are intermediate functions that handle the case gracefully, where -% the respective token registers are undefined. -% -% The |\given@due| macro prints information about the given and due status of the -% assignment. Its arguments specify the brackets. -% -% \begin{macrocode} -\newcommand\given@due[2]{ - \bool_lazy_all:nF { - {\tl_if_empty_p:V \l_@@_inclassign_given_tl} - {\tl_if_empty_p:V \l_@@_assign_given_tl} - {\tl_if_empty_p:V \l_@@_inclassign_due_tl} - {\tl_if_empty_p:V \l_@@_assign_due_tl} - }{ #1 } - - \tl_if_empty:NTF \l_@@_inclassign_given_tl { - \tl_if_empty:NF \l_@@_assign_given_tl { - \hwexam@given@kw\xspace\l_@@_assign_given_tl - } - }{ - \hwexam@given@kw\xspace\l_@@_inclassign_given_tl - } - - \bool_lazy_or:nnF { - \bool_lazy_and_p:nn { - \tl_if_empty_p:V \l_@@_inclassign_due_tl - }{ - \tl_if_empty_p:V \l_@@_assign_due_tl - } - }{ - \bool_lazy_and_p:nn { - \tl_if_empty_p:V \l_@@_inclassign_due_tl - }{ - \tl_if_empty_p:V \l_@@_assign_due_tl - } - }{ ,~ } - - \tl_if_empty:NTF \l_@@_inclassign_due_tl { - \tl_if_empty:NF \l_@@_assign_due_tl { - \hwexam@due@kw\xspace \l_@@_assign_due_tl - } - }{ - \hwexam@due@kw\xspace \l_@@_inclassign_due_tl - } - - \bool_lazy_all:nF { - { \tl_if_empty_p:V \l_@@_inclassign_given_tl } - { \tl_if_empty_p:V \l_@@_assign_given_tl } - { \tl_if_empty_p:V \l_@@_inclassign_due_tl } - { \tl_if_empty_p:V \l_@@_assign_due_tl } - }{ #2 } -} -% \end{macrocode} -% -% \begin{macro}{\assignment@title} -% This macro prints the title of an assignment, the local title is overwritten, if there -% is one from the |\inputassignment|. |\assignment@title| takes three arguments the -% first is the fallback when no title is given at all, the second and third go around -% the title, if one is given. -% \begin{macrocode} -\newcommand\assignment@title[3]{ - \tl_if_empty:NTF \l_@@_inclassign_title_tl { - \tl_if_empty:NTF \l_@@_assign_title_tl { - #1 - }{ - #2\l_@@_assign_title_tl#3 - } - }{ - #2\l_@@_inclassign_title_tl#3 - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\assignment@number} -% Like |\assignment@title| only for the number, and no around part. -% \begin{macrocode} -\newcommand\assignment@number{ - \int_compare:nNnTF \l_@@_inclassign_number_int = {-1} { - \int_compare:nNnTF \l_@@_assign_number_int = {-1} { - \arabic{assignment} - } { - \int_use:N \l_@@_assign_number_int - } - }{ - \int_use:N \l_@@_inclassign_number_int - } -} -% \end{macrocode} -% \end{macro} -% -% With them, we can define the central |assignment| environment. This has two forms -% (separated by |\ifmultiple|) in one we make a title block for an assignment sheet, and -% in the other we make a section heading and add it to the table of contents. We first -% define an assignment counter -% -% \begin{environment}{assignment} -% For the |assignment| environment we delegate the work to the |@assignment| environment -% that depends on whether |multiple| option is given. -% \begin{macrocode} -\newenvironment{assignment}[1][]{ - \_@@_assignment_args:n { #1 } - %\sref@target - \int_compare:nNnTF \l_@@_assign_number_int = {-1} { - \global\stepcounter{assignment} - }{ - \global\setcounter{assignment}{\int_use:N\l_@@_assign_number_int} - } - \setcounter{sproblem}{0} - \renewcommand\prob@label[1]{\assignment@number.##1} - \def\current@section@level{\document@hwexamtype} - %\sref@label@id{\document@hwexamtype \thesection} - \begin{@assignment} -}{ - \end{@assignment} -} -% \end{macrocode} -% In the multi-assignment case we just use the |omdoc| environment for suitable -% sectioning. -% \begin{macrocode} -\def\ass@title{ - {\protect\document@hwexamtype}~\arabic{assignment} - \assignment@title{}{\;(}{)\;} -- \given@due{}{} -} -\ifmultiple - \newenvironment{@assignment}{ - \bool_if:NTF \l_@@_assign_loadmodules_bool { - \begin{sfragment}[loadmodules]{\ass@title} - }{ - \begin{sfragment}{\ass@title} - } - }{ - \end{sfragment} - } -% \end{macrocode} -% for the single-page case we make a title block from the same components. -% \begin{macrocode} -\else - \newenvironment{@assignment}{ - \begin{center}\bf - \Large\@title\strut\\ - \document@hwexamtype~\arabic{assignment}\assignment@title{\;}{:\;}{\\} - \large\given@due{--\;}{\;--} - \end{center} - }{} -\fi% multiple -% \end{macrocode} -% \end{environment} -% -% \subsection{Including Assignments} -% -% \begin{macro}{\in*assignment} -% This macro is essentially a glorified |\include| statement, it just sets some internal -% macros first that overwrite the local points Importantly, it resets the |inclassig| -% keys after the input. -% \begin{macrocode} -\keys_define:nn { hwexam / inclassignment } { - %id .str_set_x:N = \l_@@_assign_id_str, - number .int_set:N = \l_@@_inclassign_number_int, - title .tl_set:N = \l_@@_inclassign_title_tl, - type .tl_set:N = \l_@@_inclassign_type_tl, - given .tl_set:N = \l_@@_inclassign_given_tl, - due .tl_set:N = \l_@@_inclassign_due_tl, - mhrepos .str_set_x:N = \l_@@_inclassign_mhrepos_str -} -\cs_new_protected:Nn \_@@_inclassignment_args:n { - \int_set:Nn \l_@@_inclassign_number_int {-1} - \tl_clear:N \l_@@_inclassign_title_tl - \tl_clear:N \l_@@_inclassign_type_tl - \tl_clear:N \l_@@_inclassign_given_tl - \tl_clear:N \l_@@_inclassign_due_tl - \str_clear:N \l_@@_inclassign_mhrepos_str - \keys_set:nn { hwexam / inclassignment }{ #1 } -} -\_@@_inclassignment_args:n {} - -\newcommand\inputassignment[2][]{ - \_@@_inclassignment_args:n { #1 } - \str_if_empty:NTF \l_@@_inclassign_mhrepos_str { - \input{#2} - }{ - \stex_in_repository:nn{\l_@@_inclassign_mhrepos_str}{ - \input{\mhpath{\l_@@_inclassign_mhrepos_str}{#2}} - } - } - \_@@_inclassignment_args:n {} -} -\newcommand\includeassignment[2][]{ - \newpage - \inputassignment[#1]{#2} -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Typesetting Exams} -% -% \begin{macro}{\quizheading} -% \begin{macrocode} -\ExplSyntaxOff -\newcommand\quizheading[1]{% - \def\@tas{#1}% - \large\noindent NAME: \hspace{8cm} MAILBOX:\\[2ex]% - \ifx\@tas\@empty\else% - \noindent TA:~\@for\@I:=\@tas\do{{\Large$\Box$}\@I\hspace*{1em}}\\[2ex]% - \fi% -} -\ExplSyntaxOn -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\testheading} -% \begin{macrocode} - -\def\hwexamheader{\input{hwexam-default.header}} - -\def\hwexamminutes{ - \tl_if_empty:NTF \testheading@duration { - {\testheading@min}~\hwexam@minutes@kw - }{ - \testheading@duration - } -} - -\keys_define:nn { hwexam / testheading } { - min .tl_set:N = \testheading@min, - duration .tl_set:N = \testheading@duration, - reqpts .tl_set:N = \testheading@reqpts, - tools .tl_set:N = \testheading@tools -} -\cs_new_protected:Nn \_@@_testheading_args:n { - \tl_clear:N \testheading@min - \tl_clear:N \testheading@duration - \tl_clear:N \testheading@reqpts - \tl_clear:N \testheading@tools - \keys_set:nn { hwexam / testheading }{ #1 } -} -\newenvironment{testheading}[1][]{ - \_@@_testheading_args:n{ #1 } - \newcount\check@time\check@time=\testheading@min - \advance\check@time by -\theassignment@totalmin - \newif\if@bonuspoints - \tl_if_empty:NTF \testheading@reqpts { - \@bonuspointsfalse - }{ - \newcount\bonus@pts - \bonus@pts=\theassignment@totalpts - \advance\bonus@pts by -\testheading@reqpts - \edef\bonus@pts{\the\bonus@pts} - \@bonuspointstrue - } - \edef\check@time{\the\check@time} - - \makeatletter\hwexamheader\makeatother -}{ - \newpage -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@problem} -% This macro acts on a problem's record in the |*.aux| file. Here we redefine it (it was -% defined to do nothing in |problem.sty|) to generate the correction table. -% \begin{macrocode} -%<@@=problems> -\renewcommand\@problem[3]{ - \stepcounter{assignment@probs} - \def\@@pts{#2} - \ifx\@@pts\@empty\else - \addtocounter{assignment@totalpts}{#2} - \fi - \def\@@min{#3}\ifx\@@min\@empty\else\addtocounter{assignment@totalmin}{#3}\fi - \xdef\correction@probs{\correction@probs & #1}% - \xdef\correction@pts{\correction@pts & #2} - \xdef\correction@reached{\correction@reached &} -} -%<@@=hwexam> -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\correction@table} -% This macro generates the correction table -% \begin{macrocode} -\newcounter{assignment@probs} -\newcounter{assignment@totalpts} -\newcounter{assignment@totalmin} -\def\correction@probs{\correction@probs@kw} -\def\correction@pts{\correction@pts@kw} -\def\correction@reached{\correction@reached@kw} -\stepcounter{assignment@probs} -\newcommand\correction@table{ - \resizebox{\textwidth}{!}{% -\begin{tabular}{|l|*{\theassignment@probs}{c|}|l|}\hline% -&\multicolumn{\theassignment@probs}{c||}%| -{\footnotesize\correction@forgrading@kw} &\\\hline -\correction@probs & \correction@sum@kw & \correction@grade@kw\\\hline -\correction@pts &\theassignment@totalpts & \\\hline -\correction@reached & & \\[.7cm]\hline -\end{tabular}}} -%</package> -% \end{macrocode} -% \end{macro} -% -% \subsection{Leftovers} -% -% at some point, we may want to reactivate the logos font, then we use -% \begin{verbatim} -% here we define the logos that characterize the assignment -% \font\bierfont=../assignments/bierglas -% \font\denkerfont=../assignments/denker -% \font\uhrfont=../assignments/uhr -% \font\warnschildfont=../assignments/achtung -% -% \newcommand\bierglas{{\bierfont\char65}} -% \newcommand\denker{{\denkerfont\char65}} -% \newcommand\uhr{{\uhrfont\char65}} -% \newcommand\warnschild{{\warnschildfont\char 65}} -% \newcommand\hardA{\warnschild} -% \newcommand\longA{\uhr} -% \newcommand\thinkA{\denker} -% \newcommand\discussA{\bierglas} -% \end{verbatim} -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -\endinput -% \iffalse - -%%% Local Variables: -%%% mode: doctex -%%% TeX-master: t -%%% End: -% \fi -% LocalWords: texttt scsys sc latexml fileversion filedate maketitle setcounter newpage -% LocalWords: tocdepth tableofcontents pts showmeta showmeta showignores omdoc extrefs -% LocalWords: testspace testnewpage testemptypage testheading testheading reqpts reqpts -% LocalWords: exfig makeatletter makeatother vspace hrule vspace vspace noindent textsf -% LocalWords: includeassignment includeassignment HorIacJuc cscpnrr11 importmodule baz -% LocalWords: includemhassignment includemhassignment importmhmodule foobar ldots sref -% LocalWords: mhcurrentrepos mh-variants mh-variant compactenum printbibliography Cwd -% LocalWords: langle rangle langle rangle ltxml.cls ltxml.sty respetively metakeys qw -% LocalWords: cwd stex graphicx amssymb amstext amsmath newif iftest testfalse testtrue -% LocalWords: ifsolutions solutionsfalse ifmultiple multiplefalse multipletrue keyval -% LocalWords: ltxml assig srefaddidkey addmetakey ifx assignment@titleblock stepcounter -% LocalWords: document@hwexamtype importmodules metasetkeys inclassig@title inclassig -% LocalWords: inclassig@title inclassig@type inclassig@type inclassig@number xspace kv -% LocalWords: inclassig@number inclassig@due inclassig@due inclassig@given ignorespaces -% LocalWords: inclassig@given newenvironment currentsectionlevel OptionalKeyVals kvi -% LocalWords: omgroup vals hwexamtype ednote textbackslash newcommand inputassignment -% LocalWords: unlist quizheading tas hspace hfill textbf newcount vfill addtocounter -% LocalWords: theassignment@totalmin theassignment@totalpts assignment@probs xdef hline -% LocalWords: assignment@totalpts assignment@totalmin correction@probs correction@probs -% LocalWords: newcounter theassignment@probs footnotesize mh@currentrepos endinput -% LocalWords: inclassig@mhrepos inclassig@mhrepos doctex inputmhassignment -% LocalWords: GPL structuresharing STR iffalse cls NeedsTeXFormat hwexam hwexam.dtx sc diff --git a/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx b/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx deleted file mode 100644 index e74693c26be..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/notesslides.dtx +++ /dev/null @@ -1,862 +0,0 @@ -% \iffalse meta-comment -% A LaTeX Class for Semantic Lectures Slides (originally developed for Michael Kohlhase) -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% Gnu Library Public Licences (LGPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% \fi -% -% \iffalse -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \GetFileInfo{notesslides.cls} -% \MakeShortVerb{\|} -% -% \def\twin#1#2{\index{#1!#2}\index{#2!#1}} -% \def\twintoo#1#2{{#1 #2}\twin{#1}{#2}} -% \def\atwin#1#2#3{\index{#1!#2!#3}\index{#3!#2 (#1)}} -% \def\atwintoo#1#2#3{{#1 #2 #3}\atwin{#1}{#2}{#3}} -% -% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}} -% \def\stex{\hbox{\raisebox{-.5ex}S\kern-.5ex\TeX}} -% \def\sTeX{\stex} -% \def\cnxml{\scshape{CNXml}} -% \def\connexions{\scshape{Connexions}} -% \def\element#1{{\ttfamily{#1}}} -% \def\snippet#1{{\ttfamily{#1}}} -% \def\cnxlatex{CNX\LaTeX\xspace} -% \def\mathml{{\scshape{MathML}}\xspace} -% \def\omdoc{OMDoc\xspace} -% \def\activemath{{\scshape{ActiveMath}}\xspace} -% \def\textwarning{\includegraphics[width=1.2em]{stex-dangerous-bend}\xspace} -% -% \title{NotesSlides -- Slides and Course Notes\thanks{Version {\fileversion} -% (last revised {\filedate})}} -% \author{Michael Kohlhase\\ -% FAU Erlangen-N\"urnberg\\ -% \url{http://kwarc.info/kohlhase}} -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{notesslides} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \begin{sfragment}{The User Interface} -% \input{../../doc/packages/stex-notesslides} -% \end{sfragment} -% \fi -% -% \begin{documentation}\label{pkg:notesslides:doc} -% \changes{3.1.0}{2022/02/28}{Added \detokenize{\libusetheme}} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:notesslides:impl} -% -%\section{NotesSlides -- Implementation}\label{sec:impl} -% -%\subsection{Class and Package Options}\label{sec:impl:init} -% -% We define some Package Options and switches for the |notesslides| class and activate them -% by passing them on to |beamer.cls| and |omdoc.cls| and the |notesslides| package. We pass -% the |nontheorem| option to the |statements| package when we are not in notes mode, since -% the |beamer| package has its own (overlay-aware) theorem environments. -% -% \begin{macrocode} -%<*cls> -%<@@=notesslides> -\ProvidesExplClass{notesslides}{2022/09/14}{3.2.0}{notesslides Class} -\RequirePackage{l3keys2e} - -\keys_define:nn{notesslides / cls}{ - class .str_set_x:N = \c_@@_class_str, - notes .bool_set:N = \c_@@_notes_bool , - slides .code:n = { \bool_set_false:N \c_@@_notes_bool }, - docopt .str_set_x:N = \c_@@_docopt_str, - unknown .code:n = { - \PassOptionsToPackage{\CurrentOption}{document-structure} - \PassOptionsToClass{\CurrentOption}{beamer} - \PassOptionsToPackage{\CurrentOption}{notesslides} - \PassOptionsToPackage{\CurrentOption}{stex} - } -} -\ProcessKeysOptions{ notesslides / cls } - -\str_if_empty:NF \c_@@_class_str { - \PassOptionsToPackage{class=\c_@@_class_str}{document-structure} -} - -\exp_args:No \str_if_eq:nnT\c_@@_class_str{book}{ - \PassOptionsToPackage{defaulttopsect=part}{notesslides} -} -\exp_args:No \str_if_eq:nnT\c_@@_class_str{report}{ - \PassOptionsToPackage{defaulttopsect=part}{notesslides} -} - -\RequirePackage{stex} -\stex_html_backend:T { - \bool_set_true:N\c_@@_notes_bool -} - -\bool_if:NTF \c_@@_notes_bool { - \PassOptionsToPackage{notes=true}{notesslides} - \message{notesslides.cls:~Formatting~course~materials~in~notes~mode} -}{ - \PassOptionsToPackage{notes=false}{notesslides} - \message{notesslides.cls:~Formatting~course~materials~in~slides~mode} -} -%</cls> -% \end{macrocode} -% now we do the same for the |notesslides| package. -% \begin{macrocode} -%<*package> -\ProvidesExplPackage{notesslides}{2022/09/14}{3.2.0}{notesslides Package} -\RequirePackage{l3keys2e} - -\keys_define:nn{notesslides / pkg}{ - topsect .str_set_x:N = \c_@@_topsect_str, - defaulttopsect .str_set_x:N = \c_@@_defaulttopsec_str, - notes .bool_set:N = \c_@@_notes_bool , - slides .code:n = { \bool_set_false:N \c_@@_notes_bool }, - sectocframes .bool_set:N = \c_@@_sectocframes_bool , - frameimages .bool_set:N = \c_@@_frameimages_bool , - fiboxed .bool_set:N = \c_@@_fiboxed_bool , - noproblems .bool_set:N = \c_@@_noproblems_bool, - unknown .code:n = { - \PassOptionsToClass{\CurrentOption}{stex} - \PassOptionsToClass{\CurrentOption}{tikzinput} - } -} -\ProcessKeysOptions{ notesslides / pkg } - -\RequirePackage{stex} -\stex_html_backend:T { - \bool_set_true:N\c_@@_notes_bool -} - -\newif\ifnotes -\bool_if:NTF \c_@@_notes_bool { - \notestrue -}{ - \notesfalse -} - -% \end{macrocode} -% we give ourselves a macro |\@@topsect| that needs only be evaluated once, so that the -% |\ifdefstring| conditionals work below. -% \begin{macrocode} -\str_if_empty:NTF \c_@@_topsect_str { - \str_set_eq:NN \@@topsect \c_@@_defaulttopsec_str -}{ - \str_set_eq:NN \@@topsect \c_@@_topsect_str -} -\PassOptionsToPackage{topsect=\@@topsect}{document-structure} -%</package> -% \end{macrocode} -% -% Depending on the options, we either load the |article|-based |document-structure| or the |beamer| -% class (and set some counters). -% \begin{macrocode} -%<*cls> -\bool_if:NTF \c_@@_notes_bool { - \str_if_empty:NT \c_@@_class_str { - \str_set:Nn \c_@@_class_str {article} - } - \exp_after:wN\LoadClass\exp_after:wN[\c_@@_docopt_str] - {\c_@@_class_str} -}{ - \LoadClass[10pt,notheorems,xcolor={dvipsnames,svgnames}]{beamer} - \newcounter{Item} - \newcounter{paragraph} - \newcounter{subparagraph} - \newcounter{Hfootnote} -} -\RequirePackage{document-structure} -% \end{macrocode} -% now it only remains to load the |notesslides| package that does all the rest. -% \begin{macrocode} -\RequirePackage{notesslides} -%</cls> -% \end{macrocode} -% -% In |notes| mode, we also have to make the |beamer|-specific things available to -% |article| via the |beamerarticle| package. We use options to avoid loading theorem-like -% environments, since we want to use our own from the $\sTeX$ packages. The first batch -% of packages we want are loaded on |notesslides.sty|. These are the general ones, we will -% load the \sTeX-specific ones after we have done some work (e.g. defined the counters -% |m*|). Only the |stex-logo| package is already needed now for the default theme. -% -% \begin{macrocode} -%<*package> -\bool_if:NT \c_@@_notes_bool { - \RequirePackage{a4wide} - \RequirePackage{marginnote} - \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor} - \RequirePackage{mdframed} - \RequirePackage[noxcolor,noamsthm]{beamerarticle} - \RequirePackage[bookmarks,bookmarksopen,bookmarksnumbered,breaklinks,hidelinks]{hyperref} -} -\RequirePackage{stex-tikzinput} -\RequirePackage{comment} -\RequirePackage{url} -\RequirePackage{graphicx} -\RequirePackage{pgf} -\RequirePackage{bookmark} -% \end{macrocode} -% -% \subsection{Notes and Slides}\label{sec:impl:noteslides} -% -% For the lecture notes cases, we also provide the |\usetheme| macro that would otherwise -% come from the the |beamer| class. -% \begin{macrocode} -\bool_if:NT \c_@@_notes_bool { - \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}} -} -\NewDocumentCommand \libusetheme {O{} m} { - \libusepackage[#1]{beamertheme#2} -} - -% \end{macrocode} -% We define the sizes of slides in the notes. Somehow, we cannot get by with the same -% here. -% -% \begin{macrocode} -\newcounter{slide} -\newlength{\slidewidth}\setlength{\slidewidth}{13.5cm} -\newlength{\slideheight}\setlength{\slideheight}{9cm} -% \end{macrocode} -% -% \begin{environment}{note} -% The |note| environment is used to leave out text in the |slides| mode. It does not have -% a counterpart in OMDoc. So for course notes, we define the |note| environment to be a -% no-operation otherwise we declare the |note| environment as a comment via the |comment| -% package. -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \renewenvironment{note}{\ignorespaces}{} -}{ - \excludecomment{note} -} -% \end{macrocode} -% \end{environment} -% -% We first set up the slide boxes in |article| mode. We set up sizes and provide a -% box register for the frames and a counter for the slides. -% -% \begin{macrocode} -\bool_if:NT \c_@@_notes_bool { - \newlength{\slideframewidth} - \setlength{\slideframewidth}{1.5pt} -% \end{macrocode} -% -% \begin{environment}{frame} -% We first define the keys. -% \begin{macrocode} - \cs_new_protected:Nn \_@@_do_yes_param:Nn { - \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{ - \bool_set_true:N #1 - }{ - \bool_set_false:N #1 - } - } - \keys_define:nn{notesslides / frame}{ - label .str_set_x:N = \l_@@_frame_label_str, - allowframebreaks .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_allowframebreaks_bool { #1 } - }, - allowdisplaybreaks .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_allowdisplaybreaks_bool { #1 } - }, - fragile .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_fragile_bool { #1 } - }, - shrink .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_shrink_bool { #1 } - }, - squeeze .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_squeeze_bool { #1 } - }, - t .code:n = { - \_@@_do_yes_param:Nn \l_@@_frame_t_bool { #1 } - }, - unknown .code:n = {} - } - \cs_new_protected:Nn \_@@_frame_args:n { - \str_clear:N \l_@@_frame_label_str - \bool_set_true:N \l_@@_frame_allowframebreaks_bool - \bool_set_true:N \l_@@_frame_allowdisplaybreaks_bool - \bool_set_true:N \l_@@_frame_fragile_bool - \bool_set_true:N \l_@@_frame_shrink_bool - \bool_set_true:N \l_@@_frame_squeeze_bool - \bool_set_true:N \l_@@_frame_t_bool - \keys_set:nn { notesslides / frame }{ #1 } - } -% \end{macrocode} -% We define the environment, read them, and construct the slide number and label. -% \begin{macrocode} - \renewenvironment{frame}[1][]{ - \_@@_frame_args:n{#1} - \sffamily - \stepcounter{slide} - \def\@currentlabel{\theslide} - \str_if_empty:NF \l_@@_frame_label_str { - \label{\l_@@_frame_label_str} - } -% \end{macrocode} -% We redefine the |itemize| environment so that it looks more like the one in |beamer|. -% \begin{macrocode} - \def\itemize@level{outer} - \def\itemize@outer{outer} - \def\itemize@inner{inner} - \renewcommand\newpage{\addtocounter{framenumber}{1}} - %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}} - \renewenvironment{itemize}{ - \ifx\itemize@level\itemize@outer - \def\itemize@label{$\rhd$} - \fi - \ifx\itemize@level\itemize@inner - \def\itemize@label{$\scriptstyle\rhd$} - \fi - \begin{list} - {\itemize@label} - {\setlength{\labelsep}{.3em} - \setlength{\labelwidth}{.5em} - \setlength{\leftmargin}{1.5em} - } - \edef\itemize@level{\itemize@inner} - }{ - \end{list} - } -% \end{macrocode} -% We create the box with the |mdframed| environment from the equinymous package. -% \begin{macrocode} - \stex_html_backend:TF { - \begin{stex_annotate_env}{frame}{}\vbox\bgroup - \mdf@patchamsthm - }{ - \begin{mdframed}[linewidth=\slideframewidth,skipabove=1ex,skipbelow=1ex,userdefinedwidth=\slidewidth,align=center]\sf - } - }{ - \stex_html_backend:TF { - \miko@slidelabel\egroup\end{stex_annotate_env} - }{\medskip\miko@slidelabel\end{mdframed}} - } -% \end{macrocode} -% \end{environment} -% -% Now, we need to redefine the frametitle (we are still in course notes mode). -% \begin{macro}{\frametitle} -% \begin{macrocode} - \renewcommand{\frametitle}[1]{ - \stex_document_title:n { #1 } - {\Large\bf\sf\color{blue}{#1}}\medskip - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\pause} -% \ednote{MK: fake it in notes mode for now} -% \begin{macrocode} -\bool_if:NT \c_@@_notes_bool { - \newcommand\pause{} -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{nparagraph} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{nparagraph}[1][]{\begin{sparagraph}[#1]}{\end{sparagraph}} -}{ - \excludecomment{nparagraph} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{nfragment} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{nfragment}[2][]{\begin{sfragment}[#1]{#2}}{\end{sfragment}} -}{ - \excludecomment{nfragment} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{ndefinition} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{ndefinition}[1][]{\begin{sdefinition}[#1]}{\end{sdefinition}} -}{ - \excludecomment{ndefinition} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{nassertion} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{nassertion}[1][]{\begin{sassertion}[#1]}{\end{sassertion}} -}{ - \excludecomment{nassertion} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{nsproof} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{nproof}[2][]{\begin{sproof}[#1]{#2}}{\end{sproof}} -}{ - \excludecomment{nproof} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{nexample} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{nexample}[1][]{\begin{sexample}[#1]}{\end{sexample}} -}{ - \excludecomment{nexample} -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\inputref@*skip} -% We customize the hooks for in |\inputref|. -% \begin{macrocode} -\def\inputref@preskip{\smallskip} -\def\inputref@postskip{\medskip} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\inputref*} -% \begin{macrocode} -\let\orig@inputref\inputref -\def\inputref{\@ifstar\ninputref\orig@inputref} -\newcommand\ninputref[2][]{ - \bool_if:NT \c_@@_notes_bool { - \orig@inputref[#1]{#2} - } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Header and Footer Lines}\label{sec:impl:headfootlines} -% -% Now, we set up the infrastructure for the footer line of the slides, we use boxes for -% the logos, so that they are only loaded once, that considerably speeds up processing. -% -% \begin{macro}{\setslidelogo} -% The default logo is the {\sTeX} logo. Customization can be done by |\setslidelogo{|\meta{logo name}|}|. -% \begin{macrocode} -\newlength{\slidelogoheight} - -\RequirePackage{graphicx} - -\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} -\providecommand\mhgraphics[2][]{ - \def\Gin@mhrepos{}\setkeys{Gin}{#1} - \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}} -} - -\bool_if:NTF \c_@@_notes_bool { - \setlength{\slidelogoheight}{.4cm} -}{ - \setlength{\slidelogoheight}{.25cm} -} -\ifcsname slidelogo\endcsname\else - \newsavebox{\slidelogo} - \sbox{\slidelogo}{\sTeX} -\fi -\newrobustcmd{\setslidelogo}[2][]{ - \tl_if_empty:nTF{#1}{ - \sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{#2}} - }{ - \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,mhrepos=#1]{#2}} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\author} -% In notes mode, we redefine the |\author| macro so that it does not disregard the -% optional argument (as \pkg{beamerarticle} does). We want to use it to set the source -% later. -% \begin{macrocode} -\bool_if:NT \c_@@_notes_bool { - \def\author{\@dblarg\ns@author} - \long\def\ns@author[#1]#2{% - \def\c_@@_shortauthor{#1}% - \def\@author{#2} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\setsource} -% |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he -% is the main user and designer of this package. |\setsource{|\meta{name}|}| can change -% the writer's name. -% \begin{macrocode} -\newrobustcmd{\setsource}[1]{\def\source{#1}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\setlicensing} -% Now, we set up the copyright and licensing. By default we use the Creative Commons -% Attribuition-ShareAlike license to strengthen the public domain. If package |hyperref| -% is loaded, then we can attach a hyperlink to the license -% logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used for customization, -% where ||\meta{url}|| is optional. -% \begin{macrocode} -\def\copyrightnotice{% - \footnotesize\copyright :\hspace{.3ex}% - \ifcsname source\endcsname\source\else% - \ifcsname c_@@_shortauthor\endcsname\c_@@_shortauthor\else% - \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}% - ?source/author?\fi% - \fi} -\newsavebox{\cclogo} -\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}} -\newif\ifcchref\cchreffalse -\AtBeginDocument{ - \@ifpackageloaded{hyperref}{\cchreftrue}{\cchreffalse} -} -\def\licensing{ - \ifcchref - \href{http://creativecommons.org/licenses/by-sa/2.5/}{\usebox{\cclogo}} - \else - {\usebox{\cclogo}} - \fi -} -\newrobustcmd{\setlicensing}[2][]{ - \def\@url{#1} - \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{#2}} - \ifx\@url\@empty - \def\licensing{{\usebox{\cclogo}}} - \else - \def\licensing{ - \ifcchref - \href{#1}{\usebox{\cclogo}} - \else - {\usebox{\cclogo}} - \fi - } - \fi -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\slidelabel} -% Now, we set up the slide label for the |article| mode.\ednote{see that we can use the themes for the slides some day. This is all fake.} -% \begin{macrocode} -\newrobustcmd\miko@slidelabel{ - \vbox to \slidelogoheight{ - \vss\hbox to \slidewidth - {\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}} - } -} -% \end{macrocode} -% \end{macro} -% \subsection{Frame Images}\label{sec:impl:frameimage} -% -% \begin{macro}{\frameimage} -% We have to make sure that the width is overwritten, for that we check the -% |\Gin@ewidth| macro from the |graphicx| package. We also add the |label| key. -% \begin{macrocode} -\def\Gin@mhrepos{} -\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} -\define@key{Gin}{label}{\def\@currentlabel{\arabic{slide}}\label{#1}} -\newrobustcmd\frameimage[2][]{ - \stepcounter{slide} - \bool_if:NT \c_@@_frameimages_bool { - \def\Gin@ewidth{}\setkeys{Gin}{#1} - \bool_if:NF \c_@@_notes_bool { \vfill } - \begin{center} - \bool_if:NTF \c_@@_fiboxed_bool { - \fbox{ - \ifx\Gin@ewidth\@empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[width=\slidewidth,#1]{#2} - \else - \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \else% Gin@ewidth empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[#1]{#2} - \else - \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \fi% Gin@ewidth empty - } - }{ - \ifx\Gin@ewidth\@empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[width=\slidewidth,#1]{#2} - \else - \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \ifx\Gin@mhrepos\@empty - \mhgraphics[#1]{#2} - \else - \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \fi% Gin@ewidth empty - } - \end{center} - \par\strut\hfill{\footnotesize Slide \arabic{slide}}% - \bool_if:NF \c_@@_notes_bool { \vfill } - } -} % ifmks@sty@frameimages -% \end{macrocode} -% \end{macro} -% -% \subsection{Sectioning} -% -% If the |sectocframes| option is set, then we make section frames. We first define -% counters for |part| and |chapter|, which |beamer.cls| does not have and we make the -% |section| counter which it does dependent on |chapter|. -% \begin{macrocode} -\stex_html_backend:F { - \bool_if:NT \c_@@_sectocframes_bool { - \str_if_eq:VnTF \@@topsect{part}{ - \newcounter{chapter}\counterwithin*{section}{chapter} - }{ - \str_if_eq:VnT\@@topsect{chapter}{ - \newcounter{chapter}\counterwithin*{section}{chapter} - } - } - } -} -% \end{macrocode} -% -% We set the \DescribeMacro{\section@level}|\section@level| counter that governs -% sectioning according to the class options. We also introduce the sectioning counters -% accordingly. -% -% \begin{macro}{\section@level} -% \begin{macrocode} -\def\part@prefix{} -\@ifpackageloaded{document-structure}{}{ - \str_case:VnF \@@topsect { - {part}{ - \int_set:Nn \l_document_structure_section_level_int {0} - \def\thesection{\arabic{chapter}.\arabic{section}} - \def\part@prefix{\arabic{chapter}.} - } - {chapter}{ - \int_set:Nn \l_document_structure_section_level_int {1} - \def\thesection{\arabic{chapter}.\arabic{section}} - \def\part@prefix{\arabic{chapter}.} - } - }{ - \int_set:Nn \l_document_structure_section_level_int {2} - \def\part@prefix{} - } -} - -\bool_if:NF \c_@@_notes_bool { % only in slides -% \end{macrocode} -% \end{macro} -% -% The new counters are used in the |sfragment| environment that choses the {\LaTeX} -% sectioning macros according to |\section@level|. -% -% \begin{environment}{sfragment} -% \begin{macrocode} - \renewenvironment{sfragment}[2][]{ - \__document_structure_sfragment_args:n { #1 } - \int_incr:N \l_document_structure_section_level_int - \bool_if:NT \c_@@_sectocframes_bool { - \stepcounter{slide} - \begin{frame}[noframenumbering] - \vfill\Large\centering - \red{ - \ifcase\l_document_structure_section_level_int\or - \stepcounter{part} - \def\@@label{{\omdoc@part@kw}~\Roman{part}} - \addcontentsline{toc}{part}{\protect\numberline{\thepart}#2} - \pdfbookmark[0]{\thepart\ #2}{part.\thepart} - \def\currentsectionlevel{\omdoc@part@kw} - \or - \stepcounter{chapter} - \def\@@label{{\omdoc@chapter@kw}~\arabic{chapter}} - \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#2} - \pdfbookmark[1]{\thechapter\ #2}{chapter.\cs_if_exist:cT{thepart}\thepart.\thechapter} - \def\currentsectionlevel{\omdoc@chapter@kw} - \or - \stepcounter{section} - \def\@@label{\part@prefix\arabic{section}} - \addcontentsline{toc}{section}{\protect\numberline{\thesection}#2} - \pdfbookmark[2]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection\ #2} - {section.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection} - \def\currentsectionlevel{\omdoc@section@kw} - \or - \stepcounter{subsection} - \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}} - \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#2} - \pdfbookmark[3]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection\ #2} - {subsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection} - \def\currentsectionlevel{\omdoc@subsection@kw} - \or - \stepcounter{subsubsection} - \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}} - \addcontentsline{toc}{subsubsection}{\protect\numberline{\thesubsubsection}#2} - \pdfbookmark[4]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection\ #2} - {subsubsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection} - \def\currentsectionlevel{\omdoc@subsubsection@kw} - \or - \stepcounter{paragraph} - \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}} - \addcontentsline{toc}{paragraph}{\protect\numberline{\theparagraph}#2} - \pdfbookmark[5]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph\ #2} - {paragraph.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection.\theparagraph} - \def\currentsectionlevel{\omdoc@paragraph@kw} - \else - \def\@@label{} - \def\currentsectionlevel{\omdoc@paragraph@kw} - \fi% end ifcase - \@@label\quad #2% - }% - \vfill% - \end{frame}% - } - \str_if_empty:NF \l__document_structure_sfragment_id_str { - \stex_ref_new_doc_target:n\l__document_structure_sfragment_id_str - } - }{} -} -% \end{macrocode} -% \end{environment} -% -% We set up a |beamer| template for theorems like ams style, but without a block -% environment. -% \begin{macrocode} -\def\inserttheorembodyfont{\normalfont} -%\bool_if:NF \c_@@_notes_bool { -% \defbeamertemplate{theorem begin}{miko} -% {\inserttheoremheadfont\inserttheoremname\inserttheoremnumber -% \ifx\inserttheoremaddition\@empty\else\ (\inserttheoremaddition)\fi% -% \inserttheorempunctuation\inserttheorembodyfont\xspace} -% \defbeamertemplate{theorem end}{miko}{} -% \end{macrocode} -% and we set it as the default one. -% \begin{macrocode} -% \setbeamertemplate{theorems}[miko] -% \end{macrocode} -% The following fixes an error I do not understand, this has something to do with -% beamer compatibility, which has similar definitions but only up to 1. -% \begin{macrocode} -% \expandafter\def\csname Parent2\endcsname{} -%} - -\AddToHook{begindocument}{ % this does not work for some reasone - \setbeamertemplate{theorems}[ams style] -} -\bool_if:NT \c_@@_notes_bool { - \renewenvironment{columns}[1][]{% - \par\noindent% - \begin{minipage}% - \slidewidth\centering\leavevmode% - }{% - \end{minipage}\par\noindent% - }% - \newsavebox\columnbox% - \renewenvironment<>{column}[2][]{% - \begin{lrbox}{\columnbox}\begin{minipage}{#2}% - }{% - \end{minipage}\end{lrbox}\usebox\columnbox% - }% -} -% \end{macrocode} -% -% \begin{macrocode} -\bool_if:NTF \c_@@_noproblems_bool { - \newenvironment{problems}{}{} -}{ - \excludecomment{problems} -} -% \end{macrocode} -% -% \subsection{Excursions}\label{sec:impl:excursions} -% -% \begin{macro}{\excursion} -% The excursion macros are very simple, we define a new internal macro |\excursionref| and -% use it in |\excursion|, which is just an |\inputref| that checks if the new macro is -% defined before formatting the file in the argument. -% \begin{macrocode} -\gdef\printexcursions{} -\newcommand\excursionref[2]{% label, text - \bool_if:NT \c_@@_notes_bool { - \begin{sparagraph}[title=Excursion] - #2 \sref[fallback=the appendix]{#1}. - \end{sparagraph} - } -} -\newcommand\activate@excursion[2][]{ - \gappto\printexcursions{\inputref[#1]{#2}} -} -\newcommand\excursion[4][]{% repos, label, path, text - \bool_if:NT \c_@@_notes_bool { - \activate@excursion[#1]{#3}\excursionref{#2}{#4} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\excursiongroup} -% \begin{macrocode} -\keys_define:nn{notesslides / excursiongroup }{ - id .str_set_x:N = \l_@@_excursion_id_str, - intro .tl_set:N = \l_@@_excursion_intro_tl, - mhrepos .str_set_x:N = \l_@@_excursion_mhrepos_str -} -\cs_new_protected:Nn \_@@_excursion_args:n { - \tl_clear:N \l_@@_excursion_intro_tl - \str_clear:N \l_@@_excursion_id_str - \str_clear:N \l_@@_excursion_mhrepos_str - \keys_set:nn {notesslides / excursiongroup }{ #1 } -} -\newcommand\excursiongroup[1][]{ - \_@@_excursion_args:n{ #1 } - \ifdefempty\printexcursions{}% only if there are excursions - {\begin{note} - \begin{sfragment}[#1]{Excursions}% - \ifdefempty\l_@@_excursion_intro_tl{}{ - \inputref[\l_@@_excursion_mhrepos_str]{ - \l_@@_excursion_intro_tl - } - } - \printexcursions% - \end{sfragment} - \end{note}} -} -\ifcsname beameritemnestingprefix\endcsname\else\def\beameritemnestingprefix{}\fi -%</package> -% \end{macrocode} -% \end{macro} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -\endinput -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: - diff --git a/Master/texmf-dist/source/latex/stex/extensions/problem.dtx b/Master/texmf-dist/source/latex/stex/extensions/problem.dtx deleted file mode 100644 index 3fcc3215efe..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/problem.dtx +++ /dev/null @@ -1,850 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Problems -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% \fi -% -% \iffalse -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} -\RequirePackage[hints,solutions,notes]{problem} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \GetFileInfo{problem.sty} -% -% \MakeShortVerb{\|} -% -% \title{\texttt{problem.sty}: An Infrastructure for formatting Problems\thanks{Version {\fileversion} (last revised -% {\filedate})}} -% \author{Michael Kohlhase\\ -% FAU Erlangen-N\"urnberg\\ -% \url{http://kwarc.info/kohlhase}} -% \maketitle -% -% \ifinfulldoc\else -% \begin{documentation} -% \begin{abstract} -% This is the documentation for the \pkg{problem} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% The |problem| package supplies an infrastructure that allows specify problems (for -% homework assignments, exams, or quizzes) and to reuse them efficiently in multiple -% environments. -% \end{abstract} -% -% \tableofcontents -% \begin{sfragment}{User Interface} -% \input{../../doc/packages/stex-problem} -% \ednote{MK: the input does not work! it includes the commented stuff as well. } -% \end{sfragment} -% \end{documentation} -% \fi -% -% \begin{implementation} -% -% \section{The Implementation}\label{sec:implementation} -% -% \subsection{Package Options}\label{sec:impl:options} -% -% The first step is to declare (a few) package options that handle whether certain -% information is printed or not. They all come with their own conditionals that are set by -% the options. -% -% \begin{macrocode} -%<*package> -%<@@=problems> -\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems} -\RequirePackage{l3keys2e} -\RequirePackage{amssymb}% for \Box - -\keys_define:nn { problem / pkg }{ - notes .default:n = { true }, - notes .bool_set:N = \c_@@_notes_bool, - gnotes .default:n = { true }, - gnotes .bool_set:N = \c_@@_gnotes_bool, - hints .default:n = { true }, - hints .bool_set:N = \c_@@_hints_bool, - solutions .default:n = { true }, - solutions .bool_set:N = \c_@@_solutions_bool, - pts .default:n = { true }, - pts .bool_set:N = \c_@@_pts_bool, - min .default:n = { true }, - min .bool_set:N = \c_@@_min_bool, - boxed .default:n = { true }, - boxed .bool_set:N = \c_@@_boxed_bool, - test .default:n = { true }, - test .bool_set:N = \c_@@_test_bool, - unknown .code:n = { - \PassOptionsToPackage{\CurrentOption}{stex} - } -} -\newif\ifsolutions - -\ProcessKeysOptions{ problem / pkg } -\bool_if:NTF \c_@@_solutions_bool { - \solutionstrue -}{ - \solutionsfalse -} -\RequirePackage{stex} -% \end{macrocode} -% -% Then we make sure that the necessary packages are loaded (in the right versions). -% \begin{macrocode} -\RequirePackage{comment} -% \end{macrocode} -% -% The next package relies on the \LaTeX3 kernel, which \latexml only partially -% supports. As it is purely presentational, we only load it when the |boxed| option is -% given and we run {\latexml}. -% -% \begin{macrocode} -\bool_if:NT \c_@@_boxed_bool { \RequirePackage{mdframed} } -% \end{macrocode} -% -% \begin{macro}{\prob@*@kw} -% For multilinguality, we define internal macros for keywords that can be specialized in -% |*.ldf| files. -% \begin{macrocode} -\def\prob@problem@kw{Problem} -\def\prob@solution@kw{Solution} -\def\prob@hint@kw{Hint} -\def\prob@note@kw{Note} -\def\prob@gnote@kw{Grading} -\def\prob@pt@kw{pt} -\def\prob@min@kw{min} -\def\prob@correct@kw{Correct} -\def\prob@wrong@kw{Wrong} -% \end{macrocode} -% \end{macro} -% -% For the other languages, we set up triggers -% \begin{macrocode} -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{babel}{ - \makeatletter - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ - \input{problem-ngerman.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ - \input{problem-finnish.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ - \input{problem-french.ldf} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ - \input{problem-russian.ldf} - } - \makeatother - }{} -} -% \end{macrocode} -% -% \subsection{Problems and Solutions}\label{sec:impl:probsols} -% -% We now prepare the KeyVal support for problems. The key macros just set appropriate -% internal macros. -% -% \begin{macrocode} -\keys_define:nn{ problem / problem }{ - id .str_set_x:N = \l_@@_prob_id_str, - pts .tl_set:N = \l_@@_prob_pts_tl, - min .tl_set:N = \l_@@_prob_min_tl, - title .tl_set:N = \l_@@_prob_title_tl, - type .tl_set:N = \l_@@_prob_type_tl, - imports .tl_set:N = \l_@@_prob_imports_tl, - name .str_set_x:N = \l_@@_prob_name_str, - refnum .int_set:N = \l_@@_prob_refnum_int -} -\cs_new_protected:Nn \_@@_prob_args:n { - \str_clear:N \l_@@_prob_id_str - \str_clear:N \l_@@_prob_name_str - \tl_clear:N \l_@@_prob_pts_tl - \tl_clear:N \l_@@_prob_min_tl - \tl_clear:N \l_@@_prob_title_tl - \tl_clear:N \l_@@_prob_type_tl - \tl_clear:N \l_@@_prob_imports_tl - \int_zero_new:N \l_@@_prob_refnum_int - \keys_set:nn { problem / problem }{ #1 } - \int_compare:nNnT \l_@@_prob_refnum_int = 0 { - \let\l_@@_prob_refnum_int\undefined - } -} -% \end{macrocode} -% -% Then we set up a counter for problems. -% \begin{macro}{\numberproblemsin} -% \begin{macrocode} -\newcounter{sproblem}[section] -\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}} -\def\theplainsproblem{\arabic{sproblem}} -\def\thesproblem{\thesection.\theplainsproblem} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\prob@label} -% We provide the macro |\prob@label| to redefine later to get context involved. -% \begin{macrocode} -\newcommand\prob@label[1]{\thesection.#1} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\prob@number} -% We consolidate the problem number into a reusable internal macro -% \begin{macrocode} -\newcommand\prob@number{ - \int_if_exist:NTF \l_@@_inclprob_refnum_int { - \prob@label{\int_use:N \l_@@_inclprob_refnum_int } - }{ - \int_if_exist:NTF \l_@@_prob_refnum_int { - \prob@label{\int_use:N \l_@@_prob_refnum_int } - }{ - \prob@label\theplainsproblem - } - } -} -\def\sproblemautorefname{\prob@problem@kw} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\prob@title} -% We consolidate the problem title into a reusable internal macro as well. |\prob@title| -% takes three arguments the first is the fallback when no title is given at all, the -% second and third go around the title, if one is given. -% \begin{macrocode} -\newcommand\prob@title[3]{% - \tl_if_exist:NTF \l_@@_inclprob_title_tl { - #2 \l_@@_inclprob_title_tl #3 - }{ - \tl_if_empty:NTF \l_@@_prob_title_tl { - #1 - }{ - #2 \l_@@_prob_title_tl #3 - } - } -} -% \end{macrocode} -% \end{macro} -% -% With these the problem header is a one-liner -% -% \begin{macro}{\prob@heading} -% We consolidate the problem header line into a separate internal macro that can be -% reused in various settings. -% \begin{macrocode} -\def\prob@heading{ - {\prob@problem@kw}\ \prob@number\prob@title{~}{~(}{)\strut} - %\sref@label@id{\prob@problem@kw~\prob@number}{} -} -% \end{macrocode} -% \end{macro} -% -% With this in place, we can now define the |problem| environment. It comes in two shapes, -% depending on whether we are in boxed mode or not. In both cases we increment the problem -% number and output the points and minutes (depending) on whether the respective options -% are set. -% \begin{environment}{sproblem} -% \begin{macrocode} -\newenvironment{sproblem}[1][]{ - \_@@_prob_args:n{#1}%\sref@target% - \@in@omtexttrue% we are in a statement (for inline definitions) - \refstepcounter{sproblem}\record@problem - \def\current@section@level{\prob@problem@kw} - - \str_if_empty:NT \l_@@_prob_name_str { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_get_left:NN \l_tmpa_seq \l_@@_prob_name_str - } - - \stex_if_do_html:T{ - \tl_if_empty:NF \l_@@_prob_title_tl { - \exp_args:No \stex_document_title:n \l_@@_prob_title_tl - } - } - - \exp_args:Nno\stex_module_setup:nn{type=problem}\l_@@_prob_name_str - - \stex_reactivate_macro:N \STEXexport - \stex_reactivate_macro:N \importmodule - \stex_reactivate_macro:N \symdecl - \stex_reactivate_macro:N \notation - \stex_reactivate_macro:N \symdef - - \stex_if_do_html:T{ - \begin{stex_annotate_env} {problem} { - \l_stex_module_ns_str ? \l_stex_module_name_str - } - - \stex_annotate_invisible:nnn{header}{} { - \stex_annotate:nnn{language}{ \l_stex_module_lang_str }{} - \stex_annotate:nnn{signature}{ \l_stex_module_sig_str }{} - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \stex_annotate:nnn{metatheory}{ \l_stex_module_meta_str }{} - } - } - } - - \stex_csl_to_imports:No \importmodule \l_@@_prob_imports_tl - - - \tl_if_exist:NTF \l_@@_inclprob_type_tl { - \tl_set_eq:NN \sproblemtype \l_@@_inclprob_type_tl - }{ - \tl_set_eq:NN \sproblemtype \l_@@_prob_type_tl - } - \str_if_exist:NTF \l_@@_inclprob_id_str { - \str_set_eq:NN \sproblemid \l_@@_inclprob_id_str - }{ - \str_set_eq:NN \sproblemid \l_@@_prob_id_str - } - - - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproblem_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproblem_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproblem_start: - }{ - \l_tmpa_tl - } - } - \stex_ref_new_doc_target:n \sproblemid - \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars -}{ - \__stex_modules_end_module: - \stex_if_smsmode:F{ - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproblem_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproblem_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproblem_end: - }{ - \l_tmpa_tl - } - } - \stex_if_do_html:T{ - \end{stex_annotate_env} - } - - \smallskip -} - -\seq_put_right:Nx\g_stex_smsmode_allowedenvs_seq{\tl_to_str:n{sproblem}} - - - -\cs_new_protected:Nn \_@@_sproblem_start: { - \par\noindent\textbf\prob@heading\show@pts\show@min\\\ignorespacesandpars -} -\cs_new_protected:Nn \_@@_sproblem_end: {\par\smallskip} - -\newcommand\stexpatchproblem[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sproblem_start: { #2 } - \tl_set:Nn \_@@_sproblem_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sproblem_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sproblem_#1_end:\endcsname{ #3 } - } -} - - -\bool_if:NT \c_@@_boxed_bool { - \surroundwithmdframed{problem} -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\record@problem} -% This macro records information about the problems in the |*.aux| file. -% \begin{macrocode} -\def\record@problem{ - \protected@write\@auxout{} - { - \string\@problem{\prob@number} - { - \tl_if_exist:NTF \l_@@_inclprob_pts_tl { - \l_@@_inclprob_pts_tl - }{ - \l_@@_prob_pts_tl - } - }% - { - \tl_if_exist:NTF \l_@@_inclprob_min_tl { - \l_@@_inclprob_min_tl - }{ - \l_@@_prob_min_tl - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@problem} -% This macro acts on a problem's record in the |*.aux| file. It does not have any -% functionality here, but can be redefined elsewhere (e.g. in the |assignment| -% package). -% \begin{macrocode} -\def\@problem#1#2#3{} -% \end{macrocode} -% \end{macro} -% -% The \DescribeEnv{solution}|solution| environment is similar to the |problem| -% environment, only that it is independent of the boxed mode. It also has it's own keys -% that we need to define first. -% -% \begin{macrocode} -\keys_define:nn { problem / solution }{ - id .str_set_x:N = \l_@@_solution_id_str , - for .str_set_x:N = \l_@@_solution_for_str , - type .str_set_x:N = \l_@@_solution_type_str , - title .tl_set:N = \l_@@_solution_title_tl -} -\cs_new_protected:Nn \_@@_solution_args:n { - \str_clear:N \l_@@_solution_id_str - \str_clear:N \l_@@_solution_type_str - \str_clear:N \l_@@_solution_for_str - \tl_clear:N \l_@@_solution_title_tl - \keys_set:nn { problem / solution }{ #1 } -} -% \end{macrocode} -% -% \begin{macro}{\startsolutions} -% for the |\startsolutions| macro we use the |\specialcomment| macro from the |comment| -% package. Note that we use the |\@startsolution| macro in the start codes, that parses -% the optional argument. -% \begin{macrocode} -\box_new:N \l_@@_solution_box -\newenvironment{solution}[1][]{ - \_@@_solution_args:n{#1} - \stex_html_backend:TF{ - \stex_if_do_html:T{ - \begin{stex_annotate_env}{solution}{} - \str_if_empty:NF \l_@@_solution_type_str { - \par\noindent - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ - } - }{ - \setbox\l_@@_solution_box\vbox\bgroup - \par\smallskip\hrule\smallskip - \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ - } -}{ - \stex_html_backend:TF{ - \stex_if_do_html:T{ - \end{stex_annotate_env} - } - }{ - \smallskip\hrule - \egroup - \bool_if:NT \c_@@_solutions_bool { - \strut\par\noindent - \box\l_@@_solution_box - } - } -} - -\newcommand\startsolutions{ - \bool_set_true:N \c_@@_solutions_bool - \solutionstrue -% \specialcomment{solution}{\@startsolution}{ -% \bool_if:NF \c_@@_boxed_bool { -% \hrule\medskip -% } -% \end{small}% -% } -% \bool_if:NT \c_@@_boxed_bool { -% \surroundwithmdframed{solution} -% } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stopsolutions} -% \begin{macrocode} -\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool \solutionsfalse}%\excludecomment{solution}} -% \end{macrocode} -% \end{macro} -% -% -% \begin{environment}{exnote} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{exnote}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@note@kw :~ }\small - }{ - \smallskip\hrule - } -}{ - \excludecomment{exnote} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{hint} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{hint}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@hint@kw :~ }\small - }{ - \smallskip\hrule - } - \newenvironment{exhint}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@hint@kw :~ }\small - }{ - \smallskip\hrule - } -}{ - \excludecomment{hint} - \excludecomment{exhint} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{gnote} -% \begin{macrocode} -\bool_if:NTF \c_@@_notes_bool { - \newenvironment{gnote}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@gnote@kw :~ }\small - }{ - \smallskip\hrule - } -}{ - \excludecomment{gnote} -} -% \end{macrocode} -% \end{environment} -% -% \subsection{Markup for Added Value Services}\label{sec:impl:avs} -% -% \subsubsection{Multiple Choice Blocks}\label{sec:impl:mcq} -% -% \begin{environment}{mcb} -% \ednote{MK: maybe import something better here from a dedicated MC package} -% \begin{macrocode} -\newenvironment{mcb}{ - \begin{enumerate} -}{ - \end{enumerate} -} -% \end{macrocode} -% \end{environment} -% we define the keys for the |mcc| macro -% \begin{macrocode} -\cs_new_protected:Nn \_@@_do_yes_param:Nn { - \exp_args:Nx \str_if_eq:nnTF { \str_lowercase:n{ #2 } }{ yes }{ - \bool_set_true:N #1 - }{ - \bool_set_false:N #1 - } -} -\keys_define:nn { problem / mcc }{ - id .str_set_x:N = \l_@@_mcc_id_str , - feedback .tl_set:N = \l_@@_mcc_feedback_tl , - T .default:n = { false } , - T .bool_set:N = \l_@@_mcc_t_bool , - F .default:n = { false } , - F .bool_set:N = \l_@@_mcc_f_bool , - Ttext .tl_set:N = \l_@@_mcc_Ttext_tl , - Ftext .tl_set:N = \l_@@_mcc_Ftext_tl -} -\cs_new_protected:Nn \l_@@_mcc_args:n { - \str_clear:N \l_@@_mcc_id_str - \tl_clear:N \l_@@_mcc_feedback_tl - \bool_set_false:N \l_@@_mcc_t_bool - \bool_set_false:N \l_@@_mcc_f_bool - \tl_clear:N \l_@@_mcc_Ttext_tl - \tl_clear:N \l_@@_mcc_Ftext_tl - \str_clear:N \l_@@_mcc_id_str - \keys_set:nn { problem / mcc }{ #1 } -} -% \end{macrocode} -% -% \begin{macro}{\mcc} -% \begin{macrocode} -\def\mccTrueText{\textbf{\prob@correct@kw!~}} -\def\mccFalseText{\textbf{\prob@wrong@kw!~}} -\newcommand\mcc[2][]{ - \l_@@_mcc_args:n{ #1 } - \item[$\Box$] #2 - \bool_if:NT \c_@@_solutions_bool{ - \\ - \bool_if:NT \l_@@_mcc_t_bool { - \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccTrueText\l_@@_mcc_Ttext_tl - } - \bool_if:NT \l_@@_mcc_f_bool { - \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccFalseText\l_@@_mcc_Ftext_tl - } - \tl_if_empty:NF \l_@@_mcc_feedback_tl { - \emph{\l_@@_mcc_feedback_tl} - } - } -} %solutions -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Filling in Concrete Solutions} -% -% \begin{macro}{\includeproblem} -% This is embarrasingly simple, but can grow over time. -% \begin{macrocode} -\newcommand\fillinsol[2][]{% - \def\@test{#1} - \quad% - \ifsolutions\textcolor{red}{#1!}\else% - \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}% - \fi} -% \end{macrocode} -% \end{macro} -% -% \subsection{Including Problems}\label{sec:impl:includeproblem} -% -% \begin{macro}{\includeproblem} -% The |\includeproblem| command is essentially a glorified |\input| statement, it sets -% some internal macros first that overwrite the local points. Importantly, it resets the -% |inclprob| keys after the input. -% \begin{macrocode} - -\keys_define:nn{ problem / inclproblem }{ - id .str_set_x:N = \l_@@_inclprob_id_str, - pts .tl_set:N = \l_@@_inclprob_pts_tl, - min .tl_set:N = \l_@@_inclprob_min_tl, - title .tl_set:N = \l_@@_inclprob_title_tl, - refnum .int_set:N = \l_@@_inclprob_refnum_int, - type .tl_set:N = \l_@@_inclprob_type_tl, - mhrepos .str_set_x:N = \l_@@_inclprob_mhrepos_str -} -\cs_new_protected:Nn \_@@_inclprob_args:n { - \str_clear:N \l_@@_prob_id_str - \tl_clear:N \l_@@_inclprob_pts_tl - \tl_clear:N \l_@@_inclprob_min_tl - \tl_clear:N \l_@@_inclprob_title_tl - \tl_clear:N \l_@@_inclprob_type_tl - \int_zero_new:N \l_@@_inclprob_refnum_int - \str_clear:N \l_@@_inclprob_mhrepos_str - \keys_set:nn { problem / inclproblem }{ #1 } - \tl_if_empty:NT \l_@@_inclprob_pts_tl { - \let\l_@@_inclprob_pts_tl\undefined - } - \tl_if_empty:NT \l_@@_inclprob_min_tl { - \let\l_@@_inclprob_min_tl\undefined - } - \tl_if_empty:NT \l_@@_inclprob_title_tl { - \let\l_@@_inclprob_title_tl\undefined - } - \tl_if_empty:NT \l_@@_inclprob_type_tl { - \let\l_@@_inclprob_type_tl\undefined - } - \int_compare:nNnT \l_@@_inclprob_refnum_int = 0 { - \let\l_@@_inclprob_refnum_int\undefined - } -} - -\cs_new_protected:Nn \_@@_inclprob_clear: { - \let\l_@@_inclprob_id_str\undefined - \let\l_@@_inclprob_pts_tl\undefined - \let\l_@@_inclprob_min_tl\undefined - \let\l_@@_inclprob_title_tl\undefined - \let\l_@@_inclprob_type_tl\undefined - \let\l_@@_inclprob_refnum_int\undefined - \let\l_@@_inclprob_mhrepos_str\undefined -} -\_@@_inclprob_clear: - -\newcommand\includeproblem[2][]{ - \_@@_inclprob_args:n{ #1 } - \exp_args:No \stex_in_repository:nn\l_@@_inclprob_mhrepos_str{ - \stex_html_backend:TF { - \str_clear:N \l_tmpa_str - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - \stex_annotate_invisible:nnn{includeproblem}{ - \l_tmpa_str / #2 - }{} - }{ - \begingroup - \inputreftrue - \tl_if_empty:nTF{ ##1 }{ - \input{#2} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - } - \endgroup - } - } - \_@@_inclprob_clear: -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Reporting Metadata} -% -% For messages it is OK to have them in English as the whole documentation is, and we can -% therefore assume authors can deal with it. -% -% \begin{macrocode} -\AddToHook{enddocument}{ - \bool_if:NT \c_@@_pts_bool { - \message{Total:~\arabic{pts}~points} - } - \bool_if:NT \c_@@_min_bool { - \message{Total:~\arabic{min}~minutes} - } -} -% \end{macrocode} -% -% The margin pars are reader-visible, so we need to translate -% -% \begin{macrocode} -\def\pts#1{ - \bool_if:NT \c_@@_pts_bool { - \marginpar{#1~\prob@pt@kw} - } -} -\def\min#1{ - \bool_if:NT \c_@@_min_bool { - \marginpar{#1~\prob@min@kw} - } -} -% \end{macrocode} -% -% \begin{macro}{\show@pts} -% The |\show@pts| shows the points: if no points are given from the outside and also no -% points are given locally do nothing, else show and add. If there are outside points -% then we show them in the margin. -% \begin{macrocode} -\newcounter{pts} -\def\show@pts{ - \tl_if_exist:NTF \l_@@_inclprob_pts_tl { - \bool_if:NT \c_@@_pts_bool { - \marginpar{\l_@@_inclprob_pts_tl\ \prob@pt@kw\smallskip} - \addtocounter{pts}{\l_@@_inclprob_pts_tl} - } - }{ - \tl_if_exist:NT \l_@@_prob_pts_tl { - \bool_if:NT \c_@@_pts_bool { - \tl_if_empty:NT\l_@@_prob_pts_tl{ - \tl_set:Nn \l_@@_prob_pts_tl {0} - } - \marginpar{\l_@@_prob_pts_tl\ \prob@pt@kw\smallskip} - \addtocounter{pts}{\l_@@_prob_pts_tl} - } - } - } -} -% \end{macrocode} -% \end{macro} -% and now the same for the minutes -% \begin{macro}{\show@min} -% \begin{macrocode} -\newcounter{min} -\def\show@min{ - \tl_if_exist:NTF \l_@@_inclprob_min_tl { - \bool_if:NT \c_@@_min_bool { - \marginpar{\l_@@_inclprob_pts_tl\ min} - \addtocounter{min}{\l_@@_inclprob_min_tl} - } - }{ - \tl_if_exist:NT \l_@@_prob_min_tl { - \bool_if:NT \c_@@_min_bool { - \tl_if_empty:NT\l_@@_prob_min_tl{ - \tl_set:Nn \l_@@_prob_min_tl {0} - } - \marginpar{\l_@@_prob_min_tl\ min} - \addtocounter{min}{\l_@@_prob_min_tl} - } - } - } -} -%</package> -% \end{macrocode} -% \end{macro} -% -% \subsection{Testing and Spacing} -% -% \begin{macro}{\testspace} -% \begin{macrocode} -\newcommand\testspace[1]{\bool_if:NT \c_@@_boxed_bool {\vspace*{#1}}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\testnewpage} -% \begin{macrocode} -\newcommand\testnewpage{\bool_if:NT \c_@@_boxed_bool {\newpage}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\testemptypage} -% \begin{macrocode} -\newcommand\testemptypage[1][]{% -\bool_if:NT \c_@@_boxed_bool {\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\test*space} -% \begin{macrocode} -\newcommand\testsmallspace{\testspace{1cm}} -\newcommand\testmedspace{\testspace{2cm}} -\newcommand\testbigspace{\testspace{3cm}} -% \end{macrocode} -% \end{macro} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -\endinput -%%% Local Variables: -%%% mode: doctex -%%% TeX-master: t -%%% End: -% \fi -% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse -% LocalWords: RequirePackage Semiverbatim DefEnvironment OptionalKeyVals soln texttt baz -% LocalWords: exnote DefConstructor inclprob NeedsTeXFormat omd.sty textbackslash exfig -% LocalWords: stopsolution fileversion filedate maketitle setcounter tocdepth newpage -% LocalWords: tableofcontents showmeta showmeta solutionstrue usepackage minipage hrule -% LocalWords: linewidth elefants.prob Elefants smallskip noindent textbf startsolutions -% LocalWords: startsolutions stopsolutions stopsolutions includeproblem includeproblem -% LocalWords: textsf HorIacJuc cscpnrr11 includemhproblem includemhproblem importmodule -% LocalWords: importmhmodule foobar ldots latexml mhcurrentrepos mh-variants mh-variant -% LocalWords: compactenum langle rangle langle rangle ltxml metakeys newif ifexnotes rm -% LocalWords: exnotesfalse exnotestrue ifhints hintsfalse hintstrue ifsolutions ifpts -% LocalWords: solutionsfalse ptsfalse ptstrue ifmin minfalse mintrue ifboxed boxedfalse -% LocalWords: boxedtrue sref mdframed marginpar prob srefaddidkey addmetakey refnum kv -% LocalWords: newcounter ifx thesection theproblem hfill newenvironment metasetkeys ltx -% LocalWords: stepcounter currentsectionlevel xspace ignorespaces surroundwithmdframed -% LocalWords: omdoc autoopen autoclose solvedinminutes kvi qw vals newcommand exhint -% LocalWords: specialcomment excludecomment mhrepos xref marginpar addtocounter doctex -% LocalWords: mh@currentrepos endinput - diff --git a/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx b/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx deleted file mode 100644 index acb6e4bc94b..00000000000 --- a/Master/texmf-dist/source/latex/stex/extensions/tikzinput.dtx +++ /dev/null @@ -1,220 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{Tikzinput: Treating TIKZ code as images -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -% \ifinfulldoc\else -% \begin{abstract} -% This is the documentation for the \pkg{tikzinput} package. For a more high-level -% introduction, see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% In some situations it is more efficient externalize the TIKZ pictures into separate -% (standalone) files, to let {\LaTeX} handle the TIKZ pictures to generate an image, and -% just load it via the usual {\LaTeX} graphics packages. The |tikzinput| package -% supports this workflow, and allows to switch back to native TIKZ via a package option. -% \end{abstract} -% -% \tableofcontents -% -% \input{../../doc/packages/stex-tikzinput} -% \fi -% -% \begin{documentation}\label{pkg:tikzinput:doc} -% -% -% \section{Macros and Environments}\label{pkg:tikzinput:doc:macros} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:tikzinput:impl} -% -% \section{Tikzinput Implementation} -% -% \begin{macrocode} -%<@@=tikzinput> -%<*package> - -%%%%%%%%%%%%% tikzinput.dtx %%%%%%%%%%%%% - -% \end{macrocode} -% -% \begin{macrocode} -\ProvidesExplPackage{tikzinput}{2022/09/14}{3.2.0}{tikzinput package} -\RequirePackage{l3keys2e} - -\keys_define:nn { tikzinput } { - image .bool_set:N = \c_tikzinput_image_bool, - image .default:n = false , - unknown .code:n = {} -} - -\ProcessKeysOptions { tikzinput } - -\bool_if:NTF \c_tikzinput_image_bool { - \RequirePackage{graphicx} - - \providecommand\usetikzlibrary[]{} - \newcommand\tikzinput[2][]{\includegraphics[#1]{#2}} -}{ - \RequirePackage{tikz} - \RequirePackage{standalone} - - \newcommand \tikzinput [2] [] { - \setkeys{Gin}{#1} - \ifx \Gin@ewidth \Gin@exclamation - \ifx \Gin@eheight \Gin@exclamation - \input { #2 } - \else - \resizebox{!}{ \Gin@eheight }{ - \input { #2 } - } - \fi - \else - \ifx \Gin@eheight \Gin@exclamation - \resizebox{ \Gin@ewidth }{!}{ - \input { #2 } - } - \else - \resizebox{ \Gin@ewidth }{ \Gin@eheight }{ - \input { #2 } - } - \fi - \fi - } -} - -\newcommand \ctikzinput [2] [] { - \begin{center} - \tikzinput [#1] {#2} - \end{center} -} - -\@ifpackageloaded{stex}{ - \RequirePackage{stex-tikzinput} -}{} - -% \end{macrocode} -% -% -% \begin{macrocode} -%</package> -%<*stex> -% \end{macrocode} -% -% \begin{macrocode} -\ProvidesExplPackage{stex-tikzinput}{2022/09/14}{3.2.0}{stex-tikzinput} -\RequirePackage{stex} -\RequirePackage{tikzinput} - -\newcommand\mhtikzinput[2][]{% - \def\Gin@mhrepos{}\setkeys{Gin}{#1}% - \stex_in_repository:nn\Gin@mhrepos{ - \tikzinput[#1]{\mhpath{##1}{#2}} - } -} -\newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}} - -\cs_new_protected:Nn \_@@_usetikzlibrary:nn { - \pgfkeys@spdef\pgf@temp{#1} - \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} - \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$} - \catcode`\@=11 - \catcode`\|=12 - \catcode`\$=3 - \pgfutil@InputIfFileExists{#2}{}{} - \catcode`\@=\csname tikz@library@#1@atcode\endcsname - \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname -} - - -\newcommand\libusetikzlibrary[1]{ - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary - } - \seq_clear:N \l_@@_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / tikzlibrary #1 .code.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str - } - - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / tikzlibrary #1 .code.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - - \seq_if_empty:NTF \l_@@_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex} - }{ - \int_compare:nNnTF {\seq_count:N \l_@@_libinput_files_seq} = 1 { - \seq_map_inline:Nn \l_@@_libinput_files_seq { - \_@@_usetikzlibrary:nn{#1}{ ##1 } - } - }{ - \msg_error:nnxx{stex}{error/twofiles}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex} - } - } -} -% \end{macrocode} -% -% \begin{macrocode} -%</stex> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex - -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: - -% LocalWords: libfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight -% LocalWords: ctikzinput mhpath pgfkeys@spdef pgfutil@empty 1@atcode catcode l_tmpa_str -% LocalWords: pgfutil@InputIfFileExists libusetikzlibrary msg_error:nnn notinarchive -% LocalWords: seq_clear:N seq_set_eq:NN l_tmpa_seq c_stex_mathhub_seq seq_set_split:NnV -% LocalWords: l_tmpb_seq seq_if_empty_p:N tikzlibrary seq_put_right:No seq_pop_left:NN diff --git a/Master/texmf-dist/source/latex/stex/hwexam.dtx b/Master/texmf-dist/source/latex/stex/hwexam.dtx new file mode 100644 index 00000000000..003d8a3d879 --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/hwexam.dtx @@ -0,0 +1,323 @@ +% \iffalse meta-comment +% An Infrastructure for marking up Assignments +% Copyright (c) 2019 Michael Kohlhase, all rights reserved +% this file is released under the +% LaTeX Project Public License (LPPL) +% The original of this file is in the public repository at +% http://github.com/sLaTeX/sTeX/ +% \fi +% +% \iffalse +% +%<*driver> +\def\stexdocpath{../doc} +\input{\stexdocpath/stex-docheader} +\stextoptitle{The \texttt{hwexam} Package}{hwexam} +\docmodule +%</driver> +% \fi +% +% \begin{stexmanual} +% \begin{sfragment}{HWExam Manual} + % \input{\stexdocpath/packages/stex-hwexam} +% \end{sfragment} +% \end{stexmanual} +% +% \begin{documentation} +% \begin{sfragment}{HWExam Documentation} +% TODO +% \end{sfragment} +% \end{documentation} +% +%\begin{implementation} +% +% \section{Implementation: The hwexam Package} +% +% \subsection{Package Options} +% +% The first step is to declare (a few) package options that handle whether certain +% information is printed or not. Some come with their own conditionals that are set by the +% options, the rest is just passed on to the |problems| package. +% +% \begin{macrocode} +%<*package> +\ProvidesExplPackage{hwexam}{2023/03/19}{3.3.0}{homework assignments and exams} +\RequirePackage{l3keys2e} + +\keys_define:nn {hwexam / pkg}{ + multiple .default:n = { false }, + multiple .bool_set:N = \c_hwexam_multiple_bool, + unknown .code:n = { + \PassOptionsToPackage{\CurrentOption}{problem} + } +} +\ProcessKeysOptions{ hwexam /pkg } +\RequirePackage{problem} +% \end{macrocode} +% +% \begin{macro}{\hwexam_kw_*} +% For multilinguality, we define internal macros for keywords that can be specialized in +% |*.ldf| files. +% \begin{macrocode} +\AddToHook{begindocument}{ + \ExplSyntaxOn\makeatletter + \input{hwexam-english.ldf} + \ltx@ifpackageloaded{babel}{ + \clist_set:Nx \l_tmpa_clist {\bbl@loaded} + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ + \input{hwexam-ngerman.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ + \input{hwexam-finnish.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ + \input{hwexam-french.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ + \input{hwexam-russian.ldf} + } + }{} + \makeatother\ExplSyntaxOff +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Assignments} +% +% Then we set up a counter for problems and make the problem counter inherited from +% |problem.sty| depend on it. Furthermore, we specialize the |\prob@label| macro to take +% the assignment counter into account. +% +% \begin{environment}{assignment} +% \begin{macrocode} +\stex_keys_define:nnnn{ assignment }{ + \tl_clear:N \l_stex_key_number_tl + \tl_clear:N \l_stex_key_given_tl + \tl_clear:N \l_stex_key_due_tl +}{ + number .tl_set:N = \l_stex_key_number_tl, + given .tl_set:N = \l_stex_key_given_tl, + due .tl_set:N = \l_stex_key_due_tl, + unknown .code:n = {} +}{id,title,style} + +\newcounter{assignment} +\stex_new_stylable_env:nnnnnnn {assignment}{O{}}{ + \cs_if_exist:NTF \l_hwexam_includeassignment_keys_tl { + \tl_put_left:Nn \l_hwexam_includeassignment_keys_tl {#1,} + \exp_args:Nno \stex_keys_set:nn{assignment}{ + \l_hwexam_includeassignment_keys_tl + } + }{ + \stex_keys_set:nn{assignment}{#1} + } + \tl_if_empty:NF \l_stex_key_number_tl { + \global\setcounter{assignment}{\int_eval:n{\l_stex_key_number_tl-1}} + } + \global\refstepcounter{assignment} + \setcounter{sproblem}{0} + \def\thesproblem{\theassignment.\arabic{sproblem}} + \stex_style_apply: + \_stex_do_id: +}{ + \stex_style_apply: +}{ + \par\begin{center} + \textbf{\Large\assignmentautorefname~\theassignment + \tl_if_empty:NF \l_stex_key_title_tl { + {~}--~\l_stex_key_title_tl + } + }\par\smallskip + \textbf{ + \tl_if_empty:NF \l_stex_key_given_tl { + \hwexam@kw@given:~\l_stex_key_given_tl\quad + } + \tl_if_empty:NF \l_stex_key_due_tl { + \hwexam@kw@due:~\l_stex_key_due_tl\quad + } + } + \end{center} + \par\bigskip +}{ + \par\pagebreak +}{} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\includeassignment} +% \begin{macrocode} +\NewDocumentCommand\includeassignment{O{} m}{ + \group_begin: + \tl_set:Nn \l_hwexam_includeassignment_keys_tl {#1} + \stex_keys_set:nn{includeproblem}{#1} + \exp_args:Nno \use:nn{\inputref[}\l_stex_key_mhrepos_str]{#2} + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% Restoring information about problems: +% +% \begin{macrocode} +\prop_new:N \c_@@_problems_prop +\tl_set:Nn \c_@@_total_mins_tl {0} +\tl_set:Nn \c_@@_total_pts_tl {0} +\int_new:N \c_@@_total_problems_int +\cs_set_protected:Npn \problem@restore #1 #2 #3 { + \int_gincr:N \c_@@_total_problems_int + \prop_gput:Nnn \c_@@_problems_prop {#1}{{#2}{#3}} + \tl_gset:Nx \c_@@_total_pts_tl { \int_eval:n { \c_@@_total_pts_tl + #2 }} + \tl_gset:Nx \c_@@_total_mins_tl { \int_eval:n { \c_@@_total_mins_tl + #2 }} +} +% \end{macrocode} +% +% \begin{macro}{\correction@table} +% This macro generates the correction table +% \begin{macrocode} +\newcommand\correction@table{ + \int_compare:nNnT \c_@@_total_problems_int = 0 { + \int_incr:N \c_@@_total_problems_int + \prop_put:Nnn \c_@@_problems_prop {~}{{~}{~}} + } + \tl_clear:N \l_tmpa_tl + \tl_clear:N \l_tmpb_tl + \tl_clear:N \l_tmpc_tl + \prop_map_inline:Nn \c_@@_problems_prop { + \tl_put_right:Nn \l_tmpa_tl { ##1 & } + \tl_put_right:Nx \l_tmpb_tl { \use_i:nn ##2 & } + \tl_put_right:Nn \l_tmpc_tl { & } + } + \resizebox{\textwidth}{!}{% +\exp_args:Nne \begin{tabular}{|l|*{\int_use:N \c_@@_total_problems_int}{c|}c||l|}\hline +&\exp_args:Ne \multicolumn{\int_eval:n{ \c_@@_total_problems_int + 1}}{c||} +{\footnotesize\hwexam@kw@forgrading} &\\\hline +\hwexam@kw@probs & \l_tmpa_tl \hwexam@kw@sum & \hwexam@kw@grade\\\hline +\hwexam@kw@pts & \l_tmpb_tl \c_@@_total_pts_tl & \\\hline +\hwexam@kw@reached & \l_tmpc_tl & \\[.7cm]\hline +\end{tabular}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testheading} +% \begin{macrocode} +\def\hwexamheader{\input{hwexam-default.header}} + +\def\hwexamminutes{ + \tl_if_empty:NTF \hwexam@duration { + {\hwexam@min}~\hwexam@minutes@kw + }{ + \hwexam@duration + } +} + +\stex_keys_define:nnnn{ hwexam / testheading }{ + \tl_clear:N \hwexam@min + \tl_clear:N \hwexam@duration + \tl_clear:N \hwexam@reqpts + \tl_clear:N \hwexam@tools +}{ + min .tl_set:N = \hwexam@min, + duration .tl_set:N = \hwexam@duration, + reqpts .tl_set:N = \hwexam@reqpts, + tools .tl_set:N = \hwexam@tools +}{} + +\newenvironment{testheading}[1][]{ + \stex_keys_set:nn { hwexam / testheading}{#1} + + \tl_set_eq:NN \hwexam@totalpts \c_@@_total_pts_tl + \tl_set_eq:NN \hwexam@totalmin \c_@@_total_mins_tl + \tl_set:Nx \hwexam@checktime {\int_eval:n { \hwexam@min - \hwexam@totalmin }} + + \newif\if@bonuspoints + \tl_if_empty:NTF \hwexam@reqpts { + \@bonuspointsfalse + }{ + \tl_set:Nx \hwexam@bonuspts { + \int_eval:n{\hwexam@totalpts - \hwexam@reqpts} + } + \@bonuspointstrue + } + + \makeatletter\hwexamheader\makeatother +}{ + \newpage +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testemptypage} +% \begin{macrocode} +\newcommand\testemptypage[1][]{% + \bool_if:NT \c__problems_test_bool {\ \vfill\begin{center}\hwexam@kw@testemptypage\end{center}\eject} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testspace} +% \begin{macrocode} +\newcommand\testspace[1]{\bool_if:NT \c__problems_test_bool {\vspace*{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testnewpage} +% \begin{macrocode} +\newcommand\testnewpage{\bool_if:NT \c__problems_test_bool {\newpage}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \subsection{Leftovers} +% +% at some point, we may want to reactivate the logos font, then we use +% \begin{verbatim} +% here we define the logos that characterize the assignment +% \font\bierfont=../assignments/bierglas +% \font\denkerfont=../assignments/denker +% \font\uhrfont=../assignments/uhr +% \font\warnschildfont=../assignments/achtung +% +% \newcommand\bierglas{{\bierfont\char65}} +% \newcommand\denker{{\denkerfont\char65}} +% \newcommand\uhr{{\uhrfont\char65}} +% \newcommand\warnschild{{\warnschildfont\char 65}} +% \newcommand\hardA{\warnschild} +% \newcommand\longA{\uhr} +% \newcommand\thinkA{\denker} +% \newcommand\discussA{\bierglas} +% \end{verbatim} +% \end{implementation} +\endinput +% \iffalse + +%%% Local Variables: +%%% mode: doctex +%%% TeX-master: t +%%% End: +% \fi +% LocalWords: texttt scsys sc latexml fileversion filedate maketitle setcounter newpage +% LocalWords: tocdepth tableofcontents pts showmeta showmeta showignores omdoc extrefs +% LocalWords: testspace testnewpage testemptypage testheading testheading reqpts reqpts +% LocalWords: exfig makeatletter makeatother vspace hrule vspace vspace noindent textsf +% LocalWords: includeassignment includeassignment HorIacJuc cscpnrr11 importmodule baz +% LocalWords: includemhassignment includemhassignment importmhmodule foobar ldots sref +% LocalWords: mhcurrentrepos mh-variants mh-variant compactenum printbibliography Cwd +% LocalWords: langle rangle langle rangle ltxml.cls ltxml.sty respetively metakeys qw +% LocalWords: cwd stex graphicx amssymb amstext amsmath newif iftest testfalse testtrue +% LocalWords: ifsolutions solutionsfalse ifmultiple multiplefalse multipletrue keyval +% LocalWords: ltxml assig srefaddidkey addmetakey ifx assignment@titleblock stepcounter +% LocalWords: document@hwexamtype importmodules metasetkeys inclassig@title inclassig +% LocalWords: inclassig@title inclassig@type inclassig@type inclassig@number xspace kv +% LocalWords: inclassig@number inclassig@due inclassig@due inclassig@given ignorespaces +% LocalWords: inclassig@given newenvironment currentsectionlevel OptionalKeyVals kvi +% LocalWords: omgroup vals hwexamtype ednote textbackslash newcommand inputassignment +% LocalWords: unlist quizheading tas hspace hfill textbf newcount vfill addtocounter +% LocalWords: theassignment@totalmin theassignment@totalpts assignment@probs xdef hline +% LocalWords: assignment@totalpts assignment@totalmin correction@probs correction@probs +% LocalWords: newcounter theassignment@probs footnotesize mh@currentrepos endinput +% LocalWords: inclassig@mhrepos inclassig@mhrepos doctex inputmhassignment +% LocalWords: GPL structuresharing STR iffalse cls NeedsTeXFormat hwexam hwexam.dtx sc diff --git a/Master/texmf-dist/source/latex/stex/notesslides.dtx b/Master/texmf-dist/source/latex/stex/notesslides.dtx new file mode 100644 index 00000000000..c2f9f594c92 --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/notesslides.dtx @@ -0,0 +1,706 @@ +% \iffalse meta-comment +% A LaTeX Class for Semantic Lectures Slides (originally developed for Michael Kohlhase) +% Copyright (c) 2019 Michael Kohlhase, all rights reserved +% this file is released under the +% Gnu Library Public Licences (LGPL) +% +% The original of this file is in the public repository at +% http://github.com/sLaTeX/sTeX/ +% \fi +% +% \iffalse +% +%<*driver> +\def\stexdocpath{../doc} +\input{\stexdocpath/stex-docheader} +\stextoptitle{NotesSlides -- Slides and Course Notes}{notesslides} +\docmodule +%</driver> +% \fi +% +% +% \begin{stexmanual} +% \begin{sfragment}{NotesSlides Manual} + % \input{\stexdocpath/packages/stex-notesslides} +% \end{sfragment} +% \end{stexmanual} +% +% \begin{documentation} +% \begin{sfragment}{NotesSlides Documentation} +% TODO +% \end{sfragment} +% \end{documentation} +% +% +% \begin{implementation}\label{pkg:notesslides:impl} +% +% \begin{sfragment}{Implementation: The notesslides Package} +% +%\begin{sfragment}[id=sec:impl:init]{Class and Package Options} +% +% We define some Package Options and switches for the |notesslides| class and activate them +% by passing them on to |beamer.cls| and |omdoc.cls| and the |notesslides| package. We pass +% the |nontheorem| option to the |statements| package when we are not in notes mode, since +% the |beamer| package has its own (overlay-aware) theorem environments. +% +% \begin{macrocode} +%<*cls> +%<@@=notesslides> +\ProvidesExplClass{notesslides}{2023/03/19}{3.3.0}{notesslides Class} +\RequirePackage{l3keys2e} + +\str_const:Nn \c_@@_class_str {article} + +\keys_define:nn{notesslides / cls}{ + class .str_set_x:N = \c_@@_class_str, + notes .bool_set:N = \c_notesslides_notes_bool , + slides .code:n = { \bool_set_false:N \c_notesslides_notes_bool }, + %docopt .str_set_x:N = \c_@@_docopt_str, + unknown .code:n = { + \PassOptionsToClass{\CurrentOption}{beamer} + \PassOptionsToClass{\CurrentOption}{\c_@@_class_str} + \PassOptionsToPackage{\CurrentOption}{notesslides} + \PassOptionsToPackage{\CurrentOption}{stex} + } +} +\ProcessKeysOptions{ notesslides / cls } + +\RequirePackage{stex} +\stex_if_html_backend:T { + \bool_set_true:N\c_notesslides_notes_bool +} + +\bool_if:NTF \c_notesslides_notes_bool { + \PassOptionsToPackage{notes=true}{notesslides} + \message{notesslides.cls:~Formatting~document~in~notes~mode} +}{ + \PassOptionsToPackage{notes=false}{notesslides} + \message{notesslides.cls:~Formatting~document~in~slides~mode} +} + +\bool_if:NTF \c_notesslides_notes_bool { + \LoadClass{\c_@@_class_str} +}{ + \LoadClass[10pt,notheorems,xcolor={dvipsnames,svgnames}]{beamer} + %\newcounter{Item} + %\newcounter{paragraph} + %\newcounter{subparagraph} + %\newcounter{Hfootnote} +} +\RequirePackage{notesslides} +%</cls> +% \end{macrocode} +% now we do the same for the |notesslides| package. +% \begin{macrocode} +%<*package> +\ProvidesExplPackage{notesslides}{2023/03/19}{3.3.0}{notesslides Package} +\RequirePackage{l3keys2e} + +\keys_define:nn{notesslides / pkg}{ + notes .bool_set:N = \c_notesslides_notes_bool , + slides .code:n = { \bool_set_false:N \c_notesslides_notes_bool }, + sectocframes .bool_set:N = \c_notesslides_sectocframes_bool , + topsect .str_set_x:N = \c_notesslides_topsect_str, + unknown .code:n = { + \PassOptionsToPackage{\CurrentOption}{stex} + \PassOptionsToPackage{\CurrentOption}{tikzinput} + } +} +\ProcessKeysOptions{ notesslides / pkg } + +\RequirePackage{stex} +\stex_if_html_backend:T { + \bool_set_true:N\c_notesslides_notes_bool +} + +\cs_set:Npn \sectiontitleemph #1 { + \textbf{\Large #1} +} + +\newif\ifnotes +\bool_if:NTF \c_notesslides_notes_bool { + \notestrue + \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor} + \RequirePackage[noamsthm,hyperref]{beamerarticle} + \RequirePackage{mdframed} + \str_if_empty:NTF \c_notesslides_topsect_str{ + %\setsectionlevel{section} + } { + \exp_args:No \setsectionlevel \c_notesslides_topsect_str + } +}{ + \notesfalse + + \cs_new_protected:Nn \_@@_do_sectocframes: { + \cs_set_protected:Nn \_@@_do_label:n { + \str_case:nnF{##1}{ + {part} { + \tl_set:Nx\l_@@_num{\thepart} + \tl_set:cx{@ @ label}{ + \cs_if_exist:NTF\parttitlename{\exp_not:N\parttitlename}{\exp_not:N\partname}{}~\l_@@_num\\} + } + {chapter} { + \tl_set:Nx\l_@@_num{\thechapter} + \tl_set:cx{@ @ label}{ + \cs_if_exist:NTF\chaptertitlename{\exp_not:N\chaptertitlename}{\exp_not:N\chaptername}{}~\l_@@_num\\} + } + {section} { + \tl_set:Nx\l_@@_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection} + \tl_set:cx{@ @ label}{\l_@@_num\quad} + } + {subsection} { + \tl_set:Nx\l_@@_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection} + \tl_set:cx{@ @ label}{\l_@@_num\quad} + } + {subsubsection} { + \tl_set:Nx\l_@@_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection} + \tl_set:cx{@ @ label}{\l_@@_num\quad} + } + {paragraph} { + \tl_set:Nx\l_@@_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph} + \tl_set:cx{@ @ label}{\l_@@_num\quad} + } + }{ + \tl_set:Nx\l_@@_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph.\thesubparagraph} + \tl_set:cx{@ @ label}{\l_@@_num\quad} + } + } + \cs_set_protected:Nn \_sfragment_do_level:nn { + \tl_if_exist:cT{c@##1}{\stepcounter{##1}} + \addcontentsline{toc}{##1}{\protect\numberline{\use:c{the##1}}##2} + \_@@_do_label:n{##1} + \pdfbookmark[\int_use:N \l_stex_docheader_sect]{\l_@@_num\ ##2}{##1.\l_@@_num} + \begin{frame}[noframenumbering] + \vfill\centering + \sectiontitleemph{ + \use:c{@ @ label} ##2 + } + \end{frame} + \int_incr:N \l_stex_docheader_sect + \tl_set:Nn \stex_current_section_level{##1} + } + } + + \AtBeginDocument{ + \str_if_empty:NTF \c_notesslides_topsect_str { + \setsectionlevel{section} + } { + \exp_args:No \setsectionlevel \c_notesslides_topsect_str + \exp_args:No \str_if_eq:nnTF \c_notesslides_topsect_str {chapter} { + \_@@_define_chapter: + }{ + \exp_args:No \str_if_eq:nnT \c_notesslides_topsect_str {part} { + \_@@_define_chapter: + \_@@_define_part: + } + } + } + } + + \bool_if:NT \c_notesslides_sectocframes_bool { + \_@@_do_sectocframes: + } +} + +\cs_new_protected:Nn \_@@_define_chapter: { + \cs_if_exist:NF \chaptername { + \cs_set_protected:Npn \chaptername {Chapter} + } + \cs_if_exist:NF \chapter { + \cs_set_protected:Npn \chapter {INVALID} + } + \cs_if_exist:NF \c@chapter { + \newcounter{chapter}\counterwithin*{section}{chapter} + } +} + +\cs_new_protected:Nn \_@@_define_part: { + \cs_if_exist:NF \partname { + \cs_set_protected:Npn \partname {Part} + } + \cs_if_exist:NF \part { + \cs_set_protected:Npn \part {INVALID} + } + \cs_if_exist:NF \c@part { + \newcounter{part}\counterwithin*{chapter}{part} + } +} +% \end{macrocode} +% +% \begin{macro}{\prematurestop} +% We initialize |\afterprematurestop|, and provide +% |\prematurestop@endsfragment| which looks up |\sfragment@level| and recursively ends +% enough |{sfragment}|s. +% \begin{macrocode} +\def \c_@@_document_str{document} +\newcommand\afterprematurestop{} +\def\prematurestop@endsfragment{ + \unless\ifx\@currenvir\c_@@_document_str + \expandafter\expandafter\expandafter\end\expandafter\expandafter\expandafter{\expandafter\@currenvir\expandafter} + \expandafter\prematurestop@endsfragment + \fi +} +\providecommand\prematurestop{ + \stex_if_html_backend:F{ + \message{Stopping~sTeX~processing~prematurely} + \prematurestop@endsfragment + \afterprematurestop + \end{document} + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% \begin{sfragment}[id=sec:impl:noteslides]{Notes and Slides} +% For the notes case, we also provide the |\usetheme| macro that would otherwise +% come from the the |beamer| class. +% \begin{macrocode} +\bool_if:NT \c_notesslides_notes_bool { + \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}} +} +\NewDocumentCommand \libusetheme {O{} m} { + \libusepackage[#1]{beamertheme#2} +} +% \end{macrocode} +% We define the sizes of slides in the notes. Somehow, we cannot get by with the same +% here. +% \begin{macrocode} +\newlength{\slidewidth}\setlength{\slidewidth}{13.5cm} +\newlength{\slideheight}\setlength{\slideheight}{9cm} +% \end{macrocode} +% +% We first set up the slide boxes in |notes| mode. We set up sizes and provide a +% box register for the frames and a counter for the slides. +% +% \begin{macrocode} +\ifnotes + +\newlength{\slideframewidth} +\setlength{\slideframewidth}{1.5pt} +% \end{macrocode} +% +% \begin{environment}{frame} +% We first define the keys. +% \begin{macrocode} +\cs_new_protected:Nn \_@@_do_yes_param:Nn { + \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{ + \bool_set_true:N #1 + }{ + \bool_set_false:N #1 + } +} + +\stex_keys_define:nnnn{notesslides / frame}{ + \str_clear:N \l_@@_frame_label_str + \bool_set_true:N \l_@@_frame_allowframebreaks_bool + \bool_set_true:N \l_@@_frame_allowdisplaybreaks_bool + \bool_set_true:N \l_@@_frame_fragile_bool + \bool_set_true:N \l_@@_frame_shrink_bool + \bool_set_true:N \l_@@_frame_squeeze_bool + \bool_set_true:N \l_@@_frame_t_bool +}{ + label .str_set_x:N = \l_@@_frame_label_str, + allowframebreaks .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_allowframebreaks_bool { #1 } + }, + allowdisplaybreaks .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_allowdisplaybreaks_bool { #1 } + }, + fragile .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_fragile_bool { #1 } + }, + shrink .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_shrink_bool { #1 } + }, + squeeze .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_squeeze_bool { #1 } + }, + t .code:n = { + \_@@_do_yes_param:Nn \l_@@_frame_t_bool { #1 } + }, + unknown .code:n = {} +}{} +% \end{macrocode} +% +% We redefine the |itemize| environment so that it looks more like the one in |beamer|. +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_setup_itemize: { + \def\itemize@level{outer} + \def\itemize@outer{outer} + \def\itemize@inner{inner} + %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}} + \renewenvironment{itemize}{ + \ifx\itemize@level\itemize@outer + \def\itemize@label{$\rhd$} + \fi + \ifx\itemize@level\itemize@inner + \def\itemize@label{$\scriptstyle\rhd$} + \fi + \begin{list} + {\itemize@label} + {\setlength{\labelsep}{.3em} + \setlength{\labelwidth}{.5em} + \setlength{\leftmargin}{1.5em} + } + \edef\itemize@level{\itemize@inner} + }{ + \end{list} + } +} +% \end{macrocode} +% +% We create the box with the |mdframed| environment from the equinymous package. +% +% \begin{macrocode} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_@@_frame_box_begin: { + \vbox\bgroup + \begin{stex_annotate_env}{shtml:frame={}} + \mdf@patchamsthm\notesslidesfont + } + \cs_new_protected:Nn \_@@_frame_box_end: { + %^^A \notesslides@slidelabel + \medskip\par\noindent\tiny\notesslidesfooter + \end{stex_annotate_env}\egroup + } +}{ + \cs_new_protected:Nn \_@@_frame_box_begin: { + \begin{mdframed}[ + linewidth=\slideframewidth, + skipabove=1ex, + skipbelow=1ex, + userdefinedwidth=\slidewidth, + align=center + ]\notesslidesfont + } + \cs_new_protected:Nn \_@@_frame_box_end: { + \medskip\par\noindent\tiny\notesslidesfooter%^^A\notesslides@slidelabel + \end{mdframed} + } +} +% \end{macrocode} +% +% We define the environment, read them, and construct the slide number and label. +% +% \begin{macrocode} +\renewenvironment{frame}[1][]{ + \stex_keys_set:nn{notesslides / frame}{#1} + \stepcounter{framenumber} + \renewcommand\newpage{\addtocounter{framenumber}{1}} + \def\@currentlabel{\theframenumber} + \str_if_empty:NF \l_@@_frame_label_str { + \label{\l_@@_frame_label_str} + } + \_@@_setup_itemize: + \_@@_frame_box_begin: +}{ + \_@@_frame_box_end: +} +% \end{macrocode} +% \end{environment} +% +% Now, we need to redefine the frametitle (we are still in course notes mode). +% \begin{macro}{\frametitle} +% \begin{macrocode} +\renewcommand{\frametitle}[1]{ + \stexdoctitle { #1 } + \notesslidestitleemph{#1}\medskip +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pause} +% \begin{macrocode} +\newcommand\pause{} +% \end{macrocode} +% \end{macro} +% +% We redefine the \env{columns} and \env{column} environments: +% +% \begin{macrocode} +\renewenvironment{columns}[1][]{ + \par\noindent + \begin{minipage} + \slidewidth\centering\leavevmode +% \stex_if_html_backend:T{ +% \cs_if_exist:NT \rustex_if:T { +% \rustex_if:T {\par +% \rustex_direct_HTML:n{<table><tr><td>} +% } +% } +% } +}{ +% \stex_if_html_backend:T{ +% \cs_if_exist:NT \rustex_if:T { +% \rustex_if:T {\par +% \rustex_direct_HTML:n{</td></tr></table>} +% } +% } +% } + \end{minipage}\par\noindent +} +\newsavebox\columnbox +\renewenvironment<>{column}[2][]{ + \begin{lrbox}{\columnbox} +% \stex_if_html_backend:T{ +% \cs_if_exist:NT \rustex_if:T { +% \rustex_if:T {\par +% \rustex_direct_HTML:n{</td><td>} +% } +% } +% } + \begin{minipage}{#2} +}{ + \end{minipage} +% \stex_if_html_backend:T{ +% \cs_if_exist:NT \rustex_if:T { +% \rustex_if:T {\par +% \rustex_direct_HTML:n{</td><td>} +% } +% } +% } + \end{lrbox}\usebox\columnbox +} +% \end{macrocode} +% +% +% \begin{macrocode} +\fi +% \end{macrocode} +% +% \end{sfragment} +% +% \begin{sfragment}{Environment and Macro Patches} +% +% The \env{note} environment is used to leave out text in the |slides| mode. It does not have +% a counterpart in OMDoc. So for course notes, we define the \env{note} environment to be a +% no-operation otherwise we declare the \env{note} environment to produce no +% output. +% +% \begin{macrocode} +\bool_if:NTF \c_notesslides_notes_bool { + \renewenvironment{note}{\ignorespaces}{} +}{ + \renewenvironment{note}{\setbox \l_tmpa_box\vbox\bgroup}{\egroup} +} +% \end{macrocode} +% +% For other environments we introduce variants prefixed with |n|, +% which are excluded in |slides| mode. +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_notes_env:nnnn { + \bool_if:NTF \c_notesslides_notes_bool { + \newenvironment{#1}#2{#3}{#4} + }{ + \newenvironment{#1}#2{ + \cs_set:Npn \_@@_eat: ####1 \end ####2 { + \str_if_eq:nnTF{#1}{####2}{ + \end{#1} + }{ + \_@@_eat: + } + } + \_@@_eat: + %\setbox\l_tmpa_box\vbox\bgroup#3 + }{ + %#4\egroup + } + } +} + +\_@@_notes_env:nnnn{nparagraph}{[1][]}{\begin{sparagraph}[#1]}{\end{sparagraph}} +\_@@_notes_env:nnnn{nfragment}{[2][]}{\begin{sfragment}[#1]{#2}}{\end{sfragment}} +\_@@_notes_env:nnnn{ndefinition}{[1][]}{\begin{sdefinition}[#1]}{\end{sdefinition}} +\_@@_notes_env:nnnn{nassertion}{[1][]}{\begin{sassertion}[#1]}{\end{sassertion}} +\_@@_notes_env:nnnn{nproof}{[2][]}{\begin{sproof}[#1]{#2}}{\end{sproof}} +\_@@_notes_env:nnnn{nexample}{[1][]}{\begin{sexample}[#1]}{\end{sexample}} + +\RequirePackage{graphicx} + +\NewDocumentCommand\frameimage{s O{} m}{ + \IfBooleanTF #1 { + \begin{frame}[plain] + }{ + \begin{frame} + } + \bool_if:NTF \c_notesslides_notes_bool { + \slidewidth=\dimexpr\slidewidth-(2\slideframewidth)\relax + }{ + \slidewidth=\textwidth\relax + } + \def\Gin@ewidth{}\setkeys{Gin}{#2} + \tl_if_empty:NTF \Gin@ewidth { + \mhgraphics[width=\slidewidth,#2]{#3} + }{ + \mhgraphics[#2]{#3} + } + \end{frame} +} +% \end{macrocode} +% +% hacking inputref: +% +% \begin{macro}{\inputref*} +% \begin{macrocode} +\cs_set_eq:NN\_@@_inputref:\inputref +\cs_set_protected:Npn\inputref{\@ifstar\ninputref\_@@_inputref:} +\bool_if:NTF \c_notesslides_notes_bool { + \newcommand\ninputref[2][]{ + \_@@_inputref:[#1]{#2} + } +}{ + \newcommand\ninputref[2][]{} +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Styling Across Notes/Slides} +% \begin{macrocode} +\def\notesslidestitleemph#1{ + {\Large\bf\sf#1} + \vskip0.1\baselineskip + \leaders\vrule width \textwidth + \vskip0.4pt% + \nointerlineskip +} + +\def\notesslidesfooter{} + +\let\notesslidesfont\sffamily +% \end{macrocode} +% \end{sfragment} +% +% \begin{sfragment}{Beamer Compatibility} +% All of this should be removed and made part of a template +% \begin{macrocode} + +\bool_if:NT \c_notesslides_notes_bool { + \def\author{\@dblarg\ns@author} + \long\def\ns@author[#1]#2{% + \tl_if_empty:nTF{#1}{ + \def\beamer@shortauthor{#2} + }{ + \def\beamer@shortauthor{#1} + } + \def\@author{#2} + } + \def\title{\@dblarg\ns@title} + \long\def\ns@title[#1]#2{% + \tl_if_empty:nTF{#1}{ + \def\beamer@shorttitle{#2} + }{ + \def\beamer@shorttitle{#1} + } + \def\@title{#2} + \stexdoctitle{#2} + } + \def\insertshortauthor{ + \hbox\bgroup\def\\{}\cs_if_exist:NT\beamer@shortauthor\beamer@shortauthor\egroup + } + \def\insertshorttitle{ + \hbox\bgroup\def\\{}\cs_if_exist:NT\beamer@shorttitle\beamer@shorttitle\egroup + } + \stex_if_html_backend:TF{ + \def\insertframenumber{\stex_annotate:nn{shtml:framenumber={}}{}} + }{ + \def\insertframenumber{\@arabic\c@framenumber} + } + \def\insertshortdate{\today} +} +% \end{macrocode} +% \end{sfragment} +% +% +% \subsection{TODO Excursions}\label{sec:impl:excursions} +% +% \begin{macro}{\excursion} +% The excursion macros are very simple, we define a new internal macro |\excursionref| and +% use it in |\excursion|, which is just an |\inputref| that checks if the new macro is +% defined before formatting the file in the argument. +% \begin{macrocode} +\gdef\printexcursions{} +\newcommand\excursionref[2]{% label, text + \bool_if:NT \c_notesslides_notes_bool { + \begin{sparagraph}[title=Excursion] + #2 \sref[fallback=the appendix]{#1}. + \end{sparagraph} + } +} +\newcommand\activate@excursion[2][]{ + \tl_gput_right:Nn\printexcursions{\inputref[#1]{#2}} +} +\newcommand\excursion[4][]{% repos, label, path, text + \bool_if:NT \c_notesslides_notes_bool { + \activate@excursion[#1]{#3} + \excursionref{#2}{#4} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\excursiongroup} +% \begin{macrocode} +\keys_define:nn{notesslides / excursiongroup }{ + id .str_set_x:N = \l_@@_excursion_id_str, + intro .tl_set:N = \l_@@_excursion_intro_tl, + archive .str_set_x:N = \l_@@_excursion_mhrepos_str +} +\cs_new_protected:Nn \_@@_excursion_args:n { + \tl_clear:N \l_@@_excursion_intro_tl + \str_clear:N \l_@@_excursion_id_str + \str_clear:N \l_@@_excursion_mhrepos_str + \keys_set:nn {notesslides / excursiongroup }{ #1 } +} +\newcommand\excursiongroup[1][]{ + \_@@_excursion_args:n{ #1 } + \tl_if_empty:NF\printexcursions + {\IfInputref{}{\begin{note} + \begin{sfragment}{Excursions}% TODO pass on id + \ifdefempty\l_@@_excursion_intro_tl{}{ + \exp_args:NNe \use:nn \inputref{[\l_@@_excursion_mhrepos_str]{ + \l_@@_excursion_intro_tl + }} + } + \printexcursions% + \end{sfragment} + \end{note}}} +} +\ifcsname beameritemnestingprefix\endcsname\else\def\beameritemnestingprefix{}\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\prop_new:N \g_@@_variables_prop +\cs_set_protected:Npn \setSGvar #1 #2 { + \prop_gput:Nnn \g_@@_variables_prop {#1}{#2} +} +\cs_set_protected:Npn \useSGvar #1 { + \prop_item:Nn \g_@@_variables_prop {#1} +} +\cs_set_protected:Npn \ifSGvar #1 #2 #3 { + \prop_get:NnNF \g_@@_variables_prop {#1} \l_@@_tmp { + \PackageError{document-structure} + {The sTeX Global variable #1 is undefined} + {set it with \protect\setSGvar}\TODO better error + } + \tl_if_eq:NnT \l_@@_tmp {#2}{ #3 } +} + + +%</package> +% \end{macrocode} +% +% \end{sfragment} +% \end{implementation} +\endinput +% \endinput +% Local Variables: +% mode: doctex +% TeX-master: t +% End: + diff --git a/Master/texmf-dist/source/latex/stex/problem.dtx b/Master/texmf-dist/source/latex/stex/problem.dtx new file mode 100644 index 00000000000..c62a9242ba9 --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/problem.dtx @@ -0,0 +1,638 @@ +% \iffalse meta-comment +% An Infrastructure for Problems +% Copyright (c) 2019 Michael Kohlhase, all rights reserved +% this file is released under the +% LaTeX Project Public License (LPPL) +% The original of this file is in the public repository at +% http://github.com/sLaTeX/sTeX/ +% \fi +% +% \iffalse +% +%<*driver> +\def\stexdocpath{../doc} +\input{\stexdocpath/stex-docheader} +\stextoptitle{The \texttt{problem} Package}{problem} +\docmodule +%</driver> +% \fi +% +% \begin{stexmanual} +% \begin{sfragment}{Problem Manual} + % \input{\stexdocpath/packages/stex-problem} +% \end{sfragment} +% \end{stexmanual} +% +% \begin{documentation} +% \begin{sfragment}{Problem Documentation} +% TODO +% \end{sfragment} +% \end{documentation} +% +% \begin{implementation} +% +% \section{Implementation: The problem Package} +% +% \subsection{Package Options}\label{sec:impl:options} +% +% The first step is to declare (a few) package options that handle whether certain +% information is printed or not. They all come with their own conditionals that are set by +% the options. +% +% \begin{macrocode} +%<*package> +%<@@=problems> +\ProvidesExplPackage{problem}{2023/03/19}{3.3.0}{Semantic Markup for Problems} +\RequirePackage{l3keys2e} + +\keys_define:nn { problem / pkg }{ + notes .default:n = { true }, + notes .bool_set:N = \c_@@_notes_bool, + gnotes .default:n = { true }, + gnotes .bool_set:N = \c_@@_gnotes_bool, + hints .default:n = { true }, + hints .bool_set:N = \c_@@_hints_bool, + solutions .default:n = { true }, + solutions .bool_set:N = \c_@@_solutions_bool, + pts .default:n = { true }, + pts .bool_set:N = \c_@@_pts_bool, + min .default:n = { true }, + min .bool_set:N = \c_@@_min_bool, + %boxed .default:n = { true }, + %boxed .bool_set:N = \c_@@_boxed_bool, + test .default:n = { true }, + test .bool_set:N = \c_@@_test_bool, + unknown .code:n = { + \PassOptionsToPackage{\CurrentOption}{stex} + } +} +\newif\ifsolutions + +\ProcessKeysOptions{ problem / pkg } +\bool_if:NTF \c_@@_solutions_bool { + \solutionstrue +}{ + \solutionsfalse +} +\RequirePackage{stex} +% \end{macrocode} +% +% \begin{macro}{\problem@kw@*} +% For multilinguality, we define internal macros for keywords that can be specialized in +% |*.ldf| files. +% \begin{macrocode} +\AddToHook{begindocument}{ + \ExplSyntaxOn\makeatletter + \input{problem-english.ldf} + \ltx@ifpackageloaded{babel}{ + \clist_set:Nx \l_tmpa_clist {\bbl@loaded} + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ + \input{problem-ngerman.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ + \input{problem-finnish.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ + \input{problem-french.ldf} + } + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ + \input{problem-russian.ldf} + } + }{} + \makeatother\ExplSyntaxOff +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Problems and Solutions}\label{sec:impl:probsols} +% +% We now prepare the KeyVal support for problems. The key macros just set appropriate +% internal macros. +% +% \begin{macrocode} +\stex_keys_define:nnnn{ problem }{ + \tl_set:Nn \l_stex_key_pts_tl 0 + \tl_set:Nn \l_stex_key_min_tl 0 + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_mhrepos_str +}{ + pts .tl_set:N = \l_stex_key_pts_tl, + min .tl_set:N = \l_stex_key_min_tl, + name .str_set:N = \l_stex_key_name_str, + archive .str_set:N = \l_stex_key_mhrepos_str, + creators .code:n = {} + %imports .tl_set:N = \l_@@_prob_imports_tl, + %refnum .int_set:N = \l_@@_prob_refnum_int, +}{id,title,style,uses} +% \end{macrocode} +% +% Then we set up a counter for problems. +% \begin{macro}{\numberproblemsin} +% \begin{macrocode} +\newcounter{sproblem}[section] +\newcommand\numberproblemsin[1]{ + \@addtoreset{sproblem}{#1} + \def\thesproblem{\arabic{#1}.\arabic{sproblem}} +} +\numberproblemsin{section} +%\def\theplainsproblem{\arabic{sproblem}} +%\def\thesproblem{\thesection.\theplainsproblem} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{sproblem} +% \begin{macrocode} +\newcounter{pts} +\newcounter{min} +\stex_new_stylable_env:nnnnnnn {problem} {O{}}{ + \cs_if_exist:NTF \l_problem_inputproblem_keys_tl { + \tl_put_left:Nn \l_problem_inputproblem_keys_tl {#1,} + \exp_args:Nno \stex_keys_set:nn{problem}{ + \l_problem_inputproblem_keys_tl + } + }{ + \stex_keys_set:nn{problem}{#1} + } + \refstepcounter{sproblem} + \str_if_empty:NT \l_stex_key_name_str { + \stex_file_split_off_lang:NN \l_@@_path_seq \g_stex_current_file + \seq_get_right:NN \l_@@_path_seq \l_stex_key_name_str + } + + \exp_args:No \stex_module_setup:n \l_stex_key_name_str + + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:problem={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={\l_stex_key_sig_str} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} + } + } + \stex_annotate_invisible:n{} + \tl_if_empty:NF \l_stex_key_title_tl { + \exp_args:No \stexdoctitle \l_stex_key_title_tl + } + } + \stex_if_smsmode:F { + \str_set_eq:NN \thismoduleuri \l_stex_current_module_str + \tl_set_eq:NN \thismodulename \l_stex_key_name_str + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \stex_style_apply: + \addtocounter{pts}{\l_stex_key_pts_tl} + \addtocounter{min}{\l_stex_key_min_tl} + \_stex_do_id: + \_@@_record_problem: + } + \stex_reactivate_macro:N \solution + \stex_reactivate_macro:N \mcb + \stex_reactivate_macro:N \fillinsol + \stex_smsmode_do: +}{ + \stex_close_module: + \stex_if_smsmode:F \stex_style_apply: + \stex_if_do_html:T{ \end{stex_annotate_env} } +}{ + \par\noindent\problemheader + \bool_if:NT \c_@@_pts_bool { + \marginpar{\l_stex_key_pts_tl{}~\problem@kw@points\smallskip} + } + \bool_if:NT \c_@@_min_bool { + \marginpar{\l_stex_key_min_tl{}~\problem@kw@minutes\smallskip} + } + \\ + \stex_ignore_spaces_and_pars: +}{ + \par\bigskip +% \bool_if:NT \c_@@_test_bool \pagebreak +}{s} +\stex_sms_allow_env:n{sproblem} + +\tl_set:Nn \problemheader { + \textbf{\sproblemautorefname{~}\thesproblem + \tl_if_empty:NF \thistitle { + {~}(\thistitle) + } + } +} + +\cs_new_protected:Nn \_@@_record_problem: { + \exp_args:NNe \iow_now:Nn \@auxout { + \problem@restore {\thesproblem}{\l_stex_key_pts_tl}{\l_stex_key_min_tl} + } +} + +\cs_new_protected:Npn \problem@restore #1 #2 #3 {} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\includeproblem} +% \begin{macrocode} +\stex_keys_define:nnnn{ includeproblem }{ + \str_clear:N \l_stex_key_mhrepos_str +}{ + archive .str_set:N = \l_stex_key_mhrepos_str, + unknown .code:n = {} +}{} + +\NewDocumentCommand\includeproblem{O{} m}{ + \group_begin: + \tl_set:Nn \l_problem_inputproblem_keys_tl {#1} + \stex_keys_set:nn{includeproblem}{#1} + \exp_args:Nno \use:nn{\inputref[}\l_stex_key_mhrepos_str]{#2} + \group_end: +} + +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{solution} +% \begin{macrocode} +\int_new:N \g_problem_id_counter + +\cs_new_protected:Nn \_@@_solution_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + SOLUTION_\int_use:N \g_problem_id_counter + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:solution=\l_stex_key_id_str + } + } + \stex_style_apply: +} + +\stex_new_stylable_env:nnnnnnn { solution }{ O{} }{ + \stex_if_do_html:TF{ + \_@@_solution_start:n{#1} + }{ + \ifsolutions + \_@@_solution_start:n{#1} + \else + \setbox\l_tmpa_box\vbox\bgroup + \fi + } +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} + }{ + \ifsolutions + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + \else + \egroup + \fi + } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Solution\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} + +\stex_deactivate_macro:Nn \solution {sproblem~environments} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\startsolutions,\stopsolutions} +% \begin{macrocode} +\cs_new_protected:Npn \startsolutions{ + \global\solutionstrue +} +\cs_new_protected:Npn \stopsolutions{ + \global\solutionsfalse +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{hint} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_hint_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + HINT_\int_use:N \g_problem_id_counter + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:problemhint=\l_stex_key_id_str + } + } + \stex_style_apply: +} + +\stex_new_stylable_env:nnnnnnn { hint }{ O{} }{ + \stex_if_do_html:TF{ + \_@@_hint_start:n{#1} + }{ + \bool_if:NTF \c_@@_hints_bool { + \_@@_hint_start:n{#1} + }{ + \setbox\l_tmpa_box\vbox\bgroup + } + } +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} + }{ + \bool_if:NTF \c_@@_hints_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \egroup + } + } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Hint\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{exnote} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_exnote_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + EXNOTE_\int_use:N \g_problem_id_counter + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:problemnote=\l_stex_key_id_str + } + } + \stex_style_apply: +} + +\stex_new_stylable_env:nnnnnnn { exnote }{ O{} }{ + \stex_if_do_html:TF{ + \_@@_exnote_start:n{#1} + }{ + \bool_if:NTF \c_@@_notes_bool { + \_@@_exnote_start:n{#1} + }{ + \setbox\l_tmpa_box\vbox\bgroup + } + } +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} + }{ + \bool_if:NTF \c_@@_notes_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \egroup + } + } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Note\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +% \end{macrocode} +% \end{environment} +%% \begin{environment}{gnote} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_gnote_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + GNOTE_\int_use:N \g_problem_id_counter + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:problemgnote=\l_stex_key_id_str + } + } + \stex_style_apply: +} + +\stex_new_stylable_env:nnnnnnn { gnote }{ O{} }{ + \stex_if_do_html:TF{ + \_@@_gnote_start:n{#1} + }{ + \bool_if:NTF \c_@@_gnotes_bool { + \_@@_gnote_start:n{#1} + }{ + \setbox\l_tmpa_box\vbox\bgroup + } + } +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} + }{ + \bool_if:NTF \c_@@_gnotes_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \egroup + } + } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Grading\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +% \end{macrocode} +% \end{environment} +% +% The margin pars are reader-visible, so we need to translate +% +% \begin{macrocode} +\def\pts#1{ + \bool_if:NT \c_@@_pts_bool { + \marginpar{#1~\problem@kw@points} + } +} +\def\min#1{ + \bool_if:NT \c_@@_min_bool { + \marginpar{#1~\problem@kw@minutes} + } +} +% \end{macrocode} +% +% \begin{environment}{mcb} +% +% \begin{macrocode} +\newenvironment{mcb}{\par + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:multiple-choice-block={}} + } + \stex_deactivate_macro:Nn \mcb {sproblem~environments} + \stex_deactivate_macro:Nn \solution {sproblem~environments} + \stex_reactivate_macro:N \mcc + \begin{enumerate} +}{ + \end{enumerate} + \stex_if_do_html:T{ + \end{stex_annotate_env} + } +} +\stex_deactivate_macro:Nn \mcb {sproblem~environments} +% \end{macrocode} +% +% we define the keys for the |mcc| macro +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_do_yes_param:Nn { + \exp_args:Nx \str_if_eq:nnTF { \str_lowercase:n{ #2 } }{ yes }{ + \bool_set_true:N #1 + }{ + \bool_set_false:N #1 + } +} +\stex_keys_define:nnnn{mcc}{ + \tl_clear:N \l_stex_key_feedback_tl + \bool_set_false:N \l_stex_key_T_bool + \tl_clear:N \l_stex_key_Ttext_tl + \tl_clear:N \l_stex_key_Ftext_tl +}{ + feedback .tl_set:N = \l_stex_key_feedback_tl , + T .default:n = { false } , + T .bool_set:N = \l_stex_key_T_bool , + F .default:n = { false } , + F .code:n = {\bool_set_false:N \l_stex_key_T_bool} , + Ttext .tl_set:N = \l_stex_key_Ttext_tl , + Ftext .tl_set:N = \l_stex_key_Ftext_tl , +}{id} + +% \end{macrocode} +% +% \begin{macro}{\mcc} +% \begin{macrocode} +\tl_set:Nn \problem_mcc_box_tl { + \ltx@ifpackageloaded{amssymb}{$\square$}{ + \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} + } +} +\newcommand\mcc[2][]{ + \stex_keys_set:nn{mcc}{#1}\par + \tl_set:Nn \l_tmpb_tl {~--~ + \bool_if:NTF \l_stex_key_T_bool { + \tl_if_empty:NTF \l_stex_key_Ttext_tl \problem@kw@correct \l_stex_key_Ttext_tl + }{ + \tl_if_empty:NTF \l_stex_key_Ftext_tl \problem@kw@wrong \l_stex_key_Ftext_tl + } + \tl_if_empty:NF \l_stex_key_feedback_tl { + \\\emph{\l_stex_key_feedback_tl} + } + } + \tl_set:Nn \l_tmpa_tl { + #2 + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:mcc-solution={}}{\l_tmpb_tl} + }{ + \ifsolutions\l_tmpb_tl\fi + } + } + \item[\problem_mcc_box_tl]{}~ + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:mcc={ + \bool_if:NTF \l_stex_key_T_bool {true}{false} + }}{\l_tmpa_tl} + }{\l_tmpa_tl} +} +\stex_deactivate_macro:Nn \mcc {mcb~environments} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fillinsol} +% \begin{macrocode} +\newcommand\fillinsol[2][]{ + \quad + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:fillinsol={}}{ \_stex_annotate_force_break:n{#2} } + }{ + \ifsolutions + \textcolor{red}{\fbox{#2}} + \else + \fbox{ + \tl_if_empty:nTF{#1}{ + \phantom{\huge{#2}} + }{ + \hspace{#1} + } + } + \fi + } + \quad +} +\stex_deactivate_macro:Nn \fillinsol {sproblem~environments} +% \end{macrocode} +% \end{macro} +% +% \end{environment} +% +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \end{implementation} +% ^^A \ifinfulldoc\else\printbibliography\fi +\endinput +%%% Local Variables: +%%% mode: doctex +%%% TeX-master: t +%%% End: +% \fi +% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse +% LocalWords: RequirePackage Semiverbatim DefEnvironment OptionalKeyVals soln texttt baz +% LocalWords: exnote DefConstructor inclprob NeedsTeXFormat omd.sty textbackslash exfig +% LocalWords: stopsolution fileversion filedate maketitle setcounter tocdepth newpage +% LocalWords: tableofcontents showmeta showmeta solutionstrue usepackage minipage hrule +% LocalWords: linewidth elefants.prob Elefants smallskip noindent textbf startsolutions +% LocalWords: startsolutions stopsolutions stopsolutions includeproblem includeproblem +% LocalWords: textsf HorIacJuc cscpnrr11 includemhproblem includemhproblem importmodule +% LocalWords: importmhmodule foobar ldots latexml mhcurrentrepos mh-variants mh-variant +% LocalWords: compactenum langle rangle langle rangle ltxml metakeys newif ifexnotes rm +% LocalWords: exnotesfalse exnotestrue ifhints hintsfalse hintstrue ifsolutions ifpts +% LocalWords: solutionsfalse ptsfalse ptstrue ifmin minfalse mintrue ifboxed boxedfalse +% LocalWords: boxedtrue sref mdframed marginpar prob srefaddidkey addmetakey refnum kv +% LocalWords: newcounter ifx thesection theproblem hfill newenvironment metasetkeys ltx +% LocalWords: stepcounter currentsectionlevel xspace ignorespaces surroundwithmdframed +% LocalWords: omdoc autoopen autoclose solvedinminutes kvi qw vals newcommand exhint +% LocalWords: specialcomment excludecomment mhrepos xref marginpar addtocounter doctex +% LocalWords: mh@currentrepos endinput + diff --git a/Master/texmf-dist/source/latex/stex/stex.dtx b/Master/texmf-dist/source/latex/stex/stex.dtx new file mode 100644 index 00000000000..dcbc4dfe7ab --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/stex.dtx @@ -0,0 +1,9008 @@ +%^^A meta-comment +%^^A An Infrastructure for Semantic Macros and Module Scoping +%^^A Copyright (c) 2022 Michael Kohlhase, all rights reserved +%^^A this file is released under the +%^^A LaTeX Project Public License (LPPL) +%^^A +%^^A The original of this file is in the public archive at +%^^A http://github.com/sLaTeX/sTeX/ +%^^A +% \iffalse +%<*driver> +\def\stexdocpath{../doc} +\input{\stexdocpath/stex-docheader} +\stextoptitle{The \sTeX Package}{stex} +\docmodule +%</driver> +% \fi +% +% +% \begin{stexmanual} +% \end{stexmanual} +% +% \begin{documentation} +% \begin{sfragment}{\sTeX Developer Manual} +% \input{\stexdocpath/stex-devel} +% \end{sfragment} +% \end{documentation} +% +% \begin{implementation} +% \begin{sfragment}{The \sTeX Implementation} +% +% \begin{sfragment}{Setting up} +% Setup code for the document class +% \begin{macrocode} +%<*cls> +%%%%%%%%%%%%% stex.dtx %%%%%%%%%%%%% + +\RequirePackage{expl3,l3keys2e} +\ProvidesExplClass{stex}{2023/03/19}{3.3.0}{sTeX document class} + +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}} +\ProcessOptions + +\RequirePackage{stex} + +\LoadClass{article} +%</cls> +% \end{macrocode} +% +% Setup code for the package +% +% \begin{macrocode} +%<*package> +\RequirePackage{expl3,l3keys2e,ltxcmds} +\ProvidesExplPackage{stex}{2023/03/19}{3.3.0}{sTeX package} +\RequirePackage{stex-logo} % externalized for backwards-compatibility reasons +\RequirePackage{standalone} + +\message{^^J*~This~is~sTeX~version~3.3.0~*^^J} +% \end{macrocode} +% +% Package options: +% +% \begin{macrocode} +\keys_define:nn { stex / package } { + debug .str_set_x:N = \c_stex_debug_clist , + lang .clist_set:N = \c_stex_languages_clist , + mathhub .tl_set_x:N = \mathhub , + usesms .bool_set:N = \c_stex_persist_mode_bool , + writesms .bool_set:N = \c_stex_persist_write_mode_bool , + checkterms .bool_set:N = \c_stex_check_terms_bool , + image .bool_set:N = \c_tikzinput_image_bool, + unknown .code:n = {} +} +\exp_args:NNo \clist_set:Nn \c_stex_debug_clist \c_stex_debug_clist +\ProcessKeysOptions { stex / package } +% \end{macrocode} +% +% Error messages: +% \begin{macrocode} +\input{stex-en.ldf} +% \end{macrocode} +% +% \end{sfragment} +% +% \begin{sfragment}{Utilities} +% +% \begin{macrocode} +\cs_set_eq:NN \stex_undefined: \undefined +% \end{macrocode} +% +% \begin{sfragment}{Calling kpsewhich and Environment Variables} +% +% \begin{macrocode} +%<@@=stex_envs> +% \end{macrocode} +% +% \begin{macro}{\stex_kpsewhich:Nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_kpsewhich:Nn {\group_begin: + \catcode`\ =12 + \sys_get_shell:nnN { kpsewhich ~ #2 } { } \l_tmpa_tl + \tl_gset_eq:NN \l_tmpa_tl \l_tmpa_tl + \group_end: + \exp_args:NNo\str_set:Nn #1 {\l_tmpa_tl} + \tl_trim_spaces:N #1 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_get_env:Nn} +% \begin{macrocode} +\sys_if_platform_windows:TF{ + \cs_new_protected:Nn \stex_get_env:Nn {\group_begin: + \escapechar=-1\catcode`\\=12 + \exp_args:NNe \stex_kpsewhich:Nn #1 {-expand-var~\c_percent_str#2\c_percent_str} + \exp_args:NNx\use:nn\group_end:{ + \str_set:Nn \exp_not:N #1 { #1 } + } + } +}{ + \cs_new_protected:Nn \stex_get_env:Nn { + \stex_kpsewhich:Nn #1 {-var-value~#2} + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Logging} +% \begin{macrocode} +%<@@=stex_debug> +% \end{macrocode} +% +% \begin{macro}{\stex_debug:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_debug:nn { + \exp_args:NNo \clist_if_in:NnTF \c_stex_debug_clist { \tl_to_str:n{all} }{ + \_@@_:nn{#1}{#2} + }{ + \exp_args:NNo \clist_if_in:NnT \c_stex_debug_clist { \tl_to_str:n{#1} }{ + \_@@_:nn{#1}{#2} + } + } +} + +\cs_new_protected:Nn \_@@_:nn { + \msg_set:nnn{stex}{debug / #1}{ + \\Debug~#1:~#2\\ + } + \msg_none:nn{stex}{debug / #1} +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\stex_fatal_error:n,\stex_fatal_error:nnn,\stex_fatal_error:nxx} +% To avoid dead locks etc., we throw errors and make tex stop +% entirely: +% \begin{macrocode} +\cs_new_protected:Nn \stex_fatal_error:n { + \msg_error:nn{stex}{#1}\input{Fatal~Error!!} +} +\cs_new_protected:Nn \stex_fatal_error:nnn { + \msg_error:nnn{stex}{#1}{#2}{#3}\input{Fatal~Error!!} +} +\cs_generate_variant:Nn \stex_fatal_error:nnn {nxx} +% \end{macrocode} +% \end{macro} +% +% We check an environment variable for debugging and +% set things up: +% +% \begin{macrocode} +\stex_get_env:Nn\_@@_env_str{STEX_DEBUG} +\str_if_empty:NTF\_@@_env_str { + \clist_set_eq:NN \l_@@_cl \c_stex_debug_clist +}{ + \clist_set:No \l_@@_cl {\_@@_env_str} +} +\clist_clear:N \c_stex_debug_clist +\clist_map_inline:Nn \l_@@_cl { + \exp_args:NNo \clist_put_right:Nn \c_stex_debug_clist + { \tl_to_str:n{#1} } +} + +\exp_args:NNo \clist_if_in:NnTF \c_stex_debug_clist {\tl_to_str:n{all}} { + \msg_redirect_module:nnn{ stex }{ none }{ term } + \stex_debug:nn{all}{Logging~everything!} +}{ + \clist_map_inline:Nn \c_stex_debug_clist { + \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term } + \stex_debug:nn{#1}{Logging~#1} + } +} +% \end{macrocode} +% +% \end{sfragment} +% +% \begin{sfragment}{Languages} +% \begin{macrocode} +%<@@=stex_lang> +% \end{macrocode} +% \begin{variable}{\c_stex_languages_prop,\c_stex_language_abbrevs_prop} +% +% We store language abbreviations in two (mutually inverse) +% property lists: +% \begin{macrocode} +\exp_args:NNx \prop_const_from_keyval:Nn \c_stex_languages_prop { \tl_to_str:n { + en = english , + de = ngerman , + ar = arabic , + bg = bulgarian , + ru = russian , + fi = finnish , + ro = romanian , + tr = turkish , + fr = french +}} + +\exp_args:NNx \prop_const_from_keyval:Nn \c_stex_language_abbrevs_prop { \tl_to_str:n { + english = en , + ngerman = de , + arabic = ar , + bulgarian = bg , + russian = ru , + finnish = fi , + romanian = ro , + turkish = tr , + french = fr +}} +% todo: chinese simplified (zhs) +% chinese traditional (zht) +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_stex_current_language_str} +% \begin{macrocode} +\str_new:N \l_stex_current_language_str +% \end{macrocode} +% \end{variable} +% +% we use the |lang|-package option to load the corresponding +% babel languages: +% \begin{macro}{\stex_set_language:n, \stex_set_language:x, \stex_set_language:o} +% \begin{macrocode} +\cs_new_protected:Nn \stex_set_language:n { + \str_set:Nn \l_stex_current_language_str { #1 } + \prop_if_in:NnTF \c_stex_languages_prop {#1} { + \tl_set_rescan:Nnx \l_@@_lang_str {}{\prop_item:Nn \c_stex_languages_prop {#1}} + \cs_if_eq:NNTF\@onlypreamble\@notprerr{ + \ltx@ifpackageloaded{babel}{ + \exp_args:No\selectlanguage\l_@@_lang_str + }{} + }{ + \ltx@ifpackageloaded{babel}{}{ + \str_if_eq:nnTF {#1} {tr} { + \RequirePackage[turkish,shorthands=:!]{babel} + }{ + \RequirePackage[\l_@@_lang_str]{babel} + } + } + } + }{ + \msg_error:nnx{stex}{error/unknownlanguage}{#1} + } +} +\cs_generate_variant:Nn \stex_set_language:n {x,o} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_language_from_file:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_language_from_file: { + \seq_get_right:NN \g_stex_current_file \l_tmpa_str + \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str + \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % = ".tex/.dtx/.sty" + \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { + \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { + \exp_args:No \str_if_eq:nnF \l_tmpa_str {ltx} { + \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str + } + } + } + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> + \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language + \seq_pop_right:NN \l_tmpa_seq \l_@@_str + \str_if_eq:NNF \l_@@_str \l_stex_current_language_str { + \exp_args:NNo \prop_if_in:NnT \c_stex_languages_prop \l_@@_str { + \stex_set_language:o \l_@@_str + } + } + \stex_debug:nn{lang} {Language~\l_stex_current_language_str~ + inferred~from~file~name} + } +} +% \end{macrocode} +% \end{macro} +% +% Loading babel: +% \begin{macrocode} +\clist_if_empty:NF \c_stex_languages_clist { + \bool_set_false:N \l_@@_turkish_bool + \seq_clear:N \l_tmpa_seq + \clist_map_inline:Nn \c_stex_languages_clist { + \str_set:Nx \l_tmpa_str {#1} + \str_if_eq:nnT {#1}{tr}{ + \bool_set_true:N \l_@@_turkish_bool + } + \prop_get:NoNTF \c_stex_languages_prop \l_tmpa_str \l_tmpa_str { + \tl_set_rescan:Nno \l_tmpa_str {} \l_tmpa_str + \seq_put_right:No \l_tmpa_seq \l_tmpa_str + } { + \msg_error:nnx{stex}{error/unknownlanguage}{\l_tmpa_str} + } + } + \stex_debug:nn{lang} {Languages:~\seq_use:Nn \l_tmpa_seq {,~} } + \bool_if:NTF \l_@@_turkish_bool { + \exp_args:NNe \use:nn \RequirePackage + {[main=\seq_use:Nn \l_tmpa_seq, ,shorthands=:!]}{babel} + }{ + \exp_args:NNe \use:nn \RequirePackage + {[main=\seq_use:Nn \l_tmpa_seq, ]}{babel} + } +} +% \end{macrocode} +% +% \end{sfragment} +% +% \begin{sfragment}{Group-like Behaviours} +% \begin{macrocode} +%<@@=stex_groups> +% \end{macrocode} +% +% \begin{macro}{\stex_pseudogroup:nn,\stex_pseudogroup_restore:N} +% \begin{macrocode} +\cs_new_protected:Npn \stex_pseudogroup:nn { + \exp_args:Nne \use:nn +} +\cs_new:Nn \stex_pseudogroup_restore:N { + \tl_if_exist:NTF #1 { + \tl_set:Nn \exp_not:N #1 { \exp_args:No \exp_not:n #1 } + }{ + \cs_undefine:N \exp_not:N #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_pseudogroup_with:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_pseudogroup_with:nn { + \tl_map_inline:nn{#1}{ + \cs_set_eq:cN{_@@_\tl_to_str:n{##1}}##1 + } + #2 + \tl_map_inline:nn{#1}{ + \cs_set_eq:Nc##1{_@@_\tl_to_str:n{##1}} + \cs_undefine:c{_@@_\tl_to_str:n{##1}} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_metagroup_new:n, \stex_metagroup_new:o} +% List of all currently existing metagroup identifiers +% \begin{macrocode} +\seq_new:N \l_@@_ids_seq +% \end{macrocode} +% start a new metagroup at the current group level with id \#1 +% \begin{macrocode} +\cs_new_protected:Nn \stex_metagroup_new:n { + \str_set:cx{l_@@_#1_int} {\int_use:N\currentgrouplevel} + \seq_put_right:Nn \l_@@_ids_seq {#1} +} +\cs_generate_variant:Nn \stex_metagroup_new:n {o} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_metagroup_do_in:nn, \stex_metagroup_do_in:nx} +% \begin{macrocode} +\prg_new_conditional:Nnn \_@@_exists:n {TF} { + \str_if_exist:cTF{l_@@_#1_int} + \prg_return_true: \prg_return_false: +} + +\cs_new_protected:Nn \stex_metagroup_do_in:nn { + \_@@_exists:nTF{#1}{ + \_@@_do_in:nn{#1}{#2} + }{ + \msg_error:nnn{stex}{error/metagroup/missing}{#1} + } +} +\cs_generate_variant:Nn \stex_metagroup_do_in:nn {nx} + +\cs_new_protected:Nn \_@@_do_in:nn { + \exp_args:Nnx\stex_debug:nn{metagroup}{adding~to~\detokenize{#1}:^^J\tl_to_str:n{#2}} + \tl_set:Nn\_@@_tmp{#2} + \exp_args:Nx \int_compare:nNnF {\use:c{l_@@_#1_int}} + = \currentgrouplevel { + \tl_if_exist:cTF{g_@@_#1_\the\currentgrouplevel _content}{ + \exp_args:Nno \tl_gput_right:cn{g_@@_#1_\the\currentgrouplevel _content} + }{ + \exp_args:Nno \tl_gset:cn{g_@@_#1_\the\currentgrouplevel _content} + }\_@@_tmp + \bool_if_exist:cF {l_@@_\the\currentgrouplevel _bool} { + \group_insert_after:N \_@@_do: + \bool_set_true:c {l_@@_\the\currentgrouplevel _bool} + } + } + \_@@_tmp +} + +\cs_new_protected:Nn \_@@_do: { + \seq_map_inline:Nn \l_@@_ids_seq { + \tl_if_exist:cT{g_@@_##1_\int_eval:n{\currentgrouplevel+1}_content}{ + \exp_args:NNno \exp_args:Nno \_@@_do_in:nn{##1}{ + \csname g_@@_##1_\int_eval:n{\currentgrouplevel+1}_content\endcsname + } + \cs_undefine:c{g_@@_##1_\int_eval:n{\currentgrouplevel+1}_content} + } + \bool_if_exist:cF {l_@@_\int_eval:n\currentgrouplevel _bool} { + \group_insert_after:N \_@@_do: + \bool_set_true:c {l_@@_\int_eval:n\currentgrouplevel _bool} + } + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{HTML Annotations} +% \begin{macrocode} +%<@@=stex_annotate> +% \end{macrocode} +% +% \begin{macro}[TF]{\stex_if_do_html:} +% Whether to (locally) produce HTML output +% \begin{macrocode} +\bool_new:N \_stex_html_do_output_bool +\bool_set_true:N \_stex_html_do_output_bool + +\prg_new_conditional:Nnn \stex_if_do_html: {p,T,F,TF} { + \bool_if:nTF \_stex_html_do_output_bool + \prg_return_true: \prg_return_false: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_suppress_html:n} +% Temporarily disable HTML output +% \begin{macrocode} +\cs_new_protected:Nn \stex_suppress_html:n { + \stex_pseudogroup:nn{ + \bool_set_false:N \_stex_html_do_output_bool + #1 + }{ + \stex_if_do_html:T { + \bool_set_true:N \_stex_html_do_output_bool + } + } +} +% \end{macrocode} +% \end{macro} +% +% We determine the backend: +% \begin{macro}[pTF]{\stex_if_html_backend:} +% \begin{macro}{\ifstexhtml} +% \begin{macro}{\stex@backend} +% \begin{macrocode} +\ifcsname if@rustex\endcsname\else + \expandafter\newif\csname if@rustex\endcsname + \@rustexfalse +\fi + +\stex_get_env:Nn\_@@_env_str{STEX_FORCE_PDF} +\exp_args:No \str_if_eq:nnTF \_@@_env_str {true} { + \def\stex@backend{pdflatex} +}{ + \tl_if_exist:NF\stex@backend{ + \if@rustex + \def\stex@backend{rustex} + \else + \cs_if_exist:NTF\HCode{ + \def\stex@backend{tex4ht} + }{ + \def\stex@backend{pdflatex} + } + \fi + } +} + +\input{stex-backend-\stex@backend.cfg} + +\newif\ifstexhtml +\stex_if_html_backend:TF { + \stexhtmltrue + \bool_set_true:N \_stex_html_do_output_bool +}{ + \stexhtmlfalse + \bool_set_false:N \_stex_html_do_output_bool +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\_stex_annotate_force_break:n} +% \begin{macrocode} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_annotate_force_break:n { + \stex_annotate_invisible:n{~} + #1 + \stex_annotate_invisible:n{~} + } +}{ + \cs_new_protected:Nn \_stex_annotate_force_break:n { #1 } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mmlintent,\mmlarg} +% \begin{macrocode} +\stex_if_html_backend:TF { + \cs_new_protected:Npn \mmlintent #1 #2 { + \stex_annotate:nn{mml:intent={#1}}{#2} + } + \cs_new_protected:Npn \mmlarg #1 #2 { + \stex_annotate:nn{mml:arg={#1}}{#2} + } +}{ + \cs_new_protected:Npn \mmlintent #1 #2 { #2 } + \cs_new_protected:Npn \mmlarg #1 #2 { #2 } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Auxiliary Methods} +% \begin{macrocode} +%<@@=stex_aux> +% \end{macrocode} + +% \begin{macro}{\stex_deactivate_macro:Nn, \stex_reactivate_macro:N} +% \begin{macrocode} +\cs_new_protected:Nn \stex_deactivate_macro:Nn { + \tl_set_eq:cN{\tl_to_str:n{#1}~-~orig}#1 + \tl_set:Nn#1{ + \msg_error:nnnn{stex}{error/deactivated-macro}{\detokenize{#1}}{#2} + } +} +\cs_new_protected:Nn \stex_reactivate_macro:N { + \exp_after:wN\let\exp_after:wN#1\csname \detokenize{#1}~-~orig\endcsname +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_ignore_spaces_and_pars:} +% \begin{macrocode} +\protected\def\stex_ignore_spaces_and_pars:{ + \begingroup\catcode13=10\relax + \@ifnextchar\par{ + \endgroup\expandafter\stex_ignore_spaces_and_pars:\@gobble + }{ + \endgroup + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_keys_define:nnnn} +% \begin{macrocode} +\cs_new_nopar:Nn \stex_keys_define:nnnn { + \tl_gset:cn {_@@_keys_#1_pre_tl}{#2} + \tl_gset:cn {_@@_keys_#1_def_tl}{#3} + \tl_if_empty:nF{#4}{ + \clist_map_inline:nn{#4}{ + \tl_set_eq:Nc \l_@@_tl {_@@_keys_##1_pre_tl} + \tl_gput_left:co{_@@_keys_#1_pre_tl} \l_@@_tl + \tl_set_eq:Nc \l_@@_tl {_@@_keys_##1_def_tl} + \tl_gput_left:cn{_@@_keys_#1_def_tl} , + \tl_gput_left:co{_@@_keys_#1_def_tl} \l_@@_tl + } + } + \tl_set_eq:Nc \l_@@_tl {_@@_keys_#1_def_tl} + \exp_args:Nno \keys_define:nn {stex / #1} {\l_@@_tl} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_keys_set:nn} +% \begin{macrocode} +\cs_new_nopar:Nn \stex_keys_set:nn { + \use:c{_@@_keys_#1_pre_tl} + \keys_set:nn {stex / #1} { #2 } +} +% \end{macrocode} +% \end{macro} +% +% Some ubiquitous key sets: +% \begin{macrocode} +\stex_keys_define:nnnn{archive file}{ + \str_clear:N \l_stex_key_archive_str + \str_clear:N \l_stex_key_file_str +}{ + archive .str_set_x:N = \l_stex_key_archive_str , + file .str_set_x:N = \l_stex_key_file_str +}{} + +\stex_keys_define:nnnn{id}{ + \str_clear:N \l_stex_key_id_str +}{ + id .str_set_x:N = \l_stex_key_id_str +}{} + +\stex_keys_define:nnnn{title}{ + \tl_clear:N \l_stex_key_title_tl +}{ + title .tl_set:N = \l_stex_key_title_tl +}{} + +\stex_keys_define:nnnn{style}{ + \clist_clear:N \l_stex_key_style_clist +}{ + style .clist_set:N = \l_stex_key_style_clist +}{} + +\stex_keys_define:nnnn{deprecate}{ + \str_clear:N \l_stex_key_deprecate_str +}{ + deprecate .str_set_x:N = \l_stex_key_deprecate_str +}{} + +\stex_keys_define:nnnn{uses}{}{ + uses .code:n = { + \clist_map_inline:nn{#1}{ + \stex_str_if_starts_with:nnTF{##1}[{ + \_@@_split_at_bracket:w ##1 \_stex_end: + }{ + \usemodule{##1} + } + } + } +}{} + +\cs_new_protected:Npn \_@@_split_at_bracket:w [ #1 ] #2 \_stex_end: { + \usemodule[#1]{#2} +} +% \end{macrocode} +% +% \begin{macro}{\_stex_do_deprecation:n} +% \begin{macrocode} +\cs_new:Nn \_stex_do_deprecation:n { + \str_if_empty:NF \l_stex_key_deprecate_str { + \msg_warning:nnxx{stex}{warning/deprecated}{#1}{\l_stex_key_deprecate_str} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_do_id:} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_do_id: { + \stex_if_smsmode:F { + \str_if_empty:NF \l_stex_key_id_str { + \exp_args:No \stex_ref_new_doc_target:n \l_stex_key_id_str + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_new_stylable_env:nnnnnnn,\stex_new_stylable_cmd:nnnn,\stex_style_apply:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_new_stylable_cmd:nnnn { + \exp_after:wN \newcommand \cs:w stexstyle#1 \cs_end:[2][]{ + \_@@_patch:nnn{#1}{##1}{##2} + } + \exp_after:wN \NewDocumentCommand\cs:w #1\cs_end:{#2}{ + \cs_set:Npn \stex_style_apply: { + \_@@_apply_patch:n{#1} + } + #3 + } + \tl_set:cn {_@@_style_#1:} { #4 } +} + +\cs_new_protected:Nn \_@@_apply_patch:n { + \clist_if_empty:NTF \l_stex_key_style_clist { + \tl_clear:N \thisstyle + \use:c{_@@_style_#1:} + }{ + \clist_get:NN \l_stex_key_style_clist \thisstyle + \tl_if_exist:cTF{_@@_style_#1_\thisstyle :}{ + \use:c{_@@_style_#1_\thisstyle :} + }{ + \use:c{_@@_style_#1:} + } + } +} + +\cs_new_protected:Nn \_@@_patch:nnn { + \str_if_empty:nTF {#2}{ + \tl_set:cn{_@@_style_#1:}{#3} + }{ + \tl_set:cn{_@@_style_#1_#2:}{#3} + } +} + +\cs_new_protected:Nn \stex_new_stylable_env:nnnnnnn { + \exp_after:wN \newcommand \cs:w stexstyle#1 \cs_end:[3][]{ + \_@@_patch:nnnn{#1}{##1}{##2}{##3} + } + \NewDocumentEnvironment{#7#1}{#2}{ + \cs_set:Npn \stex_style_apply: { + \_@@_apply_patch_begin:n{#1} + } + #3 + }{ + \cs_set:Npn \stex_style_apply: { + \_@@_apply_patch_end:n{#1} + } + #4 + } + \tl_set:cn {_@@_style_#1_start:} { #5 } + \tl_set:cn {_@@_style_#1_end:} { #6 } +} + +\cs_new_protected:Nn \_@@_patch:nnnn { + \str_if_empty:nTF {#2}{ + \tl_set:cn{_@@_style_#1_start:}{#3} + \tl_set:cn{_@@_style_#1_end:}{#4} + }{ + \tl_set:cn{_@@_style_#1_#2_start:}{#3} + \tl_set:cn{_@@_style_#1_#2_end:}{#4} + } +} + +\cs_new_protected:Nn \_@@_apply_patch_begin:n { + \clist_if_empty:NTF \l_stex_key_style_clist { + \tl_clear:N \thisstyle + \use:c{_@@_style_#1_start:} + }{ + \clist_get:NN \l_stex_key_style_clist \thisstyle + \stex_debug:nn{styling}{dominant~style:~\thisstyle} + \tl_if_exist:cTF{_@@_style_#1_\thisstyle _start:}{ + \use:c{_@@_style_#1_\thisstyle _start:} + }{ + \use:c{_@@_style_#1_start:} + } + } +} + +\cs_new_protected:Nn \_@@_apply_patch_end:n { + \tl_if_empty:NTF \thisstyle { + \use:c{_@@_style_#1_end:} + }{ + \tl_if_exist:cTF{_@@_style_#1_\thisstyle _end:}{ + \use:c{_@@_style_#1_\thisstyle _end:} + }{ + \use:c{_@@_style_#1_end:} + } + } +} +% \end{macrocode} +% +% \end{macro} +% +% \begin{macro}[pTF]{\stex_str_if_ends_with:nn} +% \begin{macrocode} +\prg_new_conditional:Nnn \stex_str_if_ends_with:nn {p,T,F,TF} { + \exp_args:Ne \str_if_eq:nnTF { + \str_range:nnn{#1}{- \str_count:n{#2}}{-1} + }{#2}\prg_return_true: \prg_return_false: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[pTF]{\stex_str_if_starts_with:nn} +% \begin{macrocode} +\prg_new_conditional:Nnn \stex_str_if_starts_with:nn {p,T,F,TF} { + \exp_args:Ne \str_if_eq:nnTF { + \str_range:nnn{#1}{1}{\str_count:n{#2}} + }{#2}\prg_return_true: \prg_return_false: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\stex_macro_body:N} +% \begin{macrocode} +\cs_new:Npn \_@@_start:#1\_@@_end: {\exp_not:n{#1}} +\cs_new_protected:Nn \_@@_end: {} +\cs_new:Nn \stex_macro_body:N { + \exp_args:Nne\use:nn{\exp_after:wN \_@@_start: #1}{ + \_@@_args:e {\cs_parameter_spec:N #1}\_@@_end: + } +} + +\cs_new:Nn \_@@_args:n { + \tl_if_empty:nF{#1}{ + {##\exp_args:Ne \tl_head:n {\tl_tail:n {#1}}} + \_@@_args:e {\exp_args:Ne\tl_tail:n{\tl_tail:n{#1}}} + } +} +\cs_generate_variant:Nn \_@@_args:n {e} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\stex_macro_definition:N} +% \begin{macrocode} +\cs_new:Nn \stex_macro_definition:N { + \_@@_prefix:e {\cs_prefix_spec:N #1} + \def\exp_not:N #1 + \_@@_params:e {\cs_parameter_spec:N #1} + { + \stex_macro_body:N #1 + } +} + +\cs_new:Nn \_@@_prefix:n { + \tl_if_empty:nF{#1}{ + \str_if_eq:eeTF { + \tl_range:nnn{#1}{1}{10}~ + }{\tl_to_str:n{\protected}}{ + \protected + \_@@_prefix_long:e { + \str_range:nnn{#1}{11}{-1} + } + }{ + \_@@_prefix_long:n {#1} + } + } +} +\cs_generate_variant:Nn \_@@_prefix:n {e} + +\cs_new:Nn \_@@_prefix_long:n { + \tl_if_empty:nF{#1}{ + \str_if_eq:eeT { + \tl_range:nnn{#1}{1}{10}~ + }{\tl_to_str:n{\long}}{\long} + } +} +\cs_generate_variant:Nn \_@@_prefix_long:n {e} + +\cs_new:Nn \_@@_params:n { + \tl_if_empty:nF{#1}{ + \exp_args:NNe \str_if_eq:VnTF \c_hash_str {\tl_head:n{#1}}{ + #### + }{ + \tl_head:n{#1} + } + \_@@_params:e {\tl_tail:n{#1}} + } +} +\cs_generate_variant:Nn \_@@_params:n {e} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Persistence} +% \begin{macrocode} +%<@@=stex_persist> +% \end{macrocode} +% +% We check the environment variables: +% \begin{macrocode} +\stex_get_env:Nn\_@@_env_str{STEX_USESMS} +\str_if_empty:NF\_@@_env_str{ + \exp_args:No \str_if_eq:nnF \_@@_env_str{false}{ + \bool_set_true:N \c_stex_persist_mode_bool + } +} +\stex_get_env:Nn\_@@_env_str{STEX_WRITESMS} +\str_if_empty:NF\_@@_env_str{ + \exp_args:No \str_if_eq:nnF \_@@_env_str{false}{ + \bool_set_true:N \c_stex_persist_write_mode_bool + } +} +% \end{macrocode} +% +% \begin{macro}{\stex_persist:n,\stex_persist:e} +% \begin{macrocode} +\iow_new:N \c_@@_sms_iow + +\bool_if:NTF \c_stex_persist_write_mode_bool { + \stex_if_html_backend:TF{ + \cs_new:Npn \stex_persist:n #1 {} + \cs_new:Npn \stex_persist:e #1 {} + }{ + \cs_new_protected:Nn \stex_persist:n { + \iow_now:Nn \c_@@_sms_iow {#1} + } + \cs_generate_variant:Nn \stex_persist:n {e} + } +}{ + \cs_new:Npn \stex_persist:n #1 {} + \cs_new:Npn \stex_persist:e #1 {} +} +% \end{macrocode} +% \end{macro} +% +% Is called at the end of the |.sty|-file: +% +% \begin{macrocode} + +\cs_new_protected:Nn \_@@_load_file:n { + \file_if_exist:nT{#1}{ + \group_begin: + \cs_set:Npn \stex_persist:n ##1 {} + \cs_set:Npn \stex_persist:e ##1 {} + \stex_debug:nn{persist}{restoring~from~sms~file} + \catcode`\ =10\relax + \cs:w @ @ input \cs_end:#1\relax + \group_end: + } +} + +\cs_new_protected:Nn \_@@_write_only: { + \iow_open:Nn \c_@@_sms_iow {\jobname.sms} + \AtEndDocument{ \iow_close:N \c_@@_sms_iow } +} + +\cs_new_protected:Nn \_@@_read_and_write: { + \file_if_exist:nTF{\jobname.sms}{ + \ior_open:Nn \g_tmpa_ior {\jobname.sms} + \iow_open:Nn \g_tmpa_iow {\jobname.sms2} + \ior_str_map_inline:Nn \g_tmpa_ior { + \iow_now:Nn \g_tmpa_iow {##1} + } + \iow_close:N \g_tmpa_iow + \ior_close:N \g_tmpa_ior + \_@@_write_only: + \ior_open:Nn \g_tmpa_ior {\jobname.sms2} + \ior_str_map_inline:Nn \g_tmpa_ior { + \iow_now:Nn \c_@@_sms_iow {##1} + } + \ior_close:N \g_tmpa_ior + \_@@_load_file:n{\jobname.sms2} + }\_@@_write_only: +} + +\cs_new_protected:Nn \_stex_persist_read_now: { + \bool_if:NTF \c_stex_persist_mode_bool { + \bool_if:NTF \c_stex_persist_write_mode_bool + \_@@_read_and_write: + { + \_@@_load_file:n{\jobname.sms} + } + }{ + \bool_if:NT \c_stex_persist_write_mode_bool \_@@_write_only: + } +} +% \end{macrocode} +% +% \end{sfragment} +% +% \begin{sfragment}{Files, Paths and URIs} +% \begin{macrocode} +%<@@=stex_path> +% \end{macrocode} +% +% \begin{macro}{\stex_file_set:Nn, \stex_file_set:No, \stex_file_set:Nx} +% \begin{macrocode} +\cs_new_protected:Nn \stex_file_set:Nn { + \str_if_empty:nTF {#2} { \seq_clear:N #1 }{ + \exp_args:NNno \seq_set_split:Nnn #1 / { \tl_to_str:n{#2} } + } +} +\cs_generate_variant:Nn \stex_file_set:Nn {No, Nx} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_file_resolve:Nn, \stex_file_resolve:No, \stex_file_resolve:Nx} +% \begin{macrocode} +\sys_if_platform_windows:TF{ + \cs_new_protected:Npn \_@@_win_take:w #1#2#3 \_@@_: { + \str_set:Nn \l_@@_win_drive {#1#2} + \str_set:Nn \l_@@_str{#3} + } + \cs_new_protected:Nn \stex_file_resolve:Nn { + \str_set:Nn \l_@@_str {#2} + \str_clear:N \l_@@_win_drive + \exp_args:NNo \str_replace_all:Nnn \l_@@_str \c_backslash_str / + \exp_args:Nx \str_if_eq:nnT {\str_item:Nn \l_@@_str 2} : { + \exp_after:wN \_@@_win_take:w \l_@@_str \_@@_: + } + \stex_file_set:No #1 \l_@@_str + \_@@_canonicalize:N #1 + \str_if_empty:NF \l_@@_win_drive { + \seq_pop_left:NN #1 \l_@@_str + \seq_put_left:No #1 \l_@@_win_drive + } + %\stex_debug:nn{files}{Set~\tl_to_str:n{#1}~to~\stex_file_use:N #1} + } +}{ + \cs_new_protected:Nn \stex_file_resolve:Nn { + \str_set:Nn \l_@@_str {#2} + \stex_file_set:No #1 \l_@@_str + \_@@_canonicalize:N #1 + % \stex_debug:nn{files}{Set~\tl_to_str:n{#1}~to~\stex_file_use:N #1} + } +} +\cs_generate_variant:Nn \stex_file_resolve:Nn {No, Nx} + +\cs_new_protected:Nn \_@@_canonicalize:N { + \seq_if_empty:NF #1 { + \seq_pop:NN #1 \l_@@_str + \seq_clear:N \l_@@_seq + \str_if_empty:NTF \l_@@_str { + \seq_map_function:NN #1 \_@@_dodots:n + \seq_put_left:Nn \l_@@_seq {} + }{ + \seq_push:No #1 \l_@@_str + \seq_map_function:NN #1 \_@@_dodots:n + } + \seq_set_eq:NN #1 \l_@@_seq + } +} + +\cs_new_protected:Nn \_@@_dodots:n { + \str_if_empty:nF{#1}{ + \str_if_eq:nnF {#1} {.} { + \str_if_eq:nnTF {#1} {..} { + \seq_if_empty:NF \l_@@_seq { + \seq_pop_right:NN \l_@@_seq \l_@@_str + } + }{ + \seq_put_right:Nn \l_@@_seq {#1} + } + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[pTF]{\stex_if_file_absolute:N} +% \begin{macrocode} + +\sys_if_platform_windows:TF { + \prg_new_conditional:Nnn \stex_if_file_absolute:N {p, T, F, TF} { + \seq_if_empty:NTF #1 \prg_return_false: { + \tl_set:Nx \l_@@_maybewin_str {\seq_item:Nn #1 1} + \exp_args:No \tl_if_empty:nTF \l_@@_maybewin_str \prg_return_true: { + \exp_args:Nx \str_if_eq:nnTF {\str_item:Nn \l_@@_maybewin_str 2} : + \prg_return_true: \prg_return_false: + } + } + } +}{ + \prg_new_conditional:Nnn \stex_if_file_absolute:N {p, T, F, TF} { + \seq_if_empty:NTF #1 \prg_return_false: { + \exp_args:Nx \tl_if_empty:nTF {\seq_item:Nn #1 1} + \prg_return_true: \prg_return_false: + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\stex_file_use:N} +% \begin{macrocode} +\cs_new:Nn \stex_file_use:N { + \seq_use:Nn #1 / +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[TF]{\stex_if_file_starts_with:NN} +% \begin{macrocode} +\prg_new_protected_conditional:Nnn \stex_if_file_starts_with:NN {T,F,TF} { + \seq_set_eq:NN \l_@@_a_seq #1 + \seq_set_eq:NN \l_@@_b_seq #2 + \tl_clear:N \l_@@_return_tl + \bool_while_do:nn{ + \bool_not_p:n{ + \bool_lazy_any_p:n{ + {\seq_if_empty_p:N \l_@@_a_seq} + {\seq_if_empty_p:N \l_@@_b_seq} + {\bool_not_p:n{\tl_if_empty_p:N \l_@@_return_tl}} + } + } + }{ + \seq_pop_left:NN \l_@@_a_seq \l_@@_a_tl + \seq_pop_left:NN \l_@@_b_seq \l_@@_b_tl + \str_if_eq:NNF \l_@@_a_tl \l_@@_b_tl { + \tl_set:Nn \l_@@_return_tl {\prg_return_false:} + } + } + \tl_if_empty:NTF \l_@@_return_tl { + \seq_if_empty:NTF \l_@@_b_seq \prg_return_true: \prg_return_false: + } \l_@@_return_tl +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_file_split_off_ext:NN,\stex_file_split_off_lang:NN} +% \begin{macrocode} +\cs_new_protected:Nn \stex_file_split_off_ext:NN { + \seq_set_eq:NN #1 #2 + \seq_pop_right:NN #1 \l_@@_str + \seq_set_split:NnV \l_@@_seq . \l_@@_str + \seq_pop_right:NN \l_@@_seq \l_@@_str + \seq_put_right:Nx #1 {\seq_use:Nn \l_@@_seq .} +} +\cs_new_protected:Nn \stex_file_split_off_lang:NN { + \seq_set_eq:NN #1 #2 + \seq_pop_right:NN #1 \l_@@_str + \seq_set_split:NnV \l_@@_seq . \l_@@_str + \seq_pop_right:NN \l_@@_seq \l_@@_str + + \seq_pop_right:NN \l_@@_seq \l_@@_str + \exp_args:NNo \prop_if_in:NnF \c_stex_languages_prop \l_@@_str { + \seq_put_right:No \l_@@_seq \l_@@_str + } + + \seq_put_right:Nx #1 {\seq_use:Nn \l_@@_seq .} +} +% \end{macrocode} +% \end{macro} +% +% URIs: +% +% \begin{macro}{\stex_map_uri:Nnnnn} +% \begin{macrocode} +\cs_set_protected:Nn \_@@_auth:n { + \msg_error:nnx{stex}{error/misused-uri}{\tl_to_str:n{#1}} +} +\cs_set_eq:NN \_@@_path:n \_@@_auth:n +\cs_set_eq:NN \_@@_module:n \_@@_auth:n +\cs_set_eq:NN \_@@_name:n \_@@_auth:n + +\cs_set_protected:Nn \stex_map_uri:Nnnnn{ + \stex_pseudogroup_with:nn{\_@@_auth:n\_@@_path:n\_@@_module:n\_@@_name:n}{ + \cs_set:Npn \_@@_auth:n ##1 {#2} + \cs_set:Npn \_@@_path:n ##1 {#3} + \cs_set:Npn \_@@_module:n ##1 {#4} + \cs_set:Npn \_@@_name:n ##1 {#5} + #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_uri_set:Nn, \stex_uri_set:No, \stex_uri_set:Nx} +% \begin{macrocode} +\str_set:Nx\_@@_colonslash{\c_colon_str/} +\cs_new_protected:Nn \_@@_uri_set:NnN { + \str_if_empty:nTF {#2} { + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{empty} + }{ + \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn #1 \_@@_colonslash { \tl_to_str:n{#2} } + \seq_pop_left:NN #1 \l_@@_auth_str + \seq_if_empty:NTF #1 { + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{missing~authority} + }{ + \exp_args:NNnx \seq_set_split:Nnn #1 ? {\exp_args:NNo \seq_use:Nn #1 \_@@_colonslash } + \seq_pop_left:NN #1 \l_@@_path + #3 \l_@@_path \l_@@_path + \seq_if_empty:NTF #1 { + \exp_args:NNo \_@@_uri_set:Nnxnn #1 \l_@@_auth_str + {\stex_file_use:N \l_@@_path} {} {} + }{ + \seq_pop_left:NN #1 \l_@@_mod + \seq_if_empty:NTF #1 { + \exp_args:NNo \_@@_uri_set:Nnxon #1 \l_@@_auth_str + {\stex_file_use:N \l_@@_path} \l_@@_mod {} + }{ + \seq_pop_left:NN #1 \l_@@_name + \seq_if_empty:NTF #1 { + \exp_args:NNo \_@@_uri_set:Nnxon #2 \l_@@_auth_str + {\stex_file_use:N \l_@@_path} \l_@@_mod \l_@@_name + }{ + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{too~many~?s} + } + } + } + } + } + \stex_debug:nn{uris}{Set~\tl_to_str:n{#1}~to~\stex_uri_use:N #1} +} + +\cs_new_protected:Nn \_@@_uri_set:Nnnnn{ + \tl_set:Nn #1 { + \_@@_auth:n{ #2 } + \_@@_path:n{ #3 } + \_@@_module:n{ #4 } + \_@@_name:n{ #5 } + } +} +\cs_generate_variant:Nn\_@@_uri_set:Nnnnn {Nnxnn,Nnxon,Nnxoo} + +\cs_new_protected:Nn \stex_uri_set:Nn { + \_@@_uri_set:NnN #1 {#2} \stex_file_set:No +} +\cs_generate_variant:Nn \stex_uri_set:Nn {No, Nx} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_uri_resolve:Nn, \stex_uri_resolve:No, \stex_uri_resolve:Nx} +% \begin{macrocode} +\cs_new_protected:Nn \stex_uri_resolve:Nn { + \_@@_uri_set:NnN #1 {#2} \stex_file_resolve:No +} +\cs_generate_variant:Nn \stex_uri_resolve:Nn {No, Nx} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\stex_uri_use:N} +% \begin{macrocode} +\cs_new:Npn \_@@_uri_use:w \_@@_auth:n #1 \_@@_path:n #2 \_@@_module:n #3 \_@@_name:n #4 { + #1\c_colon_str/ #2 \tl_if_empty:nF { #3 }{ ? #3 + \tl_if_empty:nF { #4 }{ ? #4 } } +} +\cs_new:Nn \stex_uri_use:N { + \exp_args:Ne \cs_if_eq:NNTF { \tl_head:N #1 } \_@@_auth:n { + \exp_after:wN \_@@_uri_use:w #1 + }{ + \msg_error:nnnn{stex}{error/invalid-uri}{#1}{Not~a~URI} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_uri_from_repo_file:NNNn, \stex_uri_from_repo_file_nolang:NNNn} +% \begin{macrocode} +\cs_new_protected:Npn \stex_uri_from_repo_file_nolang:NNNn { + \_@@_from_repo_file:NNNNn \stex_file_split_off_lang:NN +} +\cs_new_protected:Npn \stex_uri_from_repo_file:NNNn { + \_@@_from_repo_file:NNNNn \stex_file_split_off_ext:NN +} + +\cs_new_protected:Nn \_@@_from_repo_file:NNNNn { + #1 \l_@@_file #4 + \prop_if_exist:NTF #3 { + \str_clear:N \l_@@_uri + \prop_get:NnNF #3 {#5} \l_@@_uri { + \prop_get:NnNF #3 {ns} \l_@@_uri { + \_@@_uri_set:Nnxnn #2 {file} + {\stex_file_use:N \l_@@_file} {} {} + } + } + \str_if_empty:NF \l_@@_uri {\_@@_relativize:N #2} + }{ + \exp_args:NNx \_@@_uri_set:Nnxnn #2 {\tl_to_str:n{file}} + {\stex_file_use:N \l_@@_file} {} {} + } +} + +\cs_new_protected:Nn \_@@_relativize:N { + \seq_set_eq:NN \l_@@_seq \l_@@_file + \seq_map_inline:Nn \c_stex_mathhub_file { % mathhub path + \seq_pop_left:NN \l_@@_seq \l_@@_tl + } + \stex_file_set:Nx \l_@@_path {\prop_item:Nn \l_stex_current_archive_prop {id} } + \seq_map_inline:Nn \l_@@_path { % id + \seq_pop_left:NN \l_@@_seq \l_@@_tl + } + \seq_pop_left:NN \l_@@_seq \l_@@_tl % source + + \stex_uri_set:Nx #1 { \l_@@_uri / \stex_file_use:N \l_@@_seq } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_uri_from_current_file:Nn, \stex_uri_from_current_file_nolang:Nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_uri_from_current_file:Nn { + \stex_debug:nn{docuri}{Here:~\stex_file_use:N \g_stex_current_file} + \stex_uri_from_repo_file:NNNn #1 \l_stex_current_archive_prop + \g_stex_current_file {#2} + \stex_debug:nn{docuri}{resolved:~\stex_uri_use:N #1} +} +\cs_new_protected:Nn \stex_uri_from_current_file_nolang:Nn { + \stex_uri_from_repo_file_nolang:NNNn #1 \l_stex_current_archive_prop + \g_stex_current_file {#2} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_uri_add_module:NNn, \stex_uri_add_module:NNo} +% \begin{macrocode} +\cs_new_protected:Nn \stex_uri_add_module:NNn { + \exp_args:Ne \cs_if_eq:NNTF { \tl_head:N #2 } \_@@_auth:n { + \stex_pseudogroup_with:nn + {\_@@_auth:n\_@@_path:n\_@@_module:n\_@@_name:n} + { + \cs_set:Npn \_@@_module:n ##1 { + \tl_if_empty:nTF{##1}{ + \exp_not:N \_@@_module:n {#3} + }{ + \msg_error:nnn{stex}{error/invalid-dpath}{#2} + } + } + \cs_set:Npn \_@@_name:n ##1 { + \tl_if_empty:nTF{##1}{ + \exp_not:N \_@@_name:n {} + }{ + \msg_error:nnn{stex}{error/invalid-dpath}{#2} + } + } + \tl_set:Nx #1 {#2} + } + }{ + \msg_error:nnnn{stex}{error/invalid-uri}{#2}{Not~a~URI} + } +} +\cs_generate_variant:Nn \stex_uri_add_module:NNn {NNo} +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\l_stex_current_doc_uri} +% \begin{macrocode} +\tl_new:N \l_stex_current_doc_uri +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\stex_set_document_uri:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_set_document_uri: { + \stex_uri_from_current_file:Nn \l_stex_current_doc_uri {narr} + %\stex_debug:nn{sref}{Document~URI:~\stex_uri_use:N \l_stex_current_doc_uri} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_set_current_namespace:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_set_current_namespace: { + \stex_uri_from_current_file_nolang:Nn \l_stex_current_ns_uri {source-base} + %\stex_debug:nn{modules}{Namespace~URI:~\stex_uri_use:N \l_stex_current_ns_uri} +} +% \end{macrocode} +% \end{macro} +% +% We determine the PWD +% +% \begin{variable}{\c_stex_pwd_file,\c_stex_main_file} +% \begin{macrocode} +\sys_if_platform_windows:TF{ + \stex_get_env:Nn\l_@@_str{CD} +}{ + \stex_get_env:Nn\l_@@_str{PWD} +} +\stex_file_resolve:No \c_stex_pwd_file \l_@@_str +\seq_set_eq:NN \c_stex_main_file \c_stex_pwd_file +\seq_put_right:Nx \c_stex_main_file {\jobname\tl_to_str:n{.tex}} + +\stex_debug:nn {files} {PWD:~\stex_file_use:N \c_stex_pwd_file} +% \end{macrocode} +% \end{variable} +% +% \end{sfragment} +% +% \begin{sfragment}{File Hooks} +% +% keeps track of file changes: +% \begin{macrocode} +\seq_gclear_new:N\g_@@_stack +\seq_gclear_new:N\g_stex_current_file +% \end{macrocode} +% +% \begin{macro}{\stex_filestack_push:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_filestack_push:n { + \stex_str_if_ends_with:nnTF {#1}{.tex}{ + \stex_file_resolve:No \g_stex_current_file {#1} + }{ + \stex_file_resolve:No \g_stex_current_file {#1.tex} + } + \stex_if_file_absolute:NF \g_stex_current_file { + \stex_file_resolve:Nx \g_stex_current_file { + \stex_file_use:N \c_stex_pwd_file / \stex_file_use:N \g_stex_current_file + } + } + \seq_gset_eq:NN \g_stex_current_file \g_stex_current_file + \exp_args:NNx \seq_gpush:Nn \g_@@_stack {\stex_file_use:N \g_stex_current_file} + \_stex_every_file: +} + +\cs_new_protected:Nn \_stex_every_file: { + \stex_set_document_uri: + \stex_language_from_file: + \stex_set_current_namespace: +} +%\AtBeginDocument{\_stex_every_file:} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_filestack_pop:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_filestack_pop: { + \seq_if_empty:NF \g_@@_stack { + \seq_gpop:NN \g_@@_stack \l_@@_str + } + \seq_if_empty:NTF \g_@@_stack { + \seq_gset_eq:NN \g_stex_current_file \c_stex_main_file + }{ + \seq_get:NN \g_@@_stack \l_@@_str + \exp_args:NNo \stex_file_set:Nn \g_stex_current_file \l_@@_str + \seq_gset_eq:NN \g_stex_current_file \g_stex_current_file + } + \_stex_every_file: +} +% \end{macrocode} +% \end{macro} + +% Hooks for the current file: +% +% \begin{macrocode} +\cs_new_protected:Nn \stex_input_with_hooks:n { + \tl_set:Nn \l_@@_do_hooks_pre_tl { + \tl_gset:Nn \l_@@_do_hooks_pre_tl {} + \stex_debug:nn{HERE}{Hook~for~#1^^J\meaning\CurrentFilePath^^J\CurrentFile} + \tl_if_empty:NTF\CurrentFilePath{ + \exp_args:No \stex_filestack_push:n {\CurrentFile} + }{ + \exp_args:Ne \stex_filestack_push:n { \CurrentFilePath / \CurrentFile } + } + } + \input{#1} + \stex_debug:nn{HERE}{Hook~end~for~#1} + \stex_filestack_pop: +} +\tl_new:N \l_@@_do_hooks_pre_tl {} + +\AddToHook{file/before}{ + \l_@@_do_hooks_pre_tl +} +%\AddToHook{file/after}{ \stex_filestack_pop: } +% \end{macrocode} +% +% \end{sfragment} +% +% \end{sfragment} +% +% \begin{sfragment}{Math Archives} +% \begin{macrocode} +%<@@=stex_mathhub> +% \end{macrocode} +% +% \begin{variable}{\mathhub, \c_stex_home_file,\c_stex_mathhub_file} +% The path to the mathhub directory. If the \cs{mathhub}-macro is not set, +% we query |kpsewhich| for the |MATHHUB| system variable. +% \begin{macrocode} + +\sys_if_platform_windows:TF{ + \stex_get_env:Nn \l_@@_str {homedrive\c_percent_str\c_percent_str homepath} +}{ + \stex_get_env:Nn \l_@@_str {HOME} +} +\stex_file_resolve:No \c_stex_home_file \l_@@_str + +\str_if_empty:NTF\mathhub{ + \stex_get_env:Nn \l_@@_str {MATHHUB} + \str_if_empty:NTF \l_@@_str { + \ior_open:NnTF \g_tmpa_ior{\stex_file_use:N \c_stex_home_file/.stex/mathhub.path}{ + \group_begin: + \escapechar=-1\catcode`\\=12 + \ior_str_get:NN \g_tmpa_ior \l_@@_str + \str_gset_eq:NN \l_@@_str \l_@@_str + \group_end: + \ior_close:N \g_tmpa_ior + \stex_debug:nn{mathhub}{MathHub~directory~determined~from~home~directory} + }{ + \str_clear:N \l_@@_str + } + }{ + \stex_debug:nn{mathhub}{MathHub~directory~determined~from~environment~variable} + } +}{ + \str_set_eq:NN \l_@@_str \mathhub +} + +\str_if_empty:NTF \l_@@_str { + \msg_warning:nn{stex}{warning/nomathhub} + \exp_args:NNe \stex_file_set:Nn \c_stex_mathhub_file {\stex_file_use:N \c_stex_home_file \tl_to_str:n{/MathHub}} + \seq_clear:N \c_stex_mathhub_file +}{ + \stex_file_resolve:No \c_stex_mathhub_file \l_@@_str + \stex_if_file_absolute:NF \c_stex_mathhub_file { + \exp_args:NNe \stex_file_resolve:Nn \c_stex_mathhub_file { + \stex_file_use:N \c_stex_main_file / .. / \l_@@_str + } + } +} + +\exp_args:NNe \str_set:Nn \mathhub {\stex_file_use:N \c_stex_mathhub_file} +\stex_debug:nn{mathhub}{MATHHUB:~\mathhub} +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_stex_current_archive} +% \begin{macro}{\stex_set_current_archive:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_set_current_archive:n { + \stex_require_archive:n { #1 } + \stex_debug:nn{mathhub}{switching~to~archive~#1} + \prop_set_eq:Nc \l_stex_current_archive_prop { + c_stex_mathhub_#1_manifest_prop + } +} +% \end{macrocode} +% \end{macro} +% \end{variable} +% +% \begin{macro}{\stex_in_archive:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_in_archive:nn { + \cs_if_exist:NF \l_@@_cs { + \cs_set:Npn \l_@@_cs ##1 {} + } + \stex_pseudogroup:nn{ + \cs_set:Npn \l_@@_cs ##1 {#2} + \tl_if_empty:nTF{#1}{ + \prop_if_exist:NTF \l_stex_current_archive_prop { + \exp_args:Ne \l_@@_cs {\prop_item:Nn \l_stex_current_archive_prop { id } } + }{ + \l_@@_cs {} + } + }{ + \stex_set_current_archive:n{#1} + \l_@@_cs {#1} + } + }{ + \stex_pseudogroup_restore:N \l_stex_current_archive_prop + \cs_set:Npn \exp_not:N \l_@@_cs ##1 { + \exp_args:No \exp_not:n {\l_@@_cs {##1}} + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_require_archive:n,\stex_require_archive:o} +% \begin{macrocode} +\cs_new_protected:Nn \stex_require_archive:n { + \prop_if_exist:cF { c_stex_mathhub_#1_manifest_prop } { + \seq_if_empty:NTF \c_stex_mathhub_file { + \stex_fatal_error:n{warning/nomathhub} + }{ + \stex_debug:nn{mathhub}{Opening~archive:~#1} + \_@@_do_manifest:n { #1 } + } + } +} +\cs_generate_variant:Nn \stex_require_archive:n {o} +% \end{macrocode} +% \end{macro} +% +% Code for finding and parsing manifest files: +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_do_manifest:n { + \exp_args:Ne \_@@_find_manifest:n {\stex_file_use:N \c_stex_mathhub_file / #1} + \str_if_empty:NT \l_@@_manifest_str { + \stex_fatal_error:nxx{error/noarchive} + {#1}{\stex_file_use:N \c_stex_mathhub_file} + } + \_@@_parse_manifest:n {#1} +} + +\cs_new_protected:Nn \_@@_find_manifest:n { + \str_clear:N \l_@@_manifest_str + \seq_set_split:Nnn \l_@@_seq / {#1} + \bool_set_true:N \l_@@_bool + \bool_while_do:Nn \l_@@_bool { + \tl_if_eq:NNTF \l_@@_seq \c_stex_mathhub_file { + \bool_set_false:N \l_@@_bool + }{ + \_@@_check_manifest: + \bool_if:NT \l_@@_bool { + \seq_pop_right:NN \l_@@_seq \l_@@_tl + } + } + } +} +\cs_generate_variant:Nn \_@@_find_manifest:n {x} + +\cs_new_protected:Nn \_@@_check_manifest: { + \_@@_check_manifest:n {MANIFEST.MF} + \bool_if:NT \l_@@_bool { + \_@@_check_manifest:n {META-INF/MANIFEST.MF} + \bool_if:NT \l_@@_bool { + \_@@_check_manifest:n {meta-inf/MANIFEST.MF} + } + } +} + +\cs_new_protected:Nn \_@@_check_manifest:n { + \stex_debug:nn{mathhub}{Checking~\stex_file_use:N \l_@@_seq / #1} + \file_if_exist:nT {\stex_file_use:N \l_@@_seq / #1} { + \bool_set_false:N \l_@@_bool + \str_set:Nx \l_@@_manifest_str {\stex_file_use:N \l_@@_seq / #1} + } +} + +\ior_new:N \c_@@_manifest_ior +\cs_new_protected:Nn \_@@_parse_manifest:n { + \ior_open:Nn \c_@@_manifest_ior \l_@@_manifest_str + \prop_clear:N \l_@@_prop + \ior_map_inline:Nn \c_@@_manifest_ior { + \exp_args:NNNo \exp_args:NNNx + \seq_set_split:Nnn \l_@@_seq \c_colon_str {\tl_to_str:n{##1}} + \seq_pop_left:NNT \l_@@_seq \l_@@_key { + \exp_args:NNo \str_set:Nn \l_@@_key \l_@@_key + \str_set:Nx \l_@@_val {\seq_use:Nn \l_@@_seq :} + \str_case:Nn \l_@@_key { + {id} {\prop_put:Nno \l_@@_prop { id } \l_@@_val } + {narration-base} {\prop_put:Nno \l_@@_prop { narr } \l_@@_val } + {url-base} {\prop_put:Nno \l_@@_prop { docurl } \l_@@_val } + {source-base} {\prop_put:Nno \l_@@_prop { ns } \l_@@_val } + {ns} {\prop_put:Nno \l_@@_prop { ns } \l_@@_val } + } + } + } + \ior_close:N \c_@@_manifest_ior + \prop_gset_eq:cN { c_stex_mathhub_#1_manifest_prop } \l_@@_prop + \stex_debug:nn{mathhub}{Result:~\prop_to_keyval:N \l_@@_prop} + \stex_persist:e { + \prop_gset_from_keyval:cn {c_stex_mathhub_#1_manifest_prop}{ + \prop_to_keyval:N \l_@@_prop + } + } +} +% \end{macrocode} +% +% Current MathHub archive +% \begin{variable}{\c_stex_main_archive_prop, \l_stex_current_archive_prop} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_main_archive: { + \stex_if_file_starts_with:NNTF \c_stex_pwd_file \c_stex_mathhub_file { + \_@@_find_manifest:x { \stex_file_use:N \c_stex_pwd_file } + \str_if_empty:NTF \l_@@_manifest_str { + \stex_debug:nn{mathhub}{Not~currently~in~a~MathHub~archive} + }{ + \_@@_parse_manifest:n { main } + \prop_set_eq:NN \c_stex_main_archive_prop \c_stex_mathhub_main_manifest_prop + \cs_undefine:N \c_stex_mathhub_main_manifest_prop + \prop_get:NnN \c_stex_main_archive_prop {id} + \l_@@_str + \prop_set_eq:cN { c_stex_mathhub_\l_@@_str _manifest_prop } + \c_stex_main_archive_prop + \exp_args:No \stex_set_current_archive:n { \l_@@_str } + \stex_debug:nn{mathhub}{Current~archive:~ + \prop_item:Nn \l_stex_current_archive_prop {id} + } + \bool_if:NT \c_stex_persist_write_mode_bool { + \tl_put_right:Nx \_stex_persist_read_now: { + \stex_persist:n { + \prop_gset_from_keyval:cn {c_stex_mathhub_\l_@@_str _manifest_prop}{ + \prop_to_keyval:N \c_stex_main_archive_prop + } + \prop_gset_eq:Nc \exp_not:N \l_stex_current_archive_prop { + c_stex_mathhub_\l_@@_str _manifest_prop + } + \prop_gset_eq:Nc \exp_not:N \c_stex_main_archive_prop { + c_stex_mathhub_\l_@@_str _manifest_prop + } + } + } + } + } + }{ + \stex_debug:nn{mathhub}{Not~currently~in~the~MathHub~directory} + } +} + +%\bool_if:NF \c_stex_persist_mode_bool { + \_stex_main_archive: +%} +% \end{macrocode} +% \end{variable} +% +% \end{sfragment} +% +% \begin{sfragment}{Documents} +% +% \begin{sfragment}{Title} +% +% Stores the title, if it exists: +% \begin{macrocode} +%<@@=stex_doc> +\tl_new:N \g_@@_title_tl +% \end{macrocode} +% +% \begin{macro}{\stexdoctitle} +% Initital definition, will be changed at begin document: +% \begin{macrocode} +\cs_new_protected:Npn \stexdoctitle #1 { + \tl_gset:Nn \g_@@_title_tl { #1 } + \global\def\stexdoctitle##1{} +} +% \end{macrocode} +% At begin document, we switch to: +% \begin{macrocode} +\cs_new_protected:Nn \_@@_set_title:n { + \stex_if_smsmode:F{ + \global\def\stexdoctitle##1{} + \stex_debug:nn{title}{Setting~title~to:\tl_to_str:n{#1}} + \tl_gset:Nn \g_@@_title_tl { #1 } + \_@@_title_html: + } +} +% \end{macrocode} +% Hooks, changes and HTML: +% \begin{macrocode} +\cs_new_protected:Nn \_@@_title_html: { + \stex_if_do_html:T{\stex_if_html_backend:T{ + \stex_annotate_invisible:nn{shtml:doctitle={}}{ \hbox{\g_@@_title_tl} } + }} +} + +\AtBeginDocument { + \tl_if_empty:NTF \g_@@_title_tl { + \cs_set_eq:NN \stexdoctitle \_@@_set_title:n + }{ + \stex_debug:nn{title}{Setting~title~to:\exp_args:No\tl_to_str:n\g_@@_title_tl} + \global\def\stexdoctitle#1{} + \_@@_title_html: + } + + \cs_set_eq:NN \_@@_maketitle: \maketitle + \global\protected\def\maketitle{ + \tl_if_empty:NF \@title { + \exp_args:No \stexdoctitle \@title + } + \_@@_maketitle: + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Sectioning} +% \begin{macrocode} +\int_new:N \l_stex_docheader_sect + +\tl_set:Nn \stex_current_section_level {document} + +\cs_set_protected:Npn \currentsectionlevel { + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:currentsectionlevel={},shtml:capitalize=false}{} + }{ + \stex_current_section_level + } + \tl_if_exist:NT\xspace\xspace +} + +\cs_set_protected:Npn \Currentsectionlevel { + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:currentsectionlevel={},shtml:capitalize=true}{} + }{ + \exp_args:No \_stex_capitalize:n \stex_current_section_level + } + \tl_if_exist:NT\xspace\xspace +} + +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_sfragment_do_level:nn { + \stexdoctitle{#2} + \par + \begin{stex_annotate_env}{shtml:section={\int_use:N \l_stex_docheader_sect}} + \noindent\stex_annotate:nn{shtml:sectiontitle={}}{ + \_stex_annotate_force_break:n{#2} + }\par + } + \cs_new_protected:Nn \_sfragment_end: { + \end{stex_annotate_env} + } +}{ + \cs_new_protected:Nn \_sfragment_do_level:nn { + \stexdoctitle{#2} + \tl_if_empty:NTF \l_stex_key_short_tl { + \use:c{#1} + }{ + \exp_args:Nnx \use:nn{\use:c{#1}}{[\exp_args:No \exp_not:n \l_stex_key_short_tl]} + }{#2} + \int_incr:N \l_stex_docheader_sect + \tl_set:Nn \stex_current_section_level{#1} + } + \cs_new_protected:Nn \_sfragment_end: {} +} + + +\cs_new_protected:Npn \_@@_do_section:n { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart {\_sfragment_do_level:nn{part}}{ + \int_incr:N \l_stex_docheader_sect + \_@@_do_section:n + }} + {1}{\cs_if_exist:NTF \thechapter {\_sfragment_do_level:nn{chapter}}{ + \int_incr:N \l_stex_docheader_sect + \_@@_do_section:n + }} + {2}{\_sfragment_do_level:nn{section}} + {3}{\_sfragment_do_level:nn{subsection}} + {4}{\_sfragment_do_level:nn{subsubsection}} + {5}{\_sfragment_do_level:nn{paragraph}} + }{\_sfragment_do_level:nn{subparagraph}} +} + +\stex_keys_define:nnnn{ sfragment }{ + \tl_clear:N \l_stex_key_short_tl +}{ + short .tl_set:N = \l_stex_key_short_tl +}{id} + +\NewDocumentEnvironment{sfragment}{ O{} m}{ + \stex_keys_set:nn{sfragment}{#1} + \_@@_do_section:n{#2} + \_stex_do_id: +}{ + \_sfragment_end: +} + +%\int_incr:N \l_stex_docheader_sect +\NewDocumentEnvironment{blindfragment}{}{ + \_@@_skip_section: +}{ + \stex_if_html_backend:T{ + \stex_annotate_invisible:n{~} + \end{stex_annotate_env} + } +} + + +\cs_new_protected:Nn \_@@_skip_section_i: { + \int_case:nn \l_stex_docheader_sect { + {0}{\cs_if_exist:NF \thepart { + \int_incr:N \l_stex_docheader_sect \_@@_skip_section_i: + }} + {1}{\cs_if_exist:NF \thechapter { + \int_incr:N \l_stex_docheader_sect \_@@_skip_section_i: + }} + } + \int_incr:N \l_stex_docheader_sect +} + +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_@@_skip_section: { + \_@@_skip_section_i: + \begin{stex_annotate_env}{shtml:skipsection={\int_use:N \l_stex_docheader_sect}} + \stex_annotate_invisible:n{~} + } +}{ + \cs_set_eq:NN \_@@_skip_section: \_@@_skip_section_i: +} + + +\cs_new_protected:Nn \_@@_skip_fragment:n { + \stepcounter{#1} +} + +\cs_new_protected:Npn \skipfragment { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart {\_@@_skip_fragment:n{part}}{ + \int_incr:N \l_stex_docheader_sect + \skipfragment + }} + {1}{\cs_if_exist:NTF \thechapter {\_@@_skip_fragment:n{chapter}}{ + \int_incr:N \l_stex_docheader_sect + \skipfragment + }} + {2}{\_@@_skip_fragment:n{section}} + {3}{\_@@_skip_fragment:n{subsection}} + {4}{\_@@_skip_fragment:n{subsubsection}} + {5}{\_@@_skip_fragment:n{paragraph}} + }{\_@@_skip_fragment:n{subparagraph}} +} +% \end{macrocode} +% +% \begin{macro}{\setsectionlevel} +% \begin{macrocode} +\cs_new_protected:Npn \setsectionlevel #1 { + \str_case:nnF{#1}{ + {part}{\int_set:Nn \l_stex_docheader_sect 0} + {chapter}{\int_set:Nn \l_stex_docheader_sect 1} + {section}{\int_set:Nn \l_stex_docheader_sect 2} + {subsection}{\int_set:Nn \l_stex_docheader_sect 3} + {subsubsection}{\int_set:Nn \l_stex_docheader_sect 4} + {paragraph}{\int_set:Nn \l_stex_docheader_sect 5} + }{ + \int_set:Nn \l_stex_docheader_sect 6 + } + \cs_if_eq:NNTF\@onlypreamble\@notprerr{ + \stex_annotate_invisible:nn{shtml:sectionlevel={\int_use:N\l_stex_docheader_sect}}{} + }{} +} + +\stex_if_html_backend:T{ + \cs_new_protected:Nn \_@@_check_topsect: { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart { + \stex_annotate_invisible:nn{shtml:sectionlevel=0}{} + }{ + \int_incr:N \l_stex_docheader_sect + \_@@_check_topsect: + }} + {1}{\cs_if_exist:NTF \thechapter { + \stex_annotate_invisible:nn{shtml:sectionlevel=1}{} + }{ + \int_incr:N \l_stex_docheader_sect + \_@@_check_topsect: + }} + }{ + \stex_annotate_invisible:nn{shtml:sectionlevel={\int_use:N\l_stex_docheader_sect}}{} + } + } + \AtBeginDocument{\_@@_check_topsect:} +} + +\AtBeginDocument{ + \cs_if_exist:NTF\frontmatter{ + \let\_@@_orig_frontmatter\frontmatter + \let\frontmatter\relax + }{ + \tl_set:Nn\_@@_orig_frontmatter{ + \clearpage + %\@mainmatterfalse + \pagenumbering{roman} + } + } + \cs_if_exist:NTF\backmatter{ + \let\_@@_orig_backmatter\backmatter + \let\backmatter\relax + }{ + \tl_set:Nn\_@@_orig_backmatter{ + \clearpage + %\@mainmatterfalse + \pagenumbering{roman} + } + } + \newenvironment{frontmatter}{ + \_@@_orig_frontmatter + }{ + \cs_if_exist:NTF\mainmatter{ + \mainmatter + }{ + \clearpage + %\@mainmattertrue + \pagenumbering{arabic} + } + } + \newenvironment{backmatter}{ + \_@@_orig_backmatter + }{ + \cs_if_exist:NTF\mainmatter{ + \mainmatter + }{ + \clearpage + %\@mainmattertrue + \pagenumbering{arabic} + } + } +} +% \end{macrocode} +% \end{macro} +% \end{sfragment} +% +% +% \begin{sfragment}{References} +% \begin{macrocode} +%<@@=stex_refs> +% \end{macrocode} +% +% References are stored in the file |\jobname.sref|, to enable +% cross-referencing external documents. +% \begin{macrocode} +\iow_new:N \c_@@_iow +\AtBeginDocument{\iow_open:Nn \c_@@_iow {\jobname.sref}} +\AtEndDocument{\iow_close:N \c_@@_iow} +% \end{macrocode} +% +% The following macros are written to the |.aux|-file, and hence +% use \LaTeX2e character code scheme: +% +% \begin{macrocode} +\cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {} + +\cs_new_protected:Npn \STEXInternalSetSrefSymURL #1 #2 { + \str_gset:cn{g_stex_sref_sym_\tl_to_str:n{#1}_target}{#2} +} + +% \end{macrocode} +% +% \begin{macro}{\stex_ref_new_doc_target:n,\sreflabel} +% \begin{macrocode} +\seq_new:N \g_@@_files_seq +\int_new:N \l_@@_unnamed_counter_int + +\cs_new_protected:Nn \_stex_ref_new_id:n { + \str_if_empty:nTF {#1}{ + \int_gincr:N \l_@@_unnamed_counter_int + \str_set:Nx \l_@@_str {REF\int_use:N \l_@@_unnamed_counter_int} + }{ + \str_set:Nn \l_@@_str {#1} + } + \str_set:Nx \l_stex_ref_url_str {\stex_uri_use:N \l_stex_current_doc_uri ? \l_@@_str} +} + +\cs_new_protected:Nn \stex_ref_new_doc_target:n { + \_stex_ref_new_id:n{#1} + %\stex_uri_add_module:NNo \l_@@_uri \l_stex_current_doc_uri \l_@@_str + %\stex_debug:nn{sref}{New~document~target:~\stex_uri_use:N \l_@@_uri} + \_@@_add_doc_ref:xo {\stex_uri_use:N \l_stex_current_doc_uri} \l_@@_str + \stex_if_smsmode:F { + \iow_now:Nx \c_@@_iow { + \STEXInternalSrefRestoreTarget + {\stex_uri_use:N \l_stex_current_doc_uri} + {\l_@@_str} + {\@currentcounter} + {\@currentlabel} + { + \tl_if_exist:NT\@currentlabelname{ + \exp_args:No\exp_not:n\@currentlabelname + } + } + } + \exp_args:Nx \label {sref@\l_stex_ref_url_str} + \stex_if_do_html:T { + \pdfdest name "sref@\l_stex_ref_url_str" xyz\relax + } + } +} +\NewDocumentCommand \sreflabel {m} {\stex_ref_new_doc_target:n {#1}} + +\cs_new_protected:Nn \_@@_add_doc_ref:nn { + \seq_if_in:NnTF \g_@@_files_seq {#1} { + \seq_if_in:cnF {g_@@_#1_seq}{#2}{ + \seq_gput_left:cn{g_@@_#1_seq}{#2} + } + }{ + \seq_gput_right:Nn \g_@@_files_seq {#1} + \seq_new:c{g_@@_#1_seq} + \seq_gput_left:cn{g_@@_#1_seq}{#2} + } +} +\cs_generate_variant:Nn \_@@_add_doc_ref:nn {xo,xx} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sref,\extref} +% Optional arguments: +% \begin{macrocode} +\stex_keys_define:nnnn{sref / 1}{}{ + % TODO get rid of this + fallback .code:n = {}, + pre .code:n = {}, + post .code:n = {} +}{archive file} +\stex_keys_define:nnnn{sref / 2}{}{}{archive file, title} + +\str_new:N \l_@@_default_archive_str +\str_new:N \l_@@_default_file_str +\tl_new:N \l_@@_default_title_tl + +\cs_set_protected:Nn \_@@_set_keys_b:n { + \tl_if_empty:nTF{#1}{ + \str_set_eq:NN \l_stex_key_archive_str \l_@@_default_archive_str + \str_set_eq:NN \l_stex_key_file_str \l_@@_default_file_str + \tl_set_eq:NN \l_stex_key_title_tl \l_@@_default_title_tl + }{ + \stex_keys_set:nn{ sref / 2 }{ #1 } + } +} + +\newcommand\srefsetin[3][]{ + \str_set:Nx \l_@@_default_archive_str {#1} + \str_set:Nx \l_@@_default_file_str {#2} + \tl_set:Nn \l_@@_default_title_tl {#3} +} + +% \end{macrocode} +% +% Auxiliary methods: +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_find_uri:n { + \str_clear:N \l_@@_uri_str + \stex_debug:nn{sref}{ + File:~\l_stex_key_file_str^^J + Repo:\l_stex_key_archive_str + } + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1} + \seq_if_exist:cT{g_@@_\stex_uri_use:N \l_stex_current_doc_uri _seq}{ + \exp_args:Nnx \_@@_find_uri_in_file:nnn{#1} + {\stex_uri_use:N \l_stex_current_doc_uri}\seq_map_break: + } + \str_if_empty:NT \l_@@_uri_str { + \seq_map_inline:Nn \g_@@_files_seq { + \_@@_find_uri_in_file:nnn{#1}{##1}{\seq_map_break:n{\seq_map_break:}} + } + } + }{ + \str_if_empty:NTF \l_stex_key_archive_str { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \_@@_find_uri_in_prop_file:N \l_stex_current_archive_prop + }{ + \stex_file_resolve:Nx \l_@@_file + { \stex_file_use:N \g_stex_current_file / .. / \l_stex_key_file_str } + \str_set:Nx \l_@@_uri_str { file:/ \stex_file_use:N \l_@@_file } + } + }{ + \stex_require_archive:o \l_stex_key_archive_str + \prop_set_eq:Nc \l_@@_prop { c_stex_mathhub_\l_stex_key_archive_str _manifest_prop } + \_@@_find_uri_in_prop_file:N \l_@@_prop + } + } +} + +\cs_new_protected:Nn \_@@_find_uri_in_prop_file:N { + \str_set:Nx \l_@@_uri_str { + \stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn #1 {id} / + source / \l_stex_key_file_str .sref + } + \stex_file_resolve:No \l_@@_file \l_@@_uri_str + \stex_uri_from_repo_file:NNNn \l_@@_uri #1 + \l_@@_file {narr} + \str_set:Nx \l_@@_uri_str {\stex_uri_use:N \l_@@_uri} +} + +\cs_new_protected:Nn \_@@_find_uri_in_file:nnn { + \stex_debug:nn{sref}{Checking~file~#2} + \seq_map_inline:cn{g_@@_#2_seq}{ + \str_if_eq:nnT{#1}{##1}{ + \str_set:Nx \l_@@_uri_str {\stex_uri_use:N \l_stex_current_doc_uri} + \stex_debug:nn{sref}{Found.} + #3 + } + } +} +% \end{macrocode} +% Doing the actual referencing: +% \begin{macrocode} +\cs_new_protected:Nn \_@@_do_autoref:n { + \cs_if_exist:cTF{autoref}{ + \exp_args:Nx\autoref{sref@#1} + }{ + \exp_args:Nx\ref{sref@#1} + } +} + +\cs_new_protected:Nn \_@@_do_sref:nn { + \str_if_empty:NTF \l_@@_uri_str { + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{autoref~on~\stex_uri_use:N \l_stex_current_doc_uri?#1} + \exp_args:Ne \_@@_do_autoref:n{\stex_uri_use:N \l_stex_current_doc_uri ? #1} + }{ + \stex_debug:nn{sref}{srefin~on~#1} + \_@@_set_keys_b:n{ #2 } + \_@@_do_sref_in:n{#1} + } + }{ + \exp_args:NNo \seq_if_in:NnTF \g_@@_files_seq \l_@@_uri_str { + \stex_debug:nn{sref}{Using~ref~file~\l_@@_uri_str} + \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l_@@_uri_str _seq}{\detokenize{#1}}{ + \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~\l_@@_uri_str?#1} + \_@@_do_autoref:n{\l_@@_uri_str?#1} + }{ + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~\l_@@_uri_str?#1} + \_@@_do_autoref:n{\l_@@_uri_str?#1} + }{ + \stex_debug:nn{sref}{in~non-empty;~srefin~on~\l_@@_uri_str?#1} + \_@@_set_keys_b:n{ #2 } + \_@@_do_sref_in:n{#1} + } + } + }{ + \stex_debug:nn{sref}{No~ref~file~found~for~\l_@@_uri_str} + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~\l_@@_uri_str?#1} + \_@@_do_autoref:n{\l_@@_uri_str?#1} + }{ + \stex_debug:nn{sref}{in~non-empty;~srefin~on~\l_@@_uri_str?#1} + \_@@_set_keys_b:n{ #2 } + \_@@_do_sref_in:n{#1} + } + } + } +} + +\cs_new_protected:Nn \_@@_do_sref_in:n { + \stex_debug:nn{sref}{In: \l_stex_key_file_str^^JRepo:\l_stex_key_archive_str} + \stex_debug:nn{sref}{URI: \l_@@_uri_str?#1} + \tl_if_exist:cTF{r@sref@\l_@@_uri_str?#1}{ + \_@@_do_autoref:n{\l_@@_uri_str?#1} + }{ + %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>} + \group_begin:\catcode13=9\relax\catcode10=9\relax + \str_if_empty:NTF \l_stex_key_archive_str { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \str_set:Nx \l_@@_file_str { + \stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn \l_stex_current_archive_prop { id } + / source / \l_stex_key_file_str .sref + } + }{ + \str_set:Nx \l_@@_file_str { + \stex_file_use:N \g_stex_current_file / .. / \l_stex_key_file_str . sref + } + } + }{ + \str_set:Nx \l_@@_file_str { + \stex_file_use:N \c_stex_mathhub_file / \l_stex_key_archive_str + / source / \l_stex_key_file_str . sref + } + } + \stex_file_resolve:No \l_@@_file \l_@@_file_str + \str_set:Nx \l_@@_file_str {\stex_file_use:N \l_@@_file } + \stex_debug:nn{sref}{File: \l_@@_file_str } + \exp_args:NNNx \exp_args:No \str_if_eq:nnTF \l_@@_file_str {\stex_file_use:N\c_stex_pwd_file / \jobname.sref}{ + \_@@_do_autoref:n{ + \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 + } + }{ + \exp_args:No \IfFileExists \l_@@_file_str { + \tl_clear:N \l_@@_return_tl + \str_set:Nn \l_@@_id_str {#1} + \let\STEXInternalSrefRestoreTarget\_@@_restore_target:nnnnn + \use:c{@ @ input}{\l_@@_file_str} + \exp_args:No \tl_if_empty:nTF \l_@@_return_tl { + \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_@@_file_str{#1} + \_@@_do_autoref:n{ + \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 + } + }{ + \l_@@_return_tl + } + }{ + \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_@@_file_str + \_@@_do_autoref:n{ + \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 + } + } + } + \group_end: + } +} + +\cs_new_protected:Nn \_@@_do_return:nnnn { + \tl_set:Nn \l_@@_return_tl { + \stex_annotate:nn{shtml:sref={#4},shtml:srefin={\l_@@_file_str}}{ + \use:c{#3autorefname}~#1\tl_if_empty:nF{#2}{~(#2)} + \tl_if_empty:NF\l_stex_key_title_tl{ + {}~in~\l_stex_key_title_tl + } + } + } +} + +\cs_new_protected:Nn \_@@_restore_target:nnnnn { + \str_if_empty:NTF \l_@@_uri_str { + \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ + \_@@_do_return:nnnn{#4}{#5}{#3}{#1?#2} + } + }{ + \stex_debug:nn{sref}{\l_@@_uri_str{}~ == ~ #1 ~ ?} + \exp_args:No \str_if_eq:nnT \l_@@_uri_str {#1}{ + \stex_debug:nn{sref}{\l_@@_id_str~ == ~ #2 ~ ?} + \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ + \stex_debug:nn{sref}{success!} + \_@@_do_return:nnnn{#4}{#5}{#3}{#1?#2} + \endinput + } + } + } +} +% \end{macrocode} +% The actual macros: +% \begin{macrocode} +\NewDocumentCommand \sref { O{} m O{}}{ + \stex_keys_set:nn { sref / 1 }{ #1 } + \_@@_find_uri:n { #2 } + \_@@_do_sref:nn{#2}{#3} +} +\NewDocumentCommand \extref { O{} m m}{ + \stex_keys_set:nn { sref / 1 }{ #1 } + \_@@_find_uri:n { #2 } + \_@@_set_keys_b:n{ #3 } + \str_if_empty:NT \l_stex_key_file_str { + \msg_error:nn{stex}{error/extrefmissing} + } + \_@@_do_sref_in:n{#2} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_ref_new_sym_target:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_ref_new_symbol:n { + \cs_if_exist:cF{r@sref@sym@\tl_to_str:n{#1}}{ + \_@@_new_symbol:n{#1} + } +} + +\cs_new_protected:Nn \_stex_sref_do_aux:n { + #1 \iow_now:Nn \@auxout {#1} +} + +\cs_new_protected:Nn \_@@_new_symbol:n { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \prop_get:NnNTF \l_stex_current_archive_prop {docurl} \l_@@_str { + \exp_args:Ne \_stex_sref_do_aux:n { + \STEXInternalSetSrefSymURL{#1}{\l_@@_str / symbol? #1} + } + }{ + \_stex_sref_do_aux:n { \STEXInternalSetSrefSymURL{#1}{} } + } + }{ + \_stex_sref_do_aux:n { \STEXInternalSetSrefSymURL{#1}{} } + } +} + +\cs_new_protected:Nn \stex_ref_new_sym_target:n { + \exp_args:Ne \label{\tl_to_str:n{sref@sym@ #1}} +} + +\cs_new_protected:Nn \stex_ref_new_sym_target:nn { + \str_if_eq:nnTF{#1}{#2}{ + \stex_ref_new_sym_target:n{#1} + }{ + \str_gset:cn{g_stex_sref_sym_ #1 _label}{#2} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\srefsym} +% \begin{macrocode} +\NewDocumentCommand \srefsym { m m}{ + \stex_get_symbol:n { #1 } + \exp_args:Ne + \_@@_sym_aux:nn{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} +} + +\cs_new_protected:Npn \_@@_do_internal_link:nn #1 { + \cs_if_exist:NTF \hyperref { + \hyperref[{#1}] + }\use:n +} + +\cs_new_protected:Npn \_@@_do_url_link:nn { + \cs_if_exist:NTF \href \href \use_ii:nn +} + +\cs_new_protected:Npn \_@@_sym_aux:nn #1 { + \cs_if_exist:cTF{r@sref@sym@\tl_to_str:n{#1}}{ + \exp_args:Ne \_@@_do_internal_link:nn{\tl_to_str:n{sref@sym@#1}} + }{ + \str_if_exist:cTF{g_stex_sref_sym_#1_label}{ + \exp_args:Ne \_@@_sym_aux:nn{\use:c{g_stex_sref_sym_#1_label}} + }{ + \str_if_empty:cTF{g_stex_sref_sym_#1_target}{ + \exp_args:Ne \_@@_do_internal_link:nn{\tl_to_str:n{sref@sym@#1}} + }{ + \exp_args:Ne \_@@_do_url_link:nn{\use:c{g_stex_sref_sym_#1_target}} + } + } + } +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\srefsymuri} +% \begin{macrocode} +\cs_new_protected:Npn \srefsymuri #1 { + \_@@_sym_aux:nn{#1} +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Inputs} +% \begin{macrocode} +%<@@=stex_inputs> +% \end{macrocode} +% +% \begin{macro}{\stex_resolve_path_pair:Nnn,\stex_resolve_path_pair:Nxx} +% \begin{macrocode} +\cs_new_protected:Nn \stex_resolve_path_pair:Nnn { + \stex_debug:nn{resolving~path}{#3~in~[#2]} + \str_if_empty:nTF{#2}{ + \prop_if_exist:NTF \l_stex_current_archive_prop { + \str_set:Nx #1 {\stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn \l_stex_current_archive_prop { id } / source / + #3} + \stex_debug:nn{resolving~path}{In~current~archive~ + \prop_item:Nn \l_stex_current_archive_prop { id } + ;~result:~#1} + }{ + \str_set:Nx #1 {\stex_file_use:N \c_stex_pwd_file / .. / #3 } + \stex_debug:nn{resolving~path}{No~current~archive;~result:~#1} + } + }{ + \stex_require_archive:n { #2 } + \str_set:Nx #1 {\stex_file_use:N \c_stex_mathhub_file / + \prop_item:cn {c_stex_mathhub_#2_manifest_prop} { id } / source / + #3} + \stex_debug:nn{resolving~path}{result:~#1} + } +} +\cs_generate_variant:Nn \stex_resolve_path_pair:Nnn {Nxx} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\inputref,\mhinput,\ifinputref} +% \begin{macrocode} +\newif \ifinputref \inputreffalse + +\cs_new_protected:Nn \_@@_mhinput:nn { + \stex_in_archive:nn {#1} { + \ifinputref + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / ##1 / source / #2 } + \else + \inputreftrue + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / ##1 / source / #2 } + \inputreffalse + \fi + } +} + +\NewDocumentCommand \mhinput { O{} m}{ + \exp_args:NNx\exp_args:Nnx\_@@_mhinput:nn{ \tl_to_str:n{#1} }{ \tl_to_str:n{#2} } +} + +\cs_new_protected:Nn \_@@_inputref_html:nn { + \str_clear:N \l_tmpa_str + \prop_get:NnNF \l_stex_current_archive_prop { narr } \l_tmpa_str { + \prop_get:NnNF \l_stex_current_archive_prop { ns } \l_tmpa_str {} + } + \tl_if_empty:nTF{ #1 }{ + \IfFileExists{#2}{ + \ifvmode\noindent\fi\stex_annotate_invisible:nn{shtml:inputref={ + \l_tmpa_str / #2 + }}{} + }{ + \stex_input_with_hooks:n{#2} + } + }{ + \IfFileExists{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 }{ + \par\stex_annotate_invisible:nn{shtml:inputref={ + \l_tmpa_str / #2 + }}{~} + }{ + \input{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 } + } + } +} + +\cs_new_protected:Nn \_@@_inputref_pdf:nn { + \begingroup + \inputreftrue + \tl_if_empty:nTF{ #1 }{ + \stex_input_with_hooks:n{#2} + }{ + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 } + } + \endgroup +} + +\cs_new_protected:Nn \_@@_inputref:nn { + \stex_in_archive:nn {#1} { + \stex_if_html_backend:TF + \_@@_inputref_html:nn + \_@@_inputref_pdf:nn + {##1}{#2} + } +} + +\NewDocumentCommand \inputref { O{} m}{ + \exp_args:NNx \exp_args:Nnx \_@@_inputref:nn{ \tl_to_str:n{#1} }{ \tl_to_str:n{#2} } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\addmhbibresource} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_bibresource:n { + \_@@_up_archive:nn{#1}{bib} + \seq_if_empty:NTF \l_@@_libinput_files_seq { + \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\addmhbibresource}{#1.bib} + }{ + \seq_map_inline:Nn \l_@@_libinput_files_seq { + \addbibresource{ ##1 } + } + } +} +\newcommand\addmhbibresource[2][]{ + \tl_if_empty:nTF{#1}{ + \_@@_bibresource:n{#2} + }{ + \stex_in_archive:nn{#1}{\_@@_bibresource:n{#2}} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\IfInputref} +% \begin{macrocode} +\stex_if_html_backend:TF{ + \newcommand \IfInputref[2]{ + \stex_annotate:nn{shtml:ifinputref=true}{#1} + \stex_annotate:nn{shtml:ifinputref=false}{#2} + } +}{ + \newcommand \IfInputref[2]{ + \ifinputref #1 \else #2 \fi + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\libinput} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_up_archive:nn { + \prop_if_exist:NF \l_stex_current_archive_prop { + \msg_error:nnn{stex}{error/notinarchive}\libinput + } + \prop_get:NnNF \l_stex_current_archive_prop {id} \l_@@_id_str { + \msg_error:nnn{stex}{error/notinarchive}\libinput + } + \seq_clear:N \l_@@_libinput_files_seq + \seq_set_eq:NN \l_@@_path_seq \c_stex_mathhub_file + \seq_set_split:NnV \l_@@_id_seq / \l_@@_id_str + + \bool_while_do:nn { ! \seq_if_empty_p:N \l_@@_id_seq }{ + \str_set:Nx \l_@@_path_str {\stex_file_use:N \l_@@_path_seq / meta-inf / lib / #1.#2} + \IfFileExists{ \l_@@_path_str }{ + \seq_put_right:No \l_@@_libinput_files_seq \l_@@_path_str + }{} + \seq_pop_left:NN \l_@@_id_seq \l_@@_path_str + \seq_put_right:No \l_@@_path_seq \l_@@_path_str + } + + \str_set:Nx \l_@@_path_str {\stex_file_use:N \l_@@_path_seq / lib / #1.#2} + \IfFileExists{ \l_@@_path_str }{ + \seq_put_right:No \l_@@_libinput_files_seq \l_@@_path_str + }{} +} + +\cs_new_protected:Nn \_@@_libinput:n { + \_@@_up_archive:nn{#1}{tex} + \seq_if_empty:NTF \l_@@_libinput_files_seq { + \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libinput}{#1.tex} + }{ + \seq_map_inline:Nn \l_@@_libinput_files_seq { + \input{ ##1 } + } + } +} + +\newcommand \libinput [2][] { + \tl_if_empty:nTF{#1}{ + \_@@_libinput:n{#2} + }{ + \stex_in_archive:nn{#1}{\_@@_libinput:n{#2}} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\libusepackage} +% \begin{macrocode} +\newcommand\libusepackage[2][]{ + \_@@_up_archive:nn{#2}{sty} + \int_compare:nNnTF {\seq_count:N \l_@@_libinput_files_seq} = 1 { + \str_set:Nx \l_@@_tmp_str {\seq_item:Nn \l_@@_libinput_files_seq 1} + \exp_args:Nne \use:n {\usepackage[#1]} { + \str_range:Nnn\l_@@_tmp_str 1 {-5} + } + }{ + \stex_fatal_error:nnn{error/nofile}{\libusepackage}{#1.sty} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mhgraphics,\cmhgraphics,\lstinputmhlisting,\clstinputmhlisting,\mhtikzinput,\cmhtikzinput} +% \begin{macrocode} +\str_new:N \l_@@_gin_repo_str +\ltx@ifpackageloaded{graphicx}{\use:n}{\AtEndOfPackageFile{graphicx}}{ + \define@key{Gin}{archive}{ + \tl_set:Nx\Gin@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} + } + \providecommand\mhgraphics[2][]{ + \tl_set:Nx\Gin@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / + } + \setkeys{Gin}{#1} + \includegraphics[#1]{ \Gin@mhrepos #2 } + } + \providecommand\cmhgraphics[2][]{\begin{center}\mhgraphics[#1]{#2}\end{center}} +} + +\ltx@ifpackageloaded{listings}{\use:n}{\AtEndOfPackageFile{listings}}{ + \define@key{lst}{archive}{ + \def\lst@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} + } + \newcommand\lstinputmhlisting[2][]{% + \def\lst@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / + } + \setkeys{lst}{#1}% + \lstinputlisting[#1]{\lst@mhrepos #2}} + \newcommand\clstinputmhlisting[2][]{\begin{center}\lstinputmhlisting[#1]{#2}\end{center}} +} + +\ltx@ifpackageloaded{tikzinput}{\use:n}{\AtEndOfPackageFile{tikzinput}}{ + \define@key{Gin}{archive}{ + \str_set:Nn \l_@@_gin_repo_str {#1} + \def\Gin@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} + } + \newcommand\mhtikzinput[2][]{% + \str_clear:N \l_@@_gin_repo_str + \def\Gin@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / + } + \setkeys{Gin}{#1}% + \exp_args:No \stex_in_archive:nn \l_@@_gin_repo_str { + \tikzinput[#1]{\Gin@mhrepos #2} + } + } + \newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\libusetikzlibrary} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_usetikzlibrary:nn { + \pgfkeys@spdef\pgf@temp{#1} + \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$} + \catcode`\@=11 + \catcode`\|=12 + \catcode`\$=3 + \pgfutil@InputIfFileExists{#2}{}{} + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname +} + +\cs_new_protected:Npn \libusetikzlibrary #1 { + \cs_if_exist:NF \usetikzlibrary { + \msg_error:nnx{stex}{error/notikz}{\tl_to_str:n{\libusetikzlibrary}} + } + \_@@_up_archive:nn{tikzlibrary#1}{code.tex} + \int_compare:nNnTF {\seq_count:N \l_@@_libinput_files_seq} = 1 { + \exp_args:Nne \_@@_usetikzlibrary:nn{#1}{ \seq_item:Nn \l_@@_libinput_files_seq 1 } + }{ + \stex_fatal_error:nnn{error/nofile}{\libusetikzlibrary}{tikzlibrary#1.code.tex} + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \end{sfragment} +% +% \begin{sfragment}{SMS Mode} +% \begin{macrocode} +%<@@=stex_smsmode> +% \end{macrocode} +% +% Macros and environments allowed in sms mode: +% \begin{macrocode} +\tl_new:N \g_@@_allowed_tl +\tl_new:N \g_@@_allowed_escape_tl +\seq_new:N \g_@@_allowedenvs_seq +% \end{macrocode} +% +% \begin{macro}{\stex_sms_allow:N,\stex_sms_allow_escape:N,\stex_sms_allow_env:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_sms_allow:N { + \tl_gput_right:Nn \g_@@_allowed_tl {#1} +} + +\cs_new_protected:Nn \stex_sms_allow_escape:N { + \tl_gput_right:Nn \g_@@_allowed_escape_tl {#1} +} + +\cs_new_protected:Nn \stex_sms_allow_env:n { + \exp_args:NNx \seq_gput_right:Nn \g_@@_allowedenvs_seq {\tl_to_str:n{#1}} +} +% \end{macrocode} +% \end{macro} +% Some initial allowed macros: +% \begin{macrocode} +\stex_sms_allow:N \makeatletter +\stex_sms_allow:N \makeatother +\stex_sms_allow:N \ExplSyntaxOn +\stex_sms_allow:N \ExplSyntaxOff +\stex_sms_allow:N \rustexBREAK +% \end{macrocode} +% +% \begin{macro}[pTF]{\stex_if_smsmode:} +% \begin{macrocode} +\bool_new:N \g_@@_bool +\bool_set_false:N \g_@@_bool +\prg_new_conditional:Nnn \stex_if_smsmode: { p, T, F, TF } { + \bool_if:NTF \g_@@_bool \prg_return_true: \prg_return_false: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_sms_allow_import:Nn, \stex_sms_allow_import_env:nn} +% \begin{macrocode} +\tl_new:N \g_@@_allowed_import_tl +\seq_new:N \g_@@_allowed_import_env_seq +\cs_new_protected:Nn \stex_sms_allow_import:Nn { + \tl_gput_right:Nn \g_@@_allowed_import_tl {#1} + \tl_gset:cn{\tl_to_str:n{#1}~-~smsmode} {#2} +} +\cs_new_protected:Nn \stex_sms_allow_import_env:nn { + \exp_args:NNx \seq_gput_right:Nn \g_@@_allowed_import_env_seq {\tl_to_str:n{#1}} + \tl_gset:cn{\tl_to_str:n{#1}~-~env~-~smsmode} {#2} +} + +\tl_new:N \g_stex_sms_import_code +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_file_in_smsmode:nn,\stex_file_in_smsmode:on} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_in_smsmode:n { \stex_suppress_html:n { + \vbox_set:Nn \l_tmpa_box { + \bool_set_true:N \g_@@_bool + \bool_set_false:N \_stex_html_do_output_bool + #1 + } + %\box_clear:N \l_tmpa_box +} } + +\quark_new:N \q_@@_break + +\cs_new_protected:Nn \_@@_start_smsmode:n { + \everyeof{\q_@@_break\exp_not:N} + \let\stex_smsmode_do:\_@@_smsmode_do: + \exp_after:wN \exp_after:wN \exp_after:wN + \stex_smsmode_do: + \cs:w @ @ input\cs_end: "#1" \relax +} + +\cs_new_protected:Nn \stex_file_in_smsmode:nn { + \seq_gclear:N \l_@@_importmodules_seq + \seq_gclear:N \l_@@_sigmodules_seq + \tl_clear:N \g_stex_sms_import_code + \group_begin: + \let \l_stex_metatheory_uri \c_stex_default_metatheory + \cs_set:Npn \stex_check_term:n ##1 {} + \seq_clear:N \l_stex_all_modules_seq + \str_clear:N \l_stex_current_module_str + #2 + \stex_filestack_push:n{#1} + \_@@_in_smsmode:n { + \let \_@@_do_aux_curr:N \_@@_do_aux_imports:N + \tl_map_inline:Nn \g_@@_allowed_import_tl { + \use:c{\tl_to_str:n{##1}~-~smsmode} + } + \seq_map_inline:Nn \g_@@_allowed_import_env_seq { + \use:c{\tl_to_str:n{##1}~-~env~-~smsmode} + } + \_@@_start_smsmode:n{#1} + } + \_@@_in_smsmode:n \g_stex_sms_import_code + \_@@_in_smsmode:n { + \let \_@@_do_aux_curr:N \_@@_do_aux_normal:N + \_@@_start_smsmode:n{#1} + } + \stex_filestack_pop: + \group_end: +} +\cs_generate_variant:Nn \stex_file_in_smsmode:nn {on} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_smsmode_do:} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_smsmode_do: { + %\stex_if_smsmode:T { + \_@@_do:w + %} +} +\let\stex_smsmode_do:\relax + + +\cs_new:Nn \_@@_check_cs:NNn { + \exp_after:wN\if\exp_after:wN\relax\exp_not:N#3 + \exp_after:wN#1\exp_after:wN#3\else + \exp_after:wN#2\fi +} + +\cs_new_protected:Npn \_@@_do:w #1 { + \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #1 }}{ + \_@@_check_cs:NNn \_@@_do_aux:N \_@@_do:w { #1 } + }{ + \_@@_do:w + } +} + +\cs_new_protected:Nn \_@@_do_aux:N { + \cs_if_eq:NNF #1 \q_@@_break { + \_@@_do_aux_curr:N #1 + } +} + +\cs_new_protected:Nn \_@@_do_aux_imports:N { + % \stex_debug:nn{sms}{Checking~\tl_to_str:n{#1}~in~import} + \tl_if_in:NnTF \g_@@_allowed_import_tl {#1} { + \stex_debug:nn{sms}{Executing~\tl_to_str:n{#1}~in~import} + #1 + }{ + \cs_if_eq:NNTF \begin #1 { + \_@@_check_begin:Nn \g_@@_allowed_import_env_seq + }{ + \cs_if_eq:NNTF \end #1 { + \_@@_check_end:Nn \g_@@_allowed_import_env_seq + }{ + \_@@_do:w + } + } + } +} + +\cs_new_protected:Nn \_@@_do_aux_normal:N { + % \stex_debug:nn{sms}{Checking~\tl_to_str:n{#1}~in~sms~mode} + \tl_if_in:NnTF \g_@@_allowed_tl {#1} { + \stex_debug:nn{sms}{Executing~\tl_to_str:n{#1}} + #1\_@@_do:w + }{ + \tl_if_in:NnTF \g_@@_allowed_escape_tl {#1} { + \stex_debug:nn{sms}{Executing~escaped~\tl_to_str:n{#1}} + #1 + }{ + \cs_if_eq:NNTF \begin #1 { + \_@@_check_begin:Nn \g_@@_allowedenvs_seq + }{ + \cs_if_eq:NNTF \end #1 { + \_@@_check_end:Nn \g_@@_allowedenvs_seq + }{ + \_@@_do:w + } + } + } + } +} + +\cs_new_protected:Nn \_@@_check_begin:Nn { + % \stex_debug:nn{sms}{Checking~environment~#2} + \seq_if_in:NxTF #1 { \tl_to_str:n{#2} }{ + \stex_debug:nn{sms}{Environment~#2} + \begin{#2} + }{ + \_@@_do:w + } +} +\cs_new_protected:Nn \_@@_check_end:Nn { +% \stex_debug:nn{sms}{Checking~end~environment~#2} + \seq_if_in:NxTF #1 { \tl_to_str:n{#2} }{ + \stex_debug:nn{sms}{End~Environment~#2} + \end{#2}\_@@_do:w + }{ + %\str_if_eq:nnTF{#2}{document} \endinput + \_@@_do:w + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Modules} +% +% \begin{sfragment}{The smodule-environment} +% \begin{macrocode} +%<@@=stex_modules> +% \end{macrocode} +% +% \begin{variable}{\l_stex_current_module_str} +% The current module: +% \begin{macrocode} +\str_new:N \l_stex_current_module_str +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\l_stex_all_modules_seq} +% Stores all modules currently in scope +% \begin{macrocode} +\seq_new:N \l_stex_all_modules_seq +% \end{macrocode} +% \end{variable} +% +% +% \begin{macro}{\stex_every_module:n} +% \begin{macrocode} +%<@@=stex_module_setup> +\tl_clear:N \g_stex_every_module_tl { +} +\cs_new_protected:Nn \stex_every_module:n { + \tl_gput_right:Nn \g_stex_every_module_tl { #1 } +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\stex_module_setup:n} +% Sets up a new module: +% \begin{macrocode} +\cs_new_protected:Npn \stex_module_setup:n { + \stex_if_in_module:TF \_@@_setup_nested:n \_@@_setup_top:n +} + +\cs_new_protected:Nn \_@@_setup_top:n { + \_@@_get_uri_str:n{#1} + \stex_debug:nn{module}{Module~URI:~\l_@@_ns_str?#1} + \str_if_empty:NTF \l_stex_key_sig_str + \_stex_module_setup_top_nosig:n \_@@_setup_top_sig:n {\l_@@_ns_str?#1} + \stex_metagroup_new:o \l_stex_current_module_str + \g_stex_every_module_tl + \stex_execute_in_module:x { + \_stex_do_deprecation:n{#1} + } + \_@@_load_meta: +} + +\cs_new_protected:Nn \_stex_module_setup_top_nosig:n { + \stex_if_module_exists:nTF{#1}{ + \stex_debug:nn{modules}{(already exists)} + }{ + \tl_gclear:c{c_stex_module_ #1 _code} + \prop_gclear:c{c_stex_module_ #1 _morphisms_prop } + \prop_gclear:c{c_stex_module_ #1 _symbols_prop } + \prop_gclear:c{c_stex_module_ #1 _notations_prop } + } + \str_set:Nx \l_stex_current_module_str {#1} + \seq_put_right:No \l_stex_all_modules_seq \l_stex_current_module_str +} + +\cs_new_protected:Nn \_@@_setup_top_sig:n { + \stex_if_module_exists:nTF{#1}{ + \stex_debug:nn{modules}{(already exists)} + }{ + \stex_debug:nn{modules}{(needs loading)} + \_@@_load_sig: + } + %\stex_if_smsmode:F { % WHY? + \stex_activate_module:x { + #1 + } + %} + \str_set:Nx\l_stex_current_module_str{#1} +} + +\cs_new_protected:Nn \_@@_load_sig: { + \stex_file_split_off_ext:NN \l_@@_sigfile \g_stex_current_file + \stex_file_split_off_lang:NN \l_@@_sigfile \l_@@_sigfile + \exp_args:Ne \stex_file_in_smsmode:nn { + \stex_file_use:N \l_@@_sigfile . \l_stex_key_sig_str . tex + }{} +} + +\cs_new_protected:Nn \_@@_setup_nested:n { + \exp_after:wN + \_@@_split_module:n \l_stex_current_module_str \_@@_end: {#1} + \stex_debug:nn{module}{Nested~Module~URI:~\l_stex_current_module_str} + \seq_put_right:No \l_stex_all_modules_seq \l_stex_current_module_str + \stex_metagroup_new:o \l_stex_current_module_str +} + + +\cs_new_protected:Nn \_@@_get_uri_str:n { + \str_clear:N \l_@@_ns_str + \stex_map_uri:Nnnnn \l_stex_current_ns_uri { + \str_set:Nx \l_@@_ns_str{##1\c_colon_str/} + }{ + \seq_set_split:Nnn \l_@@_seq / {##1} + \seq_pop_right:NN \l_@@_seq \l_@@_seg + \exp_args:No \str_if_eq:nnF \l_@@_seg {#1} { + \seq_put_right:No \l_@@_seq \l_@@_seg + } + \tl_put_right:Nx \l_@@_ns_str {\seq_use:Nn \l_@@_seq /} + }{}{} +} + +\cs_new_protected:Npn \_@@_split_module:n #1?#2 \_@@_end: #3 { + \_stex_module_setup_top_nosig:n { #1 ? #2 / #3} +} + +\bool_new:N \l_stex_in_meta_bool +\bool_set_false:N \l_stex_in_meta_bool + +\cs_new_protected:Nn \_@@_load_meta: { + \tl_if_empty:NF \l_stex_metatheory_uri { + \stex_execute_in_module:x{ + \stex_pseudogroup_with:nn{\l_stex_in_meta_bool}{ + \stex_activate_module:n {\stex_uri_use:N \l_stex_metatheory_uri } + } + } + } +} + +%<@@=stex_modules> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_close_module:} +% \begin{macrocode} +\cs_new:Nn \stex_close_module: { + \bool_if:NT \c_stex_persist_write_mode_bool \_@@_persist_module: + \stex_debug:nn{module}{ + Closing~module~\l_stex_current_module_str^^J + Code:~\expandafter\meaning\csname c_stex_module_\l_stex_current_module_str _code\endcsname^^J + Imports:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _morphisms_prop\cs_end:^^J + Declarations:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _symbols_prop\cs_end:^^J + Notations:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _notations_prop\cs_end:^^J + } +} + +\cs_new_protected:Nn \_@@_persist_module: { + \stex_persist:e { + \_@@_restore_module:nnnn {\l_stex_current_module_str}{ + \exp_after:wN \prop_to_keyval:N \cs:w + c_stex_module_\l_stex_current_module_str _morphisms_prop + \cs_end: + }{ + \exp_after:wN \prop_to_keyval:N \cs:w + c_stex_module_\l_stex_current_module_str _symbols_prop + \cs_end: + }{ + \exp_after:wN \exp_after:wN \exp_after:wN \exp_not:n + \exp_after:wN \exp_after:wN \exp_after:wN + { \cs:w c_stex_module_\l_stex_current_module_str _code \cs_end: } + }{} + \prop_map_function:cN{c_stex_module_\l_stex_current_module_str _notations_prop} + \_@@_persist_nots_i:nn + \exp_not:N \STEXRestoreNotsEnd {} + } +} + +\cs_new_protected:Nn \_@@_restore_module:nnnn { + \prop_gset_from_keyval:cn{c_stex_module_\tl_to_str:n{#1}_morphisms_prop}{#2} + \cs_set:Npn \_@@_tl {#3} + \exp_args:Nno \prop_gset_from_keyval:cn{c_stex_module_\tl_to_str:n{#1}_symbols_prop}\_@@_tl + \prop_map_inline:cn{c_stex_module_\tl_to_str:n{#1}_symbols_prop}{ + \stex_ref_new_symbol:n{#1?##1} + } + \cs_gset:cpn{c_stex_module_\tl_to_str:n{#1}_code}{#4} + \prop_gclear:c{c_stex_module_\tl_to_str:n{#1} _notations_prop} + \str_set:Nn \l_@@_restore_mod_str {#1} + \group_begin: + \catcode`_=8\relax + \catcode`:=12\relax + \_@@_restore_nots:n +} + +\cs_new:Nn \_@@_persist_nots_i:nn { + \exp_not:n{#2} +} + +\quark_new:N \STEXRestoreNotsEnd + +\cs_new_protected:Nn \_@@_restore_nots:n { + \_@@_restore_nots_i:n +} + +\cs_new_protected:Nn \_@@_restore_nots_i:n { + \tl_if_eq:nnTF{#1}{\STEXRestoreNotsEnd}{ + \group_end: + }{ + \_@@_restore_nots_ii:nnnnn {#1} + } +} + +\cs_new_protected:Nn \_@@_restore_nots_ii:nnnnn { + \cs_set:Npn \l_@@_tl {{#4}{#5}} + \exp_args:NNe\use:nn\prop_gput:cnn{ + {c_stex_module_\l_@@_restore_mod_str _notations_prop} + {\tl_to_str:n{#1!#2}}{ + {\tl_to_str:n{#1}}{\tl_to_str:n{#2}}{#3} + \exp_args:No \exp_not:n \l_@@_tl + } + } + \_@@_restore_nots_i:n +} +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\l_stex_metatheory_uri} +% \begin{macrocode} +\tl_new:N \l_stex_metatheory_uri +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{\setmetatheory} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_set_metatheory:nn { + \group_begin: + \stex_debug:nn{metatheory}{Setting~metatheory~[#1]#2} + \stex_import_module_uri:nn { #1 } { #2 } + \stex_debug:nn{metatheory}{Here:^^J + \l_stex_import_archive_str^^J + \l_stex_import_path_str^^J + \l_stex_import_name_str^^J + } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_debug:nn{metatheory}{Found:~\l_stex_import_ns_str} + \exp_args:Nne \use:nn { + \group_end: \stex_uri_resolve:Nn \l_stex_metatheory_uri + }{{\l_stex_import_ns_str}} +} + +\NewDocumentCommand \setmetatheory {O{} m}{ + \_@@_set_metatheory:nn { #1 }{ #2 } + \stex_smsmode_do: +} +\stex_sms_allow_escape:N \setmetatheory +% \end{macrocode} +% \end{macro} +% +% Keys and key handling: +% +% \begin{macrocode} +\stex_keys_define:nnnn{smodule}{ + \str_clear:N \l_stex_key_sig_str +}{ + meta .code:n = { + \str_if_empty:nTF {#1}{ + \tl_clear:N \l_stex_metatheory_uri + }{ + \stex_uri_resolve:Nx \l_stex_metatheory_uri { #1 } + } + }, + ns .code:n = { + \stex_uri_resolve:Nx \l_stex_current_ns_uri { #1 } + } , + lang .code:n = { + \stex_set_language:n { #1 } + } , + sig .str_set_x:N = \l_stex_key_sig_str , + creators .code:n = {} , % todo ? + contributors .code:n = {} , % todo ? + srccite .code:n = {} % todo ? +}{id, title, style, deprecate} +% \end{macrocode} +% +% \begin{environment}{smodule} +% \begin{macrocode} +\stex_new_stylable_env:nnnnnnn {module} {O{} m}{ + \stex_keys_set:nn { smodule }{ #1 } + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \tl_if_empty:NF \thistitle { + \exp_args:No \stexdoctitle \thistitle + } + \exp_args:Nx \stex_module_setup:n { \tl_to_str:n{ #2 } } + + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:theory={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={\l_stex_key_sig_str} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} + } + } + \stex_annotate_invisible:n{} + } + \stex_if_smsmode:F { + \str_set_eq:NN \thismoduleuri \l_stex_current_module_str + \tl_set:Nn \thismodulename {#2} + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_close_module: + \stex_if_smsmode:F \stex_style_apply: + \stex_if_do_html:T{ \end{stex_annotate_env} } +}{}{}{s} + +\stex_sms_allow_env:n{smodule} +% \end{macrocode} +% \end{environment} +% +% +% \begin{macro}[pTF]{\stex_if_in_module:} +% Are we currently in a module? +% \begin{macrocode} +\prg_new_conditional:Nnn \stex_if_in_module: {p, T, F, TF} { + \str_if_empty:NTF \l_stex_current_module_str + \prg_return_false: \prg_return_true: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[pTF]{\stex_if_module_exists:n} +% Does a module with this URI exist? +% \begin{macrocode} +\prg_new_conditional:Nnn \stex_if_module_exists:n {p, T, F, TF} { + \tl_if_exist:cTF { c_stex_module_#1_code } + \prg_return_true: \prg_return_false: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_do_up_to_module:n,\stex_do_up_to_module:x} +% Execute code in the current module (i.e. as if the \cs{begin}\Arg{smodule} +% was the current tex group) +% \begin{macrocode} +\cs_new_protected:Nn \stex_do_up_to_module:n { + \exp_args:No \stex_metagroup_do_in:nn \l_stex_current_module_str {#1} +} +\cs_generate_variant:Nn \stex_do_up_to_module:n {x} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_module_add_code:n,\stex_module_add_code:x} +% \begin{macrocode} +\cs_new_protected:Nn \stex_module_add_code:n { + \tl_gput_right:cn {c_stex_module_\l_stex_current_module_str _code} { #1 } +} +\cs_generate_variant:Nn \stex_module_add_code:n {x} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_execute_in_module:n,\stex_execute_in_module:x} +% \begin{macrocode} +\cs_new_protected:Nn \stex_execute_in_module:n { \stex_if_in_module:TF { + \stex_module_add_code:n { #1 } + \stex_do_up_to_module:n { #1 } +}{ #1 }} +\cs_generate_variant:Nn \stex_execute_in_module:n {x} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\STEXexport} +% \begin{macrocode} +\NewDocumentCommand \STEXexport {} { + \ExplSyntaxOn + \_@@_export:n +} +\cs_new_protected:Nn \_@@_export:n { + \stex_ignore_spaces_and_pars:#1\ExplSyntaxOff + \stex_module_add_code:n { \stex_ignore_spaces_and_pars:#1} + \stex_smsmode_do: +} +% \end{macrocode} +% Only allowed in modules, and allowed (escaped) in sms mode: +% \begin{macrocode} +\stex_deactivate_macro:Nn \STEXexport {module~environments} +\stex_sms_allow_escape:N \STEXexport +\stex_every_module:n {\stex_reactivate_macro:N \STEXexport} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_module_add_morphism:nnnn, \stex_module_add_morphism:nonn, \stex_module_add_morphism:ooox} +% \begin{macrocode} +\cs_new_protected:Nn \stex_module_add_morphism:nnnn { + \exp_args:Nne \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _morphisms_prop}{ + \tl_if_empty:nTF{#1}{[#2]}{#1} + }{{#1}{#2}{#3}{#4}} +} +\cs_generate_variant:Nn \stex_module_add_morphism:nnnn {nonn,ooox} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_module_add_symbol:nnnnnnN} +% \begin{arguments} +% \item \Arg{Macro name} +% \item \Arg{Name} +% \item \Arg{arity} +% \item \{(\Arg{Arg num}\Arg{Arg str})$^\ast$\} +% \item Definiens +% \item type +% \item Return +% \item Command +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \stex_module_add_symbol:nnnnnnnN { + \stex_debug:nn{declaration}{New~declaration:~\l_stex_current_module_str?#2^^J + Macro:#1^^JArity:#3~(#4)^^J + Def:~\tl_to_str:n{#5}^^J + Type:~\tl_to_str:n{#6}^^J + Returns:~\tl_to_str:n{#7} + } + %\prop_gput:cnx{c_stex_module_\l_stex_current_module_str _symbols_prop} + %{#2}{\exp_not:n{{#1}{#2}{#3}{#4}{#5}{#6}}{#7}\exp_not:n{#8}} + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _symbols_prop} + {#2}{{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}} + \tl_if_empty:nF{#1}{ + \stex_execute_in_module:n { + \_@@_activate_sym:n {#2} + } + } +} + +\cs_new_protected:Nn \_@@_activate_sym:n { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _symbols_prop}{ + \str_if_eq:nnT{#1}{##1}{ + \_@@_activate_i:nnnnnnnn ##2 + } + } +} +\cs_new_protected:Nn \_@@_activate_i:nnnnnnnn { + \stex_debug:nn{activating}{#1:\l_stex_current_module_str^^J + \tl_to_str:n{{#2}{#3}{#4}{#5}{#6}{#7}#8} + } + \cs_set:cpx{#1} { + \_stex_invoke_symbol:nnnnnnnN + {\l_stex_current_module_str} + \exp_not:n{{#2}{#3}{#4}{#5}{#6}{#7}{#8}} + } + \stex_debug:nn{activating}{done} + \prop_map_break: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_module_add_notation:nnnnn, \stex_module_add_notation:eoeoo,\stex_set_notation_macro:nnnnn} +% \begin{arguments} +% \item URI +% \item variant +% \item arity +% \item macro body +% \item op +% \end{arguments} +% \begin{macrocode} +\cs_new_protected:Nn \stex_module_add_notation:nnnnn { + \stex_debug:nn{notations}{Adding~notation:^^J + #1~\c_hash_str#2~#3^^J + to~\l_stex_current_module_str + } + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _notations_prop} + {#1!#2}{{#1}{#2}{#3}{#4}{#5}} + \stex_execute_in_module:n { + \_@@_activate_not:nn{#1}{#2} + } +} +\cs_generate_variant:Nn \stex_module_add_notation:nnnnn {eoeoo} + + +\cs_new_protected:Nn \_@@_activate_not:nn { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _notations_prop}{ + \str_if_eq:nnT{#1!#2}{##1}{ + \prop_map_break:n{\stex_set_notation_macro:nnnnn ##2 } + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_set_notation_macro:nnnnn,\stex_set_notation_macro:eoexo} +% \begin{macrocode} +\cs_new_protected:Nn \stex_set_notation_macro:nnnnn { + \tl_set:cn {l_stex_notation_#1_#2_cs}{#4} + \cs_if_exist:cF{l_stex_notation_#1__cs}{ + \tl_set:cn {l_stex_notation_#1__cs}{#4} + } + \tl_if_empty:nF{#5}{ + \tl_set:cn{l_stex_notation_#1_op_#2_cs}{#5} + \cs_if_exist:cF{l_stex_notation_#1_op__cs}{ + \cs_set_eq:cc {l_stex_notation_#1_op__cs}{l_stex_notation_#1_op_#2_cs} + } + } +} +\cs_generate_variant:Nn \stex_set_notation_macro:nnnnn {eoexo} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_activate_module:n,\stex_activate_module:o,\stex_activate_module:x} +% \begin{macrocode} +\cs_new_protected:Nn \stex_activate_module:n { + \seq_if_in:NnF \l_stex_all_modules_seq { #1 } { + \stex_debug:nn{modules}{Activating~module~#1^^J\expandafter\meaning\csname c_stex_module_#1_code\endcsname} + \seq_put_right:Nn \l_stex_all_modules_seq { #1 } + \stex_pseudogroup:nn{ + \str_set:Nn \l_stex_current_module_str {#1} + \use:c{ c_stex_module_#1_code } + }{ + \stex_pseudogroup_restore:N \l_stex_current_module_str + } + } +} +\cs_generate_variant:Nn \stex_activate_module:n {o,x} +% \end{macrocode} +% \end{macro} +% +% Iterating: +% \begin{macrocode} +%<@@=stex_iterate> +% \end{macrocode} +% +% \begin{macro}{\stex_iterate_symbols:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_iterate_symbols:n { + \stex_pseudogroup_with:nn{\_@@_sym_cs:nnnnnnnnN\stex_iterate_break:\stex_iterate_break:n}{ + \cs_set:Npn \_@@_sym_cs:nnnnnnnnN + ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #1 } + \cs_set:Npn \stex_iterate_break: { + \prop_map_break:n{\seq_map_break:} + } + \cs_set:Npn \stex_iterate_break:n ##1 { + \prop_map_break:n{\seq_map_break:n{##1}} + } + \seq_map_inline:Nn \l_stex_all_modules_seq { + \prop_map_inline:cn{c_stex_module_##1_symbols_prop}{ + \_@@_sym_cs:nnnnnnnnN {##1} ####2 + } + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_iterate_symbols:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_iterate_symbols:nn { + \seq_clear:N \l_@@_mods_seq + \stex_pseudogroup_with:nn{\_@@_sym_cs:nnnnnnnnN}{ + \cs_set:Npn \_@@_sym_cs:nnnnnnnnN + ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #2 } + \clist_map_function:nN {#1} \_@@_it_decl_i:n + } +} + +\cs_new_protected:Nn \_@@_it_decl_i:n { + \seq_if_in:NnF \l_@@_mods_seq {#1} { + \seq_put_left:Nn \l_@@_mods_seq {#1} + \prop_map_inline:cn{c_stex_module_#1_morphisms_prop}{ + \_@@_it_decl_check:nnnn ##2 + } + \prop_map_inline:cn{c_stex_module_#1_symbols_prop}{ + \_@@_sym_cs:nnnnnnnnN {#1} ##2 + } + } +} +\cs_new_protected:Nn \_@@_it_decl_check:nnnn { + \tl_if_empty:nT{#1}{ + \_@@_it_decl_i:n {#2} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_iterate_notations:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_iterate_notations:nn { + \seq_clear:N \l_@@_mods_seq + \stex_pseudogroup_with:nn{\_@@_not_cs:nnnnn}{ + \cs_set:Npn \_@@_not_cs:nnnnn + ##1 ##2 ##3 ##4 ##5 { #2 } + \clist_map_function:nN {#1} \_@@_it_not_i:n + } +} + +\cs_new_protected:Nn \_@@_it_not_i:n { + \seq_if_in:NnF \l_@@_mods_seq {#1} { + \seq_put_left:Nn \l_@@_mods_seq {#1} + \prop_map_inline:cn{c_stex_module_#1_notations_prop}{ + \_@@_not_cs:nnnnn ##2 + } + \prop_map_inline:cn{c_stex_module_#1_morphisms_prop}{ + \_@@_it_not_check:nnnn ##2 + } + } +} +\cs_new_protected:Nn \_@@_it_not_check:nnnn { + \tl_if_empty:nT{#1}{ + \_@@_it_not_i:n {#2} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_iterate_morphisms:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_iterate_morphisms:nn { + \seq_clear:N \l_@@_mods_seq + \bool_set_true:N \l_@@_continue_bool + \cs_set:Npn \_@@_morphism_cs:nnnn ##1 ##2 ##3 ##4 ##5 { + #2 + \bool_if:NT \l_@@_continue_bool { + \str_if_eq:nnTF{##1}{[##2]}{ + \tl_put_right:Nn \l_@@_todo_tl { + \_@@_iterate_morphism:nn{##5}{##2} + } + }{ + \tl_put_right:Nn \l_@@_todo_tl { + \_@@_iterate_morphism:nn{##5 / ##1}{##2} + } + } + } + } + \cs_set:Npn \stex_iterate_break:n ##1 { + \bool_set_false:N \l_@@_continue_bool + \prop_map_break:n{##1} + } + \_@@_iterate_morphism:nn{}{#1} +} + +\cs_new_protected:Nn \_@@_iterate_morphism:nn { + \tl_clear:N \l_@@_todo_tl + \seq_if_in:NnF \l_@@_mods_seq {#1 #2}{ + \seq_put_right:Nn \l_@@_mods_seq {#1 #2} + \prop_map_inline:cn{c_stex_module_#2_morphisms_prop}{ + \_@@_morphism_cs:nnnn ##2 {#1} + % TODO + % ##1: name or [mpath] + % ##2 = {####1}{####2}{####3}{####4} + % ####1 = name + % ####2 = mpath + % ####3 = type + % ####4 = {origname}{newname}* + } + \bool_if:NT \l_@@_continue_bool \l_@@_todo_tl + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Structural Features} +% \begin{macrocode} +%<@@=stex_features> +% \end{macrocode} +% +% \begin{macro}{\stex_structural_feature_module:nn,\stex_structural_feature_module_end:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_structural_feature_module:nn { + \stex_if_do_html:TF { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:feature-#2={ + \l_stex_current_module_str/#1} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + } + \stex_annotate_invisible:n{} + }\group_begin: + \stex_module_setup:n {#1-module} +} + +\cs_new_protected:Nn \stex_structural_feature_module_end: { + \tl_gset_eq:NN \g_stex_last_feature_str \l_stex_current_module_str + \stex_close_module: + \stex_if_do_html:TF{ + \end{stex_annotate_env} + }\group_end: +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_structural_feature_morphism:nnn,\stex_structural_feature_morphism_end:} +% \begin{macrocode} +\bool_new:N \l_@@_implicit_bool +\cs_new_protected:Nn \stex_structural_feature_morphism:nnnnn { + \str_clear:N \l_stex_current_domain_str + \tl_if_empty:nT{#3}{ + \_stex_get_mathstructure:n{#4} + \str_set_eq:NN \l_stex_current_domain_str \l_stex_get_structure_module_str + } + \str_if_empty:NT \l_stex_current_domain_str { + \stex_import_module_uri:nn { #3 }{ #4 } + \group_begin: + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \exp_args:Nnx \use:nn \group_end: { + \str_set:Nn \exp_not:N\l_stex_current_domain_str {\l_stex_import_ns_str} + } + } + \tl_if_empty:nTF{#1}{ + \bool_set_true:N \l_@@_implicit_bool + \str_set:Nx \l_tmpa_str {[\l_stex_current_domain_str]} + }{ + \bool_set_false:N \l_@@_implicit_bool + \str_set:Nn \l_tmpa_str {#1} + } + + \stex_if_do_html:TF { + \begin{stex_annotate_env} { + shtml:feature-#2={\l_stex_current_module_str?\l_tmpa_str}, + shtml:domain={\l_stex_current_domain_str} + #5 + } + \stex_annotate_invisible:n{} + }\group_begin: + \str_set:Nn \l_@@_feature_str {#2} + \str_set_eq:NN \l_stex_feature_name_str \l_tmpa_str + \_@@_setup: + \_@@_reactivate: + %^^A\stex_activate_module:o \l_stex_current_domain_str + \exp_args:Ne \stex_metagroup_new:n {\l_stex_current_module_str / \l_stex_feature_name_str} +} + +\cs_new_protected:Nn \_@@_do_for_list: { + \seq_clear:N \l_stex_fors_seq + \clist_map_inline:Nn \l_stex_key_for_clist { + \exp_args:Ne\stex_get_in_morphism:n{\tl_to_str:n{##1}} + \seq_put_right:Nx \l_stex_fors_seq + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } +} + +\cs_new_protected:Nn \_@@_add_definiens:nn { + \_@@_set_definiens_macros: #1\_@@_break: + \_stex_assign_do:n{#2} + #2 +} +\cs_new_protected:Npn \_@@_set_definiens_macros: #1?#2?#3\_@@_break: { + \str_set:Nn \l_stex_get_symbol_mod_str {#1?#2} + \str_set:Nn \l_stex_get_symbol_name_str {#3} + \exp_args:Nne\use:nn{\_@@_set_definiens_macros_i:nnnnnnn}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#1?#2]/[#3]} + } +} +\cs_new_protected:Nn \_@@_set_definiens_macros_i:nnnnnnn { + \tl_set:Nn \l_stex_get_symbol_def_tl{#4} +} + +\cs_new_protected:Nn \stex_structural_feature_morphism_end: { + \str_gset_eq:NN \l_stex_feature_name_str \l_stex_feature_name_str + \str_gset_eq:NN \l_stex_current_domain_str \l_stex_current_domain_str + \seq_gset_eq:NN \l_stex_morphism_symbols_prop \l_stex_morphism_symbols_prop + \seq_gset_eq:NN \l_stex_morphism_renames_prop \l_stex_morphism_renames_prop + \seq_gset_eq:NN \l_stex_morphism_morphisms_seq \l_stex_morphism_morphisms_seq + \_@@_do_elaboration: + \stex_if_do_html:TF{ + \end{stex_annotate_env} + }\group_end: +} + +\cs_new_protected:Nn \_@@_setup: { + \prop_clear:N \l_stex_morphism_symbols_prop + \prop_clear:N \l_stex_morphism_renames_prop + \seq_clear:N \l_stex_morphism_morphisms_seq + \_@@_do_decls: + \exp_args:No \_@@_do_morphisms:n \l_stex_current_domain_str +} + +\cs_new_protected:Nn \_@@_rename_all: { + +} + +\cs_new:Npn \_@@_clean:nnw [#1] / #2 \_stex_end: { + [#1]/[#2] +} + +\cs_new_protected:Nn \_@@_do_decls: { + \exp_args:No \stex_iterate_symbols:nn \l_stex_current_domain_str { + \stex_str_if_starts_with:nnTF{##3}[{ + \exp_args:NNe \prop_put:Nnn \l_stex_morphism_symbols_prop { + \_@@_clean:nnw ##3 \_stex_end: + } + }{ + \prop_put:Nnn \l_stex_morphism_symbols_prop + {[##1]/[##3]} + }{ + {##2}{##4}{##5}{##6}{##7}{##8}##9 + } + } +} + +\cs_new_protected:Nn \stex_structural_feature_morphism_check_total: { + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \_@@_total_check: ##1 ##2 + } +} + +\cs_new_protected:Npn \_@@_total_check: [#1]/[#2] #3 #4 #5 #6 #7 #8 #9 { + \tl_if_empty:nT{#6}{ + \msg_error:nnxx{stex}{error/needsdefiniens}{#1?#2}{total~morphism} + } +} + +\cs_new:Npn \_@@_split_qm:w #1 ? #2 ? #3 { #3 } +\cs_new_protected:Nn \_@@_do_elaboration: { + \stex_debug:nn{morphisms}{ + Elaborating:^^J\prop_to_keyval:N \l_stex_morphism_symbols_prop + ^^J + Renamings:^^J + \prop_to_keyval:N \l_stex_morphism_renames_prop + } + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \_@@_elab_check: ##1 ##2 + } + \exp_args:No\stex_iterate_notations:nn\l_stex_current_domain_str{ + \prop_get:NnNTF \l_stex_morphism_renames_prop {##1}\l_@@_tmp { + \exp_args:Ne \stex_module_add_notation:nnnnn + {\l_stex_current_module_str ? \exp_after:wN \use_ii:nn \l_@@_tmp} + }{ + \exp_args:Ne \stex_module_add_notation:nnnnn + {\l_stex_current_module_str ? \l_stex_feature_name_str + / \_@@_split_qm:w ##1} + }{##2}{##3}{##4}{##5} + } + \stex_module_add_morphism:ooox + \l_stex_feature_name_str + \l_stex_current_domain_str + \l_@@_feature_str + {\prop_map_function:NN \l_stex_morphism_renames_prop \_@@_rename:nn} +} + +\cs_new:Nn \_@@_rename:nn{ + {#1}{\use_ii:nn#2} +} + +\cs_new_protected:Npn \_@@_elab_check: [#1]/[#2] #3 { + \prop_get:NnNTF \l_stex_morphism_renames_prop {#1?#2} \l_@@_tmp { + \stex_debug:nn{morphisms}{Generating~\l_@@_tmp} + \exp_after:wN \stex_module_add_symbol:nnnnnnnN \l_@@_tmp + }{ + \bool_if:NTF \l_@@_implicit_bool { + \stex_debug:nn{morphisms}{Generating~#3:~\l_stex_feature_name_str / #2} + \exp_args:Nno \stex_module_add_symbol:nnnnnnnN {#3}{\l_stex_feature_name_str / #2} + }{ + \stex_debug:nn{morphisms}{Generating~\l_stex_feature_name_str / #2} + \exp_args:Nno \stex_module_add_symbol:nnnnnnnN {}{\l_stex_feature_name_str / #2} + } + } +} + +\cs_new_protected:Nn \_@@_do_morphisms:n { + \prop_map_inline:cn {c_stex_module_#1_morphisms_prop}{ + \_@@_do_morph:nnnn ##2 + } +} + +\cs_new_protected:Nn \_@@_do_morph:nnnn { + \tl_if_empty:nF{#3}{ + \seq_put_right:Nn \l_stex_morphism_morphisms_seq {{#1}{#2}{#3}} + } + \_@@_do_morphisms:n{#2} +} + +\cs_new_protected:Npn \_@@_reactivate: { + \stex_deactivate_macro:Nn \symdecl {module~environments} + \stex_deactivate_macro:Nn \textsymdecl {module~environments} + \stex_deactivate_macro:Nn \symdef {module~environments} + \stex_deactivate_macro:Nn \notation {module~environments} + \stex_deactivate_macro:Nn \importmodule {module~environments} + \stex_deactivate_macro:Nn \requiremodule {module~environments} + \stex_deactivate_macro:Nn \smodule {outside~of~morphisms} + \stex_reactivate_macro:N \assign + \stex_reactivate_macro:N \assignMorphism + \stex_reactivate_macro:N \renamedecl + \cs_set_eq:NN \_stex_do_for_list: \_@@_do_for_list: + \cs_set_eq:NN \_stex_add_definiens:nn \_@@_add_definiens:nn +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_get_in_morphism:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_get_in_morphism:n { + \str_clear:N \l_stex_get_symbol_name_str + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \exp_args:Nx\_@@_get_check:nnnn{\tl_to_str:n{#1}}##1##2 + } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \prop_map_inline:Nn \l_stex_morphism_renames_prop { + \_@@_renamed_check:nnnnn{#1}##1=##2 + } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnxx{stex}{error/unknownsymbolin}{#1}{ + morphism~\l_stex_feature_name_str + } + } + } +} + +\cs_new_protected:Npn \_@@_renamed_check:nnnnn #1#2?#3?#4=#5#6 { + \str_if_eq:nnTF{#1}{#5}{ + \exp_args:Nnx \use:nn{\_@@_check_break:nnnnnnnnn{#2?#3}{#4}}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#2?#3]/[#4]} + } + }{ + \str_if_eq:nnT{#1}{#6}{ + \exp_args:Nnx \use:nn{\_@@_check_break:nnnnnnnnn{#2?#3}{#4}}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#2?#3]/[#4]} + } + } + } +} + +\cs_new_protected:Npn \_@@_get_check:nnnn #1[#2]/[#3]#4 { + \str_if_eq:nnTF{#1}{#3}{ + \_@@_check_break:nnnnnnnnn{#2}{#3}{#4} + }{ + \str_if_eq:nnTF{#1}{#4}{ + \_@@_check_break:nnnnnnnnn{#2}{#3}{#4} + }{ + \use_none:nnnnnn + } + } +} + +\cs_new_protected:Nn \_@@_check_break:nnnnnnnnn { + \prop_map_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str{#1} + \str_set:Nn \l_stex_get_symbol_name_str{#2} + \str_set:Nn \l_stex_get_symbol_macro_str{#3} + \int_set:Nn \l_stex_get_symbol_arity_int {#4} + \tl_set:Nn \l_stex_get_symbol_args_tl {#5} + \tl_set:Nn \l_stex_get_symbol_def_tl {#6} + \tl_set:Nn \l_stex_get_symbol_type_tl {#7} + \tl_set:Nn \l_stex_get_symbol_return_tl {#8} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#9} + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \end{sfragment} +% +% +% \begin{sfragment}{Inheritance} +% +% \begin{sfragment}{\cs{importmodule}/\cs{usemodule}} +% \begin{macrocode} +%<@@=stex_importmodule> +% \end{macrocode} +% +% \begin{macro}{\usemodule} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn {usemodule} { O{} m } { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:usemodule=\l_stex_import_ns_str} {}} + } + \stex_if_smsmode:F{ + \group_begin: + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } +}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_import_module_uri:nn} +% \begin{macrocode} +\cs_new_protected:Nn \stex_import_module_uri:nn { + \stex_debug:nn{importmodule}{URI:~>#1<~>#2<} + \exp_args:NNnx \seq_set_split:Nnn \_@@_seq ? { \tl_to_str:n{ #2 } } + \seq_pop_right:NN \_@@_seq \l_stex_import_name_str + \str_set:Nx \l_stex_import_path_str { \seq_use:Nn \_@@_seq ? } + \tl_if_empty:nTF { #1 } { + \stex_debug:nn{importmodule}{No~archive} + \prop_if_exist:NTF \l_stex_current_archive_prop { + \stex_debug:nn{importmodule}{Picking~current~archive} + \str_set:Nx \l_stex_import_archive_str { + \prop_item:Nn \l_stex_current_archive_prop { id } + } + }{ + \str_clear:N \l_stex_import_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \str_if_empty:NTF \l_stex_import_path_str { + \stex_debug:nn{importmodule}{Empty~Path} + \stex_file_split_off_ext:NN \l_@@_path_seq \g_stex_current_file + \stex_file_split_off_lang:NN \l_@@_path_seq \l_@@_path_seq + \str_set:Nx \l_stex_import_path_str { + \stex_file_use:N \l_@@_path_seq + } + }{ + \stex_debug:nn{importmodule}{Resolving~path~\l_stex_import_path_str~relative~to~\stex_file_use:N \g_stex_current_file} + \stex_file_resolve:Nx \l_@@_seq { \stex_file_use:N \g_stex_current_file / .. / \l_stex_import_path_str} + \str_set:Nx \l_stex_import_path_str { + \stex_file_use:N \l_@@_seq + } + \stex_debug:nn{importmodule}{...yields~\l_stex_import_path_str} + } + } + } { + \stex_debug:nn{importmodule}{Archive~#1} + \str_set:Nx \l_stex_import_archive_str { #1 } + \stex_require_archive:o \l_stex_import_archive_str + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ \l_stex_import_archive_str _manifest_prop}{ ns } } + } +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\stex_import_require_module:nnn,\stex_import_require_module:ooo} +% \begin{macrocode} +\cs_new_protected:Npn \stex_import_require_module:nnn #1 { + \tl_if_empty:nTF { #1 } { + \str_clear:N \l_@@_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \_@@_get_module:nnn {} + }{ + \stex_require_archive:n { #1 } + \str_set:Nx \l_@@_archive_str {#1} + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ #1 _manifest_prop}{ ns } } + \str_set:Nx \l_@@_str { \stex_file_use:N \c_stex_mathhub_file / #1 / source } + \exp_args:No \_@@_get_module:nnn \l_@@_str + } +} +\cs_generate_variant:Nn \stex_import_require_module:nnn {ooo} + +\cs_new_protected:Npn \stex_import_require_module_safe:nnn #1 { + \tl_if_empty:nTF { #1 } { + \str_clear:N \l_@@_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \_@@_get_module_safe:nnn {} + }{ + \stex_require_archive:n { #1 } + \str_set:Nx \l_@@_archive_str {#1} + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ #1 _manifest_prop}{ ns } } + \str_set:Nx \l_@@_str { \stex_file_use:N \c_stex_mathhub_file / #1 / source } + \exp_args:No \_@@_get_module_safe:nnn \l_@@_str + } +} + +\cs_new_protected:Nn \_@@_get_module_uri:nnn { + \tl_if_empty:nF {#2}{ + \str_set:Nx \l_stex_import_uri_str {\l_stex_import_uri_str / #2} + } + \stex_debug:nn{importmodule}{~>#1<^^J>#2<^^J>#3<^^J>\l_stex_import_uri_str<^^J + Current~file:\stex_file_use:N \g_stex_current_file^^J + Current~namespace:\stex_uri_use:N \l_stex_current_ns_uri + } + \stex_if_module_exists:nTF {\l_stex_import_uri_str?#3} { + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + }{ + \stex_if_module_exists:nTF{\stex_uri_use:N \l_stex_current_ns_uri ? #3}{ + \str_set:Nx \l_stex_import_ns_str {\stex_uri_use:N \l_stex_current_ns_uri ? #3} + }{ + \_@@_get_from_file:nnn{#1}{#2}{#3} + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + } + } +} +\cs_new_protected:Nn \_@@_get_module_uri_safe:nnn { + \tl_if_empty:nF {#2}{ + \str_set:Nx \l_stex_import_uri_str {\l_stex_import_uri_str / #2} + } + \stex_debug:nn{importmodule}{~>#1<^^J>#2<^^J>#3<^^J>\l_stex_import_uri_str<^^J + Current~file:\stex_file_use:N \g_stex_current_file^^J + Current~namespace:\stex_uri_use:N \l_stex_current_ns_uri + } + \stex_if_module_exists:nTF {\l_stex_import_uri_str?#3} { + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + }{ + \stex_if_module_exists:nTF{\stex_uri_use:N \l_stex_current_ns_uri ? #3}{ + \str_set:Nx \l_stex_import_ns_str {\stex_uri_use:N \l_stex_current_ns_uri ? #3} + }{ + \_@@_get_from_file_safe:nnn{#1}{#2}{#3} + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + } + } +} + +\cs_new_protected:Nn \_@@_get_module:nnn { + \stex_debug:nn{importmodule}{Requiring~>[#1]#2?#3<} + \_@@_get_module_uri:nnn{#1}{#2}{#3} + \stex_activate_module:o \l_stex_import_ns_str +} + +\cs_new_protected:Nn \_@@_get_module_safe:nnn { + \stex_debug:nn{importmodule}{Requiring~>[#1]#2?#3<} + \_@@_get_module_uri_safe:nnn{#1}{#2}{#3} +} + +\cs_new_protected:Nn \_@@_get_from_file:nnn { + \stex_file_resolve:Nx \l_@@_seq { \tl_if_empty:nF{ #1 }{ #1 / } #2 } + \str_set:Nx \l_@@_str {\stex_file_use:N \l_@@_seq} + \stex_debug:nn{imports}{Looking~for~\l_stex_import_uri_str?#3...} + \_@@_check_file:nn{ /#3.tex }{ + \_@@_check_file:nn{/#3.\l_stex_current_language_str .tex}{ + \_@@_check_file:nn{/#3.en.tex}{ + \_@@_check_file:nn{.tex}{ + \_@@_check_file:nn{.\l_stex_current_language_str .tex}{ + \_@@_check_file:nn{.en.tex}{ + \msg_error:nnx{stex}{error/unknownmodule}{\l_stex_import_uri_str?#3} + } + } + } + } + } + } + \stex_if_smsmode:TF{ + \exp_args:NNo \exp_args:Nnx \str_if_eq:nnTF{\l_@@_str}{\stex_file_use:N \g_stex_current_file}{ + \stex_debug:nn{imports}{Skipping~current~file} + }{ + \_@@_load_file:n{#3} + } + }{ + \_@@_load_file:n{#3} + } +} +\cs_new_protected:Nn \_@@_get_from_file_safe:nnn { + \stex_file_resolve:Nx \l_@@_seq { \tl_if_empty:nF{ #1 }{ #1 / } #2 } + \str_set:Nx \l_@@_str {\stex_file_use:N \l_@@_seq} + \stex_debug:nn{imports}{Looking~for~\l_stex_import_uri_str?#3...} + \_@@_check_file:nn{ /#3.tex }{ + \_@@_check_file:nn{/#3.\l_stex_current_language_str .tex}{ + \_@@_check_file:nn{/#3.en.tex}{ + \_@@_check_file:nn{.tex}{ + \_@@_check_file:nn{.\l_stex_current_language_str .tex}{ + \_@@_check_file:nn{.en.tex}{ + } + } + } + } + } + } + \stex_if_smsmode:TF{ + \exp_args:NNo \exp_args:Nnx \str_if_eq:nnTF{\l_@@_str}{\stex_file_use:N \g_stex_current_file}{ + \stex_debug:nn{imports}{Skipping~current~file} + }{ + \IfFileExists{ \l_@@_str }{ + \_@@_load_file:n{#3} + }{} + } + }{ + \IfFileExists{ \l_@@_str }{ + \_@@_load_file:n{#3} + }{} + } +} + +\cs_new_protected:Nn \_@@_load_file:n { + \stex_file_in_smsmode:on \l_@@_str { + \str_if_empty:NF \l_@@_archive_str { + \stex_set_current_archive:n \l_@@_archive_str + } + \stex_debug:nn{modules}{Loading~\l_@@_str} + } + \stex_if_module_exists:nF {\l_stex_import_uri_str?#1} { + \msg_error:nnx{stex}{error/unknownmodule}{\l_stex_import_uri_str?#1} + } +} + +\cs_new_protected:Npn \_@@_check_file:nn #1 { + \stex_debug:nn{imports}{Checking~ \l_@@_str #1} + \IfFileExists{ \l_@@_str #1 }{ + \stex_debug:nn{imports}{Success} + \str_set:Nx \l_@@_str { \l_@@_str #1 } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\importmodule} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn{importmodule} { O{} m } { + \_@@_import_module:nn {#1}{#2} + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \importmodule {module~environments} + +\cs_new_protected:Nn \_@@_import_module:nn { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_execute_in_module:x{ + \stex_activate_module:n{\l_stex_import_ns_str} + } + \stex_module_add_morphism:nonn + {}{\l_stex_import_ns_str}{import}{} + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import=\l_stex_import_ns_str} {} + } + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nn \thisarchive {#1} + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } +} + +\cs_new_protected:Nn \_@@_import_module_presms:nn { + \stex_import_module_uri:nn { #1 }{ #2 } + \tl_gput_right:Nx \g_stex_sms_import_code { + \stex_import_require_module_safe:nnn + {\l_stex_import_archive_str} + {\l_stex_import_path_str} + {\l_stex_import_name_str} + } +} + +\stex_sms_allow_escape:N \importmodule +\stex_every_module:n {\stex_reactivate_macro:N \importmodule} +\stex_sms_allow_import:Nn \importmodule { + \stex_reactivate_macro:N \importmodule + \let \_@@_import_module:nn \_@@_import_module_presms:nn +} + +\stex_new_stylable_cmd:nnnn{requiremodule} { O{} m } { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_do_up_to_module:x{ + \stex_activate_module:n{\l_stex_import_ns_str} + } + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import=\l_stex_import_ns_str} {} + } + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nn \thisarchive {#1} + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \requiremodule {module~environments} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Theory Morphisms} +% \begin{macrocode} +%<@@=stex_morphisms> +% \end{macrocode} +% +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn {assign} { m m }{ + \stex_get_in_morphism:n{#1} + \_stex_assign_do:n{#2} + \stex_smsmode_do: +}{} +\stex_sms_allow_escape:N\assign + +\cs_new_protected:Nn \_stex_assign_do:n{ + \stex_debug:nn{assign}{Assigning~\l_stex_get_symbol_name_str~to~\tl_to_str:n{#1}} + \tl_if_empty:NF \l_stex_get_symbol_def_tl { + %\msg_error:nnxx{stex}{error/symbolalreadydefined}{\l_stex_get_symbol_name_str}{ + % morphism~\l_stex_feature_name_str + %} + } + \stex_check_term:n{#1} + \stex_debug:nn{HERE!}{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str^^J + \tl_to_str:n{#1} + } + \stex_if_do_html:T{ + \stex_annotate_invisible:nn{shtml:assign={\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}}{ + \_stex_annotate_force_break:n{ + \mode_if_math:T\hbox{$\stex_annotate:nn{shtml:definiens={}}{#1}$} + } + } + } + \exp_args:Ne \stex_metagroup_do_in:nx{ + \l_stex_current_module_str / \l_stex_feature_name_str + }{ + \prop_put:Nnn \exp_not:N \l_stex_morphism_symbols_prop + {[\l_stex_get_symbol_mod_str]/[\l_stex_get_symbol_name_str]} + { + {\l_stex_get_symbol_macro_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_not:n{#1}} + {\exp_args:No\exp_not:n\l_stex_get_symbol_type_tl} + {\exp_args:No\exp_not:n\l_stex_get_symbol_return_tl} + {\l_stex_get_symbol_invoke_cs} + } + } +} + + +\stex_new_stylable_cmd:nnnn {renamedecl} { m O{} m }{ + \stex_get_in_morphism:n{#1} + \_stex_renamedecl_do:nn{#2}{#3} + \stex_smsmode_do: +}{} +\stex_sms_allow_escape:N\renamedecl + +\cs_new_protected:Nn \_stex_renamedecl_do:nn { + \stex_debug:nn{renamedecl}{Renaming~\l_stex_get_symbol_name_str~to~[#1]{#2}} + \stex_if_do_html:T{ + \exp_args:Ne \stex_annotate_invisible:nn{ + shtml:rename={\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}, + shtml:macroname={#2} + \str_if_empty:nF{#1}{ ,shtml:to={#1} } + }{} + } + \exp_args:Ne \stex_metagroup_do_in:nx{ + \l_stex_current_module_str / \l_stex_feature_name_str + }{ + \prop_put:Nnn \exp_not:N \l_stex_morphism_renames_prop + {\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}{{#2}{ + \tl_if_empty:nTF{#1}{\l_stex_feature_name_str/\l_stex_get_symbol_name_str}{#1} + }} + } +} + +\stex_new_stylable_cmd:nnnn {assignMorphism} { m m }{ + \str_clear:N \l_@@_morphism_dom_str + \stex_iterate_morphisms:nn\l_stex_current_domain_str{ + \stex_debug:nn{assignMorphism}{ + Checking:~#1~vs:^^J##1^^J##2^^J##3^^J##4 + } + \str_if_eq:nnTF{#1}{##1}{ + \_@@_do_morph_assign:nnn{##1}{##2}{##4} + }{ + \stex_str_if_ends_with:nnT{##2}{#1}{ + \_@@_do_morph_assign:nnn{##1}{##2}{##4} + } + } + } + \str_if_empty:NT \l_@@_morphism_dom_str { + \msg_error:nnn{stex}{error/nomorphism}{#1} + } + \bool_set_false:N \l_tmpa_bool + \stex_iterate_morphisms:nn \l_stex_current_module_str { + \stex_debug:nn{assignMorphism}{ + Checking:~#2~vs:^^J##1^^J##2^^J##3^^J##4 + } + \str_if_eq:nnTF{#2}{##1}{ + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_break:n{ + \stex_annotate_invisible:nn{ + shtml:assignMorphismFrom={\l_@@_morphism_dom_str} + ahtml:assignMorphismTo={\l_stex_current_module_str?##1} + }{} + \bool_set_true:N \l_tmpa_bool + } + }{ + \stex_str_if_ends_with:nnT{##2}{#2}{ + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_break:n{ + \stex_annotate_invisible:nn{ + shtml:assignMorphismFrom={\l_@@_morphism_dom_str}, + shtml:assignMorphismTo={\l_stex_current_module_str?##1} + }{} + \bool_set_true:N \l_tmpa_bool + } + } + } + } + \bool_if:NF \l_tmpa_bool { + \msg_error:nnn{stex}{error/nomorphism}{#2} + } +}{} +\cs_new_protected:Nn \_@@_do_morph_assign:nnn { + \stex_iterate_break:n{ + \str_set:Nx \l_@@_morphism_dom_str { \l_stex_current_domain_str ? #1 } + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_symbols:nn{#2}{ + \stex_debug:nn{assignMorphism}{removing~##1?##3} + % TODO: non-trivial assignments + \prop_remove:Nn \l_stex_morphism_symbols_prop { + [##1]/[##3] + } + } + } +} + +\stex_deactivate_macro:Nn \assign {morphism~environments} +\stex_deactivate_macro:Nn \renamedecl {morphism~environments} +\stex_deactivate_macro:Nn \assignMorphism {morphism~environments} +% \end{macrocode} +% +% \begin{macrocode} +\stex_new_stylable_env:nnnnnnn {copymodule}{m O{} m}{ + + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=false} + + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \copymodule {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \copymodule +} +\stex_sms_allow_env:n{copymodule} + +\stex_new_stylable_env:nnnnnnn {interpretmodule}{m O{} m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=true} + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_structural_feature_morphism_check_total: + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \interpretmodule {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \interpretmodule +} +\stex_sms_allow_env:n{interpretmodule} +% \end{macrocode} +% +% \begin{macrocode} +\stex_new_stylable_env:nnnnnnn {realization}{O{} m}{ + + \stex_structural_feature_morphism:nnnnn{}{morphism}{#1}{#2}{,shtml:total=true} + %\stex_execute_in_module:x{ + % \stex_activate_module:n{\l_stex_current_domain_str} + %} + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #2 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_structural_feature_morphism_check_total: + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \realization {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \realization +} +\stex_sms_allow_env:n{realization} +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Nn \_@@_parse_assign:n { + \str_clear:N \l_@@_name_str + \str_clear:N \l_@@_newname_str + \tl_clear:N \l_@@_ass_tl + \exp_args:NNe \seq_set_split:Nnn \l_@@_seq {\tl_to_str:n{@}} {#1} + \int_compare:nNnTF {\seq_count:N \l_@@_seq} = 1 { + \seq_pop_left:NN \l_@@_seq \l_@@_next_tl + }{ + \seq_pop_left:NN \l_@@_seq \l_@@_name_str + \exp_args:NNo \str_set:Nn \l_@@_name_str \l_@@_name_str + \tl_set:Nx \l_@@_next_tl {\seq_use:Nn \l_@@_seq @} + } + \exp_args:NNNo \seq_set_split:Nnn \l_@@_seq = \l_@@_next_tl + \str_if_empty:NTF \l_@@_name_str { + \seq_pop_left:NN \l_@@_seq \l_@@_name_str + \exp_args:NNo \str_set:Nn \l_@@_name_str \l_@@_name_str + \tl_set:Nx \l_@@_ass_tl {\seq_use:Nn \l_@@_seq =} + }{ + \seq_pop_left:NN \l_@@_seq \l_@@_newname_str + \exp_args:NNo \str_set:Nn \l_@@_newname_str \l_@@_newname_str + \tl_set:Nx \l_@@_ass_tl {\seq_use:Nn \l_@@_seq =} + } + \_@@_do_parsed_assign: +} + +\cs_new_protected:Nn \_@@_do_parsed_assign: { + \exp_args:No \stex_get_in_morphism:n \l_@@_name_str + \str_if_empty:NF \l_@@_newname_str { + \exp_after:wN \_@@_do_parsed_newname: \l_@@_newname_str \_@@_end: + } + \tl_if_empty:NF \l_@@_ass_tl { + \exp_args:No \_stex_assign_do:n \l_@@_ass_tl + } +} + +\cs_new_protected:Nn \_@@_do_parsed_newname: { + \peek_charcode:NTF [ { + \_@@_do_parsed_newname:w + }{ + \_@@_do_parsed_newname:w [] + } +} + +\cs_new_protected:Npn \_@@_do_parsed_newname:w [#1] #2 \_@@_end: { + \_stex_renamedecl_do:nn{#1}{#2} +} + +\stex_new_stylable_cmd:nnnn{copymod}{m O{} m m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=false} + + \clist_map_function:nN{#4}\_@@_parse_assign:n + + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \copymod {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \copymod +} +\stex_sms_allow_escape:N\copymod + + +\stex_new_stylable_cmd:nnnn{interpretmod}{m O{} m m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=true} + + \clist_map_function:nN{#4}\_@@_parse_assign:n + + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_structural_feature_morphism_check_total: + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \interpretmod {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \iterpretmod +} +\stex_sms_allow_escape:N\interpretmod + + +\stex_new_stylable_cmd:nnnn{realize}{O{} m m}{ + \stex_structural_feature_morphism:nnnnn{}{morphism}{#1}{#2}{,shtml:total=true} + + \clist_map_function:nN{#3}\_@@_parse_assign:n + + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_structural_feature_morphism_check_total: + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \realize {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \realize +} +\stex_sms_allow_escape:N\realize +% \end{macrocode} +% +% \end{sfragment} +% +% +% +% \end{sfragment} +% +% +% \begin{sfragment}{Symbols} +% +% \begin{sfragment}{Declarations} +% \begin{macrocode} +%<@@=stex_symdecl> +% \end{macrocode} +% Some setup: +% +% \begin{macro}[pTF]{\stex_if_check_terms:} +% \begin{macrocode} +\stex_if_html_backend:TF { + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_false: + } +}{ + \stex_get_env:Nn\_@@_env_str{STEX_CHECKTERMS} + \str_if_empty:NF\_@@_env_str{ + \exp_args:No \str_if_eq:nnF \_@@_env_str{false}{ + \bool_set_true:N \c_stex_check_terms_bool + } + } + \bool_if:NTF \c_stex_check_terms_bool { + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_true: + } + }{ + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_false: + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_check_term:n} +% \begin{macrocode} +\stex_if_check_terms:TF{ + \cs_new_protected:Nn \stex_check_term:n { + \hbox_set:Nn \l_tmpa_box { + \group_begin: + $#1$ + \group_end: + } + } +}{ + \cs_new_protected:Nn \stex_check_term:n {} +} +% \end{macrocode} +% \end{macro} +% +% |symdecl| arguments: +% \begin{macrocode} +\stex_keys_define:nnnn{symargs}{ + \str_clear:N \l_stex_key_args_str + \str_clear:N \l_stex_key_role_str + \str_clear:N \l_stex_key_reorder_str + \str_clear:N \l_stex_key_assoc_str +}{ + args .str_set:N = \l_stex_key_args_str , + reorder .str_set:N = \l_stex_key_reorder_str , + assoc .choices:nn = {bin,binl,binr,pre,conj,pwconj} + {\str_set:Nx \l_stex_key_assoc_str \l_keys_choice_tl}, + role .str_set:N = \l_stex_key_role_str +}{} + +\stex_keys_define:nnnn{decl}{ + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_args_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl + \tl_clear:N \l_stex_key_return_tl + \clist_clear:N \l_stex_key_argtypes_clist +}{ + name .str_set:N = \l_stex_key_name_str , + + return .tl_set:N = \l_stex_key_return_tl , + argtypes .clist_set:N = \l_stex_key_argtypes_clist , + + type .tl_set:N = \l_stex_key_type_tl , + def .tl_set:N = \l_stex_key_def_tl , + + align .code:n = {}, + gfc .code:n = {} +}{style,deprecate,symargs} +% \_stex_do_deprecation:n{#2} +% \end{macrocode} +% +% \begin{macro}{\symdecl} +% \begin{macrocode} +\str_new:N \l_stex_macroname_str +\stex_new_stylable_cmd:nnnn {symdecl} { s m O{}} { + \stex_keys_set:nn{decl}{#3} + \IfBooleanTF #1 { + \str_clear:N \l_stex_macroname_str + }{ + \str_set:Nx \l_stex_macroname_str { #2 } + } + \stex_symdecl_top:n{#2} + + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_set_eq:NN \thistype \l_stex_key_type_tl + \tl_set_eq:NN \thisdefiniens \l_stex_key_def_tl + \tl_set_eq:NN \thisargs \l_stex_key_args_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \symdecl {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \symdecl} +\stex_sms_allow_escape:N \symdecl +% \end{macrocode} +% \end{macro} +% +%% \begin{macro}{\stex_symdecl_top:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_symdecl_top:n { + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \_@@_add_decl: + \stex_if_do_html:T { + \_stex_symdecl_html: + } +} + +\cs_new_protected:Nn \_@@_add_decl: { + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\tl_if_empty:NF \l_stex_key_def_tl{DEFED} }%{\exp_args:No \exp_not:n \l_stex_key_def_tl} + {}%{\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: + } + \exp_args:Ne \stex_ref_new_symbol:n + {\l_stex_current_module_str?\l_stex_key_name_str} +} + +\cs_new:Nn \_stex_return_args:nn { + {\svar{ARGUMENT_#1}\_stex_eat_exclamation_point:} +} + +\cs_new_protected:Nn \_stex_symdecl_html: { + \exp_args:Ne \stex_annotate_invisible:nn { + shtml:symdecl = {\l_stex_current_module_str ? \l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} + } + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} + } + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + }{\hbox\bgroup\_stex_annotate_force_break:n{ + \bool_set_true:N \stex_in_invisible_html_bool + \tl_if_empty:NF \l_stex_key_type_tl { + $\stex_annotate:nn{shtml:type={}}{\l_stex_key_type_tl}$ + } + \tl_if_empty:NF \l_stex_key_def_tl { + $\stex_annotate:nn{shtml:definiens={}}{\l_stex_key_def_tl}$ + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l_@@_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l_@@_args_tl {\_stex_map_args:N \_stex_return_args:nn} + $\stex_annotate:nn{shtml:returntype={}}{ + \exp_after:wN \l_@@_cs \l_@@_args_tl! + }$ + } + \clist_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{\_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + $\stex_annotate:nn{shtml:type={}}{##1}$ + } + }} + } + }\egroup} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_symdecl_do:} +% Requires the above keys and \cs{l_stex_macroname_str} to be +% set first +% \begin{macrocode} +\cs_new_protected:Nn \stex_symdecl_do: { + \_stex_do_deprecation:n \l_stex_key_name_str + \_@@_parse_arity: + \_@@_do_args: +} + +\int_new:N \l_stex_assoc_args_count + +\cs_new_protected:Nn \_@@_parse_arity: { + \int_zero:N \l_stex_get_symbol_arity_int + \int_zero:N \l_stex_assoc_args_count + \str_map_inline:Nn \l_stex_key_args_str { + \str_case:nnF ##1 { + 0 { \str_map_break: } + 1 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {1} + \str_set:Nn \l_stex_key_args_str {i} + } } + 2 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {2} + \str_set:Nn \l_stex_key_args_str {ii} + } } + 3 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {3} + \str_set:Nn \l_stex_key_args_str {iii} + } } + 4 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {4} + \str_set:Nn \l_stex_key_args_str {iiii} + } } + 5 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {5} + \str_set:Nn \l_stex_key_args_str {iiiii} + } } + 6 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {6} + \str_set:Nn \l_stex_key_args_str {iiiiii} + } } + 7 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {7} + \str_set:Nn \l_stex_key_args_str {iiiiiii} + } } + 8 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {8} + \str_set:Nn \l_stex_key_args_str {iiiiiiii} + } } + 9 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {9} + \str_set:Nn \l_stex_key_args_str {iiiiiiiii} + } } + i {\int_incr:N \l_stex_get_symbol_arity_int} + b {\int_incr:N \l_stex_get_symbol_arity_int} + a {\int_incr:N \l_stex_get_symbol_arity_int \int_incr:N \l_stex_assoc_args_count} + B {\int_incr:N \l_stex_get_symbol_arity_int \int_incr:N \l_stex_assoc_args_count} + }{ + \msg_error:nnxx{stex}{error/wrongargs}{ + \l_stex_current_module_str ? \l_stex_key_name_str + }{##1} + } + } +} + +\cs_new_protected:Nn \_@@_do_args: { + \tl_clear:N \l_stex_get_symbol_args_tl + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \tl_put_right:Nn \l_stex_get_symbol_args_tl {##1} + \tl_put_right:Nx \l_stex_get_symbol_args_tl { + \str_item:Nn \l_stex_key_args_str {##1} + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_symdecl_check_terms:} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_symdecl_check_terms: { + \stex_check_term:n{ + \stex_debug:nn{check_terms}{Checking~type...} + \group_begin:\l_stex_key_type_tl\group_end: + \stex_debug:nn{check_terms}{Checking~definiens...} + \group_begin:\l_stex_key_def_tl\group_end: + \stex_debug:nn{check_terms}{Checking~return...} + \group_begin:\l_stex_key_return_tl!\group_end: + \stex_debug:nn{check_terms}{Checking~argument~types...} + \group_begin:\l_stex_key_argtypes_clist\group_end: + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\textsymdecl} +% \begin{macrocode} + +\stex_keys_define:nnnn{textsymdecl}{ + \str_clear:N \l_stex_key_name_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl +}{ + name .str_set:N = \l_stex_key_name_str , + type .tl_set:N = \l_stex_key_type_tl , + def .tl_set:N = \l_stex_key_def_tl +}{style,deprecate} + +\stex_new_stylable_cmd:nnnn {textsymdecl} {m O{} m} { + \stex_keys_set:nn{symdef}{} + \stex_keys_set:nn{textsymdecl}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nn \l_stex_key_name_str {#1} + }%{ + % \str_set:Nx \l_stex_key_name_str {\l_stex_key_name_str-sym} + %} + \str_set:Nn \l_stex_key_role_str {textsymdecl} + + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {0}{} + {\tl_if_empty:NF \l_stex_key_def_tl{DEFED} } + {}% type + {\use:c{#1name_nospace}}% return + \stex_invoke_text_symbol: + } + \exp_args:Ne \stex_ref_new_symbol:n + {\l_stex_current_module_str?\l_stex_key_name_str} + \stex_if_do_html:T { + \_stex_symdecl_html: + } + + \int_set:Nn \l_stex_get_symbol_arity_int 0 + \tl_clear:N \l_stex_key_op_tl + \str_clear:N \l_stex_key_intent_str + \str_clear:N \l_stex_key_prec_str + \str_set_eq:NN \l_stex_get_symbol_mod_str \l_stex_current_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{\hbox{#3}} + \_stex_notation_add: + \stex_if_do_html:T { + \def\comp{\_comp} + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_execute_in_module:x{ + \_@@_set_textsymdecl_macro:nnn{#1}{\l_stex_current_module_str?\l_stex_key_name_str} + \exp_not:n{{#3}} + } + + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \textsymdecl {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \textsymdecl} +\stex_sms_allow_escape:N \textsymdecl + +\cs_new_protected:Nn \_@@_set_textsymdecl_macro:nnn { + \cs_set_protected:cpn{#1name_nospace}{#3} + \cs_set_protected:cpn{#1name}{ + \mode_if_vertical:T{\hbox_unpack:N\c_empty_box} + \mode_if_math:T\hbox{\let\xspace\relax #3} + \mode_if_math:F{\cs_if_exist:NT\xspace\xspace} + } +} + +\cs_new_protected:Nn \stex_invoke_text_symbol: { + \mode_if_vertical:T{\hbox_unpack:N\c_empty_box} + \_stex_term_oms_or_omv:nnn{}{}{\maincomp{\let\xspace\relax\l_stex_current_return_tl}} + \group_end:\mode_if_math:F{\cs_if_exist:NT\xspace\xspace} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_get_symbol:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_get_symbol:n { + \_stex_get_symbol:n{ #1 } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnn{stex}{error/unknownsymbol}{#1} + } +} + +\cs_new_protected:Nn \_stex_get_symbol:n { + \str_clear:N \l_stex_get_symbol_mod_str + \str_clear:N \l_stex_get_symbol_name_str + \cs_if_exist:cTF { #1 }{ + \cs_set_eq:Nc \l_@@_cs { #1 } + % command name + \exp_args:Ne \tl_if_empty:nTF { \cs_argument_spec:N \l_@@_cs }{ + % ...that takes no arguments + \exp_args:Ne \cs_if_eq:NNTF {\tl_head:N \l_@@_cs} + \_stex_invoke_symbol:nnnnnnnN + \_@@_get_symbol_from_cs: + {\_@@_get_symbol_from_string:n { #1 }} + }{ + \_@@_get_symbol_from_string:n { #1 } + } + }{ + \_@@_get_symbol_from_string:n { #1 } + } +} + +\int_new:N \l_stex_get_symbol_arity_int +\cs_new_protected:Nn \_@@_get_symbol_from_cs: { + \stex_debug:nn{symbols}{Getting~from~cs...} + \stex_pseudogroup_with:nn{\_stex_invoke_symbol:nnnnnnnN}{ + \cs_set:Npn \_stex_invoke_symbol:nnnnnnnN ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 { + \str_set:Nn \l_stex_get_symbol_mod_str {##1} + \str_set:Nn \l_stex_get_symbol_name_str {##2} + \int_set:Nn \l_stex_get_symbol_arity_int {##3} + \tl_set:Nn \l_stex_get_symbol_args_tl {##4} + \tl_set:Nn \l_stex_get_symbol_def_tl {##5} + \tl_set:Nn \l_stex_get_symbol_type_tl {##6} + \tl_set:Nn \l_stex_get_symbol_return_tl {##7} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {##8} + } + \l_@@_cs + } +} + +\cs_new_protected:Nn \_@@_get_symbol_from_string:n { + \stex_debug:nn{symbols}{Getting~from~string~#1...} + \seq_set_split:Nnn \l_@@_seq ? {#1} + \seq_pop_right:NN \l_@@_seq \l_@@_name + \seq_if_empty:NTF \l_@@_seq { + \exp_args:No \_@@_get_from_one_string:n {#1} + }{ + \exp_args:NNe \exp_args:Nno \_@@_get_symbol_from_modules:nn { + \seq_use:Nn \l_@@_seq ? + } \l_@@_name + } +} + +\cs_new_protected:Nn \_@@_sym_from_str_i:nnnn { + \bool_lazy_any:nTF{ + {\str_if_eq_p:nn{#2}{#3}} + {\str_if_eq_p:nn{#2}{#4}} + {\stex_str_if_ends_with_p:nn{#4}{/#2}} + }{ + \_@@_sym_i_finish:nnnnnnnN{#1}{#4} + }{ + \_@@_sym_i_gobble:nnnnnn + } +} +\cs_new_protected:Nn \_@@_sym_i_gobble:nnnnnn {} + +\cs_new_protected:Nn \_@@_sym_i_finish:nnnnnnnN { + \prop_map_break:n{\seq_map_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str {#1} + \str_set:Nn \l_stex_get_symbol_name_str {#2} + \int_set:Nn \l_stex_get_symbol_arity_int {#3} + \tl_set:Nn \l_stex_get_symbol_args_tl {#4} + \tl_set:Nn \l_stex_get_symbol_def_tl {#5} + \tl_set:Nn \l_stex_get_symbol_type_tl {#6} + \tl_set:Nn \l_stex_get_symbol_return_tl {#7} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#8} + }} +} + +\cs_new_protected:Nn \_@@_get_symbol_from_modules:nn { + \stex_debug:nn{symbols}{Getting~#2~in~#1...} + \seq_map_inline:Nn \l_stex_all_modules_seq { + \stex_str_if_ends_with:nnT{##1}{#1}{ + \prop_map_inline:cn{c_stex_module_##1_symbols_prop}{ + \_@@_sym_from_str_i:nnnn{##1}{#2} ####2 + } + } + } +} + +\cs_new_protected:Nn \_@@_get_from_one_string:n { + \stex_debug:nn{symbols}{Getting~#1~anywhere...} + \stex_iterate_symbols:n{ + %\stex_debug:nn{symbols}{>#1==##2~|~#1==##3<...} + \bool_lazy_any:nT{ + {\str_if_eq_p:nn{#1}{##2}} + {\str_if_eq_p:nn{#1}{##3}} + {\stex_str_if_ends_with_p:nn{##3}{/#1}} + }{ + \stex_iterate_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str {##1} + \str_set:Nn \l_stex_get_symbol_name_str {##3} + \int_set:Nn \l_stex_get_symbol_arity_int {##4} + \tl_set:Nn \l_stex_get_symbol_args_tl {##5} + \tl_set:Nn \l_stex_get_symbol_def_tl {##6} + \tl_set:Nn \l_stex_get_symbol_type_tl {##7} + \tl_set:Nn \l_stex_get_symbol_return_tl {##8} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {##9} + } + } + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Notations} +% \begin{macrocode} +%<@@=stex_notations> +% \end{macrocode} +% +% \begin{macro}{\_stex_map_args:N,\_stex_map_notation_args:N} +% \begin{macrocode} +\cs_new:Nn \_stex_map_args:N { + \tl_if_empty:NF \l_stex_get_symbol_args_tl { + \exp_after:wN \_@@_map_args_i:w \exp_after:wN + #1 \l_stex_get_symbol_args_tl \_@@_args_end: + } +} +\cs_new:Npn \_@@_map_args_i:w #1 #2 #3 #4 \_@@_args_end: { + #1 #2 #3 + \tl_if_empty:nF{#4}{ + \_@@_map_args_i:w #1 #4 \_@@_args_end: + } +} + +\cs_new:Nn \_stex_map_notation_args:N { + \tl_if_empty:NF \l_stex_notation_args_tl { + \exp_after:wN \_@@_map_args_ii:w \exp_after:wN + #1 \l_stex_get_symbol_args_tl \_@@_args_end: + } +} +\cs_new:Npn \_@@_map_args_ii:w #1 #2 #3 #4 #5 #6 \_@@_args_end: { + #1 #2 #3 #4 #5 + \tl_if_empty:nF{#6}{ + \_@@_map_args_ii:w #1 #6 \_@@_args_end: + } +} +% \end{macrocode} +% \end{macro} +% +% |notation| arguments: +% \begin{macrocode} +\stex_keys_define:nnnn{notation}{ + \str_clear:N \l_stex_key_variant_str + \str_clear:N \l_stex_key_prec_str + \str_clear:N \l_stex_key_op_tl + \str_clear:N \l_stex_key_intent_str + \clist_clear:N \l_stex_key_intent_args_clist +}{ + variant .str_set_x:N = \l_stex_key_variant_str , + prec .str_set_x:N = \l_stex_key_prec_str , + op .tl_set:N = \l_stex_key_op_tl , + intent .str_set:N = \l_stex_key_intent_str , + argnames .clist_set:N = \l_stex_key_intent_args_clist , + unknown .code:n = { + \str_set_eq:NN \l_stex_key_variant_str \l_keys_key_str + } +}{style} +% \end{macrocode} +% +% \begin{macro}{\notation} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn {notation} { s m O{} m} { + \stex_keys_set:nn{notation}{#3} + \stex_get_symbol:n{#2} + \stex_notation_parse:n{#4} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_notation_add: + \stex_if_do_html:T { + \def\comp{\_comp} + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \IfBooleanTF#1{ + \_stex_notation_set_default:n{ + \l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str + } + }{} + \stex_if_smsmode:F{ + \group_begin: + \_@@_styledefs: + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} + +\cs_new_protected:Nn \_@@_styledefs: { + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \str_set:Nn \thisdeclname \l_stex_get_symbol_name_str + \tl_set:Nx \thisdecluri {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \def\thisnotation{ + $ + \tl_set_eq:NN \l_stex_current_symbol_str\thisdecluri + \exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs}{ + \_stex_notation_make_args: + }$ + } +} + +\stex_deactivate_macro:Nn \notation {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \notation} +\stex_sms_allow_escape:N \notation +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_notation_parse:n} +% requires the above keys, \cs{l_stex_get_symbol_arity_int}, and +% \cs{l_stex_get_symbol_args_tl} +% \begin{macrocode} +\cs_new_protected:Nn \stex_notation_parse:n { + \tl_if_empty:NF \l_stex_key_op_tl { + \tl_set:Nx \l_stex_key_op_tl { \exp_not:N\maincomp { + \exp_args:No \exp_not:n \l_stex_key_op_tl + } } + } + \seq_clear:N \l_@@_precs_seq + \tl_clear:N \l_stex_notation_args_tl + \int_compare:nNnTF \l_stex_get_symbol_arity_int = 0 { + \_@@_const_precs: + \tl_if_empty:NT \l_stex_key_op_tl { + \tl_set:Nn \l_stex_key_op_tl { \maincomp{#1} } + } + }{ + \_@@_fun_precs: + \str_set:Nn \l_@@_missing_str {#1} + \tl_clear:N \l_@@_missing_tl + \_stex_map_args:N \_@@_add_missing_args:nn + \tl_if_empty:NT \l_stex_key_op_tl { + \hbox_set:Nn \l_tmpa_box { + \str_set:Nn \l_stex_current_symbol_str {} + \cs_set:Npn \l_tmpa_cs ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #1 } + \cs_set:Npn \maincomp ##1 { + \tl_gset:Nn \l_stex_key_op_tl { \maincomp{##1} } + ##1 + } + \cs_set:Npn \argsep ##1 ##2 {##1 ##2} + \cs_set:Npn \argmap ##1 ##2 ##3 {##1 ##3} + \cs_set:Npn \argarraymap ##1 ##2 ##3 ##4 { + ##1 ##2 + } + \stex_suppress_html:n{$\l_tmpa_cs abcdefghj$} + } + } + } + \exp_args:NNe + \tl_set:Nn \l_stex_notation_macrocode_cs { + \STEXInternalNotation + { \l_stex_key_variant_str } + { \l_@@_opprec_tl } + { \l_stex_key_intent_str } + { \l_stex_notation_args_tl } + { + \int_compare:nNnTF \l_stex_get_symbol_arity_int = 0 + { \exp_not:n { \maincomp{ #1 } } } + { \exp_not:n { #1 } \l_@@_missing_tl } + } + } + \stex_debug:nn{notation}{Notation:~\meaning\l_stex_notation_macrocode_cs} +} + +\cs_new_protected:Nn \_@@_const_precs: { + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:No \l_@@_opprec_tl { \neginfprec } + }{ + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \tl_set:No \l_@@_opprec_tl { \neginfprec } + }{ + \tl_set_eq:NN \l_@@_opprec_tl \l_stex_key_prec_str + } + } +} + +\cs_new_protected:Nn \_@@_fun_precs: { + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:No \l_@@_opprec_tl { \neginfprec } + }{ + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \tl_set:No \l_@@_opprec_tl { \neginfprec } + }{ + \tl_set_eq:NN \l_@@_opprec_tl \l_stex_key_prec_str + } + } + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:Nn \l_@@_opprec_tl { 0 } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \seq_put_right:Nn \l_@@_precs_seq {0} + } + }{ + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \stex_debug:nn{notation}{No~brackets} + \tl_set:No \l_@@_opprec_tl { \neginfprec } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \exp_args:NNo \seq_put_right:Nn \l_@@_precs_seq \infprec + } + }\_@@_parse_precs: + } + \_@@_do_argnames: +} + +\cs_new_protected:Nn \_@@_parse_precs: { + \stex_debug:nn{notation}{parsing~precedence~\l_stex_key_prec_str} + \seq_set_split:NnV \l_@@_seq ; \l_stex_key_prec_str + \seq_pop_left:NNTF \l_@@_seq \l_@@_str { + \tl_set_eq:NN \l_@@_opprec_tl \l_@@_str + \seq_pop_left:NNT \l_@@_seq \l_@@_str { + \exp_args:NNo \seq_set_split:NnV \l_@@_seq + {\tl_to_str:n{x}} \l_@@_str + } + }{ + \tl_set:No \l_@@_opprec_tl { 0 } + } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \seq_pop_left:NNTF \l_@@_seq \l_@@_str { + \seq_put_right:No \l_@@_precs_seq \l_@@_str + }{ + \seq_put_right:No \l_@@_precs_seq \l_@@_opprec_tl + } + } +} + +\cs_new_protected:Nn \_@@_do_argnames: { + \tl_clear:N \l_stex_notation_args_tl + \_stex_map_args:N \_@@_do_argname:nn +} + +\cs_new_protected:Nn \_@@_do_argname:nn { + \clist_if_empty:NTF \l_stex_key_intent_args_clist { + \tl_put_right:Nx \l_stex_notation_args_tl { + #1#2{\seq_item:Nn \l_@@_precs_seq #1}{ + \str_if_empty:NF \l_stex_key_intent_str {#1} + } + } + }{ + \tl_put_right:Nx \l_stex_notation_args_tl { + #1#2{\seq_item:Nn \l_@@_precs_seq #1} + {\c_dollar_str\clist_item:Nn \l_stex_key_intent_args_clist 1} + } + \clist_pop:NN \l_stex_key_intent_args_clist \l_tmpa_tl + } +} + +\cs_new:Nn \_@@_add_missing_args:nn { + \exp_args:NNe \str_if_in:NnF \l_@@_missing_str {\c_hash_str\c_hash_str#1}{ + \tl_put_right:Nn \l_@@_missing_tl{\STEXinvisible{## #1}} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_notation_check:,\_stex_notation_add:,\_stex_notation_do_html:n,\_stex_notation_make_args:} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_notation_check: { + \stex_check_term:n{ + \str_set:Nn \l_stex_current_symbol_str {test} + \cs_set:Npn \comp ##1 {##1} + \stex_debug:nn{check_terms}{Checking~notation...} + \exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + } + } +} + +\cs_new_protected:Nn \_stex_notation_add: { + \stex_module_add_notation:eoeoo{ + \l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str + }\l_stex_key_variant_str + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_notation_macrocode_cs + \l_stex_key_op_tl +} + +\cs_new_protected:Nn \_stex_notation_do_html:n { + \hbox{\stex_annotate_invisible:nn { + shtml:notation={#1}, + shtml:notationfragment={\l_stex_key_variant_str}, + shtml:precedence={\l_@@_opprec_tl}, + shtml:argprecs={\seq_use:Nn \l_@@_precs_seq ,} + }{ + \cs_set_protected:Npn \argsep ##1 ##2 { + \stex_annotate:nn{shtml:argsep={}}{ + ##1 ##2 + } + } + \cs_set_protected:Npn \argmap ##1 ##2 ##3 { + \cs_set:Npn \_@@_map_cs: ####1 { ##2 } + \stex_annotate:nn{shtml:argmap={}}{ + \_@@_map_cs:{##1} ##3 + } + } + \cs_set_protected:Npn \maincomp { + \_do_comp:nNn {maincomp}\compemph@uri + } + $ + \str_set:Nx \l_stex_current_symbol_str {#1} + \stex_annotate:nn{shtml:notationcomp={}}{ + \exp_args:Nne \use:nn { + \l_stex_notation_macrocode_cs {} + }{ + \_stex_map_args:N \_@@_make_arg_html:nn + } + } + $ + \tl_if_empty:NF \l_stex_key_op_tl { + $ + \str_set:Nx \l_stex_current_symbol_str {#1} + \stex_annotate:nn{shtml:notationopcomp={}}{ + \_stex_term_oms:nnn{\l_stex_key_variant_str}{}{\l_stex_key_op_tl} + } + $ + } + }} +} + +\cs_new:Nn \_@@_make_arg_html:nn { +% \str_case:nnF #2 { +% a {{ +% \stex_annotate:nn{shtml:argnum=#1a}{x}, +% \stex_annotate:nn{shtml:argnum=#1b}{x} +% }} +% B {{ +% \stex_annotate:nn{shtml:argnum=#1a}{x}, +% \stex_annotate:nn{shtml:argnum=#1b}{x} +% }} +% }{ + { + \stex_annotate:nn{shtml:argnum=#1}{x} + } +% } +} + +\cs_new:Nn \_stex_notation_make_args: { + \_stex_map_notation_args:N \_@@_make_arg:nnnn +} + + +\cs_new:Nn \_@@_make_arg:nnnn { + \str_case:nnF #2 { + a {{ + a\c_math_subscript_token{#1,1}, + a\c_math_subscript_token{#1,2} + }} + B {{ + B\c_math_subscript_token{#1,1}, + B\c_math_subscript_token{#1,2} + }} + }{ + \_stex_term_arg:nnnnn{#1}{#2}{#3}{#4} + {{#2}\c_math_subscript_token{#1}} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\setnotation,\_stex_notation_set_default:n} +% \begin{macrocode} +\cs_new_protected:Npn \setnotation #1 #2 { + \stex_get_symbol:n{#1} + \cs_if_exist:cTF{l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _#2_cs + }{ + \tl_set_eq:Nc \l_stex_notation_macrocode_cs {l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _#2_cs + } + \cs_if_exist:cTF{l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _op_#2_cs + }{ + \tl_set_eq:Nc \l_stex_key_op_tl {l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _op_#2_cs + } + }{ + \tl_clear:N \l_stex_key_op_tl + } + \_stex_notation_set_default:n{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + } + }{ + \msg_error:nnxx{stex}{unknownnotation}{#2}{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + } + } +} + +\cs_new_protected:Nn \_stex_notation_set_default:n{ + \stex_module_add_notation:eoeoo{#1}{} + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_notation_macrocode_cs + \l_stex_key_op_tl +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\varnotation} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn {varnotation} { s m O{} m} { + \stex_keys_set:nn{notation}{#3} + \stex_get_var:n{#2} + \str_set_eq:NN \l_stex_key_name_str \l_stex_get_symbol_name_str + \stex_notation_parse:n{#4} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_vardecl_notation_macro: + \IfBooleanTF#1{ + \_stex_notation_set_default:n{\l_stex_get_symbol_name_str} + }{} + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_get_symbol_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + }$ + } + \stex_style_apply: + \group_end: +}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\symdef} +% \begin{macrocode} +\stex_keys_define:nnnn{symdef}{}{}{decl,notation} + +\cs_new_protected:Nn \_stex_symdef_styledefs: { + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_set_eq:NN \thistype \l_stex_key_type_tl + \tl_set_eq:NN \thisdefiniens \l_stex_key_def_tl + \tl_set_eq:NN \thisargs \l_stex_key_args_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisdecluri + \def\comp{\_comp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs}{ + \_stex_notation_make_args: + }$ + } +} + +\stex_new_stylable_cmd:nnnn {symdef} { m O{} m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \stex_symdecl_top:n{#1} + \stex_debug:nn{symdef}{Doing~\l_stex_current_module_str ? \l_stex_key_name_str} + \str_set_eq:NN \l_stex_get_symbol_mod_str \l_stex_current_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{#3} + \stex_debug:nn{Here!}{\meaning\l_stex_notation_args_tl} + \_stex_notation_check: + \_stex_notation_add: + \stex_if_do_html:T{ + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_if_smsmode:F{ + \group_begin: + \_stex_symdef_styledefs: + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} + +\stex_deactivate_macro:Nn \symdef {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \symdef} +\stex_sms_allow_escape:N \symdef +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_do_default_notation_op:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_do_default_notation: { + \stex_do_default_notation_op: + \tl_if_empty:NTF \l_stex_current_args_tl { + \tl_clear:N \l_@@_args_tl + }{ + \_@@_make_name: + \tl_set_eq:NN \l_stex_get_symbol_args_tl \l_stex_current_args_tl + \tl_set:Nx \l_@@_args_tl { + \_stex_map_args:N \_@@_augment_arg:nn + } + \tl_put_right:Nn \l_stex_default_notation {\comp(} + \seq_clear:N \l_tmpa_seq + \int_step_inline:nn \l_stex_current_arity_str { + \seq_put_right:Nn \l_tmpa_seq {#### ##1} + } + \tl_put_right:Nx \l_stex_default_notation { + \seq_use:Nn \l_tmpa_seq {\mathpunct{\comp{,}}} + } + \tl_put_right:Nn \l_stex_default_notation {\comp)} + } + \tl_set:Nx \l_stex_default_notation {\STEXInternalNotation{}{0}{}{\l_@@_args_tl}{ + \exp_args:No \exp_not:n \l_stex_default_notation + }} +} + +\cs_new:Nn \_@@_augment_arg:nn { + #1#2{0}{} +} + +\cs_new_protected:Nn \_@@_make_name: { + \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq ? \l_stex_current_symbol_str + \seq_pop_right:NN \l_tmpa_seq \l_@@_name_str + \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq / \l_@@_name_str + \seq_pop_right:NN \l_tmpa_seq \l_@@_name_str +} + +\cs_new_protected:Nn \stex_do_default_notation_op: { + \_@@_make_name: + \tl_set:Nx \l_stex_default_notation {\exp_not:N \maincomp{ \exp_not:N \mathrm {\l_@@_name_str} }} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\STEXInternalNotation} +% \begin{macrocode} +% 1: variant 2: operator precedence 3: intent 4: arguments 5: code 6: next + +\cs_new_protected:Npn \STEXInternalNotation #1 #2 #3 #4 #5 #6 { + \_@@_process_notation:nnnnnn{#1}{#2}{#3}{#4}{#5}{ + \l_@@_code_tl + #6 + } +} + +\cs_new_protected:Npn \_@@_process_notation:nnnnnn #1 #2 #3 #4 { + \tl_if_empty:nTF{#4}{ + \_@@_simple:nnnnn{#1}{#2}{#3} + }{ + \_@@_complex:nnnnnn{#1}{#2}{#3}{#4} + } +} + +\cs_new_protected:Nn \_@@_simple:nnnnn { + \stex_debug:nn{Notation~code}{\tl_to_str:n{#4}} + \tl_set:Nn \l_@@_code_tl { + \cs_set:Npn \l_@@_cs { + \_stex_maybe_brackets:nn{#2}{ + \_stex_term_oms_or_omv:nnn{#1}{#3}{#4} + } + } + \l_@@_cs + } + \stex_debug:nn{Here:Notation}{\meaning \l_@@_code_tl } + #5 +} + +\cs_new_protected:Nn \_@@_complex:nnnnnn { + \stex_debug:nn{Notation~code}{\tl_to_str:n{#5}} + \int_zero:N \l_tmpa_int + \tl_set:Nn \l_@@_pre_tl {\cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_oma:nnn} + \tl_set:Nn \l_@@_code_tl { + \cs_generate_from_arg_count:NNnn \l_@@_cs \cs_set:Npn \l_tmpa_int + { + \_stex_maybe_brackets:nn{#2}{ + \_stex_term_oma_or_omb:nnn{#1}{#3}{ + \bool_set_false:N \l_stex_brackets_dones_bool + #5 + } + } + } + \l_@@_cs + } + \tl_set:Nn \l_@@_after_tl{ + \exp_args:NNo + \tl_put_left:Nn \l_@@_code_tl \l_@@_pre_tl + \tl_put_left:Nx \l_@@_code_tl { + \int_set:Nn \l_tmpa_int {\int_use:N \l_tmpa_int} + } + \stex_debug:nn{Here:Notation}{\meaning \l_@@_code_tl } + #6 + } + \_@@_parse_notation_args:nnnnw #4 \_@@_args_end: +} + +\cs_new_protected:Npn \_@@_parse_notation_args:nnnnw #1 #2 #3 #4 #5 \_@@_args_end: { + \tl_if_empty:nTF{#5}{ + \_@@_add_last:nnnnn{#1}{#2}{#3}{#4} + }{ + \_@@_add_next:nnnnnn{#1}{#2}{#3}{#4}{#5} + } +} + +\cs_new_protected:Nn \_@@_add_next:nnnnnn { + \_@@_add:nnnnn{#1}{#2}{#3}{#4}{#6} + \_@@_parse_notation_args:nnnnw #5 \_@@_args_end: +} + +\cs_new_protected:Nn \_@@_add_last:nnnnn { + \_@@_add:nnnnn{#1}{#2}{#3}{#4}{#5} + \l_@@_after_tl +} + +\cs_new_protected:Nn \_@@_add:nnnnn { + \int_incr:N \l_tmpa_int + \str_case:nn{#2}{ + i { + \tl_put_right:Nn \l_@@_code_tl { + {\_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + b { + \tl_set:Nn \l_@@_pre_tl { + \cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_omb:nnn + } + \tl_put_right:Nn \l_@@_code_tl { + {\_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + a { + \tl_put_right:Nn \l_@@_code_tl { + {\_stex_term_arg_aB:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + B { + \tl_set:Nn \l_@@_pre_tl { + \cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_omb:nnn + } + \tl_put_right:Nn \l_@@_code_tl { + {\_stex_term_arg_aB:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{sfragment}{a/B-mode argument handling} +% +% \begin{macro}{\argsep} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_check_aB_arg:Nn { + \exp_args:Ne \cs_if_eq:NNF {\tl_head:n{#2}} + \_stex_term_arg_aB:nnnnn { + \msg_error:nnx{stex}{error/assocarg}{\tl_to_str:n{#1}} + } +} + +\cs_new_protected:Npn \argsep #1 #2 { + \_@@_check_aB_arg:Nn\argsep{#1} + \stex_pseudogroup_with:nn{\_stex_term_do_aB_clist:}{ + \tl_set:Nn \_stex_term_do_aB_clist: { + \seq_use:Nn \l_stex_aB_args_seq {#2} + } + #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\argmap} +% \begin{macrocode} +\cs_new_protected:Npn \argmap #1 #2 #3 { + \_@@_check_aB_arg:Nn\argmap{#1} + \stex_pseudogroup_with:nn{ + \_stex_term_do_aB_clist: + \_@@_map_cs: + }{ + \cs_set:Npn \_@@_map_cs: ##1 { #2 } + \tl_set:Nn \_stex_term_do_aB_clist: { + \seq_clear:N \l_tmpa_seq + \seq_map_inline:Nn \l_stex_aB_args_seq { + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l_tmpa_seq \ellipses + }{ + \seq_put_right:Nx \l_tmpa_seq { + \exp_after:wN \exp_not:n \exp_after:wN { \_@@_map_cs: {##1} } + } + } + } + \seq_set_eq:NN \l_stex_aB_args_seq \l_tmpa_seq + \seq_use:Nn \l_stex_aB_args_seq {#3} + } + #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\argarraymap} +% \begin{macrocode} +\int_new:N \l_@@_clist_count_int +\cs_new_protected:Npn \argarraymap #1 #2 #3 #4 { + \_@@_check_aB_arg:Nn\argarraymap{#1} + \stex_pseudogroup_with:nn{ + \_stex_term_do_aB_clist: + \_@@_map_cs: + }{ + \cs_set:Npn \_@@_map_cs: ##1 { #3 } + \int_set:Nn \l_@@_clist_count_int {\exp_args:No\clist_count:n{\tl_to_str:n{#4}}} + \tl_set:Nn \_stex_term_do_aB_clist: { + \tl_clear:N \l_tmpa_tl + \int_zero:N \l_tmpa_int + \seq_map_inline:Nn \l_stex_aB_args_seq { + \int_incr:N \l_tmpa_int + \int_compare:nNnT \l_tmpa_int > \l_@@_clist_count_int { + \int_set:Nn \l_tmpa_int 1 + } + \tl_put_right:Nx \l_tmpa_tl { + \exp_after:wN \exp_not:n \exp_after:wN { \_@@_map_cs: {##1} } + \clist_item:nn{#4}\l_tmpa_int + } + } + \seq_set_eq:NN \l_stex_aB_args_seq \l_tmpa_seq + \begin{array}{#2} + \l_tmpa_tl + \end{array} + } + #1 + } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \end{sfragment} +% + +% \begin{sfragment}{Variables} +% \begin{macrocode} +%<@@=stex_vars> +% \end{macrocode} +% +% \begin{macro}{\vardef} +% \begin{macrocode} +\tl_new:N \l_stex_variables_prop +\bool_new:N \l_@@_bind_bool +\cs_new_protected:Nn \_stex_variable:nnnnnnnN {} +\stex_keys_define:nnnn{vardef}{ + \bool_set_false:N \l_@@_bind_bool +}{ + bind .bool_set:N = \l_@@_bind_bool +}{symdef} + +\stex_new_stylable_cmd:nnnn {vardef} { m O{} m} { + \stex_keys_set:nn{vardef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \_@@_add: + \_@@_macro: + \stex_if_do_html:T \_@@_html: + + \int_set:Nn \l_stex_get_symbol_arity_int {\l_stex_get_symbol_arity_int} + \stex_debug:nn{vardef}{Doing~\l_stex_key_name_str} + \tl_set_eq:NN \l_stex_get_symbol_return_tl \l_stex_key_return_tl + \stex_notation_parse:n{#3} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_vardecl_notation_macro: + \stex_if_do_html:T { + \def\comp{\_varcomp} + \_stex_notation_do_html:n \l_stex_key_name_str + } + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_key_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + }$ + } + \stex_style_apply: + \group_end:\ignorespaces +}{} + +\cs_new_protected:Nn \_@@_add: { + \exp_args:NNNo \exp_args:NNnx + \prop_put:Nnn \l_stex_variables_prop \l_stex_key_name_str { + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: + } +} + +\cs_new_protected:Nn \_@@_macro: { + \tl_set:cx{\l_stex_macroname_str}{ + \_stex_invoke_variable:nnnnnnN + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: + } +} + +\cs_new_protected:Nn \_@@_html: { + \stex_if_do_html:T { + \hbox\bgroup\exp_args:Ne \stex_annotate_invisible:nn { + shtml:vardef = {\l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} + } + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} + } + \bool_if:NT \l_@@_bind_bool {, + shtml:bind={} + } + }{ + \_stex_annotate_force_break:n{ + \bool_set_true:N \stex_in_invisible_html_bool + \tl_if_empty:NF \l_stex_key_type_tl { + \stex_annotate:nn{shtml:type={}}{$\l_stex_key_type_tl$} + } + \tl_if_empty:NF \l_stex_key_def_tl { + \stex_annotate:nn{shtml:definiens={}}{$\l_stex_key_def_tl$} + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l_@@_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l_@@_args_tl {\_stex_map_args:N \_stex_return_args:nn} + $\stex_annotate:nn{shtml:returntype={}}{ + \exp_after:wN \l_@@_cs \l_@@_args_tl!}$ + } + \tl_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{ + \_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + $\stex_annotate:nn{shtml:type={}}{##1}$ + } + } + } + } + } + }\egroup + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_vardecl_notation_macro:} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_vardecl_notation_macro: { + \tl_set_eq:cN {l_stex_notation_ + \l_stex_key_name_str _ + \l_stex_key_variant_str _cs + }\l_stex_notation_macrocode_cs + \cs_if_exist:cF {l_stex_notation_\l_stex_key_name_str __cs}{ + \tl_set_eq:cN{l_stex_notation_\l_stex_key_name_str __cs} + \l_stex_notation_macrocode_cs + } + \tl_if_empty:NF \l_stex_key_op_tl { + \tl_set_eq:cN {l_stex_notation_\l_stex_key_name_str _op_ + \l_stex_key_variant_str _cs}\l_stex_key_op_tl + \cs_if_exist:cF {l_stex_notation_\l_stex_key_name_str _op__cs}{ + \cs_set_eq:cN{l_stex_notation_\l_stex_key_name_str _op__cs} + \l_stex_key_op_tl + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_get_symbol_or_var:n,\stex_get_var:n} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_set_vars:nnnnnnN { + \stex_debug:nn{symbols}{Variable~#1~found} + \cs_set:Npn \_stex_variable:nnnnnnnN ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 {} + \str_clear:N \l_stex_get_symbol_mod_str + \str_set:Nn \l_stex_get_symbol_name_str {#1} + \int_set:Nn \l_stex_get_symbol_arity_int {#2} + \tl_set:Nn \l_stex_get_symbol_args_tl {#3} + \tl_set:Nn \l_stex_get_symbol_def_tl {#4} + \tl_set:Nn \l_stex_get_symbol_type_tl {#5} + \tl_set:Nn \l_stex_get_symbol_return_tl {#6} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#7} +} + +\cs_new_protected:Nn \_@@_get_var:n { + \prop_map_inline:Nn \l_stex_variables_prop { + \_@@_check_var:nnnnnnnnN {#1} ##2 + } +} + +\cs_new_protected:Nn \_@@_check_var:nnnnnnnnN { + \str_if_eq:nnTF{#1}{#2}{ + \prop_map_break:n{\_@@_set_vars:nnnnnnN {#3}{#4}{#5}{#6}{#7}{#8}#9} + }{ + \str_if_eq:nnT{#1}{#3}{ + \prop_map_break:n{\_@@_set_vars:nnnnnnN {#3}{#4}{#5}{#6}{#7}{#8}#9} + } + } +} + +\cs_new_protected:Nn \stex_get_var:n { + \str_clear:N \l_stex_get_symbol_name_str + \_@@_get_var:n{#1} + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnn{stex}{error/unknownsymbol}{#1} + } +} + +\cs_new_protected:Nn \stex_get_symbol_or_var:n { + \str_clear:N \l_stex_get_symbol_name_str + \_@@_get_var:n{#1} + \str_if_empty:NT \l_stex_get_symbol_name_str { + \stex_debug:nn{symbols}{No~variable~#1~found} + \stex_get_symbol:n{#1} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\svar} +% \begin{macrocode} +\NewDocumentCommand \svar {O{} m}{ + \group_begin: + \tl_if_empty:nTF{#1}{ + \str_set:Nn \l_stex_current_symbol_str {#2} + }{ + \str_set:Nn \l_stex_current_symbol_str {#1} + } + \bool_if:NTF \l_stex_allow_semantic_bool{ + \tl_clear:N \l_stex_current_term_tl + \_stex_term_omv:nnn{}{}{\_varcomp{#2}} + }{ + \msg_error:nnxx{stex}{error/notallowed}{Variable}{\l_stex_current_symbol_str} + } + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Sequences} +% \begin{macrocode} +%<@@=stex_seqs> +% \end{macrocode} +% +% \begin{macro}{\varseq} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn {varseq}{m O{} m m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + \str_if_empty:NT \l_stex_key_args_str { + \str_set:Nn \l_stex_key_args_str {1} + } + \stex_symdecl_do: + + \tl_set_eq:NN \l_stex_get_symbol_return_tl \l_stex_key_return_tl + \clist_set:Nn \l_@@_range_clist {#3} + \tl_if_empty:NTF \l_stex_key_op_tl { + \stex_notation_parse:n{#4} + \tl_clear:N \l_stex_key_op_tl + }{ + \stex_notation_parse:n{#4} + } + \stex_if_do_html:T \_@@_html: + \stex_if_check_terms:T \_@@_check_terms: + \_@@_add: + \_@@_macro: + \stex_if_check_terms:T \_stex_notation_check: + \_stex_vardecl_notation_macro: + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_key_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_@@_make_args: + }$ + } + \stex_style_apply: + \group_end:\ignorespaces +}{} + +\cs_new_protected:Nn \_@@_add: { + \exp_args:NNNo \exp_args:NNnx + \prop_put:Nnn \l_stex_variables_prop \l_stex_key_name_str { + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_@@_range_clist} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_sequence: + } +} + +\cs_new_protected:Nn \_@@_macro: { + \tl_set:cx{\l_stex_macroname_str}{ + \_stex_invoke_variable:nnnnnnN + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_@@_range_clist} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_sequence: + } +} + +\cs_new_protected:Nn \_@@_make_args: { \TODO } +\cs_new_protected:Nn \_@@_check_terms: { \TODO } + +\cs_new_protected:Nn \_@@_html: { + \exp_args:Ne \stex_annotate_invisible:nn { + shtml:varseq = {\l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} + } + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} + } + }{\hbox\bgroup + \_stex_annotate_force_break:n{ + \tl_if_empty:NF \l_stex_key_type_tl { + \stex_annotate:nn{shtml:type={}}{$\l_stex_key_type_tl$} + } + \tl_if_empty:NF \l_stex_key_def_tl { + \stex_annotate:nn{shtml:definiens={}}{$\l_stex_key_def_tl$} + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l_@@_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l_@@_args_tl {\_stex_map_args:N \_stex_return_args:nn} + \stex_annotate:nn{shtml:returntype={}}{ + $\exp_after:wN \l_@@_cs \l_@@_args_tl!$} + } + \tl_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{ + \_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:type={}}{$##1$} + } + } + } + } + } + \egroup} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_invoke_sequence:} +% \begin{macrocode} +\cs_new_protected:Nn \stex_invoke_sequence: { + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ \_@@_do_op:w { \_@@_do_op:w [] } + }\_@@_do_first: +} + +\cs_new_protected:Npn \_@@_do_op:w [#1] { + \cs_if_exist:cTF {l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}{ + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\use:c{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}} + } + \group_end: + }{ + \_@@_get_index_notation:n{#1} + \peek_charcode:NTF [ \_@@_doop_range:w { \_@@_doop_range:w[] } + } +} + +\cs_new_protected:Npn \_@@_doop_range:w [#1] { + \bool_set_true:N \l_stex_allow_semantic_bool + \clist_clear:N \l_@@_clist + \clist_map_function:NN \l_stex_current_type_tl \_@@_doop_arg:n + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={} + }{ + \l_@@_clist + } + \group_end: +} + +\cs_new_protected:Nn \_@@_doop_arg:n { + \tl_if_eq:nnTF{#1}{\ellipses}{ + \clist_put_right:Nn \l_@@_clist { + \ellipses + } + }{ + \clist_put_right:Nn \l_@@_clist { + \exp_args:No \str_if_eq:nnTF \l_stex_current_arity_str {1}{ + \group_begin: + \l_@@_cs \group_end: {#1} + + }{ + \group_begin: + \l_@@_cs \group_end: #1 + } + } + } +} + +\cs_new_protected:Nn \_@@_get_index_notation:n { + \cs_if_exist:cTF {l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \cs_set_eq:Nc \l_@@_cs {l_stex_notation_\l_stex_current_symbol_str _#1_cs} + }{ + \stex_do_default_notation: + \cs_set_eq:NN \l_@@_cs \l_stex_default_notation + } +} + + +\cs_new:Nn \_@@_do_first_arg:n {{\exp_not:n{## #1}}} + +\cs_new_protected:Nn \_@@_do_first: { + \exp_args:Nnx \use:nn{ + \cs_generate_from_arg_count:NNnn \l_@@_cs \cs_set:Npn + \l_stex_current_arity_str} {{ + \tl_set:Nn \exp_not:N \l_@@_first_args_tl { + \int_step_function:nN \l_stex_current_arity_str \_@@_do_first_arg:n + } + \exp_not:N \_@@_do_first_next: + }} + \l_@@_cs +} + +\cs_new_protected:Nn \_@@_do_first_next: { + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ \_@@_do_one:w {\_@@_do_one:w []} + }{ + \peek_charcode:NTF [ \_@@_do_all:w {\_@@_do_all:w []} + } +} + +\cs_new_protected:Npn \_@@_do_one:w [#1] { + \_@@_get_index_notation:n{#1} + \stex_debug:nn{HERE~seq~one}{\meaning\l_@@_cs^^J\meaning\l_@@_first_args_tl} + \exp_args:Nno\use:nn{\l_@@_cs\group_end:}\l_@@_first_args_tl +} + +\cs_new_protected:Npn \_@@_do_all:w [#1] { + \stex_debug:nn{HERE~seq~all}{\meaning\l_@@_first_args_tl} + \exp_args:Nno\use:nn{\_stex_invoke_notation:w [#1]}\l_@@_first_args_tl +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\seqmap} +% \begin{macrocode} +\cs_new_protected:Npn \seqmap #1 #2 { + \symuse{Metatheory?sequence~expression}{\seqmap{#1}{#2}}%\l_tmpa_tl {#2} +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Expressions} +% \begin{macrocode} +%<@@=stex_expr> +% \end{macrocode} +% +% Various variables: +% +% \begin{macrocode} +\bool_new:N \l_stex_allow_semantic_bool +\bool_set_true:N \l_stex_allow_semantic_bool +\tl_new:N \l_stex_current_term_tl +\tl_set:Nn \l_stex_every_symbol_tl { + \bool_set_false:N \l_stex_allow_semantic_bool +} +% \end{macrocode} +% +% \begin{macro}{\_stex_next_symbol:n} +% \begin{macrocode} +\tl_new:N \l_@@_reset_tl +\cs_new_protected:Nn \_stex_next_symbol:n { + \tl_set:Nx \l_stex_every_symbol_tl { + \tl_gset:Nn \exp_not:N \l_@@_reset_tl { + \tl_set:Nn \exp_not:N \l_stex_every_symbol_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \tl_gset:Nn \exp_not:N \l_@@_reset_tl { + \exp_args:No \exp_not:n \l_@@_reset_tl + } + } + \tl_set:Nn \exp_not:N \l_stex_every_symbol_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \exp_not:n{ \aftergroup \l_@@_reset_tl } + \exp_not:N \l_stex_every_symbol_tl + \exp_not:n{ #1 } + } +} +\cs_generate_variant:Nn \_stex_next_symbol:n {e} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\STEXinvisible} +% \begin{macrocode} +\cs_new_protected:Npn \STEXinvisible #1 { + \stex_annotate_invisible:n { #1 } +} +% \end{macrocode} +% \end{macro} +% +% \begin{sfragment}{Invoking Semantic Macros} +% +% \begin{macro}{\_stex_invoke_symbol:nnnnnnnN} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_invoke_symbol:nnnnnnnN { + \bool_if:NTF \l_stex_allow_semantic_bool{ + \stex_if_html_backend:T{\ifvmode\indent\fi} + \_@@_setup:nnnnnn{\_comp}{#1?#2}{#3}{#4}{#7}{#6} + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn + \tl_put_right:Nn \l_stex_current_redo_tl{ + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn + } + #8 + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1?#2}{\l_stex_current_symbol_str} + } +} +\cs_generate_variant:Nn \_stex_invoke_symbol:nnnnnnnN {ooxooooN} + +\cs_new_protected:Nn \_@@_setup:nnnnnn { + \group_begin: + \tl_clear:N \l_stex_return_notation_tl + \tl_set:Nn \l_stex_current_redo_tl { + \let \this \stex_current_this: + \def\comp{#1} + \def\maincomp{\comp} + \str_set:Nn \l_stex_current_symbol_str {#2} + \str_set:Nn \l_stex_current_arity_str{ #3 } + \tl_set:Nn \l_stex_current_args_tl{ #4 } + \tl_set:Nn \l_stex_current_return_tl{ #5 } + \tl_set:Nn \l_stex_current_type_tl{ #6 } + \tl_clear:N \l_stex_current_term_tl + } + \tl_put_right:Nx \l_stex_current_redo_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \l_stex_current_redo_tl +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_invoke_variable:nnnnnn} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_invoke_variable:nnnnnnN { + \bool_if:NTF \l_stex_allow_semantic_bool{ + \stex_if_html_backend:T{\ifvmode\indent\fi} + \_@@_setup:nnnnnn{\_varcomp}{#1}{#2}{#3}{#6}{#5} + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_omv:nnn + \tl_put_right:Nn \l_stex_current_redo_tl { + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_omv:nnn + } + #7 + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\symuse} +% \begin{macrocode} +\cs_new_protected:Npn \symuse #1 { + \stex_get_symbol:n{#1} + \exp_args:Nno \use:n {\_stex_invoke_symbol:ooxooooN + \l_stex_get_symbol_mod_str + \l_stex_get_symbol_name_str + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_get_symbol_args_tl + \l_stex_get_symbol_def_tl + \l_stex_get_symbol_type_tl + \l_stex_get_symbol_return_tl} + \l_stex_get_symbol_invoke_cs +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stex_invoke_symbol:} +% +% Top-Level: Check whether text/math mode or custom notation, +% whether delimited by !, return code etc. +% \begin{macrocode} +\cs_new_protected:Nn \stex_invoke_symbol: { + \stex_debug:nn{expressions}{Invoking~\l_stex_current_symbol_str} + \mode_if_math:TF \@@_invoke_math: \@@_invoke_text: +} + +\cs_new_protected:Nn \@@_invoke_text: { + \stex_debug:nn{expressions}{text~mode} + \peek_charcode_remove:NTF ! \@@_invoke_op_custom:n \@@_invoke_custom:n +} + +\cs_new_protected:Nn \@@_invoke_math: { + \stex_debug:nn{expressions}{math~mode} + \peek_charcode_remove:NTF ! { + % operator + \peek_charcode_remove:NTF * \@@_invoke_op_custom:n { + % op notation + \peek_charcode:NTF [ \@@_invoke_op_notation:w { + \@@_invoke_op_notation:w [] + } + } + }{ + \peek_charcode_remove:NTF * \@@_invoke_custom:n { + % normal + \peek_charcode:NTF [ \_stex_invoke_notation:w { + \_stex_invoke_notation:w [] + } + } + } +} +% \end{macrocode} +% +% Notations: +% +% \begin{macrocode} +\cs_new_protected:Npn \_stex_invoke_notation:w [#1] { + \stex_debug:nn{expressions}{using~notation~#1~for~\l_stex_current_symbol_str} + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \tl_if_empty:NTF \l_stex_current_return_tl { + \stex_debug:nn{expressions}{return~empty} + \use:c{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{\group_end:\_stex_eat_exclamation_point:} + }{ + \stex_debug:nn{expressions}{return?} + \exp_after:wN\exp_after:wN\exp_after:wN + \@@_invoke_return_maybe:n + \exp_after:wN\exp_after:wN\exp_after:wN + {\cs:w l_stex_notation_\l_stex_current_symbol_str _#1_cs \cs_end: {}} + } + }{ + \stex_do_default_notation: + \tl_if_empty:NTF \l_stex_current_return_tl { + \l_stex_default_notation{\group_end:\_stex_eat_exclamation_point:} + }{ + \exp_after:wN + \@@_invoke_return_maybe:n + \exp_after:wN + {\l_stex_default_notation {}} + } + } +} + +\cs_new_protected:Npn \@@_invoke_op_notation:w [#1] { + \stex_debug:nn{expressions}{op~notation~for~\l_stex_current_symbol_str} + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}{ + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\use:c{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}} + } + \group_end: + }{ + \int_compare:nNnTF \l_stex_current_arity_str = 0 { + \tl_clear:N \l_stex_current_return_tl + \_stex_invoke_notation:w [#1] + }{ + \stex_do_default_notation_op: + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\l_stex_default_notation} + } + \group_end: + } + } +} +% \end{macrocode} +% +% Return: +% +% \begin{macrocode} +\cs_new_protected:Nn \@@_invoke_return_maybe:n { + \tl_clear:N \l_@@_return_args_tl + \tl_set:Nn \l_@@_return_this_tl {#1} + \exp_args:Nnx \use:n { + \cs_generate_from_arg_count:NNnn \_@@_ret_cs + \cs_set:Npn \l_stex_current_arity_str } { + \int_step_function:nN \l_stex_current_arity_str \_@@_return_arg:n + \_@@_invoke_return_next: + } + \_@@_ret_cs +} + +\cs_new:Nn \_@@_return_arg:n { + \tl_put_right:Nn \exp_not:N \l_@@_return_args_tl {{#### #1}} +} + +\cs_new_protected:Nn \_@@_invoke_return_next: { + \peek_charcode_remove:NTF ! { + \exp_after:wN \l_@@_return_this_tl \l_@@_return_args_tl \group_end: + }\_@@_invoke_return: +} + +\cs_new_protected:Nn \_@@_invoke_return: { + \tl_set:Nx \l_@@_return_this_tl { + \_@@_return_notation:n { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN { + \exp_after:wN \l_@@_return_this_tl \l_@@_return_args_tl + } + } + } + \stex_debug:nn{return}{Notation:~\meaning\l_@@_return_this_tl} + \tl_put_left:Nx \l_@@_return_this_tl { + \group_begin:\exp_args:No \exp_not:n \l_stex_current_redo_tl + } + \exp_args:Nnx \use:n { + \cs_generate_from_arg_count:NNnn \_@@_ret_cs + \cs_set:Npn \l_stex_current_arity_str } { + \exp_args:No \exp_not:n \l_stex_current_return_tl + } + \stex_debug:nn{return}{ + \meaning\_@@_ret_cs^^J + \meaning\l_@@_return_this_tl^^J + \exp_args:No \exp_not:n \l_@@_return_args_tl^^J + } + \exp_args:Nnx \use:nn { + \exp_after:wN \group_end: \_@@_ret_cs + }{ + \exp_args:No \exp_not:n \l_@@_return_args_tl + { + \exp_args:No \exp_not:n \l_@@_return_this_tl + \group_end: + } + } +} + + +\cs_new_protected:Nn \_@@_return_notation:n { + \tl_if_empty:NTF \l_stex_return_notation_tl { #1 }{ + \l_stex_return_notation_tl + } +} + +% \end{macrocode} +% +% Custom Notations: +% +% \begin{macrocode} +\cs_new_protected:Nn \@@_invoke_op_custom:n { + \stex_debug:nn{expressions}{custom~op} + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_oms_or_omv:nnn{}{}{\maincomp{#1}} + \group_end: +} + +\int_new:N \l_@@_arg_counter_int +\cs_new_protected:Nn \@@_invoke_custom:n { + \stex_debug:nn{custom}{custom~notation~for~\l_stex_current_symbol_str} + \stex_pseudogroup:nn{ + \bool_set_true:N \l_stex_allow_semantic_bool + \prop_gclear:N \l_@@_customs_prop + \seq_gclear:N \l_@@_customs_seq + \int_gzero:N \l_@@_arg_counter_int + \tl_if_empty:NF \l_stex_current_args_tl { + \exp_after:wN \_@@_add_prop_arg:nnw \l_stex_current_args_tl \_stex_args_end: + \cs_set_eq:NN \arg \_@@_arg:n + } + \tl_set_eq:NN \l_stex_get_symbol_args_tl \l_stex_current_args_tl + \cs_set_eq:NN \_@@_do_ab_next:nnn \_stex_term_oma:nnn + \_stex_map_args:N \_@@_check_b:nn + \_@@_do_ab_next:nnn{}{}{#1} + }{ + \prop_if_exist:NT \l_@@_customs_prop { + \prop_gset_from_keyval:Nn \exp_not:N \l_@@_customs_prop { + \prop_to_keyval:N \l_@@_customs_prop + } + } + \int_gset:Nn \l_@@_arg_counter_int { \int_use:N \l_@@_arg_counter_int} + \seq_if_exist:NT \l_@@_customs_seq { + \seq_gset_split:Nnn \exp_not:N \l_@@_customs_seq , { + \seq_use:Nn \l_@@_customs_seq , + } + } + } + % TODO check that all arguments are present + \group_end: +} + +\cs_new_protected:Npn \_@@_add_prop_arg:nnw #1 #2 #3\_stex_args_end: { + \prop_gput:Nnn \l_@@_customs_prop {#1} {} + \seq_gput_right:Nn \l_@@_customs_seq {#2} + \tl_if_empty:nF{#3}{\_@@_add_prop_arg:nnw #3 \_stex_args_end:} +} + +\cs_new:Nn \_@@_check_b:nn { + \str_case:nn #2 { + b {\cs_set_eq:NN \_@@_do_ab_next:nnn \_stex_term_omb:nnn} + B {\cs_set_eq:NN \_@@_do_ab_next:nnn \_stex_term_omb:nnn} + } +} + +\NewDocumentCommand \_@@_arg:n {s O{} m} { + \IfBooleanTF #1 { + \stex_annotate_invisible:n{ + \_@@_arg_inner:nn{#2}{#3} + } + }{ + \_@@_arg_inner:nn{#2}{#3} + } +} + +\cs_new_protected:Nn \_@@_arg_inner:nn { + \tl_if_empty:nTF{#1}{ + \int_gincr:N \l_@@_arg_counter_int + \exp_args:Ne \_@@_check:nTF{ \int_use:N \l_@@_arg_counter_int }{ + \_@@_arg_do:oon \l_tmpa_tl \l_tmpb_tl + }{ + \_@@_arg_inner:nn{} + }{ #2 } + }{ + \_@@_check:nTF {#1}{ + \_@@_arg_do:oon \l_tmpa_tl \l_tmpb_tl { #2 } + }{ + \exp_args:No \str_case:nnTF \l_tmpb_tl { + {a}{ + \exp_args:NNnx \prop_gput:Nnn \l_@@_customs_prop {#1}{ + \l_tmpa_tl X + } + \tl_set:Nx \l_tmpa_tl { #1 \int_eval:n {\tl_count:N \l_tmpa_tl + 1} } + } + {B}{ + \exp_args:NNnx \prop_gput:Nnn \l_@@_customs_prop {#1}{ + \l_tmpa_tl X + } + \tl_set:Nx \l_tmpa_tl { #1 \int_eval:n {\tl_count:N \l_tmpa_tl + 1} } + } + }{ + \_@@_arg_do:oon \l_tmpa_tl \l_tmpb_tl { #2 } + }{ + \msg_error:nnxx{stex}{error/invalidarg}{#1}{\l_stex_current_symbol_str} + } + } + } +} + +\prg_new_conditional:Nnn \_@@_check:n {TF} { + \exp_args:NNe \prop_get:NnNTF \l_@@_customs_prop {#1} \l_tmpa_tl { + \tl_set:Nx \l_tmpb_tl {\seq_item:Nn \l_@@_customs_seq {#1} } + \tl_if_empty:NTF \l_tmpa_tl { + \exp_args:NNe \prop_gput:Nnn \l_@@_customs_prop + { #1 }{X} + \exp_args:No \str_case:nnF \l_tmpb_tl { + {a}{ + \tl_set:Nx \l_tmpa_tl{ #1 1 } + } + {B}{ + \tl_set:Nx \l_tmpa_tl{ #1 1 } + } + }{ + \tl_set:Nx \l_tmpa_tl{ #1 } + } + \prg_return_true: + }{ + \prg_return_false: + } + }{ + \msg_error:nnxx{stex}{error/invalidarg}{#1}{\l_stex_current_symbol_str} + \prg_return_false: + } +} + +% #1 argnum #2 argmode #3 code +\cs_new_protected:Nn \_@@_arg_do:nnn { + \stex_debug:nn{custom}{Doing~argument~#1~of~mode~#2:~\tl_to_str:n{#3}} + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_arg:nnn {#2}{#1}{#3} + \group_end: +} +\cs_generate_variant:Nn \_@@_arg_do:nnn {oon} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Argument Handling and Annotating} +% +% \begin{macro}{\_stex_term_arg:nnnnn,\_stex_term_arg:nnn} +% \begin{macrocode} +% 1: argnum 2: argmode 3: precedence 4: argname 5: code +\cs_new_protected:Nn \_stex_term_arg:nnnnn { + \group_begin: + \str_clear:N \l_stex_current_symbol_str + \tl_clear:N \l_stex_current_term_tl + \int_set:Nn \l_stex_notation_downprec { #3 } + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_arg:nnn {#2}{#1}{ + \tl_if_empty:nTF{#4}{ + #5 + }{ + \stex_annotate:nn{mml:arg={#4}}{#5} + } + } + \group_end: +} + +\cs_new_protected:Nn \_stex_term_arg:nnn { + \stex_annotate:nn{ shtml:arg={#2}, shtml:argmode={#1}}{ + \_stex_annotate_force_break:n{ #3 } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_term_arg_aB:nnnnn} +% \begin{macrocode} +\tl_set:Nn \_@@_do_aB_clist: { + \seq_use:Nn \l_stex_aB_args_seq { + \mathpunct{\comp{,}} + } +} +\tl_set_eq:NN \_stex_term_do_aB_clist: \_@@_do_aB_clist: + +\int_new:N \l_@@_count_int +\cs_new_protected:Nn \_stex_term_arg_aB:nnnnn { + \tl_if_empty:nTF{#5}{ + \_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{} + }{ + \seq_clear:N \l_stex_aB_args_seq + \int_zero:N \l_@@_count_int + \clist_map_inline:nn{#5}{ + \_@@_aB_arg:nnnnn{##1}{#1}{#2}{#3}{#4} + } + \_stex_term_do_aB_clist: + } +} + +% 1: code 2: argnum 3: argmode 4: precedence 5: argname +\cs_new_protected:Npn \_@@_aB_arg:nnnnn #1 { + \int_incr:N \l_@@_count_int + \_@@_is_varseq:nTF{#1}{ + \exp_after:wN \exp_after:wN \exp_after:wN + \_@@_assoc_seq:nnnnnnn + \exp_after:wN + \_@@_gobble:nnnnnnnn #1 \_@@_end: + }{ + \_@@_is_seqmap:nTF{#1}{ + \exp_args:NNe \use:nn \_@@_do_seqmap:nnnnnn {\tl_tail:n{#1}} + }{ + \_@@_aB_simple_arg:nnnnn{#1} + } + } +} + +\cs_new:Npn \_@@_gobble:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 #9 \_@@_end: { + {#2} #3 {#6} +} + +\cs_new_protected:Nn \_@@_aB_simple_arg:nnnnn{ + \seq_put_right:Nx \l_stex_aB_args_seq { + \_stex_term_arg:nnnnn{#2\int_use:N\l_@@_count_int}{#3}{#4}{#5}{ + \exp_not:n{ + \tl_set_eq:NN \_stex_term_do_aB_clist: \_@@_do_aB_clist: + #1 + } + } + } +} + +\cs_new_protected:Nn \_stex_is_sequentialized:n { + \group_begin: #1 \group_end: +} +% \end{macrocode} +% +% Conditionals: Is the argument a sequence variable or a |\seqmap|? +% +% \begin{macrocode} +\prg_new_conditional:Nnn \_@@_is_varseq:n {TF} { + \int_compare:nNnTF {\tl_count:n{#1}} = 1 { + \exp_args:Ne \cs_if_eq:NNTF {\exp_args:No \tl_head:n{#1}} + \_stex_invoke_variable:nnnnnnN { + \exp_args:Ne \cs_if_eq:NNTF {\exp_args:No\tl_item:nn{#1}{8}} + \stex_invoke_sequence: + \prg_return_true:\prg_return_false: + }\prg_return_false: + }\prg_return_false: +} + +\prg_new_conditional:Nnn \_@@_is_seqmap:n {TF} { + \int_compare:nNnTF {\tl_count:n{#1}} = 3 { + \exp_args:Ne \tl_if_eq:nnTF {\tl_head:n{#1}} {\seqmap} + \prg_return_true:\prg_return_false: + }\prg_return_false: +} +% \end{macrocode} +% +% Sequence variable: +% +% \begin{macrocode} +% 1: name 2: arity 3: clist 4: argnum 5: argmode 6: precedence 7: argname +\cs_new_protected:Nn \_@@_assoc_seq:nnnnnnn { + \group_begin: + \seq_clear:N \l_stex_aB_args_seq + \_@@_assoc_make_seq:nnn{#1}{#3}{#2} + \exp_args:NNe \use:nn \group_end: { + \seq_put_right:Nn \exp_not:N \l_stex_aB_args_seq { + \_stex_is_sequentialized:n{ + \_stex_term_arg:nnnnn{#4\int_use:N\l_@@_count_int}{#5}{#6}{#7}{ + \bool_set_true:N \l_stex_allow_semantic_bool + \str_set:Nn \exp_not:N \l_stex_current_symbol_str + {\l_stex_current_symbol_str} + \tl_if_empty:NF \l_stex_current_term_tl { + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \exp_args:No \exp_not:n \l_stex_current_term_tl + } + } + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={#1}, + shtml:notationid={} + }{ + \_stex_annotate_force_break:n{ + \_stex_term_do_aB_clist: + } + } + } + } + } + } +} + +% #1: name, #2: clist, #3:arity +\cs_new_protected:Nn \_@@_assoc_make_seq:nnn { + \cs_if_exist:cTF{l_stex_notation_#1__cs}{ + \cs_set_eq:Nc \l_@@_cs {l_stex_notation_#1__cs} + }{ + \stex_do_default_notation: + \cs_set_eq:NN \l_@@_cs \l_stex_default_notation + } + \clist_map_inline:nn{#2}{ + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l_stex_aB_args_seq { ##1 } + }{ + \int_compare:nNnTF {#3} = 1 { + \tl_set:Nn \l_@@_iarg_tl { {##1} } + }{ + \tl_set:Nn \l_@@_iarg_tl { ##1 } + } + \seq_put_right:Nx \l_stex_aB_args_seq { + \group_begin: + \exp_not:n { + \tl_set_eq:NN \_stex_term_do_aB_clist: \_@@_do_aB_clist: + \def\comp{\_varcomp} + \str_set:Nn \l_stex_current_symbol_str{#1} + } + \exp_after:wN \exp_after:wN \exp_after:wN \exp_not:n + \exp_after:wN \exp_after:wN \exp_after:wN { + \exp_after:wN \l_@@_cs \exp_after:wN \group_end: \l_@@_iarg_tl + } + } + } + } +} +% \end{macrocode} +% +% |\seqmap|: +% +% \begin{macrocode} +% 1: fun 2: clist 3: argnum 4: argmode 5: precedence 6: argname +\cs_new_protected:Nn \_@@_do_seqmap:nnnnnn { + \group_begin: + \cs_set:Npn \l_tmpa_cs ##1 {#1} + \seq_clear:N \l_stex_aB_args_seq + \clist_map_inline:nn{#2}{ + \_@@_is_varseq:nTF{##1}{ + \exp_after:wN + \_@@_varseq_in_map:nnnnnnnn ##1 + }{ + \seq_put_right:Nn \l_stex_aB_args_seq {##1} + } + } + \seq_clear:N \l_@@_old_seq + \seq_map_inline:Nn \l_stex_aB_args_seq { + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l_@@_old_seq {##1} + } + % TODO \_stex_is_sequentialized:n + { + \exp_args:NNo \seq_put_right:Nn \l_@@_old_seq { + \l_tmpa_cs {##1} + } + } + } + \seq_set_eq:NN \l_stex_aB_args_seq \l_@@_old_seq + \exp_args:NNe \use:nn \group_end: { + \seq_put_right:Nn \exp_not:N \l_stex_aB_args_seq { + \_stex_is_sequentialized:n{ + \_stex_term_arg:nnnnn{#4\int_use:N\l_@@_count_int}{#4}{#5}{#6}{ + \bool_set_true:N \l_stex_allow_semantic_bool + \str_set:Nn \exp_not:N \l_stex_current_symbol_str + {\l_stex_current_symbol_str} + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \symuse{Metatheory?sequence~map} + {\exp_args:No \exp_not:n \l_tmpa_tl} + {\_stex_term_do_aB_clist:} + } + \_@@_do_headterm:nn{}{ + \_stex_term_do_aB_clist: + } + } + } + } + } +} + +\cs_new_protected:Nn \_@@_varseq_in_map:nnnnnnnn { + \_@@_assoc_make_seq:nnn{#2}{#6}{#3} +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Term HTML Annotations} +% +% \begin{macro}{\_stex_term_oms_or_omv:nnn,\_stex_term_oms:nnn,\_stex_term_omv:nnn} +% \begin{macrocode} +\cs_new_protected:Nn \_stex_eat_exclamation_point: { + \peek_charcode_remove:NT ! { + \_stex_eat_exclamation_point: + } +} + +\bool_new:N \stex_in_invisible_html_bool +\bool_set_false:N \stex_in_invisible_html_bool +\stex_if_html_backend:TF { + % 1: variant 2: intent 3: code + \cs_new_protected:Nn \_stex_term_oms:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMID, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1}, + }{ + \_stex_annotate_force_break:n{#3} + } + }{ + \_@@_do_headterm:nn{#1}{#3} + } + } + \cs_new_protected:Nn \_stex_term_omv:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} + } + }{ + \_@@_do_headterm:nn{#1}{#3} + } + } + \cs_new_protected:Nn \_@@_do_headterm:nn { + \bool_if:NTF \stex_in_invisible_html_bool { + {\bool_set_true:N \l_stex_allow_semantic_bool + \ensuremath{\l_stex_current_term_tl} + } + }{ + \stex_annotate:nn{ + shtml:term=complex, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{ + {\bool_set_true:N \l_stex_allow_semantic_bool + \ensuremath{\l_stex_current_term_tl} + } + } + } + #2 + } + } + } +}{ + \cs_new_protected:Nn \_stex_term_oms:nnn {#3} + \cs_new_protected:Nn \_stex_term_omv:nnn {#3} + \cs_new_protected:Nn \_@@_do_headterm:nn { #2 } +} +\cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_term_oma:nnn} +% \begin{macrocode} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_term_oma:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMA, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} + } + }{ + \stex_annotate:nn{ + shtml:term=OMA, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{{ + \bool_set_true:N \l_stex_allow_semantic_bool + \l_stex_current_term_tl + }} + #3 + } + } + } + } +}{ + \cs_new_protected:Nn \_stex_term_oma:nnn {#3} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\_stex_term_omb:nnn} +% \begin{macrocode} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_term_omb:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMBIND, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} + } + }{ + \stex_annotate:nn{ + shtml:term=OMBIND, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{{ + \bool_set_true:N \l_stex_allow_semantic_bool + \l_stex_current_term_tl + }} + #3 + } + } + } + } +}{ + \cs_new_protected:Nn \_stex_term_omb:nnn { #3 } +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Automated Bracketing} +% +% \begin{macro}{\infprec,\neginfprec} +% \begin{macrocode} +\tl_const:Nx \infprec {\int_use:N \c_max_int} +\tl_const:Nx \neginfprec {-\int_use:N \c_max_int} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\dobrackets} +% \begin{macrocode} +\int_new:N \l_stex_notation_downprec +\int_set:Nn \l_stex_notation_downprec \infprec +\tl_set:Nn \l_@@_left_bracket_str ( +\tl_set:Nn \l_@@_right_bracket_str ) +\bool_new:N \l_stex_brackets_dones_bool + +\cs_new_protected:Nn \_stex_maybe_brackets:nn { + \bool_if:NTF \l_stex_brackets_dones_bool { + \bool_set_false:N \l_stex_brackets_dones_bool + #2 + } { + \stex_debug:nn{brackets}{#1>\int_eval:n \l_stex_notation_downprec?} + \int_compare:nNnTF { #1 } > \l_stex_notation_downprec { + %\bool_if:NTF \l_stex_inparray_bool { #2 }{ + \dobrackets { + #2 + } + %} + }{ + #2 + } + } +} + +%\RequirePackage{scalerel} +\cs_new_protected:Npn \dobrackets #1 { + %\ThisStyle{\if D\m@switch + % \exp_args:Nnx \use:nn + % { \exp_after:wN \left\l_@@_left_bracket_str #1 } + % { \exp_not:N\right\l_@@_right_bracket_str } + % \else + \group_begin: + %\stex_pseudogroup_with:nn{\l_stex_brackets_dones_bool\l_stex_notation_downprec}{ + \bool_set_true:N \l_stex_brackets_dones_bool + %\int_set:Nn \l_stex_notation_downprec \infprec + \mathopen{\cs_if_exist:NT\l_stex_current_symbol_str\comp + \l_@@_left_bracket_str + } + #1 + \group_end:%} + \mathclose{\cs_if_exist:NT\l_stex_current_symbol_str\comp + \l_@@_right_bracket_str + } + %\fi} +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\withbrackets} +% \begin{macrocode} +\cs_new_protected:Npn \withbrackets #1 #2 #3 { + \stex_pseudogroup_with:nn{\l_@@_left_bracket_str\l_@@_right_bracket_str}{ + \tl_set:Nn \l_@@_left_bracket_str { #1 } + \tl_set:Nn \l_@@_right_bracket_str { #2 } + #3 + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\dowithbrackets} +% \begin{macrocode} +\cs_new_protected:Npn \dowithbrackets #1 #2 #3 { + \withbrackets{#1}{#2}{\dobrackets{#3}} +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Symname and Variants} +% +% \begin{macro}{\symname,\sn,\sns,\Symname,\Sn,\Sns,\symref,\sr,\varref,\varname,\Varname} +% \begin{macrocode} +\def\maincomp{\comp} + +\stex_keys_define:nnnn{symname}{ + \tl_clear:N \l_stex_key_pre_tl + \tl_clear:N \l_stex_key_post_tl + %\tl_clear:N \l_stex_key_proot_tl +}{ + pre .tl_set:N = \l_stex_key_pre_tl , + post .tl_set:N = \l_stex_key_post_tl , + root .code:n = {}%.tl_set:N = \l_stex_key_root_tl +}{} + +\NewDocumentCommand \symref { O{} m m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \_@@_do_ref:nNn{#3}\symrefemph@uri\_stex_term_oms:nnn +} +\let\sr\symref + +\NewDocumentCommand \symname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \_@@_do_ref:nNn{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\symrefemph@uri\_stex_term_oms:nnn +} +\let\sn\symname +\protected\def\sns{\symname[post=s]} + +\NewDocumentCommand \Symname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \_@@_do_ref:nNn{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\symrefemph@uri\_stex_term_oms:nnn +} +\cs_new_protected:Nn \_stex_capitalize:n { + \uppercase{#1} +} +\let\Sn\Symname +\protected\def\Sns{\Symname[post=s]} + +\cs_new:Npn \_stex_split_slash: #1/#2/#3\_stex_args_end: { + \tl_if_empty:nTF{#3}{ + #2 + }{ + \_stex_split_slash: #2 / #3 \_stex_args_end: + } +} + +\NewDocumentCommand \varref { O{} m m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \_@@_do_ref:nNn{#3}\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn + } +} + +\NewDocumentCommand \varname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \_@@_do_ref:nNn{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn + } +} + +\NewDocumentCommand \Varname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \_@@_do_ref:nNn{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn + } +} + + +\cs_new_protected:Nn \_@@_do_ref:nNn { + \stex_if_html_backend:T{\ifvmode\indent\fi} + \bool_if:NTF \l_stex_allow_semantic_bool{ + \str_set:Nx\l_stex_current_symbol_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \str_if_in:NnT \l_stex_get_symbol_name_str / { + \str_set:Nx \l_stex_get_symbol_name_str { + \exp_after:wN \_stex_split_slash: \l_stex_get_symbol_name_str + /\_stex_args_end: + } + } + \tl_clear:N \l_stex_current_term_tl + \def\comp{\_comp} + \let\compemph@uri#2 + #3{}{}{\comp{#1}} + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} + } + \group_end: +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Highlighting} +% \begin{macrocode} +%<@@=stex_notationcomps> +% \end{macrocode} +% +% \begin{macro}{\comp,\compemph@uri,\compemph,\defemph,\defemph@uri,\symrefemph,\symrefemph@uri,\varemph,\varemph@uri} +% \begin{macrocode} +\cs_new_protected:Nn \_do_comp:nNn { + \stex_pseudogroup_with:nn{\comp}{ + \def\comp##1{##1} + \str_if_empty:NTF \l_stex_current_symbol_str { + #3 + }{ + \stex_if_html_backend:TF { + \stex_annotate:nn { shtml:#1 = \l_stex_current_symbol_str}{ #3 } + }{ + \exp_args:Nno #2 { #3 } \l_stex_current_symbol_str + } + } + } +} + +\cs_new_protected:Npn \_comp { + \_do_comp:nNn {comp}\compemph@uri +} + +\cs_new_protected:Npn \_varcomp { + \_do_comp:nNn {varcomp}\varemph@uri +} + +\cs_new_protected:Npn \_defcomp { + \_do_comp:nNn {definiendum}\defemph@uri +} + +\cs_set_protected:Npn \comp {} + +\cs_new_protected:Npn \compemph@uri #1 #2 { + \compemph{ #1 } +} + +\cs_new_protected:Npn \compemph #1 { + #1 +} + +\cs_new_protected:Npn \defemph@uri #1 #2 { + \defemph{#1} +} + +\cs_new_protected:Npn \defemph #1 { + \ifmmode\else\expandafter\textbf\fi{#1} +} + +\cs_new_protected:Npn \symrefemph@uri #1 #2 { + \symrefemph{#1} +} + +\cs_new_protected:Npn \symrefemph #1 { + \emph{#1} +} + +\cs_new_protected:Npn \varemph@uri #1 #2 { + \varemph{#1} +} + +\cs_new_protected:Npn \varemph #1 { + #1 +} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \end{sfragment} +% +% \end{sfragment} +% +% \begin{sfragment}{Mathematical Structures} +% \begin{macrocode} +%<@@=stex_structures> +% \end{macrocode} +% +% \begin{macro}{\this} +% \begin{macrocode} +\cs_new_protected:Npn \stex_current_this: { + { \bool_set_true:N \l_stex_allow_semantic_bool + \tl_if_empty:NTF \l_stex_current_this_tl {{}}{ + \str_set:Nx \l_stex_current_symbol_str { + \l_stex_current_module_str ? \l_@@_name_str + } + \maincomp{\l_stex_current_this_tl} + } + } +} +\let \this \stex_current_this: +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{mathstructure} +% \begin{macrocode} +\stex_new_stylable_env:nnnnnnn {mathstructure}{m O{}}{ + \_@@_begin:nn{#1}{#2} + \stex_smsmode_do: +}{ + \stex_structural_feature_module_end: + \_@@_do_externals: +}{}{}{} + +\stex_keys_define:nnnn{mathstructure}{ + \tl_clear:N \l_stex_current_this_tl + \str_clear:N \l_@@_name_str +}{ + this .tl_set:N = \l_stex_current_this_tl , + unknown .code:n = { + \str_set_eq:NN \l_@@_name_str \l_keys_key_str + } +}{} + +\cs_new_protected:Nn \_@@_begin:nn { + \stex_keys_set:nn {mathstructure}{#2} + \str_if_empty:NT \l_@@_name_str { + \str_set:Nn \l_@@_name_str {#1} + } + \def\comp{\_comp} + + \exp_args:Nne \use:nn { \stex_module_add_symbol:nnnnnnnN } + { {#1}{\l_@@_name_str}{0}{}{defed}{ + \l_stex_current_module_str / \l_@@_name_str-module + }} + {}\stex_invoke_structure: + \str_set:Nx \l_stex_macroname_str {#1} + \stex_execute_in_module:x{ + \seq_clear:c{l_stex_structure_macros_\l_stex_current_module_str / \l_@@_name_str-module_seq} + \seq_put_right:cn{l_stex_structure_macros_\l_stex_current_module_str / \l_@@_name_str-module_seq}{#1} + } + \exp_args:No \stex_structural_feature_module:nn + {\l_@@_name_str}{structure} +} + +\stex_sms_allow_env:n{mathstructure} +\stex_deactivate_macro:Nn \mathstructure {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \mathstructure} + +\cs_new_protected:Nn \_@@_do_externals: { + \tl_set:Nn \l_@@_replace_this_tl {####1} + \exp_args:No \stex_iterate_symbols:nn{\g_stex_last_feature_str}{ + \_@@_external_decl:nnnn{##5}{##4}{##3}{##8} + } +} + +\cs_new_protected:Nn \_@@_external_decl:nnnn { + %\stex_debug:nn{structure}{ + % Generating~external~declaration~\l_@@_name_str/#3~in~ + % \l_stex_current_module_str^^J + % \tl_to_str:n{#1}^^J\tl_to_str:n{#2}^^J\tl_to_str:n{#4} + %} + %\tl_set:Nn \l_stex_get_symbol_args_tl {#1} + %\exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN} { + % {}{\l_@@_name_str/#3}{\int_eval:n{#2 + 1}} + % {1i\tl_if_empty:nF{#1}{\_stex_map_args:N \_@@_shift_argls:nn}} + % {defed}{typed} + %}{#4}\stex_invoke_outer_field: +} + +\cs_new:Nn \_@@_shift_argls:nn { + \int_eval:n{#1+1}#2 +} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\stex_get_mathstructure:n} +% \begin{macrocode} +\cs_new_protected:Nn \stex_get_mathstructure:n { + \_stex_get_mathstructure:n{#1} + \str_if_empty:NT \l_stex_get_structure_module_str { + \msg_error:nnn{stex}{error/unknownstructure}{#1} + } +} +\cs_new_protected:Nn \_stex_get_mathstructure:n { + \str_clear:N \l_stex_get_structure_module_str + \_stex_get_symbol:n{#1} + \str_if_empty:NF \l_stex_get_symbol_name_str { + \exp_args:No \tl_if_eq:NNT \l_stex_get_symbol_invoke_cs \stex_invoke_structure: { + \str_set_eq:NN \l_stex_get_structure_module_str \l_stex_get_symbol_type_tl + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{extstructure} +% \begin{macrocode} +\stex_new_stylable_env:nnnnnnn {extstructure}{m O{} m}{ + \seq_clear:N \l_@@_imports_seq + \clist_map_inline:nn{#3}{ + \stex_get_mathstructure:n{##1} + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{####1}}{ + \seq_put_right:Nn \l_@@_imports_seq{####1} + } + } + \stex_execute_in_module:x{ + \seq_put_right:cn{l_stex_structure_macros_\l_stex_get_structure_module_str _seq}{#1} + } + } + \_@@_begin:nn{#1}{#2} + \seq_map_inline:Nn\l_@@_imports_seq{ + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:import={##1}} {}} + } + \stex_module_add_morphism:nonn + {}{##1}{import}{} + \stex_execute_in_module:x{ + \stex_activate_module:n{##1} + } + } + \stex_smsmode_do: +}{ + \stex_structural_feature_module_end: + \_@@_do_externals: +}{}{}{} + +\stex_sms_allow_env:n{extstructure} +\stex_deactivate_macro:Nn \extstructure {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \extstructure +} + +\cs_new:Nn \_@@_extend_structure_i:NnnnnnnnN { + \exp_not:n{#1{#2}{#3}{#4}{#5}{defed}}{\l_@@_extmod_str,#7}\exp_not:n{{#8}#9} +} +\cs_new_protected:Nn \_@@_extend_structure:nn { + \stex_debug:nn{ext}{Extending~#1~by~#2} + \str_set:Nn \l_@@_extmod_str{#2} + \tl_set:cx{#1}{ + \exp_after:wN \exp_after:wN \exp_after:wN + \_@@_extend_structure_i:NnnnnnnnN \cs:w #1 \cs_end: + } +} + +\stex_new_stylable_env:nnnnnnn {extstructure*}{m}{ + \_@@_new_extstruct_name: + \seq_clear:N \l_@@_imports_seq + \stex_get_mathstructure:n{#1} + + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{##1}}{ + \seq_put_right:Nn \l_@@_imports_seq{##1} + } + } + + \stex_execute_in_module:x{ + \seq_map_inline:cn{l_stex_structure_macros_\l_stex_get_structure_module_str _seq}{ + \exp_not:N \tl_if_exist:cT{####1}{ + \_@@_extend_structure:nn{####1}{\l_stex_current_module_str/\l_@@_exstruct_name_str -module} + } + } + } + + \exp_args:No \_@@_begin:nn\l_@@_exstruct_name_str{} + + \seq_map_inline:Nn \l_@@_imports_seq { + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import= {##1}} {} + } + \stex_module_add_morphism:nonn + {}{##1}{import}{} + \stex_execute_in_module:x{ + \stex_activate_module:n{##1} + } + } + + \stex_smsmode_do: +}{ + \prop_map_inline:cn{ + c_stex_module_ \l_stex_current_module_str _symbols_prop + }{ + \_@@_check_def:nnnnnnnn ##2 + } + \stex_structural_feature_module_end: + \_@@_do_externals: +}{}{}{} + +\stex_sms_allow_env:n{extstructure*} +\exp_after:wN \stex_deactivate_macro:Nn + \cs:w extstructure*\cs_end: {module~environments} +\stex_every_module:n { + \exp_after:wN \stex_reactivate_macro:N \cs:w extstructure*\cs_end: +} + +\cs_new_protected:Nn \_@@_check_def:nnnnnnnn { + \tl_if_empty:nT{#5}{ + \msg_error:nnnn{stex}{error/needsdefiniens}{#2}{extstructure*} + } +} + +\stex_every_module:n{ \str_set:Nn \l_@@_extname_count 0} + +\cs_new_protected:Nn \_@@_new_extstruct_name: { + \stex_do_up_to_module:n { + \str_set:Nx \l_@@_extname_count {\int_eval:n{\l_@@_extname_count+1}} + } + \str_set:Nx \l_@@_exstruct_name_str {EXTSTRUCT_\l_@@_extname_count} +} + +% \end{macrocode} +% \end{environment} +% +% Invoking structures: +% \begin{macrocode} +\cs_new_protected:Nn \stex_invoke_structure: { + \tl_set:Nn \l_@@_set_comp_tl {\_@@_set_thiscomp:} + \_@@_invoke_top:n {} +} + +\cs_new_protected:Nn \_@@_invoke_top:n { + \stex_debug:nn{structure}{ + invoking~structure~{\l_stex_current_type_tl}<\tl_to_str:n{#1}> + } + \peek_charcode:NTF [ { + \_@@_merge:nw{#1} + }{ + \_@@_invokation_type:n {#1} + \tl_set:Nn \l_@@_this_tl {} + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ { + \_@@_maybe_notation:w + }{ + \_@@_maybe_notation:w [] + } + }{ + \_@@_invoke_this:n + } + } +} + +\cs_new_protected:Npn \_@@_merge:nw #1 [ #2 ] { + \exp_args:Ne \stex_str_if_starts_with:nnTF {\tl_to_str:n{#2}}{comp=}{ + \_@@_set_customcomp: #2 \_@@_end: + \_@@_invoke_top:n{#1} + }{ + \exp_args:Ne \stex_str_if_starts_with:nnTF {\tl_to_str:n{#2}}{this=}{ + \_@@_set_thisnotation: #2 \_@@_end: + \_@@_invoke_top:n{#1} + }{ + \tl_if_empty:nTF{#1}{ + \_@@_invoke_top:n{#2} + }{ + \tl_if_empty:nTF{#2}{ + \_@@_invoke_top:n{#1} + }{ + \_@@_invoke_top:n{#1,#2} + } + } + } + } +} + +\cs_new_protected:Npn \_@@_set_thisnotation: this= #1 \_@@_end: { + \tl_set:Nn \l_stex_return_notation_tl { \comp{#1} } + \tl_set:Nn \l_@@_set_comp_tl {} +} + +\cs_new_protected:Npn \_@@_set_customcomp: comp= #1 \_@@_end: { + \tl_set:Nn \l_@@_set_comp_tl { + \_@@_set_custom_comp:n{#1} + } + \tl_set:Nn \l_stex_return_notation_tl { \comp{} } +} +% \end{macrocode} +% The structure type: +% \begin{macrocode} +\cs_new_protected:Nn \_@@_invokation_type:n { + \_@@_do_assign_list:n{#1} + \clist_if_empty:NTF \l_@@_fields_clist { + \int_compare:nNnTF {\clist_count:N \l_stex_current_type_tl} + = 1 { + \tl_set:Nx \l_@@_current_type_tl { + \exp_args:No \exp_not:n \l_stex_current_redo_tl + \_stex_term_oms_or_omv:nnn{}{}{} + } + }{ + \exp_args:No \_@@_make_type:n \l_stex_current_type_tl + } + }{ + \int_compare:nNnTF {\clist_count:N \l_stex_current_type_tl} + = 1 { + \_@@_make_type:n {} + }{ + \exp_args:No \_@@_make_type:n \l_stex_current_type_tl + } + } +} + +\cs_new_protected:Nn \_@@_do_assign_list:n { + \clist_clear:N \l_@@_fields_clist + \tl_if_empty:nF {#1} { + \keyval_parse:NNn\TODO\_@@_do_assign:nn{#1} + } +} + +\cs_new_protected:Nn \_@@_do_assign:nn { + \clist_put_right:Nn \l_@@_fields_clist {{#1}{#2}} +} + +\cs_new_protected:Nn \_@@_make_type:n { + \tl_if_empty:nTF{#1}{ + \seq_clear:N \l_tmpa_seq + }{ + \seq_set_split:Nnn \l_tmpa_seq ,{#1} + \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl + \seq_reverse:N \l_tmpa_seq + } + \tl_set:Nx \l_@@_current_type_tl { + \symuse{Metatheory?module~type~merge}{ + { + \exp_args:No \exp_not:n \l_stex_current_redo_tl + \_stex_term_oms_or_omv:nnn{}{}{} + } + \seq_map_function:NN \l_tmpa_seq \_@@_make_mod:n + \clist_if_empty:NF \l_@@_fields_clist { + ,\symuse{Metatheory?anonymous~record}{ + \exp_args:Ne \tl_tail:n{ + \clist_map_function:NN \l_@@_fields_clist \_@@_make_oml:n + } + } + } + } + } +} + +\cs_new:Nn \_@@_make_mod:n { + ,\symuse{Metatheory?module~type}{ + \stex_annotate:nn{shtml:term=OMMOD,shtml:head={#1}}{} + } +} + +\cs_new:Nn \_@@_make_oml:n { + \_@@_make_oml:nn #1 +} +\cs_new:Nn \_@@_make_oml:nn { + ,\stex_annotate:nn{ + shtml:term=OML, + shtml:head={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate:nn{shtml:definiens={}}{\exp_not:n{#2!}} + } + } +} +% \end{macrocode} +% Insert the structure type as a term: +% \begin{macrocode} +\cs_new:Nn \_@@_current_type: { + %\exp_args:No \exp_not:n \l_stex_current_redo_tl + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \exp_args:No\exp_not:n\l_@@_current_type_tl + } + \_stex_term_oms_or_omv:nnn{}{}{} +} +% \end{macrocode} +% The structure type itself: +% \begin{macrocode} +\cs_new_protected:Npn \_@@_maybe_notation:w [ #1 ] { + \tl_set_eq:NN \l_stex_current_term_tl \l_@@_current_type_tl + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \use:c{l_stex_notation_\l_stex_current_symbol_str _#1_cs}\group_end: + }{ + \_@@_make_prop: + \_@@_make_prop_assign: + \_@@_present_i:w [#1] + } +} + +\cs_new_protected:Nn \_@@_present: { + \peek_charcode:NTF [ { + \_@@_present_i:w + }{ + \_@@_present:nn{}{} + } +} + +\cs_new_protected:Npn \_@@_present_i:w [#1] { + \int_compare:nNnTF{\clist_count:n{#1}} = 1 { + \_@@_present:nn{}{#1} + }{ + \peek_charcode:NTF [ { + \_@@_present_ii:nw{#1} + }{ + \_@@_present:nn{#1}{} + } + } +} + +%First: clist, second:notation-id +\cs_new_protected:Npn \_@@_present_ii:nw #1 [#2] { + \_@@_present:nn{#1}{#2} +} + +\cs_new_protected:Nn \_@@_present:nn { + \clist_clear:N \l_@@_clist + \tl_if_empty:nTF{#1}{ + \cs_set:Npn \l_@@_cs ##1 ##2 ##3 { + \tl_if_empty:nF{##2}{ + \_@@_present_entry:nn {##1}{##3} + } + } + }{ + \cs_set:Npn \l_@@_cs ##1 ##2 ##3 { + \exp_args:Ne \clist_if_in:nnT{\tl_to_str:n{#1}}{##1}{ + \_@@_present_entry:nn {##1}{##3} + } + } + } + \prop_map_inline:Nn \l_@@_prop { + \l_@@_cs {##1} ##2 + } + \_stex_term_oms_or_omv:nnn{}{}{ + \exp_args:Nno \use:n{ + \bool_set_true:N \l_stex_allow_semantic_bool + \symuse{Metatheory?mathematical~structure}[#2] + }{\l_@@_clist} + }\group_end: +} + +\cs_new_protected:Nn \_@@_present_entry:nn { + \seq_if_in:NnTF \l_@@_assigned_seq {#1}{ + \clist_put_right:Nn \l_@@_clist {#2!} + }{ + \exp_args:NNe \clist_put_right:Nn \l_@@_clist { + \_stex_next_symbol:n { + \exp_args:No \exp_not:n \l_@@_set_comp_tl + \tl_set:Nn \exp_not:N \l_@@_this_tl { + \exp_args:No \exp_not:n \l_@@_this_tl + } + \exp_not:n { + \tl_set_eq:NN \this \l_@@_this_tl + } + \tl_set:Nn \exp_not:N \l_stex_return_notation_tl { + \exp_args:No \exp_not:n \l_stex_return_notation_tl + } + } + \exp_not:n{#2!} + } + } +} + +\cs_new_protected:Npn \_thiscomp #1 #2 { + {\tl_set:cn{this}{{}}#1{#2}\c_math_subscript_token{ + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \l_@@_this_tl + \group_end: + } + } +} + +\cs_new_protected:Nn \_@@_set_thiscomp: { + \exp_args:Ne \tl_if_eq:NNF {\tl_head:N \maincomp} \_thiscomp { + \edef\maincomp {\_thiscomp{\comp}} + } +} + +\cs_new_protected:Nn \_@@_set_custom_comp:n { + \exp_args:Ne \tl_if_eq:NNF {\tl_head:N \maincomp} \_customthiscomp { + \cs_set_protected:Npx \_customthiscomp ##1 { + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \exp_not:n{ + \cs_set:Npn \l_@@_comp_cs ##1 { + #1 + } + \def\maincomp + }{\comp} + \exp_not:N\l_@@_comp_cs{\comp{##1}} + \group_end: + } + \def\maincomp {\_customthiscomp} + } +} + +% \end{macrocode} +% |this| (of type |structure|): +% \begin{macrocode} + +\cs_new_protected:Nn \_@@_invoke_this:n { + \peek_charcode_remove:NTF ! { + \exp_args:Nne\use:nn{ + \group_end:\symuse{Metatheory?of~type}[invisible]{#1} + }{ + {\_@@_current_type:} + } + }{ + \_@@_invoke_maybe_field:nn{#1} + } +} + +\cs_new_protected:Nn \_@@_invoke_maybe_field:nn { + \_@@_make_prop: + \_@@_set_this:n{#1} + \tl_if_empty:nTF{#2}{ + \_@@_make_prop_assign: + \_@@_present: + }{ + \_@@_invoke_field:n{#2} + } +} + +\cs_new_protected:Nn \_@@_set_this:n { + \tl_if_empty:nTF{#1}{ + %\tl_put_right:Nn \l_stex_current_redo_tl { + % \tl_clear:N \l_@@_this_tl + %} + }{ + \tl_set:Nx \l_@@_this_tl {{ + \bool_set_true:N \l_stex_allow_semantic_bool + \tl_set:Nn \exp_not:N \this { + \exp_args:No \exp_not:n \this + } + \exp_not:n{#1} + }} + \tl_set_eq:NN \this \l_@@_this_tl + % \l_stex_return_notation_tl + } +} + +\cs_new_protected:Nn \_@@_get_field_name:n { + \str_set:Nx \l_@@_field_name_str { + \exp_args:Nne \use:n {\exp_after:wN \use_i:nn \use:n} + {\prop_item:Nn \l_@@_prop {#1}} + } + \str_if_empty:NT \l_@@_field_name_str { + \str_set:Nn \l_@@_field_name_str {#1} + } +} + +\cs_new_protected:Nn \_@@_invoke_field:n { + \prop_if_in:NnTF \l_@@_prop {#1}{ + \_@@_get_field_name:n{#1} + \tl_clear:N \l_@@_more_nextsymbol_tl + %\exp_args:NNe \seq_if_in:NnF \l_@@_assigned_seq {\tl_to_str:n{#1}}{ + \tl_set:Nx \l_@@_more_nextsymbol_tl { + \tl_set:Nn \exp_not:N \l_@@_this_tl { + \exp_args:No \exp_not:n \l_@@_this_tl + } + \exp_not:n { + \tl_set_eq:NN \this \l_@@_this_tl + } + \tl_set:Nn \exp_not:N \l_stex_return_notation_tl { + \exp_args:No \exp_not:n \l_stex_return_notation_tl + } + \exp_args:No \exp_not:n \l_@@_set_comp_tl + } + %} + \exp_args:NNx \use:nn \group_end: { + \_stex_next_symbol:n { + \exp_args:No \exp_not:n \l_@@_redo_tl + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \symuse{Metatheory?record~field}{ + \symuse{Metatheory?of~type}{ + \exp_args:No \exp_not:n \l_@@_this_tl + }{ \_@@_current_type: } + }{ + \stex_annotate:nn{shtml:term=OML,shtml:head={\l_@@_field_name_str}}{} + } + } + \exp_args:No \exp_not:n \l_@@_more_nextsymbol_tl + } + \exp_not:N \use_ii:nn + \prop_item:Nn \l_@@_prop {#1} + } + }{ + \msg_error:nnn{stex}{error/unknownfield}{#1} + } +} + +\cs_new_protected:Nn \_@@_make_prop: { + \prop_clear:N \l_@@_prop + \seq_clear:N \l_@@_seq + \seq_clear:N \l_@@_assigned_seq + \tl_clear:N \l_@@_redo_tl + \_@@_prop_do_decls: + \_@@_prop_do_notations: +} + +\cs_new_protected:Nn \_@@_make_prop_assign: { + \clist_if_empty:NF \l_@@_fields_clist { + \clist_map_inline:Nn \l_@@_fields_clist { + \_@@_make_prop_assign:nn ##1 + } + } +} + +\cs_new_protected:Nn \_@@_make_prop_assign:nn { + \prop_if_in:NnTF \l_@@_prop {#1}{ + \exp_args:NNe \seq_put_right:Nn \l_@@_assigned_seq {\tl_to_str:n{#1}} + \exp_args:Nne \use:nn {\_@@_make_prop_assign_replace:nnnn {#1}{#2}} + {\prop_item:Nn \l_@@_prop {#1}} + }{ + \msg_error:nnn{stex}{error/unknownfieldass}{#1} + } +} +\cs_new_protected:Nn \_@@_make_prop_assign_replace:nnnn { + \prop_put:Nnn \l_@@_prop {#1}{{#3}{#2}} + \tl_if_empty:nF{#3}{ + \tl_set:cn{#1}{ #2 } + \tl_put_right:Nn \l_@@_redo_tl { + \tl_set:cn{#1}{ #2 } + } + } +} + +\cs_new_protected:Nn \_@@_prop_do_decls: { + \exp_args:No \stex_iterate_symbols:nn \l_stex_current_type_tl { + \tl_if_empty:nTF{##2}{ + \_@@_do_decl_nomacro:nnnnnnnnn{##3} + }{ + \_@@_do_decl:nnnnnnnnn{##2} + } + {##1}{##3}{##4}{##5}{##6}{##7}{##8}{##9} + } +} + +\cs_new_protected:Nn \_@@_do_decl_nomacro:nnnnnnnnn { + \prop_if_in:NnF \l_@@_prop {#1} { + \seq_put_left:Nx \l_@@_seq {\tl_to_str:n{#2?#3}} + \prop_put:Nnn \l_@@_prop {#1}{ + {}{ + \_stex_invoke_symbol:nnnnnnnN + {#2} + {#3} + {#4}{#5}{#6}{#7}{#8}#9 + } + } + } +} + +\cs_new_protected:Nn \_@@_do_decl:nnnnnnnnn { + \prop_if_in:NnF \l_@@_prop {#1} { + \seq_put_left:Nx \l_@@_seq {\tl_to_str:n{#2?#3}} + \prop_put:Nnn \l_@@_prop {#1}{ + {#3}{ + \_stex_invoke_symbol:nnnnnnnN + {#2} + {#3} + {#4}{#5}{#6}{#7}{#8}#9 + } + } + } + %\tl_set:cn{#1}{ + % \_stex_invoke_symbol:nnnnnnnN + % {#2}{#3}{#4}{#5}{#6}{#7}{#8}#9 + %} + %\tl_put_right:Nn \l_@@_redo_tl { + % \tl_set:cn{#1}{ + % \_stex_invoke_symbol:nnnnnnnN + % {#2}{#3}{#4}{#5}{#6}{#7}{#8}#9 + % } + %} +} + +\cs_new_protected:Nn \_@@_prop_do_notations: { + \exp_args:No \stex_iterate_notations:nn\l_stex_current_type_tl{ + \exp_args:NNe \seq_if_in:NnT \l_@@_seq {\tl_to_str:n{##1}}{ + \tl_put_right:Nn \l_@@_redo_tl { + \cs_if_exist:cF{l_stex_notation_##1 _##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _##2_cs}{##4} + } + \cs_if_exist:cF{l_stex_notation_##1 __cs}{ + \tl_set:cn{l_stex_notation_##1 __cs}{##4} + } + } + \cs_if_exist:cF{l_stex_notation_##1 _##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _##2_cs}{##4} + } + \cs_if_exist:cF{l_stex_notation_##1 __cs}{ + \tl_set:cn{l_stex_notation_##1 __cs}{##4} + } + \tl_if_empty:nF{##5}{ + \tl_put_right:Nn \l_@@_redo_tl { + \cs_if_exist:cF{l_stex_notation_##1 _op_##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _op_##2_cs}{##5} + } + \cs_if_exist:cF{l_stex_notation_##1 _op__cs}{ + \tl_set:cn{l_stex_notation_##1 _op__cs}{##5} + } + } + \cs_if_exist:cF{l_stex_notation_##1 _op_##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _op_##2_cs}{##5} + } + \cs_if_exist:cF{l_stex_notation_##1 _op__cs}{ + \tl_set:cn{l_stex_notation_##1 _op__cs}{##5} + } + } + } + } +} +% \end{macrocode} +% +% \begin{macro}{\usestructure} +% \begin{macrocode} +\cs_new_protected:Npn \usestructure #1 { + \stex_get_mathstructure:n{ #1 } + \seq_clear:N \l_@@_imports_seq + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{##1}}{ + \seq_put_right:Nn \l_@@_imports_seq{##1} + } + } + \seq_map_inline:Nn \l_@@_imports_seq { + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:usemodule=##1} {}} + } + \stex_activate_module:n {##1} + } +} +% \end{macrocode} +% +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Statements} +% \begin{macrocode} +%<@@=stex_statements> + +\stex_keys_define:nnnn{statement}{ + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_macroname_str + \clist_clear:N \l_stex_key_for_clist + \str_clear:N \l_stex_key_args_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl + \tl_clear:N \l_stex_key_return_tl + \clist_clear:N \l_stex_key_argtypes_clist +}{ + name .str_set:N = \l_stex_key_name_str , + for .clist_set:N = \l_stex_key_for_clist , + macro .str_set:N = \l_stex_key_macroname_str , + % start .str_set:N = \l_stex_key_title_str , % TODO remove + type .tl_set:N = \l_stex_key_type_tl , + judgment .code:n = {}, + from .code:n= {}, % TODO remove + to .code:n={} % TODO remove +}{id,title,style,symargs} +% \end{macrocode} +% +% \begin{macro}{\stex_new_statement:nn} +% \begin{macrocode} +\cs_new_protected:Npn \_stex_do_for_list: { + \seq_clear:N \l_stex_fors_seq + \clist_map_inline:Nn \l_stex_key_for_clist { + \exp_args:Ne\stex_get_symbol:n{\tl_to_str:n{##1}} + \seq_put_right:Nx \l_stex_fors_seq + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } +} + +\cs_new_protected:Nn \_@@_setup:nn { + \str_if_empty:NF \l_stex_key_macroname_str { + \str_if_empty:NT \l_stex_key_name_str { + \str_set_eq:NN \l_stex_key_name_str \l_stex_key_macroname_str + } + } + \_stex_do_for_list: + \str_if_empty:NF \l_stex_key_name_str { + \_@@_force_id: + \seq_put_right:Nx \l_stex_fors_seq { + \l_stex_current_module_str ? \l_stex_key_name_str + } + \str_set_eq:NN \l_stex_macroname_str \l_stex_key_macroname_str + \str_set:Nn \l_stex_key_role_str {#2} + \stex_symdecl_do: + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_key_macroname_str}{\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {#1}{}{}\stex_invoke_symbol: + } + \stex_if_do_html:T \_stex_symdecl_html: + } + \str_clear:N \l_@@_uri_str + \str_if_empty:NTF \l_stex_key_name_str { + \stex_debug:nn{statement}{no~name} + \int_compare:nNnTF {\seq_count:N \l_stex_fors_seq} = 1 { + \str_set:Nx \l_@@_uri_str {\seq_item:Nn \l_stex_fors_seq 1} + \stex_debug:nn{statement}{for:~\l_@@_uri_str} + }{ + \stex_debug:nn{statement}{no~for} + } + }{ + \str_set:Nx \l_@@_uri_str {\l_stex_current_module_str ? \l_stex_key_name_str} + \stex_debug:nn{statement}{name:~\l_@@_uri_str} + } +} + +\cs_new:Nn \_@@_html_keyvals:nn { + shtml:#1={}, + shtml:inline={#2}, + \seq_if_empty:NF \l_stex_fors_seq {, + shtml:fors={\seq_use:Nn \l_stex_fors_seq ,} + } + \str_if_empty:NF \l_stex_key_id_str {, + shtml:id={\stex_uri_use:N \l_stex_current_doc_uri ? \l_stex_key_id_str} + } + \clist_if_empty:NF \l_stex_key_style_clist {, + shtml:styles={\l_stex_key_style_clist} + } +} + +\cs_new_protected:Nn \stex_new_statement:nnn { + \stex_new_stylable_env:nnnnnnn {#1}{O{}}{ + \stex_keys_set:nn{statement}{##1} + #3 + + \stex_if_smsmode:F { + \exp_args:Nne \begin{stex_annotate_env}{ + \_@@_html_keyvals:nn{#1}{false} + } + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \str_set_eq:NN \thisname \l_stex_key_name_str + \clist_set_eq:NN \thisfor \l_stex_key_for_str + \stex_if_html_backend:TF { + \noindent + \stex_annotate:nn{shtml:statementtitle={}}{\_stex_annotate_force_break:n\l_stex_key_title_tl} + } + \stex_style_apply: + } + \_stex_do_id: + \stex_smsmode_do: + }{ + \stex_if_smsmode:F { + \stex_if_html_backend:F \stex_style_apply: + \end{stex_annotate_env} + } + }{}{}{s} + \stex_sms_allow_env:n{s#1} + + \tl_if_empty:nF{#2}{ + \exp_after:wN \NewDocumentCommand \cs:w inline#2\cs_end: { O{} m}{ + \group_begin: + \stex_keys_set:nn{statement}{##1} + #3 + \_stex_do_id: + \stex_if_smsmode:F{ + \exp_args:Ne \stex_annotate:nn{\_@@_html_keyvals:nn{#1}{true}}{ + \_stex_annotate_force_break:n{##2} + } + } + \group_end: + \stex_smsmode_do: + } + \exp_after:wN \stex_sms_allow_escape:N\cs:w inline#2\cs_end: + } +} + +\cs_new_protected:Nn \_@@_setup_def: { + \stex_if_smsmode:F{ + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_ref_new_sym_target:n{##1} + } + } + \stex_reactivate_macro:N \definiendum + \stex_reactivate_macro:N \defnotation + \stex_reactivate_macro:N \definame + \stex_reactivate_macro:N \Definame + \stex_reactivate_macro:N \varbind +} + +\cs_new_protected:Nn \_@@_force_id: { + \str_if_empty:NT \l_stex_key_id_str { + \_stex_ref_new_id:n{} + \str_set_eq:NN \l_stex_key_id_str \l__stex_refs_str + } +} + +\stex_new_statement:nnn{definition}{def}{ + \_@@_force_id: + \_@@_setup:nn{}{} + \_@@_setup_def: + \stex_reactivate_macro:N \definiens +} +\stex_new_statement:nnn{assertion}{ass}{ + \_@@_setup:nn{}{assertion} + \stex_if_smsmode:F{ + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_ref_new_sym_target:n{##1} + } + } + \stex_reactivate_macro:N \varbind + \stex_reactivate_macro:N \conclusion + \stex_reactivate_macro:N \premise + \stex_reactivate_macro:N \definiendum + \stex_reactivate_macro:N \defnotation + \stex_reactivate_macro:N \definame + \stex_reactivate_macro:N \Definame +} +\stex_new_statement:nnn{example}{ex}{\_@@_setup:nn{}{example}} +\stex_new_statement:nnn{paragraph}{}{ + \clist_if_in:NnTF \l_stex_key_style_clist {symdoc}{ + \_@@_force_id: + \_@@_setup:nn{}{} + \_@@_setup_def: + }{ + \_@@_setup:nn{}{} + } +} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{definiendum} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_do_defref:nn { + \stex_if_html_backend:T{\ifvmode\indent\fi} + \group_begin: + \stex_get_symbol:n{#1} + \bool_if:NTF \l_stex_allow_semantic_bool{ + \str_set:Nx\l_stex_current_symbol_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \str_if_in:NnT \l_stex_get_symbol_name_str / { + \str_set:Nx \l_stex_get_symbol_name_str { + \exp_after:wN \_stex_split_slash: \l_stex_get_symbol_name_str + /\_stex_args_end: + } + } + \exp_args:No \stex_ref_new_sym_target:n \l_stex_current_symbol_str + \def\comp{\_defcomp} + \stex_annotate:nn{shtml:definiendum=\l_stex_current_symbol_str}{\comp{#2}} + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} + } + \group_end: +} + +\NewDocumentCommand \defnotation{ m } { + \_stex_next_symbol:n { \def\comp{\_defcomp}}#1 +} +\stex_deactivate_macro:Nn \defnotation {definition~environments} + +\NewDocumentCommand \definiendum { O{} m m} { + \stex_keys_set:nn{symname}{ #1 } + \_@@_do_defref:nn{#2}{#3} +} +\stex_deactivate_macro:Nn \definiendum {definition~environments} + +\NewDocumentCommand \definame { O{} m } { + \stex_keys_set:nn{symname}{#1} + \_@@_do_defref:nn{#2}{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + } +} +\stex_deactivate_macro:Nn \definame {definition~environments} + +\NewDocumentCommand \Definame { O{} m } { + \stex_keys_set:nn{symname}{#1} + \_@@_do_defref:nn{#2}{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + } +} +\stex_deactivate_macro:Nn \Definame {definition~environments} + + +\NewDocumentCommand \definiens { O{} m }{ + \group_begin: + \str_clear:N \l_stex_get_symbol_name_str + \tl_if_empty:nF {#1} { + \stex_get_symbol:n { #1 } + \str_set:Nx \l_@@_uri_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \str_if_empty:NT \l_@@_uri_str { + \msg_error:nn{stex}{error/definiensfor} + } + \stex_debug:nn{definiens}{Checking~\l_@@_uri_str} + + \exp_args:No \_stex_add_definiens:nn \l_@@_uri_str{#2} + + \group_end: + \stex_smsmode_do: +} +\stex_deactivate_macro:Nn \definiens {definition~environments} +\stex_sms_allow_escape:N \definiens + +\cs_new_protected:Nn \_stex_add_definiens:nn { + \exp_args:Nno \stex_str_if_starts_with:nnT{#1} \l_stex_current_module_str { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _symbols_prop}{ + \stex_debug:nn{definiens}{#1 == \l_stex_current_module_str?##1} + \str_if_eq:noT {#1} {\l_stex_current_module_str?##1}{ + \prop_map_break:n{\_stex_add_definiens_inner:nnnnnnnn ##2} + } + } + } + \stex_if_smsmode:F{ + \stex_annotate:nn{ shtml:definiens={#1}}{ + #2 %\_stex_annotate_force_break:n{ #2 } + } + } +} + +\cs_new_protected:Nn \_stex_add_definiens_inner:nnnnnnnn { + \stex_debug:nn{definiens}{Adding~definiens~to~\l_stex_current_module_str?#2} + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _symbols_prop} + {#2}{{#1}{#2}{#3}{#4}{defed}{#6}{#7}{#8}} +} + +\NewDocumentCommand \varbind {m} { + \clist_map_inline:nn {#1} { + \stex_get_var:n {##1} + \stex_if_do_html:T { + \stex_annotate_invisible:nn {shtml:bind=\l_stex_get_symbol_name_str}{} + } + } +} +\stex_deactivate_macro:Nn \varbind {definition~or~assertion~environments} + +\NewDocumentCommand \conclusion { O{} m} { + \group_begin: + \str_clear:N \l_stex_get_symbol_name_str + \tl_if_empty:nF {#1} { + \stex_get_symbol:n { #1 } + \str_set:Nx \l_@@_uri_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \str_if_empty:NT \l_@@_uri_str { + \msg_error:nn{stex}{error/conclusionfor} + } + \stex_annotate:nn{ shtml:conclusion=\l_@@_uri_str}{ + #2 %\_stex_annotate_force_break:n{ #2 } + } + \group_end: +} +\stex_deactivate_macro:Nn \conclusion {assertion~environments} + +\NewDocumentCommand \premise {O{} m} { + \tl_if_empty:nF {#1} { + \stex_debug:nn{Here:}{Variable~#1} + \exp_args:NNx\exp_args:Nnx\vardef{v#1}{#1} + } + \stex_annotate:nn{shtml:premise={#1}}{#2} +} +\stex_deactivate_macro:Nn \premise {assertion~environments} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Proofs} +% +% We first define some keys for the \env{sproof} environment. +% \begin{macrocode} +%<@@=stex_proof> +\stex_keys_define:nnnn{ spf }{ + \tl_clear:N \l_stex_key_for_clist + \tl_clear:N \l_stex_key_from_tl + \tl_set_eq:NN \l_stex_key_proofend_tl \_@@_proof_box_tl + \tl_clear:N \l_stex_key_continues_tl + \tl_clear:N \l_stex_key_term_tl + \tl_clear:N \l_stex_key_functions_tl + \tl_clear:N \l_stex_key_method_tl + \bool_set_false:N \l_stex_key_hide_bool +}{ + for .clist_set:N = \l_stex_key_for_clist , + from .tl_set:N = \l_stex_key_from_tl , + proofend .tl_set:N = \l_stex_key_proofend_tl, + continues .tl_set:N = \l_stex_key_continues_tl, + functions .tl_set:N = \l_stex_key_functions_tl, + term .tl_set:N = \l_stex_key_term_tl, + method .tl_set:N = \l_stex_key_method_tl, + hide .bool_set:N = \l_stex_key_hide_bool +}{id,style,title} + +\bool_set_true:N \l_@@_inc_counter_bool +% \end{macrocode} +% +% For proofs, we will have to have deeply nested structures of enumerated list-like +% environments. However, {\LaTeX} only allows |enumerate| environments up to nesting depth +% 4 and general list environments up to listing depth 6. This is not enough for us. +% Therefore we have decided to go along the route proposed by Leslie Lamport to use a +% single top-level list with dotted sequences of numbers to identify the position in the +% proof tree. Unfortunately, we could not use his |pf.sty| package directly, since it does +% not do automatic numbering, and we have to add keyword arguments all over the place, to +% accomodate semantic information. +% +% \begin{macrocode} +\intarray_new:Nn\l_@@_counter_intarray{50} +\cs_new_protected:Npn \_@@_insert_number: { + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + } > 0 + }{ + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int . + \int_incr:N \l_tmpa_int + } +} +\cs_new_protected:Nn \_@@_number_as_string:N { + \str_clear:N #1 + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + } > 0 + }{ + \str_put_right:Nx #1 {\intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int .} + \int_incr:N \l_tmpa_int + } +} + +\cs_new_protected:Npn \_@@_inc_counter: { + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + } > 0 + }{ + \int_incr:N \l_tmpa_int + } + \int_compare:nNnF \l_tmpa_int = 1 { + \int_decr:N \l_tmpa_int + } + \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + 1 + } +} + +\cs_new_protected:Npn \_@@_add_counter: { + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + } > 0 + }{ + \int_incr:N \l_tmpa_int + } + \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { 1 } +} + +\cs_new_protected:Npn \_@@_remove_counter: { + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + } > 0 + }{ + \int_incr:N \l_tmpa_int + } + \int_decr:N \l_tmpa_int + \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { 0 } +} +% \end{macrocode} +% +% \begin{macro}{spfsketch} +% \begin{macrocode} +\newenvironment{spfsketchenv}{}{} +\stex_new_stylable_cmd:nnnn{spfsketch}{O{} m}{\par + \begin{spfsketchenv} + \stex_keys_set:nn{spf}{#1} + \_stex_do_for_list: + \_stex_do_id: + \exp_args:Ne \stex_annotate:nn{ + shtml:proofsketch={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , + } + } + }{ + \stex_style_apply: + #2 + } + \end{spfsketchenv} +}{ + \noindent\emph{\spfsketchenvautorefname :}~ +} +% \end{macrocode} +% \end{macro} +% +%\begin{macro}{\sproofend} +% This macro places a little box at the end of the line if there is space, or at the +% end of the next line if there isn't +% \begin{macrocode} +\tl_set:Nn \_@@_proof_box_tl { + \ltx@ifpackageloaded{amssymb}{$\square$}{ + \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} + } +} + +\tl_set:Nn \sproofend { + \tl_if_empty:NF \l_stex_key_proofend_tl { + \hfil\null\nobreak\hfill\l_stex_key_proofend_tl\par\smallskip + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stexcommentfont} +% \begin{macrocode} +\cs_new_protected:Npn \stexcommentfont { + \small\itshape +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{sproof} +% \begin{macrocode} +\cs_new_protected:Nn \_@@_start_list:n { + \begin{list}{}{ + \setlength\topsep{0pt} + \setlength\parsep{0pt} + \setlength\rightmargin{0pt} + }\item[#1] +} +\cs_new_protected:Nn \_@@_end_list: { + \end{list} +} + +\cs_new_protected:Nn \_@@_html: { + \stex_annotate_invisible:n{\hbox{ + \tl_if_empty:NF \l_stex_key_term_tl { + $\stex_annotate:nn{shtml:proofterm={}}{\l_stex_key_term_tl}$ + } + \tl_if_empty:NF \l_stex_key_method_tl { + \stex_annotate:nn{shtml:proofmethod={}}{\l_stex_key_method_tl} + } + }} +} + +\cs_new_protected:Nn \_@@_html_env:n { + \exp_args:Nne \begin{stex_annotate_env}{ + shtml:#1={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , + } + } + \bool_if:NT \l_stex_key_hide_bool {, + shtml:proofhide=true + } + } + \_@@_html: +} + +\bool_set_false:N \l_@@_in_spfblock_bool +\cs_new_protected:Nn \_@@_begin_proof:nn {\par + \intarray_gzero:N \l_@@_counter_intarray + \intarray_gset:Nnn \l_@@_counter_intarray 1 1 + \stex_keys_set:nn{spfsteps}{#1} + \_stex_do_for_list: + \stex_if_do_html:T { + \_@@_html_env:n{proof} + } + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_debug:nn{definiens}{Adding~definiens~to~##1} + \_stex_add_definiens:nn {##1}{\STEXinvisible{proven}} + } + \stex_style_apply: + \_stex_do_id: + \stex_reactivate_macro:N \subproof + \stex_reactivate_macro:N \spfstep + \stex_reactivate_macro:N \conclude + \stex_reactivate_macro:N \assumption + \stex_reactivate_macro:N \eqstep + \stex_reactivate_macro:N \yield + \stex_reactivate_macro:N \spfblock + \stex_reactivate_macro:N \spfjust + \stex_annotate:nn{shtml:prooftitle={}}{#2} + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:proofbody={}} + } +} +\stex_new_stylable_env:nnnnnnn{proof}{O{} m}{ + \_@@_begin_proof:nn{#1}{#2} + \bool_set_true:N\l_@@_in_spfblock_bool\_@@_start_list:n{} + \group_begin:\stexcommentfont +}{ + \stex_style_apply: + \stex_if_do_html:T{\end{stex_annotate_env}\end{stex_annotate_env}} +}{ + \emph{\sproofautorefname :}~ +}{ + \sproofend +}{s} +\AddToHook{env/sproof/end}{ + \bool_if:NT\l_@@_in_spfblock_bool { + \group_end:\_@@_end_list: + } +} + +\stex_new_stylable_env:nnnnnnn{proof*}{O{}}{ + \_@@_begin_proof:nn{#1}{} + \bool_set_false:N\l_@@_in_spfblock_bool +}{ + \stex_style_apply: + \stex_if_do_html:T{\end{stex_annotate_env}\end{stex_annotate_env}} +}{ + \emph{Proof:}~ +}{ + \sproofend +}{s} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{subproof} +% \begin{macrocode} +\str_set_eq:NN \subproofautorefname \spfstepautorefname +\stex_new_stylable_env:nnnnnnn{subproof}{s O{} m}{\par + \stex_keys_set:nn{spf}{#2} + \_stex_do_for_list: + \stex_if_do_html:T { + \_@@_html_env:n{subproof} + } + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_debug:nn{definiens}{Adding~definiens~to~##1} + \_stex_add_definiens:nn {##1}{\STEXinvisible{proven}} + } + + \IfBooleanTF #1 { + \stex_style_apply: + \str_if_empty:NF \l_stex_key_id_str { + \_@@_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{subproof.\@currentlabel} + \_stex_do_id: + } + \bool_set_false:N \l_@@_in_spfblock_bool + \stex_annotate:nn{shtml:prooftitle={}}{#3} + }{ + \bool_if:NTF \l_@@_in_spfblock_bool { + \str_if_empty:NF \l_stex_key_id_str { + \_@@_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{subproof.\@currentlabel} + \_stex_do_id: + } + \_@@_start_list:n\_@@_insert_number: + \stex_annotate:nn{shtml:prooftitle={}}{#3} + \_@@_add_counter: + \stex_style_apply: + }{ + \stex_annotate:nn{shtml:prooftitle={}}{#3} + \stex_style_apply: + \_stex_do_id: + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:proofbody={}} + } + \bool_if:NT \l_@@_in_spfblock_bool {\group_begin:\stexcommentfont} +}{ + \stex_style_apply: + \bool_if:NT \l_@@_in_spfblock_bool \_@@_inc_counter: + \stex_if_do_html:T{\end{stex_annotate_env}} + \bool_if:NT\l_@@_in_spfblock_bool \_@@_end_list: + \stex_if_do_html:T{\end{stex_annotate_env}} + \aftergroup \_@@_inblock_restore: +}{}{}{} +\AddToHook{env/subproof/before}{ + \bool_if:NT \l_@@_in_spfblock_bool \group_end: +} +\AddToHook{env/subproof/end}{ + \bool_if:NT\l_@@_in_spfblock_bool { + \group_end:\_@@_remove_counter: + %\_@@_end_list: + } +} +\stex_deactivate_macro:Nn \subproof {sproof~environments} + +\cs_new_protected:Nn \_@@_inblock_restore: { + \bool_if:NT\l_@@_in_spfblock_bool { + \group_begin:\stexcommentfont + } +} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\spfstep,\conclude,\assumption,\have,\eqstep} +% \begin{macrocode} + +\stex_keys_define:nnnn { spfsteps } { + \clist_clear:N \l_stex_key_for_clist + \str_clear:N \l_stex_key_name_str + \tl_clear:N \l_stex_key_method_tl + \tl_clear:N \l_stex_key_term_tl +}{ + for .clist_set:N = \l_stex_key_for_clist , + method .tl_set:N = \l_stex_key_method_tl, + term .tl_set:N = \l_stex_key_term_tl, + name .str_set_x:N = \l_stex_key_name_str + % todo: style=inline +}{id,style,title} + +\newenvironment{spfstepenv}{ + \str_set_eq:NN \spfstepenvautorefname \spfstepautorefname +}{} + +\cs_new_protected:Nn \_@@_step_html:nn { + \stex_if_do_html:TF{ + \exp_args:Ne \stex_annotate:nn{ + shtml:spf#1={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , + } + } + \str_if_empty:NF \l_stex_key_name_str {, + shtml:stepname={\l_stex_key_name_str} + } + }{ + \_@@_html: + #2 + } + }{ #2 } +} + +\cs_new_protected:Nn \_@@_make_step_macro:Nnnnn { + \NewDocumentCommand #1 {s O{} +m} { + \bool_if:NT \l_@@_in_spfblock_bool \group_end: + \stex_keys_set:nn{spfsteps}{##2} + \str_if_empty:NF \l_stex_key_name_str { + \stex_debug:nn{Here:}{Variable~\l_stex_key_name_str} + \exp_args:NNx\exp_args:Nnx\vardef{v\l_stex_key_name_str}{\l_stex_key_name_str} + } + + \begin{spfstepenv} + \str_if_empty:NF \l_stex_key_id_str { + \_@@_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{spfstep.\@currentlabel} + \_stex_do_id: + } + + \bool_if:NTF \l_@@_in_spfblock_bool { + \IfBooleanTF ##1 { + \_@@_step_html:nn{#2}{##3} + }{ + \_@@_step_html:nn{#2}{\_@@_start_list:n{#3} ##3 \_@@_end_list:} + #5 + } + \end{spfstepenv} + \group_begin:\stexcommentfont + }{ + \_@@_step_html:nn{#2}{##3} + \end{spfstepenv} + } + } + \stex_deactivate_macro:Nn #1 {sproof~environments} +} + +\_@@_make_step_macro:Nnnnn \assumption {assumption} \_@@_insert_number: {} \_@@_inc_counter: +\_@@_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {} +\_@@_make_step_macro:Nnnnn \spfstep {step} \_@@_insert_number: {} \_@@_inc_counter: + +\NewDocumentCommand \eqstep {s m}{ + \bool_if:NTF \l_@@_in_spfblock_bool { + \group_end: + \IfBooleanTF #1 { + \_@@_step_html:nn{eqstep}{$= #2$} + }{ + \_@@_step_html:nn{eqstep}{\_@@_start_list:n{$=$} $#2$ \_@@_end_list:} + } + \group_begin:\stexcommentfont + }{ + \_@@_step_html:nn{eqstep}{$= #2$} + } +} +\stex_deactivate_macro:Nn \eqstep {sproof~environments} + +\NewDocumentCommand \yield {+m}{ + \stex_annotate:nn{shtml:proofterm={}}{ #1 } +} +\stex_deactivate_macro:Nn \yield {sproof~environments} + +\NewDocumentEnvironment{spfblock}{}{ + \bool_set_false:N \l_@@_in_spfblock_bool +}{ + \aftergroup\_@@_inblock_restore: +} +\stex_deactivate_macro:Nn \spfblock {sproof~environments} +\AddToHook{env/spfblock/before}{ + \bool_if:NT \l_@@_in_spfblock_bool \group_end: +} + + +\newcommand\spfjust[1]{ + \stex_annotate:nn{spfjust={}}{ #1 } +} +\stex_deactivate_macro:Nn \spfjust {sproof~environments} +% \end{macrocode} +% \end{macro} +% +% \end{sfragment} +% +% \begin{sfragment}{Metatheory} +% \begin{macrocode} +%<@@=stex_meta> +\group_begin: + \cs_set:Npn \__stex_modules_persist_module: {} + \cs_set:Npn \stex_check_term:n #1 {} + \cs_set:Npn \_stex_sref_do_aux:n #1 { #1 } + \bool_set_false:N \_stex_html_do_output_bool + \bool_set_false:N \c_stex_check_terms_bool + \stex_uri_resolve:Nn \l_stex_current_ns_uri {http://mathhub.info/sTeX/meta} + \stex_module_setup:n{Metatheory} + + \symdef{of~type}[args=ii,invisible]{#1} + \notation{of~type}[colon]{#1 \mathbin{\comp{:}} #2} + + \symdef{apply}[args=ia,prec=0;\infprec x\infprec]{#1\mathopen{\comp(} #2 \mathclose{\comp)}} + \notation{apply}[lambda]{#1\; \argsep{#2}{\;}} + \notation{apply}[infixop]{\argsep{#2}{\mathbin{#1}}} + \notation{apply}[infixrel]{\argsep{#2}{\mathrel{#1}}} + + % structures + \symdef{module~type}[args=i,op=\mathtt{MOD}] + {\mathopen{\comp{\mathtt{MOD}(}}#1\mathclose{\comp{)}}} + \symdef{module~type~merge}[args=a,op=\oplus] + {\argsep{#1}{\mathbin{\comp{\oplus}}}} + \symdef{anonymous~record}[args=a] + {\mathopen{\comp{[[}}#1\mathclose{\comp{]]}}} + \symdef{record~field}[args=2]{#1\comp{.}#2} + \symdecl*{record~type} + + \symdecl{mathstruct}[name=mathematical~structure,args=a] % TODO + \notation{mathstruct}[angle,prec=nobrackets] + {\mathopen{\comp\langle} #1 \mathclose{\comp\rangle}} + \notation{mathstruct}[parens,prec=nobrackets] + {\mathopen{\comp(} #1 \mathclose{\comp)}} + + % sequences + \symdef{ellipses}[ldots]{\ldots} + \symdef{sequence~expression}[comma,args=a]{#1} + \symdef{sequence~type}[args=1]{#1^{\comp\ast}} + \symdef{sequence~map}[args=ia]{ + \comp{\mathrm{map}}\mathopen{\comp{(}}#1\mathpunct{\comp{,}} + #2\mathclose{\comp{)}} + } +\iffalse + % binder (\forall, \Pi, \lambda etc.) + \symdef{pibind}[name=dependent function type,prec=nobrackets, + op=(\cdot)\;\to\;\cdot,args=Bi,assoc=pre] + {\argmap{#1}{ + \mathopen{\comp(} ##1 \mathclose{\comp{)}} + }{\mathbin{\comp{\to}}} \mathbin{\comp{\to}} #2} + \notation{pibind}[forall]{\comp\forall #1\mathpunct{\comp.} #2} + \notation{pibind}[Pi]{\mathop{\comp\prod}\c_math_subscript_token{#1}#2} + + \symdef{mapbind}[name=lambda,mapsto,prec=nobrackets,op=\mapsto,args=Bi,assoc=pre] + { #1 \mathrel{\comp\mapsto} #2} + \notation{mapbind}[lambda,prec=nobrackets,op=\lambda] + {\comp\lambda #1 \mathpunct{\comp.} #2} +\fi + \symdecl{bind}[args=Bi,assoc=pre] + \notation{bind}[depfun,prec=nobrackets,op=(\cdot)\;\to\;\cdot] + {\mathopen{\comp(} #1 \mathclose{\comp{)}\mathbin{\comp{\to}}} #2} + \notation{bind}[forall]{\comp\forall #1.\;#2} + \notation{bind}[Pi]{\mathop{\comp\prod}\c_math_subscript_token{#1}#2} + + \symdef{implicit~bind}[args=Bi,assoc=pre]{\mathopen{\comp\{} #1 \mathclose{\comp{\}\c_math_subscript_token I}} #2} + + \symdecl*{integer~literal} + \notation{integer~literal}{\mathbb Z} + + \symdecl*{ordinal} + \notation{ordinal}{\mathtt{Ord}} + + % propositions + \symdef{prop}[name=proposition]{\mathtt{Prop}} + \symdef{judgment~holds}[args=i,role=judgment]{\comp\vdash\;#1} + + % any object + \symdef{object}{\mathtt{Obj}} + + % TODO DELETE + \symdef{aseqdots}[args=a,prec=nobrackets] + {#1\comp{,\ldots}}%{##1\comp,##2} + \symdef{aseqfromto}[args=ai,prec=nobrackets] + {#1\comp{,\ldots,}#2}%{##1\comp,##2} + \symdef{aseqfromtovia}[args=aii,prec=nobrackets] + {#1\comp{,\ldots,}#2\comp{,\ldots,}#3}%{##1\comp,##2} + + + \stex_close_module: + \stex_uri_add_module:NNn \l_stex_metatheory_uri \l_stex_current_ns_uri {Metatheory} + \global \let \l_stex_metatheory_uri \l_stex_metatheory_uri + \global \let \c_stex_default_metatheory \l_stex_metatheory_uri +\group_end: +% \end{macrocode} +% +% \end{sfragment} +% +% +% \begin{sfragment}{MMT Interfaces} +% \begin{macrocode} +%<@@=todo> +\cs_new_protected:Npn \MSC #1 {} +% \end{macrocode} +% \end{sfragment} +% +% \begin{macro}{\MMTinclude} +% \begin{macrocode} +\stex_new_stylable_cmd:nnnn{MMTinclude}{m}{ + \stex_annotate_invisible:nn{shtml:import={#1}}{} +}{} +\stex_deactivate_macro:Nn \MMTinclude {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \MMTinclude} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MMTrule} +% \begin{macrocode} +\NewDocumentCommand \MMTrule {m m}{ + \tl_if_empty:nTF{#2}{\seq_clear:N \l_tmpa_seq}{ + \seq_set_split:Nnn \l_tmpa_seq , {#2} + } + \int_zero:N \l_tmpa_int + \stex_annotate_invisible:n{ + $ + \stex_annotate:nn{shtml:rule={scala://#1}}{ + \_stex_annotate_force_break:n{ + \seq_if_empty:NF \l_tmpa_seq { + \seq_map_inline:Nn \l_tmpa_seq { + \int_incr:N \l_tmpa_int + \stex_annotate:nn{ + shtml:argmode=i, + shtml:arg={\int_use:N \l_tmpa_int} + }{ ##1 } + } + } + } + }$ + } +} +\stex_deactivate_macro:Nn \MMTrule {module~environments} +\stex_every_module:n{\stex_reactivate_macro:N \MMTrule} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{mmtinterface} +% \begin{macrocode} +\NewDocumentEnvironment { mmtinterface } { O{} m m } { + \_stex_module_setup_top_nosig:n { #3 } + \str_set_eq:NN \l_@@_mmt_module_str \l_stex_current_module_str + \str_clear:N \l_stex_current_module_str + \stex_keys_set:nn { smodule }{ #1 } + \stex_module_setup:n{ #2 } + \str_set_eq:NN \l_@@_stex_module_str \l_stex_current_module_str + \stex_debug:nn{mmt}{Interface~\l_@@_stex_module_str^^Jfor~\l_@@_mmt_module_str} + + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:theory={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} + } + } + \stex_annotate_invisible:n{} + \stex_annotate_invisible:nn + {shtml:import=\l_@@_mmt_module_str} {} + } + \stex_module_add_code:x{ + \stex_activate_module:n{ \l_@@_mmt_module_str } + } + \stex_module_add_morphism:nonn + {}{\l_@@_mmt_module_str}{import}{} + \stex_reactivate_macro:N \mmtdef + \stex_smsmode_do: +}{ + \str_set_eq:NN \l_stex_current_module_str \l_@@_mmt_module_str + \stex_close_module: + \str_set_eq:NN \l_stex_current_module_str \l_@@_stex_module_str + \stex_close_module: + \stex_if_do_html:T { \end{stex_annotate_env} } +} +\stex_sms_allow_env:n{mmtinterface} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\mmtdef} +% \begin{macrocode} +\NewDocumentCommand \mmtdef {m O{} m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + \stex_symdecl_do: + + \str_set_eq:NN \l_stex_current_module_str \l_@@_mmt_module_str + \cs_set_eq:NN \l_@@_old_metagroup_cd \stex_metagroup_do_in:nn + \cs_set_protected:Npn \stex_metagroup_do_in:nn ##1 ##2 {##2} + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {} + {} + {} + \stex_invoke_symbol: + } + \cs_set_eq:NN \stex_metagroup_do_in:nn \l_@@_old_metagroup_cd + \str_set_eq:NN \l_stex_current_module_str \l_@@_stex_module_str + + \str_set_eq:NN \l_stex_get_symbol_mod_str \l_@@_mmt_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{#3} + \_stex_notation_check: + \_stex_notation_add: + \stex_if_do_html:T{ + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_smsmode_do: +} +\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments} +\stex_sms_allow_escape:N \mmtdef +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +\seq_if_empty:NT \g_stex_current_file { + \seq_gset_eq:NN \g_stex_current_file \c_stex_main_file +} +\_stex_persist_read_now: +\_stex_every_file: +\cs_new_protected:Nn \_@@_newlabel:n { + \exp_args:Ne\_@@_old_newlabel:{\tl_to_str:n{#1}} +} +\AtBeginDocument{ + \iow_now:Nn \@auxout { + \ExplSyntaxOn + \let\_@@_old_newlabel:\newlabel + \let\newlabel\_@@_newlabel:n + \ExplSyntaxOff + } +} +%</package> +% \end{macrocode} +% \end{sfragment} +% \end{implementation} +\endinput
\ No newline at end of file diff --git a/Master/texmf-dist/source/latex/stex/extensions/stex-extensions.ins b/Master/texmf-dist/source/latex/stex/stex.ins index e6fe5099f05..a365175f8d9 100644 --- a/Master/texmf-dist/source/latex/stex/extensions/stex-extensions.ins +++ b/Master/texmf-dist/source/latex/stex/stex.ins @@ -2,7 +2,7 @@ %% This file generates files required to use the ed package. %% At your command prompt write %% -%% latex extensions.ins +%% latex stex.ins %% %% Copyright (c) 2021 Michael Kohlhase %% @@ -18,13 +18,15 @@ \askforoverwritefalse \generate{ - \file{document-structure.sty}{\from{document-structure.dtx}{package}} + \file{stex.cls}{\from{stex.dtx}{cls}} + \file{stex.sty}{ + \from{stex.dtx}{package} + } \file{notesslides.cls}{\from{notesslides.dtx}{cls}} \file{notesslides.sty}{\from{notesslides.dtx}{package}} + \file{problem.sty}{\from{problem.dtx}{package}} + \file{hwexam.sty}{\from{hwexam.dtx}{package}} \file{tikzinput.sty}{\from{tikzinput.dtx}{package}} - \file{stex-tikzinput.sty}{\from{tikzinput.dtx}{stex}} - \file{problem.sty}{\from{problem.dtx}{package}} - \file{hwexam.sty}{\from{hwexam.dtx}{package}} } \Msg{*} diff --git a/Master/texmf-dist/source/latex/stex/stex/Makefile b/Master/texmf-dist/source/latex/stex/stex/Makefile deleted file mode 100644 index 2b9a63750bd..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -DTX = $(shell ls *.dtx) -DOC = $(DTX:%.dtx=%.pdf) -INS = stex.ins - -PDFLATEX = pdflatex -interaction=batchmode -TEXDIR = ../../tex -TEXINPUTS = $(TEXDIR)//: - -all: package doc - -doc: $(DOC) - -package: $(DTX) $(INS) - $(PDFLATEX) $(INS) - mv *.sty *.cls $(TEXDIR) - -$(DOC): %.pdf: %.dtx - $(PDFLATEX) $< - biber -q $(basename $<) - $(PDFLATEX) $< - -echo: - @echo $(TEXINPUTS) diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx deleted file mode 100644 index 0387e16439f..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-basics.dtx +++ /dev/null @@ -1,683 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Basics -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-basics} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \fi -% -% \begin{documentation}\label{pkg:basics:doc} -% -% This sub package provides general set up code, auxiliary methods -% and abstractions for |xhtml| annotations. -% -%\ifinfulldoc\else -% \input{../../doc/packages/stex-basics} -% \fi -% -% -% \section{Macros and Environments}\label{pkg:basics:doc:macros} -% -% \begin{function}{\sTeX , \stex} -% Both print this \stex logo. -% \end{function} -% -% \begin{function}{\stex_debug:nn} -% \begin{syntax} -% \cs{stex_debug:nn} \Arg{log-prefix} \Arg{message} ^^A \meta{comma list} -% \end{syntax} -% Logs \meta{message}, if the package option |debug| contains \meta{log-prefix}. -% \end{function} -% -% \subsection{HTML Annotations} -% -% \begin{function}{\if@latexml} -% \LaTeX2e conditional for \latexml -% \end{function} -% -% \begin{function}[pTF]{\latexml_if:} -% \LaTeX3 conditionals for \latexml. -% \end{function} -% -% \begin{function}[pTF]{\stex_if_do_html:} -% Whether to currently produce any HTML annotations (can be false -% in some advanced structuring environments, for example) -% \end{function} -% -% \begin{function}{\stex_suppress_html:n} -% Temporarily disables HTML annotations in its argument code -% \end{function} -% -% -% We have four macros for annotating generated HTML (via \latexml -% or \rustex) with attributes: -% -% \begin{function}{\stex_annotate:nnn, \stex_annotate_invisible:nnn, -% \stex_annotate_invisible:n} -% \begin{syntax} \cs{stex_annotate:nnn} \Arg{property} \Arg{resource} \Arg{content} \end{syntax} -% Annotates the HTML generated by \meta{content} with\\ -% \begin{center} -% |property="stex:|\meta{property}|", resource="|\meta{resource}|"|. -% \end{center} -% -% \cs{stex_annotate_invisible:n} adds the attributes\\ -% \begin{center} -% |stex:visible="false", style="display:none"|. -% \end{center} -% -% \cs{stex_annotate_invisible:nnn} combines the functionality of both. -% \end{function} -% -% \begin{environment}{stex_annotate_env} -% \begin{syntax} \cs{begin}|{stex_annotate_env}|\Arg{property}\Arg{resource} -% \meta{content} -% \cs{end}|{stex_annotate_env}| -% \end{syntax} -% behaves like \cs{stex_annotate:nnn} \Arg{property} \Arg{resource} -% \Arg{content}. -% \end{environment} -% -% \subsection{Babel Languages} -% -% \begin{variable}{\c_stex_languages_prop,\c_stex_language_abbrevs_prop} -% Map language abbreviations to their full babel names and vice versa. -% e.g. \cs{c_stex_languages_prop}|{en}| yields |english|, and -% \cs{c_stex_language_abbrevs_prop}|{english}| yields |en|. -% \end{variable} -% -% \subsection{Auxiliary Methods} -% -% \begin{function}{\stex_deactivate_macro:Nn , \stex_reactivate_macro:N} -% \begin{syntax}\cs{stex_deactivate_macro:Nn}\meta{cs}\Arg{environments}\end{syntax} -% Makes the macro \meta{cs} throw an error, indicating that it -% is only allowed in the context of \meta{environments}. -% -% \cs{stex_reactivate_macro:N}\meta{cs} reactivates it again, i.e. -% this happens ideally in the \meta{begin}-code of the associated -% environments. -% \end{function} -% -% \begin{function}{\ignorespacesandpars} -% ignores white space characters and |\par| control sequences. -% Expands tokens in the process. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation} -% -% \section{\sTeX-Basics Implementation}\label{pkg:basics:impl} -% -% \subsection{The \sTeX Document Class} -% -% The \cls{stex} document class is pretty straight-forward: It largely extends the \cls{standalone} package -% and loads the \pkg{stex} package, passing all provided options on to the package. -% -% \begin{macrocode} -%<*cls> - -%%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% - -\RequirePackage{expl3,l3keys2e} -\ProvidesExplClass{stex}{2022/09/14}{3.2.0}{sTeX document class} - -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}} -\ProcessOptions - -\bool_set_true:N \c_stex_document_class_bool - -\RequirePackage{stex} - -\stex_html_backend:TF { - \LoadClass{article} -}{ - \LoadClass[border=1px,varwidth,crop=false]{standalone} - \setlength\textwidth{15cm} -} -\RequirePackage{standalone} - - -\clist_if_empty:NT \c_stex_languages_clist { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { - \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str - } - } - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \prop_if_in:NoT \c_stex_languages_prop \l_tmpa_str { - \stex_debug:nn{language} {Language~\l_tmpa_str~ - inferred~from~file~name} - \exp_args:NNo \stex_set_language:Nn \l_tmpa_str \l_tmpa_str - } - } -} -%</cls> -% \end{macrocode} -% -% \subsection{Preliminaries} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% - -\RequirePackage{expl3,l3keys2e,ltxcmds} -\ProvidesExplPackage{stex}{2022/09/14}{3.2.0}{sTeX package} - -\bool_if_exist:NF \c_stex_document_class_bool { - \bool_set_false:N \c_stex_document_class_bool - \RequirePackage{standalone} -} - -\message{^^J*~This~is~sTeX~version~3.2.0~*^^J} - -%\RequirePackage{morewrites} -%\RequirePackage{amsmath} - -% \end{macrocode} -% -% Package options: -% -% \begin{macrocode} -\keys_define:nn { stex } { - debug .clist_set:N = \c_stex_debug_clist , - lang .clist_set:N = \c_stex_languages_clist , - mathhub .tl_set_x:N = \mathhub , - usesms .bool_set:N = \c_stex_persist_mode_bool , - writesms .bool_set:N = \c_stex_persist_write_mode_bool , - image .bool_set:N = \c_tikzinput_image_bool, - unknown .code:n = {} -} -\ProcessKeysOptions { stex } -% \end{macrocode} -% -% \begin{macro}{\stex,\sTeX} -% The \sTeX logo: -% -% \begin{macrocode} -\RequirePackage{stex-logo} % externalized for backwards-compatibility reasons -% \end{macrocode} -% \end{macro} -% -% -% \subsection{Messages and logging} -% -% \begin{macrocode} -%<@@=stex_log> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/unknownlanguage}{ - Unknown~language:~#1 -} -\msg_new:nnn{stex}{warning/nomathhub}{ - MATHHUB~system~variable~not~found~and~no~ - \detokenize{\mathhub}-value~set! -} -\msg_new:nnn{stex}{error/deactivated-macro}{ - The~\detokenize{#1}~command~is~only~allowed~in~#2! -} -% \end{macrocode} -% -% \begin{macro}{\stex_debug:nn} -% -% A simple macro issuing package messages with subpath. -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_debug:nn { - \clist_if_in:NnTF \c_stex_debug_clist { all } { - \msg_set:nnn{stex}{debug / #1}{ - \\Debug~#1:~#2\\ - } - \msg_none:nn{stex}{debug / #1} - }{ - \clist_if_in:NnT \c_stex_debug_clist { #1 } { - \msg_set:nnn{stex}{debug / #1}{ - \\Debug~#1:~#2\\ - } - \msg_none:nn{stex}{debug / #1} - } - } -} -% \end{macrocode} -% \end{macro} -% -% Redirecting messages: -% -% \begin{macrocode} -\clist_if_in:NnTF \c_stex_debug_clist {all} { - \msg_redirect_module:nnn{ stex }{ none }{ term } -}{ - \clist_map_inline:Nn \c_stex_debug_clist { - \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term } - } -} - -\stex_debug:nn{log}{debug~mode~on} -% \end{macrocode} -% -% -% \subsection{HTML Annotations} -% \begin{macrocode} -%<@@=stex_annotate> -% \end{macrocode} -% -% \begin{macrocode} -% \end{macrocode} -% -% \begin{variable}{\l_stex_html_arg_tl, \c_stex_html_emptyarg_tl} -% -% Used by annotation macros to ensure that the HTML output to annotate -% is not empty. -% -% \begin{macrocode} -\tl_new:N \l_stex_html_arg_tl -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\_stex_html_checkempty:n} -% \begin{macrocode} -\cs_new_protected:Nn \_stex_html_checkempty:n { - \tl_set:Nn \l_stex_html_arg_tl { #1 } - \tl_if_empty:NT \l_stex_html_arg_tl { - \tl_set_eq:NN \l_stex_html_arg_tl \c_stex_html_emptyarg_tl - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[pTF]{\stex_if_do_html:} -% Whether to (locally) produce HTML output -% \begin{macrocode} -\bool_new:N \_stex_html_do_output_bool -\bool_set_true:N \_stex_html_do_output_bool - -\prg_new_conditional:Nnn \stex_if_do_html: {p,T,F,TF} { - \bool_if:nTF \_stex_html_do_output_bool - \prg_return_true: \prg_return_false: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_suppress_html:n} -% Whether to (locally) produce HTML output -% \begin{macrocode} -\cs_new_protected:Nn \stex_suppress_html:n { - \exp_args:Nne \use:nn { - \bool_set_false:N \_stex_html_do_output_bool - #1 - }{ - \stex_if_do_html:T { - \bool_set_true:N \_stex_html_do_output_bool - } - } -} -% \end{macrocode} -% \end{macro} -% -% -% \begin{environment}{stex_annotate_env} -% \begin{macro}{\stex_annotate:nnn, \stex_annotate_invisible:n, -% \stex_annotate_invisible:nnn} -% -% We define four macros for introducing attributes in the HTML -% output. The definitions depend on the ``backend'' used -% (\latexml, \rustex, \texttt{pdflatex}). -% -% The \texttt{pdflatex}-macros largely do nothing; the -% \rustex-implementations are pretty clear in what they do, -% the \latexml-implementations resort to perl bindings. -% -% \begin{macrocode} -\ifcsname if@rustex\endcsname\else - \expandafter\newif\csname if@rustex\endcsname - \@rustexfalse -\fi -\ifcsname if@latexml\endcsname\else - \expandafter\newif\csname if@latexml\endcsname - \@latexmlfalse -\fi -\tl_if_exist:NF\stex@backend{ - \if@rustex - \def\stex@backend{rustex} - \else - \if@latexml - \def\stex@backend{latexml} - \else - \cs_if_exist:NTF\HCode{ - \def\stex@backend{tex4ht} - }{ - \def\stex@backend{pdflatex} - } - \fi - \fi -} -\input{stex-backend-\stex@backend.cfg} - -\newif\ifstexhtml -\stex_html_backend:TF\stexhtmltrue\stexhtmlfalse - -% \end{macrocode} -% \end{macro} -% \end{environment} -% -% \subsection{Babel Languages} -% \begin{macrocode} -%<@@=stex_language> -% \end{macrocode} -% -% \begin{variable}{\c_stex_languages_prop,\c_stex_language_abbrevs_prop} -% -% We store language abbreviations in two (mutually inverse) -% property lists: -% \begin{macrocode} -\exp_args:NNx \prop_const_from_keyval:Nn \c_stex_languages_prop { \tl_to_str:n { - en = english , - de = ngerman , - ar = arabic , - bg = bulgarian , - ru = russian , - fi = finnish , - ro = romanian , - tr = turkish , - fr = french -}} - -\exp_args:NNx \prop_const_from_keyval:Nn \c_stex_language_abbrevs_prop { \tl_to_str:n { - english = en , - ngerman = de , - arabic = ar , - bulgarian = bg , - russian = ru , - finnish = fi , - romanian = ro , - turkish = tr , - french = fr -}} -% todo: chinese simplified (zhs) -% chinese traditional (zht) -% \end{macrocode} -% \end{variable} -% -% we use the |lang|-package option to load the corresponding -% babel languages: -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_set_language:Nn { - \str_set:Nx \l_tmpa_str {#2} - \prop_get:NoNT \c_stex_languages_prop \l_tmpa_str #1 { - \ifx\@onlypreamble\@notprerr - \ltx@ifpackageloaded{babel}{ - \exp_args:No \selectlanguage #1 - }{} - \else - \exp_args:No \str_if_eq:nnTF #1 {turkish} { - \RequirePackage[#1,shorthands=:!]{babel} - }{ - \RequirePackage[#1]{babel} - } - \fi - } -} - -\clist_if_empty:NF \c_stex_languages_clist { - \bool_set_false:N \l_tmpa_bool - \clist_clear:N \l_tmpa_clist - \clist_map_inline:Nn \c_stex_languages_clist { - \str_set:Nx \l_tmpa_str {#1} - \str_if_eq:nnT {#1}{tr}{ - \bool_set_true:N \l_tmpa_bool - } - \prop_get:NoNTF \c_stex_languages_prop \l_tmpa_str \l_tmpa_str { - \clist_put_right:No \l_tmpa_clist \l_tmpa_str - } { - \msg_error:nnx{stex}{error/unknownlanguage}{\l_tmpa_str} - } - } - \stex_debug:nn{lang} {Languages:~\clist_use:Nn \l_tmpa_clist {,~} } - \bool_if:NTF \l_tmpa_bool { - \RequirePackage[\clist_use:Nn \l_tmpa_clist,,shorthands=:!]{babel} - }{ - \RequirePackage[\clist_use:Nn \l_tmpa_clist,]{babel} - } -} - -\AtBeginDocument{ - \stex_html_backend:T { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be language - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \stex_debug:nn{basics} {Language~\l_tmpa_str~ - inferred~from~file~name} - \stex_annotate_invisible:nnn{language}{ \l_tmpa_str }{} - } - } -} - -% \end{macrocode} -% -% \subsection{Persistence} -% -% \begin{macrocode} -%<@@=stex_persist> -\bool_if:NTF \c_stex_persist_mode_bool { - \def \stex_persist:n #1 {} - \def \stex_persist:x #1 {} -}{ - \bool_if:NTF \c_stex_persist_write_mode_bool { - \iow_new:N \c_@@_iow - \iow_open:Nn \c_@@_iow{\jobname.sms} - \AtEndDocument{ - \iow_close:N \c_@@_iow - } - \cs_new_protected:Nn \stex_persist:n { - \tl_set:Nn \l_tmpa_tl { #1 } - \regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl - \regex_replace_all:nnN { \ } { \~ } \l_tmpa_tl - \exp_args:NNo \iow_now:Nn \c_@@_iow \l_tmpa_tl - } - \cs_generate_variant:Nn \stex_persist:n {x} - }{ - \def \stex_persist:n #1 {} - \def \stex_persist:x #1 {} - } -} -% \end{macrocode} -% -% \subsection{Auxiliary Methods} -% -% \begin{macro}{\stex_deactivate_macro:Nn} -% \begin{macrocode} -\cs_new_protected:Nn \stex_deactivate_macro:Nn { - \exp_after:wN\let\csname \detokenize{#1} - orig\endcsname#1 - \def#1{ - \msg_error:nnnn{stex}{error/deactivated-macro}{\detokenize{#1}}{#2} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_reactivate_macro:N} -% \begin{macrocode} -\cs_new_protected:Nn \stex_reactivate_macro:N { - \exp_after:wN\let\exp_after:wN#1\csname \detokenize{#1} - orig\endcsname -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\ignorespacesandpars} -% \begin{macrocode} -\protected\def\ignorespacesandpars{ - \begingroup\catcode13=10\relax - \@ifnextchar\par{ - \endgroup\expandafter\ignorespacesandpars\@gobble - }{ - \endgroup - } -} - -\cs_new_protected:Nn \stex_copy_control_sequence:NNN { - \tl_set:Nx \_tmp_args_tl {\cs_argument_spec:N #2} - \exp_args:NNo \tl_remove_all:Nn \_tmp_args_tl \c_hash_str - \int_set:Nn \l_tmpa_int {\tl_count:N \_tmp_args_tl} - - \tl_clear:N \_tmp_args_tl - \int_step_inline:nn \l_tmpa_int { - \tl_put_right:Nx \_tmp_args_tl {{\exp_not:n{####}\exp_not:n{##1}}} - } - - \tl_set:Nn #3 {\cs_generate_from_arg_count:NNnn #1 \cs_set:Npn} - \tl_put_right:Nx #3 { {\int_use:N \l_tmpa_int}{ - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN #2 \_tmp_args_tl - } - }} -} -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {cNN} -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {NcN} -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {ccN} - -\cs_new_protected:Nn \stex_copy_control_sequence_ii:NNN { - \tl_set:Nx \_tmp_args_tl {\cs_argument_spec:N #2} - \exp_args:NNo \tl_remove_all:Nn \_tmp_args_tl \c_hash_str - \int_set:Nn \l_tmpa_int {\tl_count:N \_tmp_args_tl} - - \tl_clear:N \_tmp_args_tl - \int_step_inline:nn \l_tmpa_int { - \tl_put_right:Nx \_tmp_args_tl {{\exp_not:n{########}\exp_not:n{##1}}} - } - - \edef \_tmp_args_tl { - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN #2 \_tmp_args_tl - } - } - - \exp_after:wN \def \exp_after:wN \_tmp_args_tl - \exp_after:wN ##\exp_after:wN 1 \exp_after:wN ##\exp_after:wN 2 - \exp_after:wN { \_tmp_args_tl } - - \edef \_tmp_args_tl { - \exp_after:wN \exp_not:n \exp_after:wN { - \_tmp_args_tl {####1}{####2} - } - } - - \tl_set:Nn #3 {\cs_generate_from_arg_count:NNnn #1 \cs_set:Npn} - \tl_put_right:Nx #3 { {\int_use:N \l_tmpa_int}{ - \exp_after:wN\exp_not:n\exp_after:wN{\_tmp_args_tl} - }} -} - -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {cNN} -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {NcN} -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {ccN} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\MMTrule} -% \begin{macrocode} -\NewDocumentCommand \MMTrule {m m}{ - \seq_set_split:Nnn \l_tmpa_seq , {#2} - \int_zero:N \l_tmpa_int - \stex_annotate_invisible:nnn{mmtrule}{scala://#1}{ - \seq_if_empty:NF \l_tmpa_seq { - $\seq_map_inline:Nn \l_tmpa_seq { - \int_incr:N \l_tmpa_int - \stex_annotate:nnn{arg}{i\int_use:N \l_tmpa_int}{##1} - }$ - } - } -} - -\NewDocumentCommand \MMTinclude {m}{ - \stex_annotate_invisible:nnn{import}{#1}{} -} - -\tl_new:N \g_stex_document_title -\cs_new_protected:Npn \STEXtitle #1 { - \tl_if_empty:NT \g_stex_document_title { - \tl_gset:Nn \g_stex_document_title { #1 } - } -} -\cs_new_protected:Nn \stex_document_title:n { - \tl_if_empty:NT \g_stex_document_title { - \tl_gset:Nn \g_stex_document_title { #1 } - \stex_annotate_invisible:n{\noindent - \stex_annotate:nnn{doctitle}{}{ #1 } - \par} - } -} -\AtBeginDocument { - \let \STEXtitle \stex_document_title:n - \tl_if_empty:NF \g_stex_document_title { - \stex_annotate_invisible:n{\noindent - \stex_annotate:nnn{doctitle}{}{ \g_stex_document_title } - \par} - } - \let\_stex_maketitle:\maketitle - \def\maketitle{ - \tl_if_empty:NF \@title { - \exp_args:No \stex_document_title:n \@title - } - \_stex_maketitle: - } -} - -\cs_new_protected:Nn \stex_par: { - \mode_if_vertical:F{ - \if@minipage\else\if@nobreak\else\par\fi\fi - } -} - -%</package> -% \end{macrocode} -% \end{macro} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx deleted file mode 100644 index d770b76e42d..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-features.dtx +++ /dev/null @@ -1,1148 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Structural Features -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-features} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \input{../../doc/packages/stex-features} -% \fi -% -% \begin{documentation}\label{pkg:features:doc} -% \changes{3.1.0}{2022/03/03}{Implemented mathstructures and instantiations} -% -% Code related to structural features -% -% \section{Macros and Environments}\label{pkg:features:doc:macros} -% -% \subsection{Structures} -% -% \begin{environment}{mathstructure} -% TODO -% \end{environment} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:features:impl} -% -% \section{\sTeX-Structural Features Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% features.dtx %%%%%%%%%%%%% - -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/copymodule/notallowed}{ - Symbol~#1~can~not~be~assigned~in~copymodule~#2 -} -\msg_new:nnn{stex}{error/interpretmodule/nodefiniens}{ - Symbol~#1~not~assigned~in~interpretmodule~#2 -} - -\msg_new:nnn{stex}{error/unknownstructure}{ - No~structure~#1~found! -} - -\msg_new:nnn{stex}{error/unknownfield}{ - No~field~#1~in~instance~#2~found!\\#3 -} - -\msg_new:nnn{stex}{error/keyval}{ - Invalid~key=value~pair:#1 -} -\msg_new:nnn{stex}{error/instantiate/missing}{ - Assignments~missing~in~instantiate:~#1 -} -\msg_new:nnn{stex}{error/incompatible}{ - Incompatible~signature:~#1~(#2)~and~#3~(#4) -} - -% \end{macrocode} -% -% \subsection{Imports with modification} -% -% \begin{macrocode} -%<@@=stex_copymodule> -\cs_new_protected:Nn \stex_get_symbol_in_seq:nn { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \_@@_get_symbol_from_cs: - }{ - % argument is a string - % is it a command name? - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N \l_tmpa_tl - } \stex_invoke_symbol:n { - \_@@_get_symbol_from_cs:n{ #2 } - }{ - \_@@_get_symbol_from_string:nn { #1 }{ #2 } - } - } { - \_@@_get_symbol_from_string:nn { #1 }{ #2 } - } - }{ - % argument is not a command name - \_@@_get_symbol_from_string:nn { #1 }{ #2 } - % \l_stex_all_symbols_seq - } - } -} - -\cs_new_protected:Nn \_@@_get_symbol_from_string:nn { - \str_set:Nn \l_tmpa_str { #1 } - \bool_set_false:N \l_tmpa_bool - \bool_if:NF \l_tmpa_bool { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownsymbol}{#1} - } - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \seq_map_inline:Nn #2 { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { - ##1 - } - } - } - } - } - \l_tmpa_tl - } -} - -\cs_new_protected:Nn \_@@_get_symbol_from_cs:n { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \tl_if_single:NTF \l_tmpa_tl { - \exp_args:No \tl_if_head_is_group:nTF \l_tmpa_tl { - \exp_after:wN \str_set:Nn \exp_after:wN - \l_stex_get_symbol_uri_str \l_tmpa_tl - \_@@_get_symbol_check:n { #1 } - }{ - % TODO - % tail is not a single group - } - }{ - % TODO - % tail is not a single group - } -} - -\cs_new_protected:Nn \_@@_get_symbol_check:n { - \exp_args:NNx \seq_if_in:NnF #1 \l_stex_get_symbol_uri_str { - \msg_error:nnxx{stex}{error/copymodule/notallowed}{\l_stex_get_symbol_uri_str}{ - :~\seq_use:Nn #1 {,~} - } - } -} - -\cs_new_protected:Nn \stex_copymodule_start:nnnn { - % import module - \stex_import_module_uri:nn { #1 } { #2 } - \str_set:Nx \l_stex_current_copymodule_name_str {#3} - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - - \stex_collect_imports:n {\l_stex_import_ns_str ?\l_stex_import_name_str } - \seq_set_eq:NN \l_@@_copymodule_modules_seq \l_stex_collect_imports_seq - - % fields - \seq_clear:N \l_@@_copymodule_fields_seq - \seq_map_inline:Nn \l_@@_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \exp_args:NNx \seq_put_right:Nn \l_@@_copymodule_fields_seq { - ##1 ? ####1 - } - } - } - - % setup prop - \seq_clear:N \l_tmpa_seq - \exp_args:NNx \prop_set_from_keyval:Nn \l_stex_current_copymodule_prop { - name = \l_stex_current_copymodule_name_str , - module = \l_stex_current_module_str , - from = \l_stex_import_ns_str ?\l_stex_import_name_str , - includes = \l_tmpa_seq %, - % fields = \l_tmpa_seq - } - \stex_debug:nn{copymodule}{#4~for~module~{\l_stex_import_ns_str ?\l_stex_import_name_str} - as~\l_stex_current_module_str?\l_stex_current_copymodule_name_str} - \stex_debug:nn{copymodule}{modules:\seq_use:Nn \l_@@_copymodule_modules_seq {,~}} - \stex_debug:nn{copymodule}{fields:\seq_use:Nn \l_@@_copymodule_fields_seq {,~}} - - \stex_if_do_html:T { - \begin{stex_annotate_env} {#4} { - \l_stex_current_module_str?\l_stex_current_copymodule_name_str - } - \stex_annotate_invisible:nnn{domain}{\l_stex_import_ns_str ?\l_stex_import_name_str}{} - } -} - -\cs_new_protected:Nn \stex_copymodule_end:n { - % apply to every field - \def \l_tmpa_cs ##1 ##2 {#1} - - \tl_clear:N \_@@_module_tl - \tl_clear:N \_@@_exec_tl - - %\prop_get:NnN \l_stex_current_copymodule_prop {fields} \l_tmpa_seq - \seq_clear:N \_@@_fields_seq - - \seq_map_inline:Nn \l_@@_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - - \tl_clear:N \_@@_curr_symbol_tl % <- wrap in current symbol html - \l_tmpa_cs{##1}{####1} - - \str_if_exist:cTF {l_@@_copymodule_##1?####1_name_str} { - \str_set_eq:Nc \_@@_curr_name_str {l_@@_copymodule_##1?####1_name_str} - \stex_if_do_html:T { - \tl_put_right:Nx \_@@_curr_symbol_tl { - \stex_annotate_invisible:nnn{alias}{\use:c{l_@@_copymodule_##1?####1_name_str}}{} - } - } - }{ - \str_set:Nx \_@@_curr_name_str { \l_stex_current_copymodule_name_str / ####1 } - } - - \prop_set_eq:Nc \l_tmpa_prop {l_stex_symdecl_ ##1?####1 _prop} - \prop_put:Nnx \l_tmpa_prop { name } \_@@_curr_name_str - \prop_put:Nnx \l_tmpa_prop { module } \l_stex_current_module_str - - \tl_if_exist:cT {l_@@_copymodule_##1?####1_def_tl}{ - \stex_if_do_html:T { - \tl_put_right:Nx \_@@_curr_symbol_tl { - $\stex_annotate_invisible:nnn{definiens}{}{\exp_after:wN \exp_not:N\csname l_@@_copymodule_##1?####1_def_tl\endcsname}$ - } - } - \prop_put:Nnn \l_tmpa_prop { defined } { true } - } - - \stex_add_constant_to_current_module:n \_@@_curr_name_str - \tl_put_right:Nx \_@@_module_tl { - \seq_clear:c {l_stex_symdecl_ \l_stex_current_module_str ? \_@@_curr_name_str _notations} - \prop_set_from_keyval:cn { - l_stex_symdecl_\l_stex_current_module_str ? \_@@_curr_name_str _prop - }{ - \prop_to_keyval:N \l_tmpa_prop - } - } - - \str_if_exist:cT {l_@@_copymodule_##1?####1_macroname_str} { - \stex_if_do_html:T { - \tl_put_right:Nx \_@@_curr_symbol_tl { - \stex_annotate_invisible:nnn{macroname}{\use:c{l_@@_copymodule_##1?####1_macroname_str}}{} - } - } - \tl_put_right:Nx \_@@_module_tl { - \tl_set:cx {\use:c{l_@@_copymodule_##1?####1_macroname_str}}{ - \stex_invoke_symbol:n { - \l_stex_current_module_str ? \_@@_curr_name_str - } - } - } - } - - \seq_put_right:Nx \_@@_fields_seq {\l_stex_current_module_str ? \_@@_curr_name_str } - - \tl_put_right:Nx \_@@_exec_tl { - \stex_copy_notations:nn {\l_stex_current_module_str ? \_@@_curr_name_str} { ##1 ? ####1 } - } - - \tl_put_right:Nx \_@@_exec_tl { - \stex_if_do_html:TF{ - \stex_annotate_invisible:nnn{assignment} {##1?####1} { \exp_after:wN \exp_not:n \exp_after:wN {\_@@_curr_symbol_tl} } - }{ - \exp_after:wN \exp_not:n \exp_after:wN {\_@@_curr_symbol_tl} - } - } - } - } - - - \prop_put:Nno \l_stex_current_copymodule_prop {fields} \_@@_fields_seq - \tl_put_left:Nx \_@@_module_tl { - \prop_set_from_keyval:cn { - l_stex_copymodule_ \l_stex_current_module_str?\l_stex_current_copymodule_name_str _prop - }{ - \prop_to_keyval:N \l_stex_current_copymodule_prop - } - } - - \seq_gput_right:cx{c_stex_module_\l_stex_current_module_str _copymodules}{ - \l_stex_current_module_str?\l_stex_current_copymodule_name_str - } - - \exp_args:No \stex_execute_in_module:n \_@@_module_tl - \stex_debug:nn{copymodule}{result:\meaning \_@@_module_tl} - \stex_debug:nn{copymodule}{output:\meaning \_@@_exec_tl} - - \_@@_exec_tl - \stex_if_do_html:T { - \end{stex_annotate_env} - } -} - -\NewDocumentEnvironment {copymodule} { O{} m m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #3 }{ copymodule } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \assign - \stex_reactivate_macro:N \renamedecl - \stex_reactivate_macro:N \donotcopy - \stex_smsmode_do: -}{ - \stex_copymodule_end:n {} -} - -\NewDocumentEnvironment {interpretmodule} { O{} m m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #3 }{ interpretmodule } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \assign - \stex_reactivate_macro:N \renamedecl - \stex_reactivate_macro:N \donotcopy - \stex_smsmode_do: -}{ - \stex_copymodule_end:n { - \tl_if_exist:cF { - l_@@_copymodule_##1?##2_def_tl - }{ - \str_if_eq:eeF { - \prop_item:cn{ - l_stex_symdecl_ ##1 ? ##2 _prop }{ defined } - }{ true }{ - \msg_error:nnxx{stex}{error/interpretmodule/nodefiniens}{ - ##1?##2 - }{\l_stex_current_copymodule_name_str} - } - } - } -} - -\iffalse \begin{stex_annotate_env} \fi -\NewDocumentEnvironment {realization} { O{} m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #2 }{ realize } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \donotcopy - \stex_reactivate_macro:N \assign - \stex_smsmode_do: -}{ - \stex_import_module_uri:nn { #1 } { #2 } - \tl_clear:N \_@@_exec_tl - \tl_set:Nx \_@@_module_tl { - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - } - \exp_args:Nx \stex_add_import_to_current_module:n{ - \l_stex_import_ns_str ? \l_stex_import_name_str - } - - \seq_map_inline:Nn \l_@@_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \str_set:Nx \_@@_curr_name_str { \l_stex_current_copymodule_name_str / ####1 } - \tl_if_exist:cT {l_@@_copymodule_##1?####1_def_tl}{ - \stex_if_do_html:T { - \tl_put_right:Nx \_@@_exec_tl { - \stex_annotate_invisible:nnn{assignment} {##1?####1} { - $\stex_annotate_invisible:nnn{definiens}{}{\exp_after:wN \exp_not:N\csname l_@@_copymodule_##1?####1_def_tl\endcsname}$ - } - } - } - \tl_put_right:Nx \_@@_module_tl { - \prop_put:cnn {l_stex_symdecl_##1?####1_prop}{ defined }{ true } - } - } - }} - - \exp_args:No \stex_execute_in_module:n \_@@_module_tl - - \_@@_exec_tl - \stex_if_do_html:T {\end{stex_annotate_env}} -} - -\NewDocumentCommand \donotcopy { m }{ - \str_clear:N \l_stex_import_name_str - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \stex_if_do_html:T { - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn{donotcopy}{##1}{ - \stex_annotate:nnn{domain}{##1}{} - } - } - } - \str_set_eq:NN \l_stex_import_name_str \l_tmpb_str - } - } - \seq_map_inline:cn {c_stex_module_##1_copymodules}{ - \str_set:Nn \l_tmpb_str { ####1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n {\seq_map_break:n { - \stex_if_do_html:T { - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn{donotcopy}{####1}{ - \stex_annotate:nnn{domain}{ - \prop_item:cn {l_stex_copymodule_ ####1 _prop}{module} - }{} - } - } - } - \str_set:Nx \l_stex_import_name_str { - \prop_item:cn {l_stex_copymodule_ ####1 _prop}{module} - } - }} - } - } - } - \str_if_empty:NTF \l_stex_import_name_str { - % TODO throw error - }{ - \stex_collect_imports:n {\l_stex_import_name_str } - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_remove_all:Nn \l_@@_copymodule_modules_seq { ##1 } - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_remove_all:Nn \l_@@_copymodule_fields_seq { ##1 ? ####1 } - \bool_lazy_any:nT { - { \cs_if_exist_p:c {l_@@_copymodule_##1?####1_name_str}} - { \cs_if_exist_p:c {l_@@_copymodule_##1?####1_macroname_str}} - { \cs_if_exist_p:c {l_@@_copymodule_##1?####1_def_tl}} - }{ - % TODO throw error - } - } - } - \prop_get:NnN \l_stex_current_copymodule_prop { includes } \l_tmpa_seq - \seq_put_right:Nx \l_tmpa_seq {\l_stex_import_name_str } - \prop_put:Nno \l_stex_current_copymodule_prop {includes} \l_tmpa_seq - } - \stex_smsmode_do: -} - -\NewDocumentCommand \assign { m m }{ - \stex_get_symbol_in_seq:nn {#1} \l_@@_copymodule_fields_seq - \stex_debug:nn{assign}{defining~{\l_stex_get_symbol_uri_str}~as~\detokenize{#2}} - \tl_set:cn {l_@@_copymodule_\l_stex_get_symbol_uri_str _def_tl}{#2} - \stex_smsmode_do: -} - -\keys_define:nn { stex / renamedecl } { - name .str_set_x:N = \l_stex_renamedecl_name_str -} -\cs_new_protected:Nn \_@@_renamedecl_args:n { - \str_clear:N \l_stex_renamedecl_name_str - \keys_set:nn { stex / renamedecl } { #1 } -} - -\NewDocumentCommand \renamedecl { O{} m m}{ - \_@@_renamedecl_args:n { #1 } - \stex_get_symbol_in_seq:nn {#2} \l_@@_copymodule_fields_seq - \stex_debug:nn{renamedecl}{renaming~{\l_stex_get_symbol_uri_str}~to~#3} - \str_set:cx {l_@@_copymodule_\l_stex_get_symbol_uri_str _macroname_str}{#3} - \str_if_empty:NTF \l_stex_renamedecl_name_str { - \tl_set:cx { #3 }{ \stex_invoke_symbol:n { - \l_stex_get_symbol_uri_str - } } - } { - \str_set:cx {l_@@_copymodule_\l_stex_get_symbol_uri_str _name_str}{\l_stex_renamedecl_name_str} - \stex_debug:nn{renamedecl}{@~\l_stex_current_module_str ? \l_stex_renamedecl_name_str} - \prop_set_eq:cc {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop} - \seq_set_eq:cc {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _notations - }{l_stex_symdecl_ \l_stex_get_symbol_uri_str _notations} - \prop_put:cnx {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{ name }{ \l_stex_renamedecl_name_str } - \prop_put:cnx {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{ module }{ \l_stex_current_module_str } - \exp_args:NNx \seq_put_left:Nn \l_@@_copymodule_fields_seq { - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - } - \tl_set:cx { #3 }{ \stex_invoke_symbol:n { - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - } } - } - \stex_smsmode_do: -} - -\stex_deactivate_macro:Nn \assign {copymodules} -\stex_deactivate_macro:Nn \renamedecl {copymodules} -\stex_deactivate_macro:Nn \donotcopy {copymodules} - - -% \end{macrocode} -% -% -% \subsection{The feature environment} -% -% \begin{environment}{structural@feature} -% \begin{macrocode} -%<@@=stex_features> - -\NewDocumentEnvironment{structural_feature_module}{ m m m }{ - \stex_if_in_module:F { - \msg_set:nnn{stex}{error/nomodule}{ - Structural~Feature~has~to~occur~in~a~module:\\ - Feature~#2~of~type~#1\\ - In~File:~\stex_path_to_string:N \g_stex_currentfile_seq - } - \msg_error:nn{stex}{error/nomodule} - } - - \str_set_eq:NN \l_stex_feature_parent_str \l_stex_current_module_str - - \stex_module_setup:nn{meta=NONE}{#2 - #1} - - \stex_if_do_html:T { - \begin{stex_annotate_env}{ feature:#1 }{\l_stex_feature_parent_str ? #2 - #1} - \stex_annotate_invisible:nnn{header}{}{ #3 } - } -}{ - \str_gset_eq:NN \l_stex_last_feature_str \l_stex_current_module_str - \prop_gput:cnn {c_stex_module_ \l_stex_current_module_str _prop}{feature}{#1} - \stex_debug:nn{features}{ - Feature: \l_stex_last_feature_str - } - \stex_if_do_html:T { - \end{stex_annotate_env} - } -} -% \end{macrocode} -% \end{environment} -% -% \subsection{Structure} -% -% \begin{environment}{structure} -% \begin{macrocode} -%<@@=stex_structures> -\cs_new_protected:Nn \stex_add_structure_to_current_module:nn { - \prop_if_exist:cF {c_stex_module_\l_stex_current_module_str _structures}{ - \prop_new:c {c_stex_module_\l_stex_current_module_str _structures} - } - \prop_gput:cxx{c_stex_module_\l_stex_current_module_str _structures} - {#1}{#2} -} - -\keys_define:nn { stex / features / structure } { - name .str_set_x:N = \l_@@_name_str , -} - -\cs_new_protected:Nn \_@@_structure_args:n { - \str_clear:N \l_@@_name_str - \keys_set:nn { stex / features / structure } { #1 } -} -\NewDocumentEnvironment{mathstructure}{m O{}}{ - \begin{mathstructure_inner}{#1}[#2] - \stex_smsmode_do: - \ignorespacesandpars - }{\end{mathstructure_inner}} -\NewDocumentEnvironment{mathstructure_inner}{m O{}}{ - \_@@_structure_args:n { #2 } - \str_if_empty:NT \l_@@_name_str { - \str_set:Nx \l_@@_name_str { #1 } - } - \stex_suppress_html:n { - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \exp_args:Nx \stex_symdecl_do:nn { - name = \l_@@_name_str , - def = {\STEXsymbol{module-type}{ - \STEXInternalTermMathOMSiiii { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { ns } ? - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { name } / \l_@@_name_str - structure - }{}{0}{} - }} - }{ #1 } - } - \exp_args:Nnnx - \begin{structural_feature_module}{ structure } - { \l_@@_name_str }{} -}{ - \end{structural_feature_module} - \_stex_reset_up_to_module:n \l_stex_last_feature_str - \exp_args:No \stex_collect_imports:n \l_stex_last_feature_str - \seq_clear:N \l_tmpa_seq - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \seq_put_right:Nn \l_tmpa_seq { ##1 ? ####1 } - } - } - \exp_args:Nnno - \prop_gput:cnn {c_stex_module_ \l_stex_last_feature_str _prop}{fields}\l_tmpa_seq - \stex_debug:nn{structure}{Fields:~\seq_use:Nn \l_tmpa_seq ,} - \stex_add_structure_to_current_module:nn - \l_@@_name_str - \l_stex_last_feature_str - - \stex_execute_in_module:x { - \tl_set:cn { #1 }{ - \exp_not:N \stex_invoke_structure:nn {\l_stex_current_module_str }{ \l_@@_name_str} - } - } -} - -\cs_new:Nn \stex_invoke_structure:nn { - \stex_invoke_symbol:n { #1?#2 } -} - -\cs_new_protected:Nn \stex_get_structure:n { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \_@@_get_from_cs: - }{ - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_cs { #1 } - \str_set:Nx \l_tmpa_str {\cs_argument_spec:N \l_tmpa_cs } - \str_if_empty:NTF \l_tmpa_str { - \cs_if_eq:NNTF { \tl_head:N \l_tmpa_cs} \stex_invoke_structure:nn { - \_@@_get_from_cs: - }{ - \_@@_get_from_string:n { #1 } - } - }{ - \_@@_get_from_string:n { #1 } - } - }{ - \_@@_get_from_string:n { #1 } - } - } -} - -\cs_new_protected:Nn \_@@_get_from_cs: { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \str_set:Nx \l_tmpa_str { - \exp_after:wN \use_i:nn \l_tmpa_tl - } - \str_set:Nx \l_tmpb_str { - \exp_after:wN \use_ii:nn \l_tmpa_tl - } - \str_set:Nx \l_stex_get_structure_str { - \l_tmpa_str ? \l_tmpb_str - } - \str_set:Nx \l_stex_get_structure_module_str { - \exp_args:Nno \prop_item:cn {c_stex_module_\l_tmpa_str _structures}{\l_tmpb_str} - } -} - -\cs_new_protected:Nn \_@@_get_from_string:n { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownstructure}{#1} - } - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - - \seq_map_inline:Nn \l_stex_all_modules_seq { - \prop_if_exist:cT {c_stex_module_##1_structures} { - \prop_map_inline:cn {c_stex_module_##1_structures} { - \exp_args:No \str_if_eq:nnT \l_tmpa_str {####1}{ - %\str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{ - \prop_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_structure_str {##1?####1} - \str_set:Nn \l_stex_get_structure_module_str {####2} - } - }} - } - } - } - } - \l_tmpa_tl -} -% \end{macrocode} -% \end{environment} -% -% -% \begin{macro}{\instantiate} -% \begin{macrocode} - -\NewDocumentEnvironment{usestructure}{m}{ - \stex_get_structure:n {#1} - \exp_args:Nnx \stex_debug:nn{features}{using~structure:~\l_stex_get_structure_module_str} - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str -}{} - -\keys_define:nn { stex / instantiate } { - name .str_set_x:N = \l_@@_name_str -} -\cs_new_protected:Nn \_@@_instantiate_args:n { - \str_clear:N \l_@@_name_str - \keys_set:nn { stex / instantiate } { #1 } -} - -\NewDocumentEnvironment{extstructure}{m m O{}}{ - \begin{mathstructure_inner}{#1}[#3] - \seq_set_split:Nnn\_@@_extstructure_imports_seq,{#2} - \seq_map_inline:Nn\_@@_extstructure_imports_seq { - \stex_get_structure:n {##1} - \exp_args:Nnx \stex_debug:nn{features}{importing~structure:~\l_stex_get_structure_module_str{}~into~\l_stex_current_module_str} - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn - {import} {\l_stex_get_structure_module_str} {} - } - \exp_args:Nx \stex_add_import_to_current_module:n { - \l_stex_get_structure_module_str - } - \exp_args:Nx \stex_add_to_current_module:n { - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - } - } - \stex_smsmode_do: - \ignorespacesandpars -}{ - \end{mathstructure_inner} -} - -\NewDocumentEnvironment{extstructure*}{m m O{}}{ - % TODO - \begin{extstructure}{#1}{#2}[#3] -}{ - \end{extstructure} -} - -\NewDocumentCommand \instantiate {m O{} m m O{}}{ - \begingroup - \stex_get_structure:n {#3} - \_@@_instantiate_args:n { #2 } - \str_if_empty:NT \l_@@_name_str { - \str_set:Nn \l_@@_name_str { #1 } - } - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \seq_clear:N \l_@@_fields_seq - \exp_args:Nx \stex_collect_imports:n \l_stex_get_structure_module_str - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_put_right:Nx \l_@@_fields_seq { ##1 ? ####1 } - } - } - - \tl_if_empty:nF{#5}{ - \seq_set_split:Nnn \l_tmpa_seq , {#5} - \prop_clear:N \l_tmpa_prop - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq = { ##1 } - \int_compare:nNnF { \seq_count:N \l_tmpb_seq } = 2 { - \msg_error:nnn{stex}{error/keyval}{##1} - } - \exp_args:Nx \stex_get_symbol_in_seq:nn {\seq_item:Nn \l_tmpb_seq 1} \l_@@_fields_seq - \str_set_eq:NN \l_@@_dom_str \l_stex_get_symbol_uri_str - \exp_args:NNx \seq_remove_all:Nn \l_@@_fields_seq \l_stex_get_symbol_uri_str - \exp_args:Nx \stex_get_symbol:n {\seq_item:Nn \l_tmpb_seq 2} - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l_@@_dom_str} - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}} - } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} \l_stex_get_symbol_uri_str - } - } - - \seq_map_inline:Nn \l_@@_fields_seq { - \str_set:Nx \l_tmpa_str {field:\l_@@_name_str . \prop_item:cn {l_stex_symdecl_##1_prop}{name} } - \stex_debug:nn{instantiate}{Field~\l_tmpa_str :~##1} - - \stex_add_constant_to_current_module:n {\l_tmpa_str} - \stex_execute_in_module:x { - \prop_set_from_keyval:cn { l_stex_symdecl_ \l_stex_current_module_str?\l_tmpa_str _prop}{ - name = \l_tmpa_str , - args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , - arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , - argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} - } - \seq_clear:c {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations} - } - - \seq_if_empty:cF{l_stex_symdecl_##1_notations}{ - \stex_find_notation:nn{##1}{} - \stex_execute_in_module:x { - \seq_put_right:cn {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations}{\l_stex_notation_variant_str} - } - - \stex_copy_control_sequence_ii:ccN - {stex_notation_\l_stex_current_module_str?\l_tmpa_str\c_hash_str \l_stex_notation_variant_str _cs} - {stex_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \l_tmpa_tl - \exp_args:No \stex_execute_in_module:n \l_tmpa_tl - - - \cs_if_exist:cT{stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs}{ - \tl_set_eq:Nc \l_tmpa_cs {stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_execute_in_module:x { - \tl_set:cn - {stex_op_notation_\l_stex_current_module_str?\l_tmpa_str\c_hash_str \l_stex_notation_variant_str _cs} - { \exp_args:No \exp_not:n \l_tmpa_cs} - } - } - - } - - \prop_put:Nxx \l_tmpa_prop {\prop_item:cn {l_stex_symdecl_##1_prop}{name}}{\l_stex_current_module_str?\l_tmpa_str} - } - - \stex_execute_in_module:x { - \prop_set_from_keyval:cn {l_stex_instance_\l_stex_current_module_str?\l_@@_name_str _prop}{ - domain = \l_stex_get_structure_module_str , - \prop_to_keyval:N \l_tmpa_prop - } - \tl_set:cn{ #1 }{\stex_invoke_instance:n{ \l_stex_current_module_str?\l_@@_name_str} } - } - \stex_debug:nn{instantiate}{ - Instance~\l_stex_current_module_str?\l_@@_name_str \\ - \prop_to_keyval:N \l_tmpa_prop - } - \exp_args:Nxx \stex_symdecl_do:nn { - type={\STEXsymbol{module-type}{ - \STEXInternalTermMathOMSiiii { - \l_stex_get_structure_module_str - }{}{0}{} - }} - }{\l_@@_name_str} -% { - \str_set:Nx \l_stex_get_symbol_uri_str {\l_stex_current_module_str?\l_@@_name_str} - \tl_set:Nn \l_stex_notation_after_do_tl {\__stex_notation_final:} - \stex_notation_do:nnnnn{}{0}{}{}{\comp{#4}} - % } - %\exp_args:Nx \notation{\l_@@_name_str}{\comp{#5}} - \endgroup - \stex_smsmode_do:\ignorespacesandpars -} - -\cs_new_protected:Nn \stex_symbol_or_var:n { - \cs_if_exist:cTF{#1}{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { \tl_head:N \l_tmpa_tl } - \stex_invoke_variable:n { - \bool_set_true:N \l_stex_symbol_or_var_bool - \bool_set_false:N \l_stex_instance_or_symbol_bool - \tl_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\exp_after:wN \use:n \l_tmpa_tl} - \str_set:Nx \l_stex_get_symbol_uri_str { - \exp_after:wN \use:n \l_tmpa_tl - } - }{ % TODO \stex_invoke_varinstance:n - \exp_args:Nx \cs_if_eq:NNTF { \tl_head:N \l_tmpa_tl } \stex_invoke_varinstance:n { - \bool_set_true:N \l_stex_symbol_or_var_bool - \bool_set_true:N \l_stex_instance_or_symbol_bool - \tl_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\exp_after:wN \use:n \l_tmpa_tl} - \str_set:Nx \l_stex_get_symbol_uri_str { - \exp_after:wN \use:n \l_tmpa_tl - } - }{ - \bool_set_false:N \l_stex_symbol_or_var_bool - \stex_get_symbol:n{#1} - } - } - }{ - \_@@_symbolorvar_from_string:n{ #1 } - } - }{ - \_@@_symbolorvar_from_string:n{ #1 } - } -} - -\cs_new_protected:Nn \_@@_symbolorvar_from_string:n { - \prop_if_exist:cTF {l_stex_symdecl_var://#1 _prop}{ - \bool_set_true:N \l_stex_symbol_or_var_bool - \str_set:Nn \l_stex_get_symbol_uri_str { #1 } - }{ - \bool_set_false:N \l_stex_symbol_or_var_bool - \stex_get_symbol:n{#1} - } -} - -\keys_define:nn { stex / varinstantiate } { - name .str_set_x:N = \l_@@_name_str, - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l_@@_bind_str {\l_keys_choice_tl}} - -} -\cs_new_protected:Nn \_@@_varinstantiate_args:n { - \str_clear:N \l_@@_name_str - \str_clear:N \l_@@_bind_str - \keys_set:nn { stex / varinstantiate } { #1 } -} - -\NewDocumentCommand \varinstantiate {m O{} m m O{}}{ - \begingroup - \stex_get_structure:n {#3} - \_@@_varinstantiate_args:n { #2 } - \str_if_empty:NT \l_@@_name_str { - \str_set:Nn \l_@@_name_str { #1 } - } - \stex_if_do_html:TF{ - \stex_annotate:nnn{varinstance}{\l_@@_name_str} - }{\use:n} - { - \stex_if_do_html:T{ - \stex_annotate_invisible:nnn{domain}{\l_stex_get_structure_module_str}{} - } - \seq_clear:N \l_@@_fields_seq - \exp_args:Nx \stex_collect_imports:n \l_stex_get_structure_module_str - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_put_right:Nx \l_@@_fields_seq { ##1 ? ####1 } - } - } - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \prop_clear:N \l_tmpa_prop - \tl_if_empty:nF {#5} { - \seq_set_split:Nnn \l_tmpa_seq , {#5} - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq = { ##1 } - \int_compare:nNnF { \seq_count:N \l_tmpb_seq } = 2 { - \msg_error:nnn{stex}{error/keyval}{##1} - } - \exp_args:Nx \stex_get_symbol_in_seq:nn {\seq_item:Nn \l_tmpb_seq 1} \l_@@_fields_seq - \str_set_eq:NN \l_@@_dom_str \l_stex_get_symbol_uri_str - \exp_args:NNx \seq_remove_all:Nn \l_@@_fields_seq \l_stex_get_symbol_uri_str - \exp_args:Nx \stex_symbol_or_var:n {\seq_item:Nn \l_tmpb_seq 2} - \stex_if_do_html:T{ - \stex_annotate:nnn{assign}{\l_@@_dom_str, - \bool_if:NTF\l_stex_symbol_or_var_bool{var://}{}\l_stex_get_symbol_uri_str}{} - } - \bool_if:NTF \l_stex_symbol_or_var_bool { - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l_@@_dom_str} - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}} - } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_variable:n {\l_stex_get_symbol_uri_str}} - }{ - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l_@@_dom_str} - {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}} - } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_symbol:n {\l_stex_get_symbol_uri_str}} - } - } - } - \tl_gclear:N \g_@@_aftergroup_tl - \seq_map_inline:Nn \l_@@_fields_seq { - \str_set:Nx \l_tmpa_str {\l_@@_name_str . \prop_item:cn {l_stex_symdecl_##1_prop}{name} } - \stex_debug:nn{varinstantiate}{Field~\l_tmpa_str :~##1} - \seq_if_empty:cF{l_stex_symdecl_##1_notations}{ - \stex_find_notation:nn{##1}{} - \cs_gset_eq:cc{g_@@_tmpa_\l_tmpa_str _cs} - {stex_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_debug:nn{varinstantiate}{Notation:~\cs_meaning:c{g_@@_tmpa_\l_tmpa_str _cs}} - \cs_if_exist:cT{stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs}{ - \cs_gset_eq:cc {g_@@_tmpa_op_\l_tmpa_str _cs} - {stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_debug:nn{varinstantiate}{Operator~Notation:~\cs_meaning:c{g_@@_tmpa_op_\l_tmpa_str _cs}} - } - } - - \exp_args:NNx \tl_gput_right:Nn \g_@@_aftergroup_tl { - \prop_set_from_keyval:cn { l_stex_symdecl_ var://\l_tmpa_str _prop}{ - name = \l_tmpa_str , - args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , - arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , - argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} , - } - \cs_set_eq:cc {stex_var_notation_\l_tmpa_str _cs} - {g_@@_tmpa_\l_tmpa_str _cs} - \cs_set_eq:cc {stex_var_op_notation_\l_tmpa_str _cs} - {g_@@_tmpa_op_\l_tmpa_str _cs} - } - \prop_put:Nxx \l_tmpa_prop {\prop_item:cn {l_stex_symdecl_##1_prop}{name}}{\stex_invoke_variable:n {\l_tmpa_str}} - } - \exp_args:NNx \tl_gput_right:Nn \g_@@_aftergroup_tl { - \prop_set_from_keyval:cn {l_stex_varinstance_\l_@@_name_str _prop }{ - domain = \l_stex_get_structure_module_str , - \prop_to_keyval:N \l_tmpa_prop - } - \tl_set:cn { #1 }{\stex_invoke_varinstance:n {\l_@@_name_str}} - \tl_set:cn {l_stex_varinstance_\l_@@_name_str _op_tl}{ - \exp_args:Nnx \exp_not:N \use:nn { - \str_set:Nn \exp_not:N \STEXInternalCurrentSymbolStr {var://\l_@@_name_str} - \_stex_term_omv:nn {var://\l_@@_name_str}{ - \exp_not:n{ - \_varcomp{#4} - } - } - }{ - \exp_not:n{\_stex_reset:N \STEXInternalCurrentSymbolStr} - } - } - } - } - \stex_debug:nn{varinstantiate}{\expandafter\detokenize\expandafter{\g_@@_aftergroup_tl}} - \aftergroup\g_@@_aftergroup_tl - \endgroup - \stex_smsmode_do:\ignorespacesandpars -} - -\cs_new_protected:Nn \stex_invoke_instance:n { - \peek_charcode_remove:NTF ! { - \stex_invoke_symbol:n{#1} - }{ - \_stex_invoke_instance:nn {#1} - } -} - - -\cs_new_protected:Nn \stex_invoke_varinstance:n { - \peek_charcode_remove:NTF ! { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \use:c{l_stex_varinstance_#1_op_tl} - }{ - \_stex_reset:N \comp - } - }{ - \_stex_invoke_varinstance:nn {#1} - } -} - -\cs_new_protected:Nn \_stex_invoke_instance:nn { - \prop_if_in:cnTF {l_stex_instance_ #1 _prop}{#2}{ - \exp_args:Nx \stex_invoke_symbol:n {\prop_item:cn{l_stex_instance_ #1 _prop}{#2}} - }{ - \prop_set_eq:Nc \l_tmpa_prop{l_stex_instance_ #1 _prop} - \msg_error:nnxxx{stex}{error/unknownfield}{#2}{#1}{ - \prop_to_keyval:N \l_tmpa_prop - } - } -} - -\cs_new_protected:Nn \_stex_invoke_varinstance:nn { - \prop_if_in:cnTF {l_stex_varinstance_ #1 _prop}{#2}{ - \prop_get:cnN{l_stex_varinstance_ #1 _prop}{#2}\l_tmpa_tl - \l_tmpa_tl - }{ - \msg_error:nnnnn{stex}{error/unknownfield}{#2}{#1}{} - } -} -% \end{macrocode} -% \end{macro} -% -% -% -% \begin{macro}{\stex_invoke_structure:nnn} -% \begin{macrocode} -% #1: URI of the instance -% #2: URI of the instantiated module -\cs_new_protected:Nn \stex_invoke_structure:nnn { - \tl_if_empty:nTF{ #3 }{ - \prop_set_eq:Nc \l_@@_structure_prop { - c_stex_feature_ #2 _prop - } - \tl_clear:N \l_tmpa_tl - \prop_get:NnN \l_@@_structure_prop { fields } \l_tmpa_seq - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq ? { ##1 } - \seq_get_right:NN \l_tmpb_seq \l_tmpa_str - \cs_if_exist:cT { - stex_notation_ #1/\l_tmpa_str \c_hash_str\c_hash_str _cs - }{ - \tl_if_empty:NF \l_tmpa_tl { - \tl_put_right:Nn \l_tmpa_tl {,} - } - \tl_put_right:Nx \l_tmpa_tl { - \stex_invoke_symbol:n {#1/\l_tmpa_str}! - } - } - } - \exp_args:No \mathstruct \l_tmpa_tl - }{ - \stex_invoke_symbol:n{#1/#3} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx deleted file mode 100644 index 109f7af5c9e..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-inheritance.dtx +++ /dev/null @@ -1,706 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Module Inheritance -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-inheritance} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \fi -% -% \begin{documentation}\label{pkg:inheritance:doc} -% \changes{3.1.0}{2022/03/10}{SMS mode now loads recursive dependencies \emph{first}} -% -% Code related to Module Inheritance, in particular \emph{sms mode}. -% -%\ifinfulldoc\else -% \input{../../doc/packages/stex-inheritance} -%\fi -% -% \section{Macros and Environments}\label{pkg:inheritance:doc:macros} -% -% \subsection{SMS Mode} -% ``SMS Mode'' is used when loading modules from external tex files. -% It deactivates any output and ignores all \TeX\ commands -% not explicitly allowed via the following lists -- all of which either -% declare module content or are needed in order to declare module content: -% -% \begin{variable}{\g_stex_smsmode_allowedmacros_tl} -% Macros that are executed as is; i.e. sms mode continues immediately after. -% These macros may not take any arguments or otherwise gobble tokens. -% -% Initially: \cs{makeatletter}, \cs{makeatother}, \cs{ExplSyntaxOn}, -% \cs{ExplSyntaxOff}. -% \end{variable} -% -% \begin{variable}{\g_stex_smsmode_allowedmacros_escape_tl} -% Macros that are executed and potentially gobble up further tokens. -% These macros need to make sure, that the very last token they ultimately -% expand to is \cs{stex_smsmode_do:}. -% -% Initially: \cs{symdecl}, \cs{notation}, \cs{symdef}, -% \cs{importmodule}, \cs{STEXexport}, \cs{inlineass}, \cs{inlinedef}, -% \cs{inlineex}, \cs{endinput}, \cs{setnotation}, \cs{copynotation}. -% \end{variable} -% -% \begin{variable}{\g_stex_smsmode_allowedenvs_seq} -% The names of environments that should be allowed in SMS mode. -% The corresponding \cs{begin}-statements are treated like -% the macros in \cs{g_stex_smsmode_allowedmacros_escape_tl}, so -% \cs{stex_smsmode_do:} needs to be the last token in the -% \cs{begin}-code. Since \cs{end}-statements take no arguments anyway, -% those are called directly and sms mode continues afterwards. -% -% Initially: |smodule|, |copymodule|, |interpretmodule|, |sdefinition|, -% |sexample|, |sassertion|, |sparagraph|. -% \end{variable} -% -% \begin{function}[pTF]{\stex_if_smsmode:} -% Tests whether SMS mode is currently active. -% \end{function} -% -% \begin{function}{\stex_file_in_smsmode:nn} -% \begin{syntax} \cs{stex_in_smsmode:nn} \Arg{filename} \Arg{code} \end{syntax} -% Executes \meta{code} in SMS mode, followed by the content of \meta{filename}. -% \meta{code} can be used e.g. to set the current repository, and is -% executed within a new tex group, and the same group as the file content. -% \end{function} -% -% \begin{function}{\stex_smsmode_do:} -% Starts gobbling tokens until one is encountered that is allowed in SMS mode. -% \end{function} -% -% \subsection{Imports and Inheritance} -% -% \begin{function}{\importmodule} -% \begin{syntax} \cs{importmodule}|[|\meta{archive-ID}|]|\Arg{module-path} \end{syntax} -% Imports a module by reading it from a file and ``activating'' it. -% \sTeX determines the module and its containing file by passing its -% arguments on to \cs{stex_import_module_path:nn}. -% -% \end{function} -% -% \begin{function}{\usemodule} -% \begin{syntax} \cs{importmodule}|[|\meta{archive-ID}|]|\Arg{module-path} \end{syntax} -% Like \cs{importmodule}, but does not export its contents; -% i.e. including the current module will not activate the used module -% \end{function} -% -% \begin{function}{\stex_import_module_uri:nn} -% \begin{syntax} \cs{stex_import_module_uri:nn} \Arg{archive-ID} \Arg{module-path} \end{syntax} -% Determines the URI of a module by splitting -% \meta{module-path} into \meta{path}|?|\meta{name}. If \meta{module-path} -% does \emph{not} contain a |?|-character, we consider it to be the \meta{name}, -% and \meta{path} to be empty. -% -% If \meta{archive-ID} is empty, it is automatically set to the -% ID of the current archive (if one exists). -% -% \begin{enumerate} -% \item If \meta{archive-ID} is empty: -% \begin{enumerate} -% \item If \meta{path} is empty, then -% \meta{name} must have been declared earlier in the same file -% and retrievable from \cs{g_stex_modules_in_file_seq}, or -% a file with name \meta{name}|.|\meta{lang}|.tex| must exist -% in the same folder, containing a module \meta{name}. -% -% That module should have the same namespace as the current one. -% \item If \meta{path} is not empty, it must point to the relative -% path of the containing file as well as the namespace. -% \end{enumerate} -% \item Otherwise: -% \begin{enumerate} -% \item If \meta{path} is empty, then -% \meta{name} must have been declared earlier in the same file -% and retrievable from \cs{g_stex_modules_in_file_seq}, or -% a file with name \meta{name}|.|\meta{lang}|.tex| must exist -% in the top |source| folder of the archive, -% containing a module \meta{name}. -% -% That module should lie directly in the namespace -% of the archive. -% \item If \meta{path} is not empty, it must point to the -% path of the containing file as well as the namespace, -% relative to the namespace of the archive. -% -% If a module by that namespace exists, it is returned. -% Otherwise, we call \cs{stex_require_module:nn} -% on the |source| directory of the archive to find the -% file. -% \end{enumerate} -% \end{enumerate} -% \end{function} -% \begin{variable}{ -% \l_stex_import_name_str,\l_stex_import_archive_str,\l_stex_import_path_str,\l_stex_import_ns_str -% } -% stores the result in these four variables. -% \end{variable} -% -% \begin{function}{\stex_import_require_module:nnnn} -% \begin{syntax} \Arg{ns} \Arg{archive-ID} \Arg{path} \Arg{name} \end{syntax} -% Checks whether a module with URI \meta{ns}|?|\meta{name} already -% exists. If not, it looks for a plausible file that declares -% a module with that URI. -% -% Finally, activates that module by executing its |_code|-macro. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:inheritance:impl} -% -% \section{\sTeX-Module Inheritance Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% inheritance.dtx %%%%%%%%%%%%% - -% \end{macrocode} -% -% \subsection{SMS Mode} -% \begin{macrocode} -%<@@=stex_smsmode> -% \end{macrocode} -% -% \begin{variable}{ -% \g_stex_smsmode_allowedmacros_tl, -% \g_stex_smsmode_allowedmacros_escape_tl, -% \g_stex_smsmode_allowedenvs_seq -% } -% \begin{macrocode} -\tl_new:N \g_stex_smsmode_allowedmacros_tl -\tl_new:N \g_stex_smsmode_allowedmacros_escape_tl -\seq_new:N \g_stex_smsmode_allowedenvs_seq - -\tl_set:Nn \g_stex_smsmode_allowedmacros_tl { - \makeatletter - \makeatother - \ExplSyntaxOn - \ExplSyntaxOff - \rustexBREAK -} - -\tl_set:Nn \g_stex_smsmode_allowedmacros_escape_tl { - \symdef - \importmodule - \notation - \symdecl - \STEXexport - \inlineass - \inlinedef - \inlineex - \endinput - \setnotation - \copynotation - \assign - \renamedecl - \donotcopy - \instantiate - \textsymdecl -} - -\exp_args:NNx \seq_set_from_clist:Nn \g_stex_smsmode_allowedenvs_seq { - \tl_to_str:n { - smodule, - copymodule, - interpretmodule, - realization, - sdefinition, - sexample, - sassertion, - sparagraph, - mathstructure, - extstructure, - extstructure* - } -} -% \end{macrocode} -% \end{variable} -% -% \begin{macro}[pTF]{\stex_if_smsmode:} -% \begin{macrocode} -\bool_new:N \g_@@_bool -\bool_set_false:N \g_@@_bool -\prg_new_conditional:Nnn \stex_if_smsmode: { p, T, F, TF } { - \bool_if:NTF \g_@@_bool \prg_return_true: \prg_return_false: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_in_smsmode:nn} -% \begin{macrocode} -\cs_new_protected:Nn \_@@_in_smsmode:nn { \stex_suppress_html:n { - \vbox_set:Nn \l_tmpa_box { - \bool_set_eq:cN { l_@@_#1_bool } \g_@@_bool - \bool_gset_true:N \g_@@_bool - #2 - \bool_gset_eq:Nc \g_@@_bool { l_@@_#1_bool } - } - \box_clear:N \l_tmpa_box -} } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_file_in_smsmode:nn} -% \begin{macrocode} -\quark_new:N \q_@@_break - -\NewDocumentCommand \_@@_importmodule: { O{} m} { - \seq_gput_right:Nn \l_@@_importmodules_seq {{#1}{#2}} - \stex_smsmode_do: -} - -\cs_new_protected:Nn \_@@_module:nn { - \__stex_modules_args:n{#1} - \stex_if_in_module:F { - \str_if_empty:NF \l_stex_module_sig_str { - \stex_modules_current_namespace: - \str_set:Nx \l_stex_module_name_str { #2 } - \stex_if_module_exists:nF{\l_stex_module_ns_str?\l_stex_module_name_str}{ - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpb_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpb_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str % <filename> - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \l_tmpa_seq / - \l_tmpa_str . \l_stex_module_sig_str .tex - } - \IfFileExists \l_tmpa_str { - \exp_args:NNx \seq_gput_right:Nn \l_@@_sigmodules_seq \l_tmpa_str - }{ - \msg_error:nnx{stex}{error/unknownmodule}{for~signature~\l_tmpa_str} - } - } - } - } -} - -\prg_new_conditional:Nnn \_@@_check_import_pair:nn {T,F,TF} { - %\stex_debug:nn{import-pair}{\detokenize{{#1}~{#2}}} - \tl_if_empty:nTF{#1}{ - \prop_if_exist:NTF \l_stex_current_repository_prop - { - %\stex_debug:nn{import-pair}{in repository \prop_item:Nn \l_stex_current_repository_prop {id}} - \prg_return_true: - } { - \seq_set_split:Nnn \l_tmpa_seq ? {#2} - \seq_get_left:NN \l_tmpa_seq \l_tmpa_tl - \tl_if_empty:NT \l_tmpa_tl { - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl - } - %\stex_debug:nn{import-pair}{\seq_use:Nn \l_tmpa_seq,~of~length~\seq_count:N \l_tmpa_seq} - \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} > 1 - \prg_return_true: \prg_return_false: - } - }\prg_return_true: -} - -\cs_new_protected:Nn \stex_file_in_smsmode:nn { - \stex_filestack_push:n{#1} - \seq_gclear:N \l_@@_importmodules_seq - \seq_gclear:N \l_@@_sigmodules_seq - % ----- new ----------------------------- - \_@@_in_smsmode:nn{#1}{ - \let\importmodule\_@@_importmodule: - \let\stex_module_setup:nn\_@@_module:nn - \let\__stex_modules_begin_module:\relax - \let\__stex_modules_end_module:\relax - \seq_clear:N \g_stex_smsmode_allowedenvs_seq - \exp_args:NNx \seq_put_right:Nn \g_stex_smsmode_allowedenvs_seq {\tl_to_str:n{smodule}} - \tl_clear:N \g_stex_smsmode_allowedmacros_tl - \tl_clear:N \g_stex_smsmode_allowedmacros_escape_tl - \tl_put_right:Nn \g_stex_smsmode_allowedmacros_escape_tl {\importmodule} - \everyeof{\q_@@_break\noexpand} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "#1"\relax - - \seq_map_inline:Nn \l_@@_sigmodules_seq { - \stex_filestack_push:n{##1} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "##1"\relax - \stex_filestack_pop: - } - } - % ----- new ----------------------------- - \_@@_in_smsmode:nn{#1} { - #2 - % ----- new ----------------------------- - \begingroup - %\stex_debug:nn{smsmode}{Here:~\seq_use:Nn\l_@@_importmodules_seq, } - \seq_map_inline:Nn \l_@@_importmodules_seq { - \_@@_check_import_pair:nnT ##1 { \begingroup - \stex_import_module_uri:nn ##1 - \stex_import_require_module:nnnn - \l_stex_import_ns_str - \l_stex_import_archive_str - \l_stex_import_path_str - \l_stex_import_name_str \endgroup - } - } - \endgroup - \stex_debug:nn{smsmode}{Actually~loading~file~#1} - % ----- new ----------------------------- - \everyeof{\q_@@_break\noexpand} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "#1"\relax - } - \stex_filestack_pop: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_smsmode_do:} -% is executed on encountering |\| in smsmode. -% It checks whether the corresponding command is allowed and executes -% or ignores it accordingly: -% \begin{macrocode} -\cs_new_protected:Npn \stex_smsmode_do: { - \stex_if_smsmode:T { - \_@@_do:w - } -} -\cs_new_protected:Npn \_@@_do:w #1 { - \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #1 }}{ - \expandafter\if\expandafter\relax\noexpand#1 - \expandafter\_@@_do_aux:N\expandafter#1 - \else\expandafter\_@@_do:w\fi - }{ - \_@@_do:w %#1 - } -} -\cs_new_protected:Nn \_@@_do_aux:N { - \cs_if_eq:NNF #1 \q_@@_break { - \tl_if_in:NnTF \g_stex_smsmode_allowedmacros_tl {#1} { - #1\_@@_do:w - }{ - \tl_if_in:NnTF \g_stex_smsmode_allowedmacros_escape_tl {#1} { - #1 - }{ - \cs_if_eq:NNTF \begin #1 { - \_@@_check_begin:n - }{ - \cs_if_eq:NNTF \end #1 { - \_@@_check_end:n - }{ - \_@@_do:w - } - } - } - } - } -} - -\cs_new_protected:Nn \_@@_check_begin:n { - \seq_if_in:NxTF \g_stex_smsmode_allowedenvs_seq { \detokenize{#1} }{ - \begin{#1} - }{ - \_@@_do:w - } -} -\cs_new_protected:Nn \_@@_check_end:n { - \seq_if_in:NxTF \g_stex_smsmode_allowedenvs_seq { \detokenize{#1} }{ - \end{#1}\_@@_do:w - }{ - \str_if_eq:nnTF{#1}{document}{\endinput}{\_@@_do:w} - } -} -% \end{macrocode} -% \end{macro} -% - -% \subsection{Inheritance} -% \begin{macrocode} -%<@@=stex_importmodule> -% \end{macrocode} -% -% \begin{macro}{\stex_import_module_uri:nn} -% \begin{macrocode} -\cs_new_protected:Nn \stex_import_module_uri:nn { - \str_set:Nx \l_stex_import_archive_str { #1 } - \str_set:Nn \l_stex_import_path_str { #2 } - - \exp_args:NNNo \seq_set_split:Nnn \l_tmpb_seq ? { \l_stex_import_path_str } - \seq_pop_right:NN \l_tmpb_seq \l_stex_import_name_str - \str_set:Nx \l_stex_import_path_str { \seq_use:Nn \l_tmpb_seq ? } - - \stex_modules_current_namespace: - \bool_lazy_all:nTF { - {\str_if_empty_p:N \l_stex_import_archive_str} - {\str_if_empty_p:N \l_stex_import_path_str} - {\stex_if_module_exists_p:n { \l_stex_module_ns_str ? \l_stex_import_name_str } } - }{ - \str_set_eq:NN \l_stex_import_path_str \l_stex_module_subpath_str - \str_set_eq:NN \l_stex_import_ns_str \l_stex_module_ns_str - }{ - \str_if_empty:NT \l_stex_import_archive_str { - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { id } \l_stex_import_archive_str - } - } - \str_if_empty:NTF \l_stex_import_archive_str { - \str_if_empty:NF \l_stex_import_path_str { - \stex_path_from_string:Nn \l_tmpb_seq { - \l_stex_module_ns_str / .. / \l_stex_import_path_str - } - \str_set:Nx \l_stex_import_ns_str {\stex_path_to_string:N \l_tmpb_seq} - \str_replace_once:Nnn \l_stex_import_ns_str {file:/} {file://} - } - }{ - \stex_require_repository:n \l_stex_import_archive_str - \prop_get:cnN { c_stex_mathhub_\l_stex_import_archive_str _manifest_prop } { ns } - \l_stex_import_ns_str - \str_if_empty:NF \l_stex_import_path_str { - \str_set:Nx \l_stex_import_ns_str { - \l_stex_import_ns_str / \l_stex_import_path_str - } - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{ -% \l_stex_import_name_str,\l_stex_import_archive_str,\l_stex_import_path_str,\l_stex_import_ns_str -% } -% Store the return values of \cs{stex_import_module_uri:nn}. -% \begin{macrocode} -\str_new:N \l_stex_import_name_str -\str_new:N \l_stex_import_archive_str -\str_new:N \l_stex_import_path_str -\str_new:N \l_stex_import_ns_str -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_import_require_module:nnnn} -% \begin{syntax} \Arg{ns} \Arg{archive-ID} \Arg{path} \Arg{name} \end{syntax} -% \begin{macrocode} -\cs_new_protected:Nn \stex_import_require_module:nnnn { - \exp_args:Nx \stex_if_module_exists:nF { #1 ? #4 } { - - \stex_debug:nn{requiremodule}{Here:\\~~1:~#1\\~~2:~#2\\~~3:~#3\\~~4:~#4} - - \exp_args:NNxx \seq_set_split:Nnn \l_tmpa_seq {\tl_to_str:n{/}} {#4} - \seq_get_left:NN \l_tmpa_seq \l_tmpc_str - - %\stex_debug:nn{requiremodule}{Top~module:\l_tmpc_str} - - % archive - \str_set:Nx \l_tmpa_str { #2 } - \str_if_empty:NTF \l_tmpa_str { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_put_right:Nn \l_tmpa_seq {..} - } { - \stex_path_from_string:Nn \l_tmpb_seq { \l_tmpa_str } - \seq_concat:NNN \l_tmpa_seq \c_stex_mathhub_seq \l_tmpb_seq - \seq_put_right:Nn \l_tmpa_seq { source } - } - - % path - \str_set:Nx \l_tmpb_str { #3 } - \str_if_empty:NTF \l_tmpb_str { - \str_set:Nx \l_tmpa_str { \stex_path_to_string:N \l_tmpa_seq / \l_tmpc_str } - - \ltx@ifpackageloaded{babel} { - \exp_args:NNx \prop_get:NnNF \c_stex_language_abbrevs_prop - { \languagename } \l_tmpb_str { - \msg_error:nnx{stex}{error/unknownlanguage}{\languagename} - } - } { - \str_clear:N \l_tmpb_str - } - - \stex_debug:nn{modules}{Checking~a1~\l_tmpa_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~a2~\l_tmpa_str.tex} - \IfFileExists{ \l_tmpa_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~a3~\l_tmpa_str.en.tex} - \IfFileExists{ \l_tmpa_str.en.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.en.tex } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{#1?#4} - } - } - } - - } { - \seq_set_split:NnV \l_tmpb_seq / \l_tmpb_str - \seq_concat:NNN \l_tmpb_seq \l_tmpa_seq \l_tmpb_seq - - \ltx@ifpackageloaded{babel} { - \exp_args:NNx \prop_get:NnNF \c_stex_language_abbrevs_prop - { \languagename } \l_tmpb_str { - \msg_error:nnx{stex}{error/unknownlanguage}{\languagename} - } - } { - \str_clear:N \l_tmpb_str - } - - \stex_path_canonicalize:N \l_tmpb_seq - \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str - - \stex_debug:nn{modules}{Checking~b1~\l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~b2~\l_tmpa_str/\l_tmpc_str.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str/\l_tmpc_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~b3~\l_tmpa_str/\l_tmpc_str.en.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.en.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str/\l_tmpc_str.en.tex } - }{ - \stex_debug:nn{modules}{Checking~b4~\l_tmpa_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~b4~\l_tmpa_str.tex} - \IfFileExists{ \l_tmpa_str.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~b5~\l_tmpa_str.en.tex} - \IfFileExists{ \l_tmpa_str.en.tex }{ - \str_gset:Nx \g_@@_file_str { \l_tmpa_str.en.tex } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{#1?#4} - } - } - } - } - } - } - } - - \str_if_eq:eeF{\g_@@_file_str}{\seq_use:Nn \g_stex_currentfile_seq /}{ - \exp_args:No \stex_file_in_smsmode:nn { \g_@@_file_str } { - \seq_clear:N \l_stex_all_modules_seq - \str_clear:N \l_stex_current_module_str - \str_set:Nx \l_tmpb_str { #2 } - \str_if_empty:NF \l_tmpb_str { - \stex_set_current_repository:n { #2 } - } - \stex_debug:nn{modules}{Loading~\g_@@_file_str} - } - - \stex_if_module_exists:nF { #1 ? #4 } { - \msg_error:nnx{stex}{error/unknownmodule}{ - #1?#4~(in~file~\g_@@_file_str) - } - } - } - - } - \stex_activate_module:n { #1 ? #4 } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\importmodule} -% \begin{macrocode} -\NewDocumentCommand \importmodule { O{} m } { - \stex_import_module_uri:nn { #1 } { #2 } - \stex_debug:nn{modules}{Importing~module:~ - \l_stex_import_ns_str ? \l_stex_import_name_str - } - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn - {import} {\l_stex_import_ns_str ? \l_stex_import_name_str} {} - } - \stex_execute_in_module:x { - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - } - \exp_args:Nx \stex_add_import_to_current_module:n { - \l_stex_import_ns_str ? \l_stex_import_name_str - } - \stex_smsmode_do: - \ignorespacesandpars -} -\stex_deactivate_macro:Nn \importmodule {module~environments} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\usemodule} -% \begin{macrocode} -\NewDocumentCommand \usemodule { O{} m } { - \stex_if_smsmode:F { - \stex_import_module_uri:nn { #1 } { #2 } - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - \stex_annotate_invisible:nnn - {usemodule} {\l_stex_import_ns_str ? \l_stex_import_name_str} {} - } - \stex_smsmode_do: - \ignorespacesandpars -} -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_csl_to_imports:Nn { - \tl_if_empty:nF{#2}{ - \clist_set:Nn \l_tmpa_clist {#2} - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_head_eq_charcode:nNTF {##1}[{ - #1 ##1 - }{ - #1{##1} - } - } - } -} -\cs_generate_variant:Nn \stex_csl_to_imports:Nn {No} - - -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx deleted file mode 100644 index e7749dad93f..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-mathhub.dtx +++ /dev/null @@ -1,975 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-MathHub -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-mathhub} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \fi -% -% -% \begin{documentation}\label{pkg:mathhub:doc} -% \changes{3.1.0}{2022/03/09}{Fixed a bug with \textbackslash inputref outside of archives} -% -% This sub package provides code for handling \sTeX archives, -% files, file paths and related methods. -% -% \ifinfulldoc\else -% \begin{sfragment}{Manual}\input{../../doc/packages/stex-mathhub}\end{sfragment} -% \fi -% -% \section{Macros and Environments}\label{pkg:mathhub:doc:macros} -% -% \begin{function}{\stex_kpsewhich:n} -% |\stex_kpsewhich:n| executes kpsewhich and stores the return -% in\\ |\l_stex_kpsewhich_return_str|. This does not require -% shell escaping. -% \end{function} -% -% \subsection{Files, Paths, URIs} -% -% \begin{function}{\stex_path_from_string:Nn} -% -% \begin{syntax} \cs{stex_path_from_string:Nn} \meta{path-variable} \Arg{string} \end{syntax} -% turns the \meta{string} into a path by splitting it at |/|-characters -% and stores the result in \meta{path-variable}. Also applies -% \cs{stex_path_canonicalize:N}. -% \end{function} -% -% \begin{function}{\stex_path_to_string:NN, \stex_path_to_string:N} -% The inverse; turns a path into a string and stores it in the second -% argument variable, or leaves it in the input stream. -% \end{function} -% -% \begin{function}{\stex_path_canonicalize:N} -% Canonicalizes the path provided; in particular, resolves |.| and |..| -% path segments. -% \end{function} -% -% \begin{function}[pTF]{\stex_path_if_absolute:N} -% Checks whether the path provided is \emph{absolute}, i.e. starts -% with an empty segment -% \end{function} -% -% \begin{variable}{\c_stex_pwd_seq, \c_stex_pwd_str, \c_stex_mainfile_seq, \c_stex_mainfile_str} -% Store the current working directory as path-sequence and string, -% respectively, and the (heuristically guessed) full path to the -% main file, based on the PWD and |\jobname|. -% \end{variable} -% -% \begin{variable}{\g_stex_currentfile_seq} -% The file being currently processed (respecting |\input| etc.) -% \end{variable} -% -% \begin{function}{\stex_filestack_push:n,\stex_filestack_pop:} -% Push and pop (repsectively) a file path to the file stack, -% to keep track of the current file. Are called in hooks |file/before| -% and |file/after|, respectively. -% \end{function} -% -% \subsection{MathHub Archives} -% -% \begin{variable}{\mathhub, \c_stex_mathhub_seq, \c_stex_mathhub_str} -% We determine the path to the local MathHub folder via one of -% four means, in order of precedence: -% \begin{enumerate} -% \item The |mathhub| package option, or -% \item the |\mathhub|-macro, if it has been defined before -% the |\usepackage{stex}|-statement, or -% \item the |MATHHUB| system variable, or -% \item a path specified in |~/.stex/mathhub.path|. -% \end{enumerate} -% In all four cases, \cs{c_stex_mathhub_seq} and -% \cs{c_stex_mathhub_str} are set accordingly. -% \end{variable} -% -% \begin{variable}{\l_stex_current_repository_prop} -% Always points to the \emph{current} MathHub repository (if -% we currently are in one). Has the following fields corresponding -% to the entries in the |MANIFEST.MF|-file: -% \begin{itemize} -% \item[|id|:] The name of the archive, including its group (e.g. |smglom/calculus|), -% \item[|ns|:] The content namespace (for modules and symbols), -% \item[|narr|:] the narration namespace (for document references), -% \item[|docurl|:] The URL that is used as a basis for \emph{external references}, -% \item[|deps|:] All archives that this archive depends on (currently not in use). -% \end{itemize} -% \end{variable} -% -% \begin{function}{\stex_set_current_repository:n} -% Sets the current repository to the one with the provided ID. -% calls \cs{__stex_mathhub_do_manifest:n}, so works whether this -% repository's |MANIFEST.MF|-file has already been read or not. -% \end{function} -% -% \begin{function}{\stex_require_repository:n} -% Calls \cs{__stex_mathhub_do_manifest:n} iff the corresponding -% archive property list does not already exist, and -% adds a corresponding definition to the |.sms|-file. -% \end{function} -% -% \begin{function}{\stex_in_repository:nn} -% \begin{syntax}\cs{stex_in_repository:nn}\Arg{repository-name}\Arg{code}\end{syntax} -% Change the current repository to \Arg{repository-name} (or not, if \Arg{repository-name} is -% empty), and passes its ID on to \Arg{code} as |#1|. Switches back -% to the previous repository after executing \Arg{code}. -% \end{function} -% -% \subsection{Using Content in Archives} -% -% \begin{function}[EXP]{\mhpath} -% \begin{syntax}\cs{mhpath}\Arg{archive-ID}\Arg{filename}\end{syntax} -% Expands to the full path of file \meta{filename} in repository \meta{archive-ID}. -% Does not check whether the file or the repository exist. -% \end{function} -% -% \begin{function}{\inputref,\mhinput} -% \begin{syntax}\cs{inputref}|[|\meta{archive-ID}|]|\Arg{filename}\end{syntax} -% Both \cs{input} the file \meta{filename} in archive \meta{archive-ID} (relative -% to the |source|-subdirectory). \cs{mhinput} does so directly. -% \cs{inputref} does so within an |\begingroup|...|\endgroup|-block, -% and skips it in |html|-mode, inserting a \emph{reference} to the -% file instead. -% -% Both also set |\ifinputref| to true. -% \end{function} -% -% \begin{function}{\addmhbibresource} -% \begin{syntax}\cs{inputref}|[|\meta{archive-ID}|]|\Arg{filename}\end{syntax} -% Adds a |.bib|-file \meta{filename} in archive \meta{archive-ID} (relative -% to the top-directory of the archive!). -% \end{function} -% -% \begin{function}{\libinput} -% \begin{syntax} \cs{libinput}\Arg{filename} \end{syntax} -% Inputs \meta{filename}|.tex| from the |lib| folders in the -% current archive and the |meta-inf|-archive of the current archive group(s) -% (if existent) in descending order. Throws an error if no file by that name exists in -% any of the relevant |lib|-folders. -% \end{function} -% -% \begin{function}{\libusepackage} -% \begin{syntax} \cs{libusepackage}[\meta{args}]\Arg{filename} \end{syntax} -% Like \cs{libinput}, but looks for |.sty|-files and calls -% |\usepackage[\meta{args}]\Arg{filename}| instead of \cs{input}. -% -% Throws an error, if none or more than one suitable package file is found. -% \end{function} -% -% \begin{function}{\mhgraphics,\cmhgraphics} -% \emph{If} the \pkg{graphicx} package is loaded, these -% macros are defined at |\begin{document}|. -% -% \cs{mhgraphics} takes the same arguments as \cs{includegraphics}, -% with the additional optional key |mhrepos|. It then resolves -% the file path in |\mhgraphics[mhrepos=Foo/Bar]{foo/bar.png}| -% relative to the |source|-folder of the |Foo/Bar|-archive. -% -% \cs{cmhgraphics} additional wraps the image in a |center|-environment. -% \end{function} -% -% \begin{function}{\lstinputmhlisting,\clstinputmhlisting} -% Like \cs{mhgraphics}, but only defined if the \pkg{listings}-package -% is loaded, and with \cs{lstinputlisting} instead of \cs{includegraphics}. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation} -% -% \section{\sTeX-MathHub Implementation}\label{pkg:mathhub:doc:impl} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% mathhub.dtx %%%%%%%%%%%%% - -%<@@=stex_path> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/norepository}{ - No~archive~#1~found~in~#2 -} -\msg_new:nnn{stex}{error/notinarchive}{ - Not~currently~in~an~archive,~but~\detokenize{#1}~ - needs~one! -} -\msg_new:nnn{stex}{error/nofile}{ - \detokenize{#1}~could~not~find~file~#2 -} -\msg_new:nnn{stex}{error/twofiles}{ - \detokenize{#1}~found~two~candidates~for~#2 -} -% \end{macrocode} -% -% \subsubsection{Generic Path Handling} -% -% We treat paths as \LaTeX3-sequences (of the individual -% path segments, i.e. separated by a /-character) unix-style; -% i.e. a path is absolute if the sequence starts with an empty -% entry. -% -% \begin{macro}{\stex_path_from_string:Nn} -% \begin{macrocode} -\cs_new_protected:Nn \stex_path_from_string:Nn { - \stex_debug:nn{files}{#2} - \str_set:Nx \l_tmpa_str { #2 } - \str_if_empty:NTF \l_tmpa_str { - \seq_clear:N #1 - }{ - \exp_args:NNNo \seq_set_split:Nnn #1 / { \l_tmpa_str } - \sys_if_platform_windows:T{ - \seq_clear:N \l_tmpa_tl - \seq_map_inline:Nn #1 { - \seq_set_split:Nnn \l_tmpb_tl \c_backslash_str { ##1 } - \seq_concat:NNN \l_tmpa_tl \l_tmpa_tl \l_tmpb_tl - } - \seq_set_eq:NN #1 \l_tmpa_tl - } - \stex_path_canonicalize:N #1 - } - \stex_debug:nn{files}{Yields: \stex_path_to_string:N#1} -} - -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_path_to_string:NN,\stex_path_to_string:N} -% \begin{macrocode} -\cs_new_protected:Nn \stex_path_to_string:NN { - \exp_args:NNe \str_set:Nn #2 { \seq_use:Nn #1 / } -} - -\cs_new:Nn \stex_path_to_string:N { - \seq_use:Nn #1 / -} -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\c_@@_dot_str,\c_@@_up_str} -% -% |.| and |..|, respectively. -% -% \begin{macrocode} -\str_const:Nn \c_@@_dot_str {.} -\str_const:Nn \c_@@_up_str {..} -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_path_canonicalize:N} -% -% Canonicalizes the path provided; in particular, resolves |.| and |..| -% path segments. -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_path_canonicalize:N { - \seq_if_empty:NF #1 { - \seq_clear:N \l_tmpa_seq - \seq_get_left:NN #1 \l_tmpa_tl - \str_if_empty:NT \l_tmpa_tl { - \seq_put_right:Nn \l_tmpa_seq {} - } - \seq_map_inline:Nn #1 { - \str_set:Nn \l_tmpa_tl { ##1 } - \str_if_eq:NNF \l_tmpa_tl \c_@@_dot_str { - \str_if_eq:NNTF \l_tmpa_tl \c_@@_up_str { - \seq_if_empty:NTF \l_tmpa_seq { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \c_@@_up_str - } - }{ - \seq_get_right:NN \l_tmpa_seq \l_tmpa_tl - \str_if_eq:NNTF \l_tmpa_tl \c_@@_up_str { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \c_@@_up_str - } - }{ - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_tl - } - } - }{ - \str_if_empty:NF \l_tmpa_tl { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { \l_tmpa_tl } - } - } - } - } - \seq_gset_eq:NN #1 \l_tmpa_seq - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[pTF]{\stex_path_if_absolute:N} -% \begin{macrocode} -\prg_new_conditional:Nnn \stex_path_if_absolute:N {p, T, F, TF} { - \seq_if_empty:NTF #1 { - \prg_return_false: - }{ - \seq_get_left:NN #1 \l_tmpa_tl - \sys_if_platform_windows:TF{ - \str_if_in:NnTF \l_tmpa_tl {:}{ - \prg_return_true: - }{ - \prg_return_false: - } - }{ - \str_if_empty:NTF \l_tmpa_tl { - \prg_return_true: - }{ - \prg_return_false: - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \subsubsection{PWD and kpsewhich} -% -% \begin{macro}{\stex_kpsewhich:n} -% \begin{macrocode} -\str_new:N\l_stex_kpsewhich_return_str -\cs_new_protected:Nn \stex_kpsewhich:n {\begingroup - \catcode`\ =12 - \sys_get_shell:nnN { kpsewhich ~ #1 } { } \l_tmpa_tl - \tl_gset_eq:NN \l_tmpa_tl \l_tmpa_tl - \endgroup - \exp_args:NNo\str_set:Nn\l_stex_kpsewhich_return_str{\l_tmpa_tl} - \tl_trim_spaces:N \l_stex_kpsewhich_return_str -} -% \end{macrocode} -% \end{macro} -% -% We determine the PWD -% -% \begin{variable}{\c_stex_pwd_seq,\c_stex_pwd_str} -% \begin{macrocode} -\sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str CD\c_percent_str} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} -}{ - \stex_kpsewhich:n{-var-value~PWD} -} - -\stex_path_from_string:Nn\c_stex_pwd_seq\l_stex_kpsewhich_return_str -\stex_path_to_string:NN\c_stex_pwd_seq\c_stex_pwd_str -\stex_debug:nn {mathhub} {PWD:~\str_use:N\c_stex_pwd_str} -% \end{macrocode} -% \end{variable} -% -% \subsubsection{File Hooks and Tracking} -% \begin{macrocode} -%<@@=stex_files> -% \end{macrocode} -% -% We introduce hooks for file inputs that keep track of the -% absolute paths of files used. This will be useful to keep track -% of modules, their archives, namespaces etc. -% -% Note that the absolute paths are only accurate in |\input|-statements -% for paths relative to the PWD, so they shouldn't be relied upon -% in any other setting than for \sTeX-purposes. -% -% \begin{variable}{\g_@@_stack} -% -% keeps track of file changes -% -% \begin{macrocode} -\seq_gclear_new:N\g_@@_stack -% \end{macrocode} -% \end{variable} -% -% \begin{variable}{\c_stex_mainfile_seq, \c_stex_mainfile_str} -% \begin{macrocode} -\str_set:Nx \c_stex_mainfile_str {\c_stex_pwd_str/\jobname.tex} -\stex_path_from_string:Nn \c_stex_mainfile_seq - \c_stex_mainfile_str -% \end{macrocode} -% \end{variable} -% -% \begin{variable}{\g_stex_currentfile_seq} -% \begin{macrocode} -\seq_gclear_new:N\g_stex_currentfile_seq -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_filestack_push:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_filestack_push:n { - \stex_path_from_string:Nn\g_stex_currentfile_seq{#1} - \stex_path_if_absolute:NF\g_stex_currentfile_seq{ - \stex_path_from_string:Nn\g_stex_currentfile_seq{ - \c_stex_pwd_str/#1 - } - } - \seq_gset_eq:NN\g_stex_currentfile_seq\g_stex_currentfile_seq - \exp_args:NNo\seq_gpush:Nn\g_@@_stack\g_stex_currentfile_seq - \stex_get_document_uri: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_filestack_pop:} -% \begin{macrocode} -\cs_new_protected:Nn \stex_filestack_pop: { - \seq_if_empty:NF\g_@@_stack{ - \seq_gpop:NN\g_@@_stack\l_tmpa_seq - } - \seq_if_empty:NTF\g_@@_stack{ - \seq_gset_eq:NN\g_stex_currentfile_seq\c_stex_mainfile_seq - }{ - \seq_get:NN\g_@@_stack\l_tmpa_seq - \seq_gset_eq:NN\g_stex_currentfile_seq\l_tmpa_seq - } - \stex_get_document_uri: -} -% \end{macrocode} -% \end{macro} -% -% Hooks for the current file: -% -% \begin{macrocode} -\AddToHook{file/before}{ - \tl_if_empty:NTF\CurrentFilePath{ - \stex_filestack_push:n{\CurrentFile} - }{ - \stex_filestack_push:n{\CurrentFilePath/\CurrentFile} - } -} -\AddToHook{file/after}{ - \stex_filestack_pop: -} -% \end{macrocode} -% -% \subsection{MathHub Repositories} -% \begin{macrocode} -%<@@=stex_mathhub> -% \end{macrocode} -% -% \begin{variable}{\mathhub, \c_stex_mathhub_seq, \c_stex_mathhub_str} -% The path to the mathhub directory. If the \cs{mathhub}-macro is not set, -% we query |kpsewhich| for the |MATHHUB| system variable. -% \begin{macrocode} -\str_if_empty:NTF\mathhub{ - \sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str MATHHUB\c_percent_str} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:NNx\str_if_eq:onT\l_stex_kpsewhich_return_str{\c_percent_str MATHHUB\c_percent_str}{\str_clear:N\l_stex_kpsewhich_return_str} - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} - }{ - \stex_kpsewhich:n{-var-value~MATHHUB} - } - \str_set_eq:NN\c_stex_mathhub_str\l_stex_kpsewhich_return_str - - \str_if_empty:NT \c_stex_mathhub_str { - \sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-var-value~HOME} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} - }{ - \stex_kpsewhich:n{-var-value~HOME} - } - \ior_open:NnT \g_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{ - \begingroup\escapechar=-1\catcode`\\=12 - \ior_str_get:NN \g_tmpa_ior \l_tmpa_str - \sys_if_platform_windows:T{ - \exp_args:NNx\str_replace_all:Nnn\l_tmpa_str{\c_backslash_str}/ - } - \str_gset_eq:NN \c_stex_mathhub_str\l_tmpa_str - \endgroup - \ior_close:N \g_tmpa_ior - } - } - \str_if_empty:NTF\c_stex_mathhub_str{ - \msg_warning:nn{stex}{warning/nomathhub} - }{ - \stex_debug:nn{mathhub}{MathHub:~\str_use:N\c_stex_mathhub_str} - \exp_args:NNo \stex_path_from_string:Nn\c_stex_mathhub_seq\c_stex_mathhub_str - } -}{ - \stex_path_from_string:Nn \c_stex_mathhub_seq \mathhub - \stex_path_if_absolute:NF \c_stex_mathhub_seq { - \exp_args:NNx \stex_path_from_string:Nn \c_stex_mathhub_seq { - \c_stex_pwd_str/\mathhub - } - } - \stex_path_to_string:NN\c_stex_mathhub_seq\c_stex_mathhub_str - \stex_debug:nn{mathhub} {MathHub:~\str_use:N\c_stex_mathhub_str} -} -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\_@@_do_manifest:n} -% Checks whether the manifest for archive |#1| already exists, and -% if not, finds and parses the corresponding manifest file -% \begin{macrocode} -\cs_new_protected:Nn \_@@_do_manifest:n { - \prop_if_exist:cF {c_stex_mathhub_#1_manifest_prop} { - \str_set:Nx \l_tmpa_str { #1 } - \prop_new:c { c_stex_mathhub_#1_manifest_prop } - \seq_set_split:NnV \l_tmpa_seq / \l_tmpa_str - \seq_concat:NNN \l_tmpa_seq \c_stex_mathhub_seq \l_tmpa_seq - \_@@_find_manifest:N \l_tmpa_seq - \seq_if_empty:NTF \l_@@_manifest_file_seq { - \msg_error:nnxx{stex}{error/norepository}{#1}{ - \stex_path_to_string:N \c_stex_mathhub_str - } - \input{Fatal~Error!} - } { - \exp_args:No \_@@_parse_manifest:n { \l_tmpa_str } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\l_@@_manifest_file_seq} -% \begin{macrocode} -\seq_new:N\l_@@_manifest_file_seq -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\_@@_find_manifest:N} -% -% Attempts to find the |MANIFEST.MF| in some file path and -% stores its path in \cs{l_@@_manifest_file_seq}: -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_find_manifest:N { - \seq_set_eq:NN\l_tmpa_seq #1 - \bool_set_true:N\l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_if_empty:NTF \l_tmpa_seq { - \bool_set_false:N\l_tmpa_bool - }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool - }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/META-INF/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{META-INF} - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool - }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/meta-inf/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{meta-inf} - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool - }{ - \seq_pop_right:NN\l_tmpa_seq\l_tmpa_tl - } - } - } - } - } - \seq_set_eq:NN\l_@@_manifest_file_seq\l_tmpa_seq -} -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\c_@@_manifest_ior} -% -% File variable used for |MANIFEST|-files -% -% \begin{macrocode} -\ior_new:N \c_@@_manifest_ior -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\_@@_parse_manifest:n} -% -% Stores the entries in manifest file in the -% corresponding property list: -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_parse_manifest:n { - \seq_set_eq:NN \l_tmpa_seq \l_@@_manifest_file_seq - \ior_open:Nn \c_@@_manifest_ior {\stex_path_to_string:N \l_tmpa_seq} - \ior_map_inline:Nn \c_@@_manifest_ior { - \str_set:Nn \l_tmpa_str {##1} - \exp_args:NNoo \seq_set_split:Nnn - \l_tmpb_seq \c_colon_str \l_tmpa_str - \seq_pop_left:NNTF \l_tmpb_seq \l_tmpa_tl { - \exp_args:NNe \str_set:Nn \l_tmpb_tl { - \exp_args:NNo \seq_use:Nn \l_tmpb_seq \c_colon_str - } - \exp_args:No \str_case:nnTF \l_tmpa_tl { - {id} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { id } \l_tmpb_tl - } - {narration-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { narr } \l_tmpb_tl - } - {url-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { docurl } \l_tmpb_tl - } - {source-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { ns } \l_tmpb_tl - } - {ns} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { ns } \l_tmpb_tl - } - {dependencies} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { deps } \l_tmpb_tl - } - }{}{} - }{} - } - \ior_close:N \c_@@_manifest_ior - \stex_persist:x { - \prop_set_from_keyval:cn{ c_stex_mathhub_#1_manifest_prop }{ - \exp_after:wN \prop_to_keyval:N \csname c_stex_mathhub_#1_manifest_prop\endcsname - } - } -} -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\stex_set_current_repository:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_set_current_repository:n { - \stex_require_repository:n { #1 } - \prop_set_eq:Nc \l_stex_current_repository_prop { - c_stex_mathhub_#1_manifest_prop - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_require_repository:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_require_repository:n { - \prop_if_exist:cF { c_stex_mathhub_#1_manifest_prop } { - \stex_debug:nn{mathhub}{Opening~archive:~#1} - \_@@_do_manifest:n { #1 } - } -} -% \end{macrocode} -% \end{macro} -% -%\begin{variable}{\l_stex_current_repository_prop} -% -% Current MathHub repository -% -% \begin{macrocode} -%\prop_new:N \l_stex_current_repository_prop -\bool_if:NF \c_stex_persist_mode_bool { - \_@@_find_manifest:N \c_stex_pwd_seq - \seq_if_empty:NTF \l_@@_manifest_file_seq { - \stex_debug:nn{mathhub}{Not~currently~in~a~MathHub~repository} - } { - \_@@_parse_manifest:n { main } - \prop_get:NnN \c_stex_mathhub_main_manifest_prop {id} - \l_tmpa_str - \prop_set_eq:cN { c_stex_mathhub_\l_tmpa_str _manifest_prop } - \c_stex_mathhub_main_manifest_prop - \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str } - \stex_debug:nn{mathhub}{Current~repository:~ - \prop_item:Nn \l_stex_current_repository_prop {id} - } - } -} -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_in_repository:nn} -% Executes the code in the second argument in the context -% of the repository whose ID is provided as the first argument. -% \begin{macrocode} -\cs_new_protected:Nn \stex_in_repository:nn { - \str_set:Nx \l_tmpa_str { #1 } - \cs_set:Npn \l_tmpa_cs ##1 { #2 } - \str_if_empty:NTF \l_tmpa_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \stex_debug:nn{mathhub}{do~in~current~repository:~\prop_item:Nn \l_stex_current_repository_prop { id }} - \exp_args:Ne \l_tmpa_cs{ - \prop_item:Nn \l_stex_current_repository_prop { id } - } - }{ - \l_tmpa_cs{} - } - }{ - \stex_debug:nn{mathhub}{in~repository:~\l_tmpa_str} - \stex_require_repository:n \l_tmpa_str - \str_set:Nx \l_tmpa_str { #1 } - \exp_args:Nne \use:nn { - \stex_set_current_repository:n \l_tmpa_str - \exp_args:Nx \l_tmpa_cs{\l_tmpa_str} - }{ - \stex_debug:nn{mathhub}{switching~back~to:~ - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_item:Nn \l_stex_current_repository_prop { id }:~ - \meaning\l_stex_current_repository_prop - }{ - no~repository - } - } - \prop_if_exist:NTF \l_stex_current_repository_prop { - \stex_set_current_repository:n { - \prop_item:Nn \l_stex_current_repository_prop { id } - } - }{ - \let\exp_not:N\l_stex_current_repository_prop\exp_not:N\undefined - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Using Content in Archives} -% -% \begin{macro}{\mhpath} -% \begin{macrocode} -\def \mhpath #1 #2 { - \exp_args:Ne \tl_if_empty:nTF{#1}{ - \c_stex_mathhub_str / - \prop_item:Nn \l_stex_current_repository_prop { id } - / source / #2 - }{ - \c_stex_mathhub_str / #1 / source / #2 - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\inputref,\mhinput} -% \begin{macrocode} -\newif \ifinputref \inputreffalse - -\cs_new_protected:Nn \_@@_mhinput:nn { - \stex_in_repository:nn {#1} { - \ifinputref - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - \else - \inputreftrue - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - \inputreffalse - \fi - } -} -\NewDocumentCommand \mhinput { O{} m}{ - \_@@_mhinput:nn{ #1 }{ #2 } -} - -\cs_new_protected:Nn \_@@_inputref:nn { - \stex_in_repository:nn {#1} { - \stex_html_backend:TF { - \str_clear:N \l_tmpa_str - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - - \tl_if_empty:nTF{ ##1 }{ - \IfFileExists{#2}{ - \stex_annotate_invisible:nnn{inputref}{ - \l_tmpa_str / #2 - }{} - }{ - \input{#2} - } - }{ - \IfFileExists{ \c_stex_mathhub_str / ##1 / source / #2 }{ - \stex_annotate_invisible:nnn{inputref}{ - \l_tmpa_str / #2 - }{} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - } - } - - }{ - \begingroup - \inputreftrue - \tl_if_empty:nTF{ ##1 }{ - \input{#2} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - } - \endgroup - } - } -} -\NewDocumentCommand \inputref { O{} m}{ - \_@@_inputref:nn{ #1 }{ #2 } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\addmhbibresource} -% \begin{macrocode} -\cs_new_protected:Nn \_@@_mhbibresource:nn { - \stex_in_repository:nn {#1} { - \addbibresource{ \c_stex_mathhub_str / ##1 / #2 } - } -} -\newcommand\addmhbibresource[2][]{ - \_@@_mhbibresource:nn{ #1 }{ #2 } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\libinput} -% \begin{macrocode} -\cs_new_protected:Npn \libinput #1 { - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libinput - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libinput - } - \seq_clear:N \l_@@_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / #1.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str - } - - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / #1.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - - \seq_if_empty:NTF \l_@@_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libinput}{#1.tex} - }{ - \seq_map_inline:Nn \l_@@_libinput_files_seq { - \input{ ##1 } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\libusepackage} -% \begin{macrocode} -\NewDocumentCommand \libusepackage {O{} m} { - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libusepackage - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libusepackage - } - \seq_clear:N \l_@@_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / #2} - \IfFileExists{ \l_tmpa_str.sty }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str - } - - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / #2} - \IfFileExists{ \l_tmpa_str.sty }{ - \seq_put_right:No \l_@@_libinput_files_seq \l_tmpa_str - }{} - - \seq_if_empty:NTF \l_@@_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libusepackage}{#2.sty} - }{ - \int_compare:nNnTF {\seq_count:N \l_@@_libinput_files_seq} = 1 { - \seq_map_inline:Nn \l_@@_libinput_files_seq { - \usepackage[#1]{ ##1 } - } - }{ - \msg_error:nnxx{stex}{error/twofiles}{\exp_not:N\libusepackage}{#2.sty} - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\mhgraphics,\cmhgraphics} -% \begin{macrocode} - -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{graphicx}{ - \define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} - \providecommand\mhgraphics[2][]{% - \def\Gin@mhrepos{}\setkeys{Gin}{#1}% - \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}}} - \providecommand\cmhgraphics[2][]{\begin{center}\mhgraphics[#1]{#2}\end{center}} - }{} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\lstinputmhlisting,\clstinputmhlisting} -% \begin{macrocode} - \ltx@ifpackageloaded{listings}{ - \define@key{lst}{mhrepos}{\def\lst@mhrepos{#1}} - \newcommand\lstinputmhlisting[2][]{% - \def\lst@mhrepos{}\setkeys{lst}{#1}% - \lstinputlisting[#1]{\mhpath\lst@mhrepos{#2}}} - \newcommand\clstinputmhlisting[2][]{\begin{center}\lstinputmhlisting[#1]{#2}\end{center}} - }{} -} - -%</package> -% \end{macrocode} -% \end{macro} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx deleted file mode 100644 index 5a9644ac5e8..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-metatheory.dtx +++ /dev/null @@ -1,191 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Metatheory -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-metatheory} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \input{../../doc/packages/stex-metatheory} -% \fi -% -% \begin{documentation}\label{pkg:metatheory:doc} -% -% \section{Symbols}\label{pkg:metatheory:symbols} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:metatheory:impl} -% -% \section{\sTeX-Metatheory Implementation} -% -% \begin{macrocode} -%<*package> -%<@@=stex_modules> - -%%%%%%%%%%%%% metatheory.dtx %%%%%%%%%%%%% - -\str_const:Nn \c_stex_metatheory_ns_str {http://mathhub.info/sTeX/meta} -\begingroup -\stex_module_setup:nn{ - ns=\c_stex_metatheory_ns_str, - meta=NONE -}{Metatheory} -\stex_reactivate_macro:N \symdecl -\stex_reactivate_macro:N \notation -\stex_reactivate_macro:N \symdef -\ExplSyntaxOff -\csname stex_suppress_html:n\endcsname{ - % is-a (a:A, a \in A, a is an A, etc.) - \symdecl{isa}[args=ai] - \notation{isa}[typed,op=:]{#1 \comp{:} #2}{##1 \comp, ##2} - \notation{isa}[in]{#1 \comp\in #2}{##1 \comp, ##2} - \notation{isa}[pred]{#2\comp(#1 \comp)}{##1 \comp, ##2} - - % bind (\forall, \Pi, \lambda etc.) - \symdecl{bind}[args=Bi,assoc=pre] - \notation{bind}[depfun,prec=nobrackets,op={(\cdot)\;\to\;\cdot}]{\comp( #1 \comp{)\;\to\;} #2}{##1 \comp, ##2} - \notation{bind}[forall]{\comp\forall #1.\;#2}{##1 \comp, ##2} - \notation{bind}[Pi]{\comp\prod_{#1}#2}{##1 \comp, ##2} - - % implicit bind - \symdecl{implicitbind}[args=Bi,assoc=pre] - \notation{implicitbind}[braces,prec=nobrackets,op={\{\cdot\}_I\;\cdot}]{\comp\{ #1 \comp{\}_I\;} #2}{##1 \comp, ##2} - \notation{implicitbind}[depfun,prec=nobrackets]{\comp( #1 \comp{)\;\to_I\;} #2}{##1 \comp, ##2} - \notation{implicitbind}[Pi]{\comp\prod^I_{#1}#2}{##1\comp,##2} - - % dummy variable - \symdecl{dummyvar} - \notation{dummyvar}[underscore]{\comp\_} - \notation{dummyvar}[dot]{\comp\cdot} - \notation{dummyvar}[dash]{\comp{{\rm --}}} - - %fromto (function space, Hom-set, implication etc.) - \symdecl{fromto}[args=ai] - \notation{fromto}[xarrow]{#1 \comp\to #2}{##1 \comp\times ##2} - \notation{fromto}[arrow]{#1 \comp\to #2}{##1 \comp\to ##2} - - % mapto (lambda etc.) - %\symdecl{mapto}[args=Bi] - %\notation{mapto}[mapsto]{#1 \comp\mapsto #2}{#1 \comp, #2} - %\notation{mapto}[lambda]{\comp\lambda #1 \comp.\; #2}{#1 \comp, #2} - %\notation{mapto}[lambdau]{\comp\lambda_{#1} \comp.\; #2}{#1 \comp, #2} - - % function/operator application - \symdecl{apply}[args=ia] - \notation{apply}[prec=0;0x\infprec,parens,op=\cdot(\cdot)]{#1 \comp( #2 \comp)}{##1 \comp, ##2} - \notation{apply}[prec=0;0x\infprec,lambda]{#1 \; #2 }{##1 \; ##2} - - % collection of propositions/booleans/truth values - \symdecl{prop}[name=proposition] - \notation{prop}[prop]{\comp{{\rm prop}}} - \notation{prop}[BOOL]{\comp{{\rm BOOL}}} - - \symdecl{judgmentholds}[args=1] - \notation{judgmentholds}[vdash,op=\vdash]{\comp\vdash\; #1} - - % sequences - \symdecl{seqtype}[args=1] - \notation{seqtype}[kleene]{#1^{\comp\ast}} - - \symdecl{seqexpr}[args=a] - \notation{seqexpr}[angle,prec=nobrackets]{\comp\langle #1\comp\rangle}{##1\comp,##2} - - \symdef{seqmap}[args=abi,setlike]{\comp\{#3 \comp| #2\comp\in \dobrackets{#1} \comp\}}{##1 \comp, ##2} - \symdef{seqprepend}[args=ia]{#1 \comp{::} #2}{##1 \comp, ##2} - \symdef{seqappend}[args=ai]{#1 \comp{::} #2}{##1 \comp, ##2} - \symdef{seqfoldleft}[args=iabbi]{ \comp{foldl}\dobrackets{#1,#2}\dobrackets{#3\comp,#4\comp\mapsto#5}}{##1 \comp, ##2} - \symdef{seqfoldright}[args=iabbi,op=foldr]{ \comp{foldr}\dobrackets{#1,#2}\dobrackets{#3\comp,#4\comp\mapsto#5}}{##1 \comp, ##2} - \symdef{seqhead}[args=a]{\comp{head}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqtail}[args=a]{\comp{tail}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqlast}[args=a]{\comp{last}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqinit}[args=a]{\comp{tail}\dobrackets{#1}}{##1 \comp, ##2} - - \symdef{sequence-index}[args=2,li,prec=nobrackets]{{#1}_{#2}} - \notation{sequence-index}[ui,prec=nobrackets]{{#1}^{#2}} - - \symdef{aseqdots}[args=a,prec=nobrackets]{#1\comp{,\ellipses}}{##1\comp,##2} - \symdef{aseqfromto}[args=ai,prec=nobrackets]{#1\comp{,\ellipses,}#2}{##1\comp,##2} - \symdef{aseqfromtovia}[args=aii,prec=nobrackets]{#1\comp{,\ellipses,}#2\comp{,\ellipses,}#3}{##1\comp,##2} - - % nat literals - \symdef{natliteral}{\comp{\mathtt{Ord}}} - - % letin (``let'', local definitions, variable substitution) - \symdecl{letin}[args=bii] - \notation{letin}[let]{\comp{{\rm let}}\;#1\comp{=}#2\;\comp{{\rm in}}\;#3} - \notation{letin}[subst]{#3 \comp[ #1 \comp/ #2 \comp]} - \notation{letin}[frac]{#3 \comp[ \frac{#2}{#1} \comp]} - - % structures - \symdecl*{module-type}[args=1] - \notation{module-type}{\comp{\mathtt{MOD}} #1} - \symdecl{mathstruct}[name=mathematical-structure,args=a] % TODO - \notation{mathstruct}[angle,prec=nobrackets]{\comp\langle #1 \comp\rangle}{##1 \comp, ##2} - - % objects - \symdecl{object} - \notation{object}{\comp{\mathtt{OBJECT}}} - -} - -% The following are abbreviations in the sTeX corpus that are left over from earlier -% developments. They will eventually be phased out. - - \ExplSyntaxOn - \stex_add_to_current_module:n{ - \def\nappli#1#2#3#4{\apply{#1}{\naseqli{#2}{#3}{#4}}} - \def\nappui#1#2#3#4{\apply{#1}{\nasequi{#2}{#3}{#4}}} - \def\livar{\csname sequence-index\endcsname[li]} - \def\uivar{\csname sequence-index\endcsname[ui]} - \def\naseqli#1#2#3{\aseqfromto{\livar{#1}{#2}}{\livar{#1}{#3}}} - \def\nasequi#1#2#3{\aseqfromto{\uivar{#1}{#2}}{\uivar{#1}{#3}}} - } -\_@@_end_module: -\endgroup -% \end{macrocode} -% -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% -% \PrintIndex -% \ifinfulldoc\else\printbibliography\fi -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx deleted file mode 100644 index e76e1ead894..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-modules.dtx +++ /dev/null @@ -1,881 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Modules -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-modules} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}.\fi -% -% -% \begin{documentation}\label{pkg:modules:doc} -% -% This sub package contains code related to Modules -% -% \ifinfulldoc\else -% \input{../../doc/packages/stex-modules} -% \fi -% -% \section{Macros and Environments}\label{pkg:modules:doc:macros} -% -% The content of a module with uri \meta{<URI>} is stored in four -% macros. All modifications of these macros are global: -% \begin{variable}{\c_stex_module_<URI>_prop} -% A property list with the following fields: -% \begin{itemize} -% \item[|name|] The \emph{name} of the module, -% \item[|ns|] the \emph{namespace} in field |ns|, -% \item[|file|] the \emph{file} containing the module, -% as a sequence of path fragments -% \item[|lang|] the module's \emph{language}, -% \item[|sig|] the language of the signature module, if the -% current file is a translation from some other language, -% \item[|deprecate|] if this module is deprecated, the module -% that replaces it, -% \item[|meta|] the metatheory of the module. -% \end{itemize} -% \end{variable} -% -% \begin{variable}{\c_stex_module_<URI>_code} -% The code to execute when this module is activated (i.e. imported), -% e.g. to set all the semantic macros, notations, etc. -% \end{variable} -% -% \begin{variable}{\c_stex_module_<URI>_constants} -% The names of all constants declared in the module -% \end{variable} -% -% \begin{variable}{\c_stex_module_<URI>_constants} -% The full URIs of all modules imported in this module -% \end{variable} -% -% \begin{variable}{\l_stex_current_module_str} -% \cs{l_stex_current_module_str} always -% contains the URI of the current module (if existent). -% \end{variable} -% -% \begin{variable}{\l_stex_all_modules_seq} -% Stores full URIs for all modules currently in scope. -% \end{variable} -% -% \begin{function}[pTF]{\stex_if_in_module:} -% Conditional for whether we are currently in a module -% \end{function} -% -% \begin{function}[pTF]{\stex_if_module_exists:n} -% Conditional for whether a module with the provided URI -% is already known. -% \end{function} -% -% \begin{function}{\stex_add_to_current_module:n,\STEXexport} -% Adds the provided tokens to the |_code| control sequence of the -% current module. -% -% \cs{stex_add_to_current_module:n} is used internally, -% \cs{STEXexport} is intended for users and additionally executes -% the provided code immediately. -% \end{function} -% -% \begin{function}{\stex_add_constant_to_current_module:n} -% Adds the declaration with the provided name to the |_constants| -% control sequence of the current module. -% \end{function} -% -% \begin{function}{\stex_add_import_to_current_module:n} -% Adds the module with the provided full URI to the |_imports| -% control sequence of the current module. -% \end{function} -% -% \begin{function}{\stex_collect_imports:n} -% Iterates over all imports of the provided (full URI of a) module -% and stores them as a topologically sorted list -- including -% the provided module as the last element -- in -% |\l_stex_collect_imports_seq| -% \end{function} -% -% \begin{function}{\stex_do_up_to_module:n} -% Code that is \emph{exported} from module (such as symbol declarations) -% should be local \emph{to the current module}. For that reason, ideally -% all symbol declarations and similar commands should be called directly -% in the module environment, however, that is not always feasible, e.g. -% in structural features or |sparapraph|s. \cs{stex_do_up_to_module} -% therefore executes the provided code repeatedly in an \cs{aftergroup} -% up until the group level is equal to that of the innermost smodule environment. -% \end{function} -% -% \begin{function}{\stex_modules_current_namespace:} -% Computes the current namespace as follows: -% -% If the current file is |.../source/sub/file.tex| in some archive -% with namespace |http://some.namespace/foo|, then the namespace of -% is |http://some.namespace/foo/sub/file|. Otherwise, the namespace -% is the absolute file path of the current file (i.e. starting with |file:///|). -% -% The result is stored in |\l_stex_module_ns_str|. Additionally, the sub path -% relative to the current repository is stored in |\l_stex_module_subpath_str|. -% \end{function} -% -% \subsection{The \texttt{smodule} environment} -% -% \begin{environment}{module} -% \begin{syntax} \cs{begin}|{module}[|\meta{options}|]|\Arg{name}\end{syntax} -% -% Opens a new module with name \meta{name}. Options are: -% \begin{itemize} -% \item[|title|] (\meta{token list}) to display in customizations. -% \item[|type|] (\meta{string}$\ast$) for use in customizations. -% \item[|deprecate|] (\meta{module}) if set, will throw a warning -% when loaded, urging to use \meta{module} instead. -% \item[|id|] (\meta{string}) for cross-referencing. -% \item[|ns|] (\meta{URI}) the namespace to use. \emph{Should not be used, -% unless you know precisely what you're doing}. If not explicitly set, is -% computed using \cs{stex_modules_current_namespace:}. -% \item[|lang|] (\meta{language}) if not set, computed from the current file name (e.g. |foo.en.tex|). -% \item[|sig|] (\meta{language}) if the current file is a translation of a file with the same base name -% but a different language suffix, setting |sig=<lang>| will preload the module -% from that language file. This helps ensuring that the (formal) content of both modules -% is (almost) identical across languages and avoids duplication. -% \item[|creators|] (\meta{string}$\ast$) names of the creators. -% \item[|contributors|] (\meta{string}$\ast$) names of contributors. -% \item[|srccite|] (\meta{string}) a source citation for the content of this module. -% \end{itemize} -% -% \begin{function}{\stex_module_setup:nn} -% \begin{syntax}\cs{stex_module_setup:nn}\Arg{params}\Arg{name}\end{syntax} -% Sets up a new module with name \meta{name} and optional parameters -% \meta{params}. In particular, sets -% \cs{l_stex_current_module_str} appropriately. -% \end{function} -% -% \end{environment} -% -% \begin{function}{\stexpatchmodule} -% \begin{syntax} \cs{stexpatchmodule} [\meta{type}] \Arg{begincode} \Arg{endcode} \end{syntax} -% Customizes the presentation for those |smodule|-environments -% with |type=|\meta{type}, or all others if no \meta{type} is given. -% \end{function} -% -% \begin{function}{\STEXModule} -% \begin{syntax} \cs{STEXModule} \Arg{fragment} \end{syntax} -% Attempts to find a module whose URI ends with \meta{fragment} -% in the current scope and passes the full URI on to -% \cs{stex_invoke_module:n}. -% \end{function} -% -% \begin{function}{\stex_invoke_module:n} -% Invoked by \cs{STEXModule}. Needs to be followed either -% by |!\macro| or |?|\Arg{symbolname}. In the first case, -% it stores the full URI in \cs{macro}; in the second -% case, it invokes the symbol \meta{symbolname} in the -% selected module. -% \end{function} -% -% \begin{function}{\stex_activate_module:n} -% Activate the module with the provided URI; i.e. executes -% all macro code of the module's |_code|-macro (does -% nothing if the module is already activated in the current -% context) and adds the module to \cs{l_stex_all_modules_seq}. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:modules:impl} -% -% \section{\sTeX-Modules Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% modules.dtx %%%%%%%%%%%%% - -%<@@=stex_modules> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/unknownmodule}{ - No~module~#1~found -} -\msg_new:nnn{stex}{error/syntax}{ - Syntax~error:~#1 -} -\msg_new:nnn{stex}{error/siglanguage}{ - Module~#1~declares~signature~#2,~but~does~not~ - declare~its~language -} -\msg_new:nnn{stex}{warning/deprecated}{ - #1~is~deprecated;~please~use~#2~instead! -} - -\msg_new:nnn{stex}{error/conflictingmodules}{ - Conflicting~imports~for~module~#1 -} -% \end{macrocode} -% -% -% \begin{variable}{\l_stex_current_module_str} -% The current module: -% \begin{macrocode} -\str_new:N \l_stex_current_module_str -% \end{macrocode} -% \end{variable} -% -% \begin{variable}{\l_stex_all_modules_seq} -% Stores all available modules -% \begin{macrocode} -\seq_new:N \l_stex_all_modules_seq -% \end{macrocode} -% \end{variable} -% -% \begin{macro}[pTF]{\stex_if_in_module:} -% \begin{macrocode} -\prg_new_conditional:Nnn \stex_if_in_module: {p, T, F, TF} { - \str_if_empty:NTF \l_stex_current_module_str - \prg_return_false: \prg_return_true: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[pTF]{\stex_if_module_exists:n} -% \begin{macrocode} -\prg_new_conditional:Nnn \stex_if_module_exists:n {p, T, F, TF} { - \prop_if_exist:cTF { c_stex_module_#1_prop } - \prg_return_true: \prg_return_false: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_add_to_current_module:n,\STEXexport} -% -% Only allowed within modules: -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_execute_in_module:n { \stex_if_in_module:T { - \stex_add_to_current_module:n { #1 } - \stex_do_up_to_module:n { #1 } -}} -\cs_generate_variant:Nn \stex_execute_in_module:n {x} - -\cs_new_protected:Nn \stex_add_to_current_module:n { - \tl_gput_right:cn {c_stex_module_\l_stex_current_module_str _code} { #1 } -} -\cs_generate_variant:Nn \stex_add_to_current_module:n {x} -\cs_new_protected:Npn \STEXexport { - \ExplSyntaxOn - \_@@_export:n -} -\cs_new_protected:Nn \_@@_export:n { - \ignorespacesandpars#1\ExplSyntaxOff - \stex_add_to_current_module:n { \ignorespacesandpars#1} - \stex_smsmode_do: -} -\let \stex_module_export_helper:n \use:n -\stex_deactivate_macro:Nn \STEXexport {module~environments} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_add_constant_to_current_module:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_add_constant_to_current_module:n { - \str_set:Nx \l_tmpa_str { #1 } - \seq_gput_right:co {c_stex_module_\l_stex_current_module_str _constants} { \l_tmpa_str } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_add_import_to_current_module:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_add_import_to_current_module:n { - \str_set:Nx \l_tmpa_str { #1 } - \exp_args:Nno - \seq_if_in:cnF{c_stex_module_\l_stex_current_module_str _imports}\l_tmpa_str{ - \seq_gput_right:co{c_stex_module_\l_stex_current_module_str _imports}\l_tmpa_str - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_collect_imports:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_collect_imports:n { - \seq_clear:N \l_stex_collect_imports_seq - \_@@_collect_imports:n {#1} -} -\cs_new_protected:Nn \_@@_collect_imports:n { - \seq_map_inline:cn {c_stex_module_#1_imports} { - \seq_if_in:NnF \l_stex_collect_imports_seq { ##1 } { - \_@@_collect_imports:n { ##1 } - } - } - \seq_if_in:NnF \l_stex_collect_imports_seq { #1 } { - \seq_put_right:Nx \l_stex_collect_imports_seq { #1 } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_do_up_to_module:n} -% \begin{macrocode} -\int_new:N \l_@@_group_depth_int -\cs_new_protected:Nn \stex_do_up_to_module:n { - \int_compare:nNnTF \l_@@_group_depth_int = \currentgrouplevel { - #1 - }{ - #1 - \expandafter \tl_gset:Nn - \csname l_@@_aftergroup_\l_stex_current_module_str _tl - \expandafter\expandafter\expandafter\endcsname - \expandafter\expandafter\expandafter { \csname - l_@@_aftergroup_\l_stex_current_module_str _tl\endcsname #1 } - \aftergroup\_@@_aftergroup_do: - } -} -\cs_generate_variant:Nn \stex_do_up_to_module:n {x} -\cs_new_protected:Nn \_@@_aftergroup_do: { - \stex_debug:nn{aftergroup}{\cs_meaning:c{ - l_@@_aftergroup_\l_stex_current_module_str _tl - }} - \int_compare:nNnTF \l_@@_group_depth_int = \currentgrouplevel { - \use:c{l_@@_aftergroup_\l_stex_current_module_str _tl} - \tl_gclear:c{l_@@_aftergroup_\l_stex_current_module_str _tl} - }{ - \use:c{l_@@_aftergroup_\l_stex_current_module_str _tl} - \aftergroup\_@@_aftergroup_do: - } -} -\cs_new_protected:Nn \_stex_reset_up_to_module:n { - \expandafter\let\csname l_@@_aftergroup_#1_tl\endcsname\undefined -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_modules_compute_namespace:nN} -% Computes the appropriate namespace from the top-level namespace -% of a repository (|#1|) and a file path -% (|#2|). -% -% -% \begin{macrocode} - -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_modules_current_namespace:} -% -% Computes the current namespace based on the current -% MathHub repository (if existent) and the current file. -% -% \begin{macrocode} -\str_new:N \l_stex_module_ns_str -\str_new:N \l_stex_module_subpath_str -\cs_new_protected:Nn \_@@_compute_namespace:nN { - \seq_set_eq:NN \l_tmpa_seq #2 - % split off file extension - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str % <- filename - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str % <- filename without suffixes - \seq_put_right:No \l_tmpa_seq \l_tmpb_str % <- file path including name without suffixes - - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } - } - - \stex_path_to_string:NN \l_tmpa_seq \l_stex_module_subpath_str - % \l_tmpa_seq <- sub-path relative to archive - \str_if_empty:NTF \l_stex_module_subpath_str { - \str_set:Nx \l_stex_module_ns_str {#1} - }{ - \str_set:Nx \l_stex_module_ns_str { - #1/\l_stex_module_subpath_str - } - } -} - -\cs_new_protected:Nn \stex_modules_current_namespace: { - \str_clear:N \l_stex_module_subpath_str - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { ns } \l_tmpa_str - \_@@_compute_namespace:nN \l_tmpa_str \g_stex_currentfile_seq - }{ - % split off file extension - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - \str_set:Nx \l_stex_module_ns_str { - file:/\stex_path_to_string:N \l_tmpa_seq - } - } -} -% \end{macrocode} -% \end{macro} -% -% \subsubsection{The \texttt{smodule} environment} -% -% |smodule| arguments: -% -% \begin{macrocode} -\keys_define:nn { stex / module } { - title .tl_set:N = \smoduletitle , - type .str_set_x:N = \smoduletype , - id .str_set_x:N = \smoduleid , - deprecate .str_set_x:N = \l_stex_module_deprecate_str , - ns .str_set_x:N = \l_stex_module_ns_str , - lang .str_set_x:N = \l_stex_module_lang_str , - sig .str_set_x:N = \l_stex_module_sig_str , - creators .str_set_x:N = \l_stex_module_creators_str , - contributors .str_set_x:N = \l_stex_module_contributors_str , - meta .str_set_x:N = \l_stex_module_meta_str , - srccite .str_set_x:N = \l_stex_module_srccite_str -} - -\cs_new_protected:Nn \_@@_args:n { - \str_clear:N \smoduletitle - \str_clear:N \smoduletype - \str_clear:N \smoduleid - \str_clear:N \l_stex_module_ns_str - \str_clear:N \l_stex_module_deprecate_str - \str_clear:N \l_stex_module_lang_str - \str_clear:N \l_stex_module_sig_str - \str_clear:N \l_stex_module_creators_str - \str_clear:N \l_stex_module_contributors_str - \str_clear:N \l_stex_module_meta_str - \str_clear:N \l_stex_module_srccite_str - \keys_set:nn { stex / module } { #1 } -} - -% module parameters here? In the body? - -% \end{macrocode} -% -% \begin{macro}{\stex_module_setup:nn} -% Sets up a new module property list: -% \begin{macrocode} -\cs_new_protected:Nn \stex_module_setup:nn { - \int_set:Nn \l_@@_group_depth_int {\currentgrouplevel} - \str_set:Nx \l_stex_module_name_str { #2 } - \_@@_args:n { #1 } -% \end{macrocode} -% -% First, we set up the name and namespace of the module. -% -% Are we in a nested module? -% -% \begin{macrocode} - \stex_if_in_module:TF { - % Nested module - \prop_get:cnN {c_stex_module_\l_stex_current_module_str _prop} - { ns } \l_stex_module_ns_str - \str_set:Nx \l_stex_module_name_str { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { name } / \l_stex_module_name_str - } - \str_if_empty:NT \l_stex_module_lang_str { - \str_set:Nx \l_stex_module_lang_str { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { lang } - } - } - }{ - % not nested: - \str_if_empty:NT \l_stex_module_ns_str { - \stex_modules_current_namespace: - \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq - / {\l_stex_module_ns_str} - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \str_if_eq:NNT \l_tmpa_str \l_stex_module_name_str { - \str_set:Nx \l_stex_module_ns_str { - \stex_path_to_string:N \l_tmpa_seq - } - } - } - } -% \end{macrocode} -% -% Next, we determine the language of the module: -% -% \begin{macrocode} - \str_if_empty:NT \l_stex_module_lang_str { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { - \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str - } - } - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language - \seq_pop_right:NN \l_tmpa_seq \l_stex_module_lang_str - \stex_debug:nn{modules} {Language~\l_stex_module_lang_str~ - inferred~from~file~name} - } - } - - \stex_if_smsmode:F { \str_if_empty:NF \l_stex_module_lang_str { - \exp_args:NNo \stex_set_language:Nn \l_tmpa_str \l_stex_module_lang_str - }} -% \end{macrocode} -% -% We check if we need to extend a signature module, and set -% \cs{l_stex_current_module_prop} accordingly: -% -% \begin{macrocode} - \str_if_empty:NTF \l_stex_module_sig_str { - \exp_args:Nnx \prop_gset_from_keyval:cn { - c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _prop - } { - name = \l_stex_module_name_str , - ns = \l_stex_module_ns_str , - file = \exp_not:o { \g_stex_currentfile_seq } , - lang = \l_stex_module_lang_str , - sig = \l_stex_module_sig_str , - deprecate = \l_stex_module_deprecate_str , - meta = \l_stex_module_meta_str - } - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _imports} - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _constants} - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _copymodules} - \tl_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _code} - \str_set:Nx\l_stex_current_module_str{\l_stex_module_ns_str?\l_stex_module_name_str} -% \end{macrocode} -% -% We load the metatheory: -% -% \begin{macrocode} - \str_if_empty:NT \l_stex_module_meta_str { - \str_set:Nx \l_stex_module_meta_str { - \c_stex_metatheory_ns_str ? Metatheory - } - } - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \bool_set_true:N \l_stex_in_meta_bool - \exp_args:Nx \stex_add_to_current_module:n { - \bool_set_true:N \l_stex_in_meta_bool - \stex_activate_module:n {\l_stex_module_meta_str} - \bool_set_false:N \l_stex_in_meta_bool - } - \stex_activate_module:n {\l_stex_module_meta_str} - \bool_set_false:N \l_stex_in_meta_bool - } - }{ - \str_if_empty:NT \l_stex_module_lang_str { - \msg_error:nnxx{stex}{error/siglanguage}{ - \l_stex_module_ns_str?\l_stex_module_name_str - }{\l_stex_module_sig_str} - } - \stex_debug:nn{modules}{Signature~\l_stex_module_sig_str~for~\l_stex_module_ns_str?\l_stex_module_name_str} - \stex_if_module_exists:nTF{\l_stex_module_ns_str?\l_stex_module_name_str}{ - \stex_debug:nn{modules}{(already exists)} - }{ - \stex_debug:nn{modules}{(needs loading)} - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpb_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpb_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str % <filename> - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \l_tmpa_seq / - \l_tmpa_str . \l_stex_module_sig_str .tex - } - \IfFileExists \l_tmpa_str { - \exp_args:No \stex_file_in_smsmode:nn { \l_tmpa_str } { - \str_clear:N \l_stex_current_module_str - \seq_clear:N \l_stex_all_modules_seq - \stex_debug:nn{modules}{Loading~signature} - } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{for~signature~\l_tmpa_str} - } - } - \stex_if_smsmode:F { - \stex_activate_module:n { - \l_stex_module_ns_str ? \l_stex_module_name_str - } - } - \str_set:Nx\l_stex_current_module_str{\l_stex_module_ns_str?\l_stex_module_name_str} - } - \str_if_empty:NF \l_stex_module_deprecate_str { - \msg_warning:nnxx{stex}{warning/deprecated}{ - Module~\l_stex_current_module_str - }{ - \l_stex_module_deprecate_str - } - } - \seq_put_right:Nx \l_stex_all_modules_seq { - \l_stex_module_ns_str ? \l_stex_module_name_str - } - \tl_clear:c{l_@@_aftergroup_\l_stex_module_ns_str ? \l_stex_module_name_str _tl} -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{smodule} -% -% The |module| environment. -% -% \begin{macro}{\_@@_begin_module:} -% -% implements |\begin{smodule}| -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_begin_module: { - \stex_reactivate_macro:N \STEXexport - \stex_reactivate_macro:N \importmodule - \stex_reactivate_macro:N \symdecl - \stex_reactivate_macro:N \notation - \stex_reactivate_macro:N \symdef - - \stex_debug:nn{modules}{ - New~module:\\ - Namespace:~\l_stex_module_ns_str\\ - Name:~\l_stex_module_name_str\\ - Language:~\l_stex_module_lang_str\\ - Signature:~\l_stex_module_sig_str\\ - Metatheory:~\l_stex_module_meta_str\\ - File:~\stex_path_to_string:N \g_stex_currentfile_seq - } - - \stex_if_do_html:T{ - \begin{stex_annotate_env} {theory} { - \l_stex_module_ns_str ? \l_stex_module_name_str - } - - \stex_annotate_invisible:nnn{header}{} { - \stex_annotate:nnn{language}{ \l_stex_module_lang_str }{} - \stex_annotate:nnn{signature}{ \l_stex_module_sig_str }{} - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \stex_annotate:nnn{metatheory}{ \l_stex_module_meta_str }{} - } - \str_if_empty:NF \smoduletype { - \stex_annotate:nnn{type}{\smoduletype}{} - } - } - } - % TODO: Inherit metatheory for nested modules? -} -\iffalse \end{stex_annotate_env} \fi %^^A make syntax highlighting work again -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_end_module:} -% -% implements |\end{module}| -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_end_module: { - \stex_debug:nn{modules}{Closing~module~\prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} { name }} - \_stex_reset_up_to_module:n \l_stex_current_module_str - \stex_if_smsmode:T { - \stex_persist:x { - \prop_set_from_keyval:cn{c_stex_module_\l_stex_current_module_str _prop}{ - \exp_after:wN \prop_to_keyval:N \csname c_stex_module_\l_stex_current_module_str _prop\endcsname - } - \seq_set_from_clist:cn{c_stex_module_\l_stex_current_module_str _constants}{ - \seq_use:cn{c_stex_module_\l_stex_current_module_str _constants}, - } - \seq_set_from_clist:cn{c_stex_module_\l_stex_current_module_str _imports}{ - \seq_use:cn{c_stex_module_\l_stex_current_module_str _imports}, - } - \tl_set:cn {c_stex_module_\l_stex_current_module_str _code} - } - \exp_after:wN \let \exp_after:wN \l_tmpa_tl \csname c_stex_module_\l_stex_current_module_str _code\endcsname - \exp_after:wN \stex_persist:n \exp_after:wN { \exp_after:wN { \l_tmpa_tl } } - } -} -% \end{macrocode} -% \end{macro} -% -% The core environment -% -% \begin{macrocode} -\iffalse \begin{stex_annotate_env} \fi %^^A make syntax highlighting work again -\NewDocumentEnvironment { smodule } { O{} m } { - \stex_module_setup:nn{#1}{#2} - %\par - \stex_if_smsmode:F{ - \tl_if_empty:NF \smoduletitle { - \exp_args:No \stex_document_title:n \smoduletitle - } - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \smoduletype { - \tl_if_exist:cT {_@@_smodule_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_smodule_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_smodule_start: - }{ - \l_tmpa_tl - } - } - \_@@_begin_module: - \str_if_empty:NF \smoduleid { - \stex_ref_new_doc_target:n \smoduleid - } - \stex_smsmode_do: -} { - \_@@_end_module: - \stex_if_smsmode:F { - \end{stex_annotate_env} - \clist_set:No \l_tmpa_clist \smoduletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_smodule_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_smodule_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_smodule_end: - }{ - \l_tmpa_tl - } - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\stexpatchmodule} -% \begin{macrocode} -\cs_new_protected:Nn \_@@_smodule_start: {} -\cs_new_protected:Nn \_@@_smodule_end: {} - -\newcommand\stexpatchmodule[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_smodule_start: { #2 } - \tl_set:Nn \_@@_smodule_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_smodule_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_smodule_#1_end:\endcsname{ #3 } - } -} -% \end{macrocode} -% \end{macro} -% -% \subsubsection{Invoking modules} -% -% \begin{macro}{\STEXModule,\stex_invoke_module:n} -% \begin{macrocode} -\NewDocumentCommand \STEXModule { m } { - \exp_args:NNx \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnx{stex}{error/unknownmodule}{#1} - } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \tl_set:Nn \l_tmpa_tl { - \stex_invoke_module:n { ##1 } - } - } - } - } - \l_tmpa_tl -} - -\cs_new_protected:Nn \stex_invoke_module:n { - \stex_debug:nn{modules}{Invoking~module~#1} - \peek_charcode_remove:NTF ! { - \_@@_invoke_uri:nN { #1 } - } { - \peek_charcode_remove:NTF ? { - \_@@_invoke_symbol:nn { #1 } - } { - \msg_error:nnx{stex}{error/syntax}{ - ?~or~!~expected~after~ - \c_backslash_str STEXModule{#1} - } - } - } -} - -\cs_new_protected:Nn \_@@_invoke_uri:nN { - \str_set:Nn #2 { #1 } -} - -\cs_new_protected:Nn \_@@_invoke_symbol:nn { - \stex_invoke_symbol:n{#1?#2} -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_activate_module:n} -% \begin{macrocode} -\bool_new:N \l_stex_in_meta_bool -\bool_set_false:N \l_stex_in_meta_bool -\cs_new_protected:Nn \stex_activate_module:n { - \stex_debug:nn{modules}{Activating~module~#1} - \exp_args:NNx \seq_if_in:NnF \l_stex_all_modules_seq { #1 } { - \seq_put_right:Nx \l_stex_all_modules_seq { #1 } - \use:c{ c_stex_module_#1_code } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{mmtinterface} -% \begin{macrocode} -\NewDocumentEnvironment { mmtinterface } { O{} m m } { - \begin{smodule}[#1]{#3} - \str_set:Nx \l_stex_module_mmtfor_str {#2} - \MMTinclude{#2} - \stex_reactivate_macro:N \mmtdecl - \stex_reactivate_macro:N \mmtdef -}{ - \end{smodule} -} -% \end{macrocode} -% \end{environment} -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx deleted file mode 100644 index dd07d0e65c5..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-others.dtx +++ /dev/null @@ -1,113 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Others -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -% \begin{documentation}\label{pkg:finally:doc} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:finally:impl} -% -% Some auxiliary code, and clean up to be executed at the -% end of the package. -% -% \section{\sTeX-Others Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% others.dtx %%%%%%%%%%%%% - -%<@@=stex_others> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} - % None -% \end{macrocode} -% -% \begin{macro}{\MSC} -% -% Math subject classifier -% -% \begin{macrocode} -\NewDocumentCommand \MSC {m} { - % TODO -} -% \end{macrocode} -% \end{macro} -% -% -% Patching \pkg{tikzinput}, if loaded -% -% \begin{macrocode} -\@ifpackageloaded{tikzinput}{ - \RequirePackage{stex-tikzinput} -}{} - -\bool_if:NT \c_stex_persist_mode_bool { - \let\__stex_notation_restore_notation_old:nnnnn - \__stex_notation_restore_notation:nnnnn - \def\__stex_notation_restore_notation_new:nnnnn#1#2#3#4#5{ - \__stex_notation_restore_notation_old:nnnnn{#1}{#2}{#3}{#4}{#5} - \ExplSyntaxOn - } - \def\__stex_notation_restore_notation:nnnnn{ - \ExplSyntaxOff - \catcode`~10 - \__stex_notation_restore_notation_new:nnnnn - } - \input{\jobname.sms} - \let\__stex_notation_restore_notation:nnnnn - \__stex_notation_restore_notation_old:nnnnn - \prop_if_exist:NT\c_stex_mathhub_main_manifest_prop{ - \prop_get:NnN \c_stex_mathhub_main_manifest_prop {id} - \l_tmpa_str - \prop_set_eq:cN { c_stex_mathhub_\l_tmpa_str _manifest_prop } - \c_stex_mathhub_main_manifest_prop - \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str } - } -} - -\stex_get_document_uri: -% \end{macrocode} -% -% -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx deleted file mode 100644 index 7c48dc2f89d..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-proofs.dtx +++ /dev/null @@ -1,550 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Structural Markup for Proofs -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \GetFileInfo{sproof.sty} -% -% \title{\sTeX-Proofs: Structural Markup for Proofs\thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -%c } -% -% \maketitle -% -%\ifinfulldoc\else -% \begin{abstract} -% This is the documentation for the \pkg{stex-proofs} package. -% -% The |sproof| package is part of the {\stex} collection, a version of {\TeX/\LaTeX} that -% allows to markup {\TeX/\LaTeX} documents semantically without leaving the document -% format, essentially turning {\TeX/\LaTeX} into a document format for mathematical -% knowledge management (MKM). -% -% The \pkg{stex-proofs} package supplies macros and environment that allow to annotate the -% structure of mathematical proofs in {\stex} files. This structure can be used by MKM -% systems for added-value services, either directly from the \sTeX sources, or after -% translation. -% -% For a more high-level introduction, see \href{\basedocurl/manual.pdf}{the \sTeX Manual} -% or the \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \end{abstract} -% -% \tableofcontents -% -% \input{../../doc/packages/stex-proofs} -% \fi -% -% \begin{documentation} -% \changes{v0.9}{2022/02/14}{Moved over from the \pkg{sproofs} package} -% -% -% -% \end{documentation} -% -% \begin{implementation} -% -% \section{The Implementation} -% -% \begin{macrocode} -%<*package> -%<@@=stex_sproof> - -%%%%%%%%%%%%% sproof.dtx %%%%%%%%%%%%% - -% \end{macrocode} -% -% -% \subsection{Proofs}\label{sec:impl:proofs} -% -% We first define some keys for the |proof| environment. -% \begin{macrocode} -\keys_define:nn { stex / spf } { - id .str_set_x:N = \spfid, - for .clist_set:N = \l_@@_spf_for_clist , - from .tl_set:N = \l_@@_spf_from_tl , - proofend .tl_set:N = \l_@@_spf_proofend_tl, - type .str_set_x:N = \spftype, - title .tl_set:N = \spftitle, - continues .tl_set:N = \l_@@_spf_continues_tl, - functions .tl_set:N = \l_@@_spf_functions_tl, - term .tl_set:N = \l_@@_spf_term_tl, - method .tl_set:N = \l_@@_spf_method_tl, - hide .bool_set:N = \l_@@_spf_hide_bool -} -\cs_new_protected:Nn \_@@_spf_args:n { - \str_clear:N \spfid - \tl_clear:N \l_@@_spf_for_tl - \tl_clear:N \l_@@_spf_from_tl - \tl_set:Nn \l_@@_spf_proofend_tl {\sproof@box} - \str_clear:N \spftype - \tl_clear:N \spftitle - \tl_clear:N \l_@@_spf_continues_tl - \tl_clear:N \l_@@_spf_term_tl - \tl_clear:N \l_@@_spf_functions_tl - \tl_clear:N \l_@@_spf_method_tl - \bool_set_false:N \l_@@_spf_hide_bool - \keys_set:nn { stex / spf }{ #1 } -} -\bool_set_true:N \l_@@_inc_counter_bool -% \end{macrocode} -% -% \begin{macro}{\c_@@_flow_str} -% We define this macro, so that we can test whether the |display| key has the value |flow| -% \begin{macrocode} -\str_set:Nn\c_@@_flow_str{inline} -% \end{macrocode} -% \end{macro} -% -% For proofs, we will have to have deeply nested structures of enumerated list-like -% environments. However, {\LaTeX} only allows |enumerate| environments up to nesting depth -% 4 and general list environments up to listing depth 6. This is not enough for us. -% Therefore we have decided to go along the route proposed by Leslie Lamport to use a -% single top-level list with dotted sequences of numbers to identify the position in the -% proof tree. Unfortunately, we could not use his |pf.sty| package directly, since it does -% not do automatic numbering, and we have to add keyword arguments all over the place, to -% accomodate semantic information. -% -% \begin{macrocode} -\intarray_new:Nn\l_@@_counter_intarray{50} -\cs_new_protected:Npn \sproofnumber { - \int_set:Nn \l_tmpa_int {1} - \bool_while_do:nn { - \int_compare_p:nNn { - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int - } > 0 - }{ - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int . - \int_incr:N \l_tmpa_int - } -} -\cs_new_protected:Npn \_@@_inc_counter: { - \int_set:Nn \l_tmpa_int {1} - \bool_while_do:nn { - \int_compare_p:nNn { - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int - } > 0 - }{ - \int_incr:N \l_tmpa_int - } - \int_compare:nNnF \l_tmpa_int = 1 { - \int_decr:N \l_tmpa_int - } - \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int + 1 - } -} - -\cs_new_protected:Npn \_@@_add_counter: { - \int_set:Nn \l_tmpa_int {1} - \bool_while_do:nn { - \int_compare_p:nNn { - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int - } > 0 - }{ - \int_incr:N \l_tmpa_int - } - \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { 1 } -} - -\cs_new_protected:Npn \_@@_remove_counter: { - \int_set:Nn \l_tmpa_int {1} - \bool_while_do:nn { - \int_compare_p:nNn { - \intarray_item:Nn \l_@@_counter_intarray \l_tmpa_int - } > 0 - }{ - \int_incr:N \l_tmpa_int - } - \int_decr:N \l_tmpa_int - \intarray_gset:Nnn \l_@@_counter_intarray \l_tmpa_int { 0 } -} -% \end{macrocode} -% -%\begin{macro}{\sproofend} -% This macro places a little box at the end of the line if there is space, or at the -% end of the next line if there isn't -% \begin{macrocode} -\def\sproof@box{ - \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} -} -\def\sproofend{ - \tl_if_empty:NF \l_@@_spf_proofend_tl { - \hfil\null\nobreak\hfill\l_@@_spf_proofend_tl\par\smallskip - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{spf@*@kw} -% \begin{macrocode} -\def\spf@proofsketch@kw{Proof~Sketch} -\def\spf@proof@kw{Proof} -\def\spf@step@kw{Step} -% \end{macrocode} -% \end{macro} -% -% For the other languages, we set up triggers -% \begin{macrocode} -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{babel}{ - \makeatletter - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ - \input{sproof-ngerman.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {finnish}{ - \input{sproof-finnish.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {french}{ - \input{sproof-french.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {russian}{ - \input{sproof-russian.ldf} - } - \makeatother - }{} -} -% \end{macrocode} -% -% \begin{macro}{spfsketch} -% \begin{macrocode} -\newcommand\spfsketch[2][]{ - \begingroup - \let \premise \stex_proof_premise: - \_@@_spf_args:n{#1} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnx - \stex_annotate:nnn{proofsketch}{\seq_use:Nn \l_tmpa_seq {,}}{ - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \titleemph{ - \tl_if_empty:NTF \spftitle { - \spf@proofsketch@kw - }{ - \spftitle - } - }:~ - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - \l_tmpa_tl #2 \sproofend - } - } - \endgroup - \stex_smsmode_do: -} - -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_maybe_comment:,\_@@_maybe_comment_end:,\_@@_start_comment:} -% \begin{macrocode} -\bool_set_false:N \l_@@_in_spfblock_bool - -\cs_new_protected:Nn \_@@_maybe_comment: { - \bool_if:NF \l_@@_in_spfblock_bool { - \par \setbox \l_tmpa_box \vbox \bgroup \everypar{\_@@_start_comment:} - } -} -\cs_new_protected:Nn \_@@_maybe_comment_end: { - \bool_if:NF \l_@@_in_spfblock_bool { \egroup } -} -\cs_new_protected:Nn \_@@_start_comment: { - \csname @ @ par\endcsname\egroup\item[]\bgroup\stexcommentfont -} - -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stexcommentfont} -% \begin{macrocode} -\cs_new_protected:Npn \stexcommentfont { - \small\itshape -} -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{sproof} -% In this environment, we initialize the proof depth counter |\count10| to 10, and set -% up the description environment that will take the proof steps. At the end of the -% proof, we position the proof end into the last line. -% \begin{macrocode} -\cs_new_protected:Nn \_@@_start_env:nnn { - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{#1}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - #3 {~\stex_annotate:nnn{spftitle}{}{#2}} - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - \begin{stex_annotate_env}{spfbody}{\bool_if:NTF \l_@@_spf_hide_bool {false}{true}} - \bool_if:NT \l_@@_spf_hide_bool{ - \stex_html_backend:F{\setbox\l_tmpa_box\vbox\bgroup} - } - \begin{list}{}{ - \setlength\topsep{0pt} - \setlength\parsep{0pt} - \setlength\rightmargin{0pt} - - }\_@@_maybe_comment: -} -\cs_new_protected:Nn \_@@_end_env:n { - \stex_if_smsmode:F{ - \_@@_maybe_comment_end: - \end{list} - \bool_if:NT \l_@@_spf_hide_bool{ - \stex_html_backend:F{\egroup} - } - \clist_set:No \l_tmpa_clist \spftype - #1 - \end{stex_annotate_env} - \end{stex_annotate_env} - } -} -\NewDocumentEnvironment{sproof}{s O{} m}{ - \intarray_gzero:N \l_@@_counter_intarray - \intarray_gset:Nnn \l_@@_counter_intarray 1 1 - \stex_reactivate_macro:N \yield - \stex_reactivate_macro:N \eqstep - \stex_reactivate_macro:N \assumption - \stex_reactivate_macro:N \conclude - \stex_reactivate_macro:N \spfstep - \_@@_spf_args:n{#2} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \_@@_start_env:nnn{sproof}{#3}{ - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproof_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_start:}} - } - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_set:Nn \l_tmpa_tl {\use:n{}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproof_start: - }{ - \l_tmpa_tl - } - } - } - \stex_smsmode_do: -}{\_@@_end_env:n{ - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproof_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproof_end: - }{ - \l_tmpa_tl - } -}} -\NewDocumentEnvironment{subproof}{s O{} m}{ - \_@@_spf_args:n{#2} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \_@@_start_env:nnn{subproof}{\item[\sproofnumber]\ignorespacesandpars #3}{} - } - \_@@_add_counter: - \stex_smsmode_do: -}{\_@@_remove_counter:\_@@_end_env:n{} - \bool_if:NT \l_@@_inc_counter_bool { - \_@@_inc_counter: - } - \aftergroup\_@@_maybe_comment: -} -\AddToHook{env/subproof/before}{\_@@_maybe_comment_end:} - -\cs_new_protected:Nn \_@@_sproof_start: { - \par\noindent\titleemph{ - \tl_if_empty:NTF \spftype { - \spf@proof@kw - }{ - \spftype - } - }: -} -\cs_new_protected:Nn \_@@_sproof_end: {\sproofend} - -\newcommand\stexpatchproof[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sproof_start: { #2 } - \tl_set:Nn \_@@_sproof_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sproof_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sproof_#1_end:\endcsname{ #3 } - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\pstep,\conclude,\assumption,\have,\eqstep} -% \begin{macrocode} - -\keys_define:nn { stex / spfsteps } { - id .str_set_x:N = \spfstepid, - for .clist_set:N = \l_@@_spf_for_clist , - type .str_set_x:N = \spftype, - title .tl_set:N = \spftitle, - method .tl_set:N = \l_@@_spf_method_tl, - term .tl_set:N = \l_@@_spf_term_tl -} -\cs_new_protected:Nn \_@@_spfstep_args:n { - \str_clear:N \spfstepid - \clist_clear:N \l_@@_spf_for_clist - \str_clear:N \spftype - \tl_clear:N \l_@@_spf_method_tl - \tl_clear:N \l_@@_spf_term_tl - %\bool_set_false:N \l_@@_inc_counter_bool - \keys_set:nn { stex / spfsteps }{ #1 } -} - -\cs_new_protected:Nn \_@@_make_step_macro:Nnnnn { - \NewDocumentCommand #1 {s O{} +m} { - \_@@_maybe_comment_end: - - \_@@_spfstep_args:n{##2} - \stex_annotate:nnn{spfstep}{#2}{ - \tl_if_empty:NF \l_@@_spf_term_tl { - \stex_annotate_invisible:nnn{spfyield}{}{$\l_@@_spf_term_tl$} - } - \bool_if:NTF \l_@@_in_spfblock_bool { - #4 - }{ - \item[\IfBooleanTF ##1 {}{#3}] - } - \ignorespacesandpars ##3 - } - \bool_if:NF \l_@@_in_spfblock_bool { \IfBooleanTF ##1 {}{ #5 } } - \_@@_maybe_comment: - } - \stex_deactivate_macro:Nn #1 {sproof~environments} -} - -\_@@_make_step_macro:Nnnnn \assumption {assumption} \sproofnumber {} \_@@_inc_counter: -\_@@_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {} -\_@@_make_step_macro:Nnnnn \spfstep {} \sproofnumber {} \_@@_inc_counter: - -\NewDocumentCommand \eqstep {s m}{ - \_@@_maybe_comment_end: - \bool_if:NTF \l_@@_in_spfblock_bool { - $=$ - }{ - \item[$=$] - } - $\stex_annotate:nnn{spfstep}{eq}{ #2 }$ - \_@@_maybe_comment: -} -\stex_deactivate_macro:Nn \eqstep {sproof~environments} - -\NewDocumentCommand \yield {+m}{ - \stex_annotate:nnn{spfyield}{}{ #1 } -} -\stex_deactivate_macro:Nn \yield {sproof~environments} - -\NewDocumentEnvironment{spfblock}{}{ - \item[] - \bool_set_true:N \l_@@_in_spfblock_bool -}{ - \aftergroup\_@@_maybe_comment: -} -\AddToHook{env/spfblock/before}{\_@@_maybe_comment_end:} - -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\spfidea} -% \begin{macrocode} -\NewDocumentCommand\spfidea{O{} +m}{ - \_@@_spf_args:n{#1} - \titleemph{ - \tl_if_empty:NTF \spftype {Proof~Idea}{ - \spftype - }: - }~#2 - \sproofend -} -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -\newcommand\spfjust[1]{ - #1 -} -%</package> -% \end{macrocode} -% \end{implementation} -% \Finale -% \ifinfulldoc\else\printbibliography\fi -\endinput - -%%% Local Variables: -%%% mode: doctex -%%% TeX-master: t -%%% End: diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx deleted file mode 100644 index 841115fd0e4..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-references.dtx +++ /dev/null @@ -1,747 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-References -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-references} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% \fi -% -% \begin{documentation}\label{pkg:sref:doc} -% -% This sub package contains code related to links and cross-references -% -%\ifinfulldoc\else -% \input{../../doc/packages/stex-references} -% \fi -% -% \section{Macros and Environments}\label{pkg:sref:doc:macros} -% -% -% \begin{function}{\stex_get_document_uri:} -% Computes the current document uri from the current archive's |narr|-field and its -% location relative to the archive's |source|-directory. Reference targets are computed -% from this URI and the reference-id. -% -% \begin{variable}{\l_stex_current_docns_str} -% Stores its result in |\l_stex_current_docns_str| -% \end{variable} -% \end{function} -% -% \begin{function}{\stex_get_document_url:} -% Computes the current URL from the current archive's |docurl|-field and its location -% relative to the archive's |source|-directory. Reference targets are computed from this -% URL and the reference-id, if this document is only included in SMS mode. -% -% \begin{variable}{\l_stex_current_docurl_str} -% Stores its result in |\l_stex_current_docurl_str| -% \end{variable} -% \end{function} -% -% \subsection{Setting Reference Targets} -% -% \begin{function}{\stex_ref_new_doc_target:n} -% \begin{syntax} \cs{stex_ref_new_doc_target:n}\Arg{id} \end{syntax} -% -% Sets a new reference target with id \meta{id}. -% \end{function} -% -% \begin{function}{\stex_ref_new_sym_target:n} -% \begin{syntax} \cs{stex_ref_new_sym_target:n}\Arg{uri} \end{syntax} -% -% Sets a new reference target for the symbol \meta{uri}. -% \end{function} -% -% \subsection{Using References} -% -% \begin{function}{\sref} -% \begin{syntax} \cs{sref}|[|\meta{opt-args}|]|\Arg{id} \end{syntax} -% References the label with if \meta{id}. -% Optional arguments: \textcolor{red}{TODO} -% \end{function} -% -% \begin{function}{\srefsym} -% \begin{syntax} \cs{srefsym}|[|\meta{opt-args}|]|\Arg{symbol} \end{syntax} -% Like \cs{sref}, but references the \emph{canonical label} for -% the provided symbol. The canonical target is the last of the following -% occuring in the document: -% \begin{itemize} -% \item A \cs{definiendum} or \cs{definame} for \meta{symbol}, -% \item The |sassertion|, |sexample| or |sparagraph| with |for=|\meta{symbol} that -% generated \meta{symbol} in the first place, or -% \item A \cs{sparagraph} with |type=symdoc| and |for=|\meta{symbol}. -% \end{itemize} -% \end{function} -% -% \begin{function}{\srefsymuri} -% \begin{syntax} \cs{srefsymuri}\Arg{URI}\Arg{text} \end{syntax} -% A convenient short-hand for |\srefsym[linktext={text}]{URI}|, -% but requires the first argument to be a full URI already. -% Intended to be used in e.g. \cs{compemph@uri}, \cs{defemph@uri}, etc. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:sref:impl} -% -% \section{\sTeX-References Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% stex-references.dtx %%%%%%%%%%%%% - -%<@@=stex_refs> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/extrefmissing}{ - Missing~in~or~cite~value~for~\detokenize{\extref}! -} -\msg_new:nnn{stex}{warning/smsmissing}{ - .sref~file~#1~doesn't~exist! -} -\msg_new:nnn{stex}{warning/smslabelmissing}{ - No~label~#2~in~.sref~file~#1! -} -% \end{macrocode} -% -% References are stored in the file |\jobname.sref|, to enable -% cross-referencing external documents. -% -% \begin{macrocode} -\iow_new:N \c_@@_refs_iow -\AtBeginDocument{ - \iow_open:Nn \c_@@_refs_iow {\jobname.sref} -} -\AtEndDocument{ - \iow_close:N \c_@@_refs_iow -} -% \end{macrocode} -% -% -% \subsection{Document URIs and URLs} -% -% \begin{variable}{\l_stex_current_docns_str} -% \begin{macrocode} -\str_new:N \l_stex_current_docns_str -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_get_document_uri:} -% \begin{macrocode} -\cs_new_protected:Nn \stex_get_document_uri: { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - - \str_clear:N \l_tmpa_str - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - } - - \str_if_empty:NTF \l_tmpa_str { - \str_set:Nx \l_stex_current_docns_str { - file:/\stex_path_to_string:N \l_tmpa_seq - } - }{ - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } - } - - \seq_if_empty:NTF \l_tmpa_seq { - \str_gset_eq:NN \l_stex_current_docns_str \l_tmpa_str - }{ - \str_gset:Nx \l_stex_current_docns_str { - \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq - } - } - } - %\stex_get_document_url: -} -% \end{macrocode} -% \end{macro} -% -% \begin{variable}{\l_stex_current_docurl_str} -% \begin{macrocode} -\str_new:N \l_stex_current_docurl_str -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\stex_get_document_url:} -% \begin{macrocode} -\cs_new_protected:Nn \stex_get_document_url: { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - - \str_clear:N \l_tmpa_str - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnNF \l_stex_current_repository_prop { docurl } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - } - } - - \str_if_empty:NTF \l_tmpa_str { - \str_set:Nx \l_stex_current_docurl_str { - file:/\stex_path_to_string:N \l_tmpa_seq - } - }{ - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } - } - - \seq_if_empty:NTF \l_tmpa_seq { - \str_set_eq:NN \l_stex_current_docurl_str \l_tmpa_str - }{ - \str_set:Nx \l_stex_current_docurl_str { - \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Setting Reference Targets} -% -% \begin{macrocode} -\str_const:Nn \c_@@_url_str{URL} -\str_const:Nn \c_@@_ref_str{REF} -\str_new:N \l_@@_curr_label_str -% @currentlabel -> number -% @currentlabelname -> title -% @currentHref -> name.number <- id of some kind -% @currentcounter <- name/id -% \#autorefname <- "Section" -% \theH# -> \arabic{section} -% \the# -> number -% \hyper@makecurrent{#} -\int_new:N \l_@@_unnamed_counter_int -% \end{macrocode} -% -% Restoring references from |.sref|-files -% -% \begin{macro}{\STEXInternalSrefRestoreTarget} -% \begin{macrocode} -\cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {} -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\stex_ref_new_doc_target:n} -% \begin{macrocode} -\seq_new:N \g_stex_ref_files_seq - -\cs_new_protected:Nn \stex_ref_new_doc_target:n { - %\stex_get_document_uri: - \str_clear:N \l_@@_curr_label_str - \str_set:Nx \l_tmpa_str { #1 } - \str_if_empty:NT \l_tmpa_str { - \int_gincr:N \l_@@_unnamed_counter_int - \str_set:Nx \l_tmpa_str {REF\int_use:N \l_@@_unnamed_counter_int} - } - \str_set:Nx \l_@@_curr_label_str { - \l_stex_current_docns_str?\l_tmpa_str - } - - \exp_args:Noo \STEXInternalAuxAddDocRef\l_stex_current_docns_str\l_tmpa_str - - %\seq_if_exist:cF{g_@@_labels_\l_tmpa_str _seq}{ - % \seq_new:c {g_@@_labels_\l_tmpa_str _seq} - %} - %\seq_if_in:coF{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str { - % \seq_gput_right:co{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str - %} - - - \stex_if_smsmode:TF { - %\stex_get_document_url: - %\str_gset_eq:cN {sref_url_\l_@@_curr_label_str _str}\l_stex_current_docurl_str - %\str_gset_eq:cN {sref_\l_@@_curr_label_str _type}\c_@@_url_str - }{ - \iow_now:Nx \c_@@_refs_iow { - \STEXInternalSrefRestoreTarget - {\l_stex_current_docns_str} - {\l_tmpa_str} - {\@currentcounter} - {\@currentlabel} - {\tl_if_exist:NT\@currentlabelname{\exp_args:No\unexpanded\@currentlabelname}} - } - %\iow_now:Nx \c_@@_refs_iow { - % {\l_stex_current_docns_str?\l_tmpa_str}~=~{{\use:c{\@currentcounter autorefname}~\@currentlabel}~(\@currentlabelname)~in~\exp_args:No\unexpanded\g_@@_title_tl},} - \stex_debug:nn{sref}{New~label~\l_@@_curr_label_str~at~\use:c{\use:c{@currentcounter}autorefname}} - \exp_args:Nx\label{sref_\l_@@_curr_label_str} - \immediate\write\@auxout{\STEXInternalAuxAddDocRef{\l_stex_current_docns_str}{\l_tmpa_str}} - %\str_gset:cx {sref_\l_@@_curr_label_str _type}\c_@@_ref_str - } -} -\NewDocumentCommand \slabel {m} {\stex_ref_new_doc_target:n {#1}} -% \end{macrocode} -% \end{macro} -% -% The following is used to set the necessary macros in the |.aux|-file. -% -% \begin{macrocode} -\cs_new_protected:Npn \STEXInternalAuxAddDocRef #1 #2 { - \exp_args:NNx \seq_if_in:NnTF \g_stex_ref_files_seq {\detokenize{#1}} { - \exp_args:Nnx \seq_if_in:cnF{g_stex_ref_ #1 _seq}{\detokenize{#2}}{ - \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} - } - }{ - \exp_args:NNx \seq_gput_right:Nn \g_stex_ref_files_seq {\detokenize{#1}} - %\seq_if_exist:cF{g_stex_ref_ #1 _seq}{ - \seq_new:c{g_stex_ref_ #1 _seq} % <- seq_new throws errors?? - %} - \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} - } - - %\str_set:Nn \l_tmpa_str {#1?#2} - %\str_gset_eq:cN{sref_#1?#2_type}\c_@@_ref_str - %\seq_if_exist:cF{g_@@_labels_#2_seq}{ - % \seq_new:c {g_@@_labels_#2_seq} - %} - %\seq_if_in:coF{g_@@_labels_#2_seq}\l_tmpa_str { - % \seq_gput_right:co{g_@@_labels_#2_seq}\l_tmpa_str - %} -} -% \end{macrocode} -% To avoid resetting the same macros when the |.aux|-file is read -% at the end of the document: -% -% \begin{macrocode} -\AtEndDocument{ - \def\STEXInternalAuxAddDocRef#1 #2 {}{} -} -% \end{macrocode} -% -% \begin{macro}{\stex_ref_new_sym_target:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_ref_new_sym_target:n { - -% \stex_if_smsmode:TF { -% \str_if_exist:cF{sref_sym_#1_type}{ -% \stex_get_document_url: -% \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str -% \str_gset_eq:cN {sref_sym_#1_type}\c_@@_url_str -% } -% }{ -% \str_if_empty:NF \l_@@_curr_label_str { -% \str_gset_eq:cN {sref_sym_#1_label_str}\l_@@_curr_label_str -% \immediate\write\@auxout{ -% \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{ -% \l_@@_curr_label_str -% } -% } -% } -% } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Using References} -% -% \begin{macro}{\sref} -% Optional arguments: -% \begin{macrocode} - -\keys_define:nn { stex / sref / 1 } { - archive .str_set_x:N = \l_@@_repo_str, - file .str_set_x:N = \l_@@_file_str, - % TODO get rid of this - fallback .code:n = {}, - pre .code:n = {}, - post .code:n = {} -} -\cs_new_protected:Nn \_@@_args_i:n { - \str_clear:N \l_@@_repo_str - \str_clear:N \l_@@_file_str - \keys_set:nn { stex / sref / 1 } { #1 } -} -\keys_define:nn { stex / sref / 2 } { - in .str_set_x:N = \l_@@_in_str, - archive .str_set_x:N = \l_@@_repob_str, - title .tl_set:N = \l_@@_title_tl -} -\cs_new_protected:Nn \_@@_args_ii:n { - \str_clear:N \l_@@_in_str - \tl_clear:N \l_@@_title_tl - \str_clear:N \l_@@_repob_str - \keys_set:nn { stex / sref / 2 } { #1 } -} -% \end{macrocode} -% The actual macro: -% \begin{macrocode} -\NewDocumentCommand \sref { O{} m O{}}{ - \_@@_args_i:n{#1} - \_@@_args_ii:n{#3} - \str_clear:N \l_@@_uri_str - \_@@_find_uri:n{#2} - \_@@_do_sref:n{#2} -} -\NewDocumentCommand \extref { O{} m m}{ - \_@@_args_i:n{#1} - \_@@_args_ii:n{#3} - \str_if_empty:NT \l_@@_in_str { - \msg_error:nn{stex}{error/extrefmissing} - } - \str_clear:N \l_@@_uri_str - \_@@_find_uri:n{#2} - \_@@_do_sref_in:n{#2} -} - -\cs_new_protected:Nn \_@@_find_uri:n { - \stex_debug:nn{sref}{File:~\l_@@_file_str^^JRepo:\l_@@_repo_str} - \str_if_empty:NTF \l_@@_file_str { - \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1} - \seq_if_exist:cT{g_stex_ref_\l_stex_current_docns_str _seq}{ - \seq_map_inline:cn{g_stex_ref_\l_stex_current_docns_str _seq}{ - \str_if_eq:nnT{#1}{##1}{ - \str_set_eq:NN \l_@@_uri_str \l_stex_current_docns_str - \stex_debug:nn{sref}{Found.} - \seq_map_break: - } - } - } - \str_if_empty:NT \l_@@_uri_str { - \stex_debug:nn{sref}{Checking~other~files} - \seq_map_inline:Nn \g_stex_ref_files_seq { - \stex_debug:nn{sref}{##1...} - \seq_map_inline:cn{g_stex_ref_##1_seq}{ - \str_if_eq:nnT{#1}{####1}{ - \stex_debug:nn{sref}{Found~##1} - \str_set:Nn \l_@@_uri_str {##1} - \seq_map_break:n{\seq_map_break:} - } - } - } - } - }{ - \str_if_empty:NTF \l_@@_repo_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { ns } \l_@@_uri_str - \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str} - \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str - \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq} - }{ - \stex_path_from_string:Nn \l_tmpb_seq { - \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_file_str - } - \str_set:Nx \l_@@_uri_str {file:/\stex_path_to_string:N \l_tmpb_seq} - } - }{ - \stex_require_repository:n \l_@@_repo_str - \prop_get:cnN { c_stex_mathhub_\l_@@_repo_str _manifest_prop } { ns } \l_@@_uri_str - \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str} - \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str - \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq} - } - } -} - -\cs_new_protected:Nn \_@@_do_autoref:n{ - \cs_if_exist:cTF{autoref}{ - \exp_args:Nx\autoref{sref_#1} - }{ - \exp_args:Nx\ref{sref_#1} - } -} - -\cs_new_protected:Nn \_@@_do_sref:n { - \str_if_empty:NTF \l_@@_uri_str { - \str_if_empty:NTF \l_@@_in_str { - \stex_debug:nn{sref}{autoref~on~#1} - \_@@_do_autoref:n{#1} - }{ - \stex_debug:nn{sref}{srefin~on~#1} - \_@@_do_sref_in:n{#1} - } - }{ - \exp_args:NNo \seq_if_in:NnTF \g_stex_ref_files_seq \l_@@_uri_str { - \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l_@@_uri_str _seq}{\detokenize{#1}}{ - \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~#1} - \_@@_do_autoref:n{\l_@@_uri_str?#1} - }{ - \str_if_empty:NTF \l_@@_in_str { - \stex_debug:nn{sref}{in~empty;~autoref~on~#1} - \_@@_do_autoref:n{#1} - }{ - \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} - \_@@_do_sref_in:n{#1} - } - } - }{ - \str_if_empty:NTF \l_@@_in_str { - \stex_debug:nn{sref}{in~empty;~autoref~on~#1} - \_@@_do_autoref:n{#1} - }{ - \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} - \_@@_do_sref_in:n{#1} - } - } - } -} - -\cs_new_protected:Nn \_@@_restore_target:nnnnn { - \str_if_empty:NTF \l_@@_uri_str { - \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ - \tl_set:Nn \l_@@_return_tl { - \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ - \tl_if_empty:nTF\l_@@_title_tl{ - ??? - }\l_@@_title_tl - } - } - }{ - \stex_debug:nn{sref}{\l_@@_uri_str{}~ == ~ #1 ~ ?} - \exp_args:No \str_if_eq:nnT \l_@@_uri_str {#1}{ - \stex_debug:nn{sref}{\l_@@_id_str~ == ~ #2 ~ ?} - \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ - \stex_debug:nn{sref}{success!} - \tl_set:Nn \l_@@_return_tl { - \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ - \tl_if_empty:nTF\l_@@_title_tl{ - ??? - }\l_@@_title_tl - } - \endinput - } - } - } -} - -\cs_new_protected:Nn \_@@_do_sref_in:n { - \stex_debug:nn{sref}{In: \l_@@_in_str^^JRepo:\l_@@_repo_str} - \stex_debug:nn{sref}{URI: \l_@@_uri_str?#1} - %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>} - \begingroup\catcode13=9\relax\catcode10=9\relax - \str_if_empty:NTF \l_@@_repob_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \str_set:Nx \l_tmpa_str { - \c_stex_mathhub_str / - \prop_item:Nn \l_stex_current_repository_prop { id } - / source / \l_@@_in_str .sref - } - }{ - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_in_str . sref - } - } - }{ - \str_set:Nx \l_tmpa_str { - \c_stex_mathhub_str / \l_@@_repob_str - / source / \l_@@_in_str . sref - } - } - \stex_path_from_string:Nn \l_tmpb_seq \l_tmpa_str - \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str - \stex_debug:nn{sref}{File: \l_tmpa_str} - \exp_args:No \IfFileExists \l_tmpa_str { - \tl_clear:N \l_@@_return_tl - \str_set:Nn \l_@@_id_str {#1} - \let\STEXInternalSrefRestoreTarget\_@@_restore_target:nnnnn - \use:c{@ @ input}{\l_tmpa_str} - \exp_args:No \tl_if_empty:nTF \l_@@_return_tl { - \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_tmpa_str{#1} - \_@@_do_autoref:n{ - \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 - } - }{ - \l_@@_return_tl - } - }{ - \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_tmpa_str - \_@@_do_autoref:n{ - \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 - } - } - \endgroup -} - - % \_@@_args:n { #1 } - % \str_if_empty:NTF \l_@@_indocument_str { - % \str_set:Nx \l_tmpa_str { #2 } - % \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str - % \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 { - % \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ - % \seq_get_left:cNF {g_@@_labels_\l_tmpa_str _seq} \l_tmpa_str { - % \str_clear:N \l_tmpa_str - % } - % }{ - % \str_clear:N \l_tmpa_str - % } - % }{ - % \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - % \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - % \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} } - % \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ - % \str_set_eq:NN \l_tmpc_str \l_tmpa_str - % \str_clear:N \l_tmpa_str - % \seq_map_inline:cn {g_@@_labels_\l_tmpc_str _seq} { - % \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{ - % \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } - % }{ - % \seq_map_break:n { - % \str_set:Nn \l_tmpa_str { ##1 } - % } - % } - % } - % }{ - % \str_clear:N \l_tmpa_str - % } - % } - % \str_if_empty:NTF \l_tmpa_str { - % \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl - % }{ - % \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c_@@_ref_str { - % \tl_if_empty:NTF \l_@@_linktext_tl { - % \cs_if_exist:cTF{autoref}{ - % \l_@@_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l_@@_post_tl - % }{ - % \l_@@_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l_@@_post_tl - % } - % }{ - % \ltx@ifpackageloaded{hyperref}{ - % \hyperref[sref_\l_tmpa_str]\l_@@_linktext_tl - % }{ - % \l_@@_linktext_tl - % } - % } - % }{ - % \ltx@ifpackageloaded{hyperref}{ - % \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} - % }{ - % \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl - % } - % } - % } - % }{ - % TODO - % } -%} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\srefsym} -% \begin{macrocode} -\NewDocumentCommand \srefsym { O{} m}{ - \stex_get_symbol:n { #2 } - \_@@_sym_aux:nn{#1}{\l_stex_get_symbol_uri_str} -} - -\cs_new_protected:Nn \_@@_sym_aux:nn { - -% \str_if_exist:cTF {sref_sym_#2 _label_str }{ -% \sref[#1]{\use:c{sref_sym_#2 _label_str}} -% }{ -% \_@@_args:n { #1 } -% \str_if_empty:NTF \l_@@_indocument_str { -% \tl_if_exist:cTF{sref_sym_#2 _type}{ -% % doc uri in \l_tmpb_str -% \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}} -% \str_if_eq:NNTF \l_tmpa_str \c_@@_ref_str { -% % reference -% \tl_if_empty:NTF \l_@@_linktext_tl { -% \cs_if_exist:cTF{autoref}{ -% \l_@@_pre_tl\autoref{sref_sym_#2}\l_@@_post_tl -% }{ -% \l_@@_pre_tl\ref{sref_sym_#2}\l_@@_post_tl -% } -% }{ -% \ltx@ifpackageloaded{hyperref}{ -% \hyperref[sref_sym_#2]\l_@@_linktext_tl -% }{ -% \l_@@_linktext_tl -% } -% } -% }{ -% % URL -% \ltx@ifpackageloaded{hyperref}{ -% \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} -% }{ -% \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl -% } -% } -% }{ -% \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl -% } -% }{ -% % TODO -% } -% } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\srefsymuri} -% \begin{macrocode} -\cs_new_protected:Npn \srefsymuri #1 #2 { % TODO - #2%\_@@_sym_aux:nn{linktext={#2}}{#1} -} -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx deleted file mode 100644 index cab2a678c85..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-statements.dtx +++ /dev/null @@ -1,997 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Statements -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-statements} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \input{../../doc/packages/stex-statements} -% \fi -% -% \begin{documentation}\label{pkg:statements:doc} -% \changes{3.1.0}{2022/02/28}{Added \detokenize{\definiendum} and related macros to \detokenize{sparagraph}, -% if \detokenize{type=symdoc}} -% -% Code related to statements, e.g. definitions, theorems -% -% \section{Macros and Environments}\label{pkg:statements:doc:macros} -% -% \begin{environment}{symboldoc} -% \begin{syntax} \cs{begin}\Arg{symboldoc}\Arg{symbols} \meta{text} \cs{end}\Arg{symboldoc} \end{syntax} -% Declares \meta{text} to be a (natural language, encyclopaedic) description -% of \Arg{symbols} (a comma separated list of symbol identifiers). -% \end{environment} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:statements:impl} -% -% \section{\sTeX-Statements Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% features.dtx %%%%%%%%%%%%% - -%<@@=stex_statements> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} - -% \end{macrocode} -% \begin{macro}{\titleemph} -% \begin{macrocode} -\def\titleemph#1{\textbf{#1}} -% \end{macrocode} -% \end{macro} -% -% \subsection{Definitions} -% -% \begin{macro}{definiendum} -% \begin{macrocode} -\keys_define:nn {stex / definiendum }{ - pre .tl_set:N = \l_@@_definiendum_pre_tl, - post .tl_set:N = \l_@@_definiendum_post_tl, - root .str_set_x:N = \l_@@_definiendum_root_str, - gfa .str_set_x:N = \l_@@_definiendum_gfa_str -} -\cs_new_protected:Nn \_@@_definiendum_args:n { - \str_clear:N \l_@@_definiendum_root_str - \tl_clear:N \l_@@_definiendum_post_tl - \str_clear:N \l_@@_definiendum_gfa_str - \keys_set:nn { stex / definiendum }{ #1 } -} -\NewDocumentCommand \definiendum { O{} m m} { - \_@@_definiendum_args:n { #1 } - \stex_get_symbol:n { #2 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \str_if_empty:NTF \l_@@_definiendum_root_str { - \tl_if_empty:NTF \l_@@_definiendum_post_tl { - \tl_set:Nn \l_tmpa_tl { #3 } - } { - \str_set:Nx \l_@@_definiendum_root_str { #3 } - \tl_set:Nn \l_tmpa_tl { - \l_@@_definiendum_pre_tl\l_@@_definiendum_root_str\l_@@_definiendum_post_tl - } - } - } { - \tl_set:Nn \l_tmpa_tl { #3 } - } - - % TODO root - \stex_html_backend:TF { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { \l_tmpa_tl } - } { - \exp_args:Nnx \defemph@uri { \l_tmpa_tl } { \l_stex_get_symbol_uri_str } - } -} -\stex_deactivate_macro:Nn \definiendum {definition~environments} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{definame} -% \begin{macrocode} - -\NewDocumentCommand \definame { O{} m } { - \_@@_definiendum_args:n { #1 } - % TODO: root - \stex_get_symbol:n { #2 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \str_replace_all:Nnn \l_tmpa_str {-} {~} - \stex_html_backend:TF { - \stex_if_do_html:T { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { - \l_tmpa_str\l_@@_definiendum_post_tl - } - } - } { - \exp_args:Nnx \defemph@uri { - \l_tmpa_str\l_@@_definiendum_post_tl - } { \l_stex_get_symbol_uri_str } - } -} -\stex_deactivate_macro:Nn \definame {definition~environments} - -\NewDocumentCommand \Definame { O{} m } { - \_@@_definiendum_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \stex_html_backend:TF { - \stex_if_do_html:T { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { - \exp_after:wN \stex_capitalize:n \l_tmpa_str\l__stex_statements_definiendum_post_tl - } - } - } { - \exp_args:Nnx \defemph@uri { - \exp_after:wN \stex_capitalize:n \l_tmpa_str\l__stex_statements_definiendum_post_tl - } { \l_stex_get_symbol_uri_str } - } -} -\stex_deactivate_macro:Nn \Definame {definition~environments} - -\NewDocumentCommand \premise { m }{ - \noindent\stex_annotate:nnn{ premise }{}{\ignorespaces #1 } -} -\NewDocumentCommand \conclusion { m }{ - \noindent\stex_annotate:nnn{ conclusion }{}{\ignorespaces #1 } -} -\NewDocumentCommand \definiens { O{} m }{ - \str_clear:N \l_stex_get_symbol_uri_str - \tl_if_empty:nF {#1} { - \stex_get_symbol:n { #1 } - } - \str_if_empty:NT \l_stex_get_symbol_uri_str { - \int_compare:nNnTF {\clist_count:N \l_@@_sdefinition_for_clist} = 1 { - \str_set:Nx \l_stex_get_symbol_uri_str {\clist_item:Nn \l_@@_sdefinition_for_clist 1} - }{ - % TODO throw error - } - } - \str_if_eq:eeT {\prop_item:cn {l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{module}} - {\l_stex_current_module_str}{ - \str_if_eq:eeF {\prop_item:cn {l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}} - {true}{ - \prop_put:cnn{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}{true} - \exp_args:Nx \stex_add_to_current_module:n { - \prop_put:cnn{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}{true} - } - } - } - \stex_annotate:nnn{ definiens }{\l_stex_get_symbol_uri_str}{ #2 } -} - -\NewDocumentCommand \varbindforall {m}{ - \stex_symbol_or_var:n {#1} - \bool_if:NTF\l_stex_symbol_or_var_bool{ - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {bindtype}{forall,\l_stex_get_symbol_uri_str}{} - } - }{ - % todo throw error - } -} - -\stex_deactivate_macro:Nn \premise {definition,~example~or~assertion~environments} -\stex_deactivate_macro:Nn \conclusion {example~or~assertion~environments} -\stex_deactivate_macro:Nn \definiens {definition~environments} -\stex_deactivate_macro:Nn \varbindforall {definition~or~assertion~environments} - -% \end{macrocode} -% \end{macro} -% -% \begin{environment}{sdefinition} -% \begin{macrocode} - -\keys_define:nn {stex / sdefinition }{ - type .str_set_x:N = \sdefinitiontype, - id .str_set_x:N = \sdefinitionid, - name .str_set_x:N = \sdefinitionname, - for .clist_set:N = \l_@@_sdefinition_for_clist , - title .tl_set:N = \sdefinitiontitle -} -\cs_new_protected:Nn \_@@_sdefinition_args:n { - \str_clear:N \sdefinitiontype - \str_clear:N \sdefinitionid - \str_clear:N \sdefinitionname - \clist_clear:N \l_@@_sdefinition_for_clist - \tl_clear:N \sdefinitiontitle - \keys_set:nn { stex / sdefinition }{ #1 } -} - -\NewDocumentEnvironment{sdefinition}{O{}}{ - \_@@_sdefinition_args:n{ #1 } - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - \stex_reactivate_macro:N \varbindforall - \stex_if_smsmode:F{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sdefinition_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \clist_set_from_seq:NN \l_@@_sdefinition_for_clist \l_tmpb_seq - \exp_args:Nnnx - \begin{stex_annotate_env}{definition}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sdefinitiontype { - \stex_annotate_invisible:nnn{typestrings}{\sdefinitiontype}{} - } - \str_if_empty:NF \sdefinitionname { - \stex_annotate_invisible:nnn{statementname}{\sdefinitionname}{} - } - \clist_set:No \l_tmpa_clist \sdefinitiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sdefinition_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sdefinition_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sdefinition_start: - }{ - \l_tmpa_tl - } - } - \stex_ref_new_doc_target:n \sdefinitionid - \stex_smsmode_do: -}{ - \stex_suppress_html:n { - \str_if_empty:NF \sdefinitionname { \stex_symdecl_do:nn{}{\sdefinitionname} } - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sdefinitiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sdefinition_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sdefinition_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sdefinition_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\stexpatchdefinition} -% \begin{macrocode} -\cs_new_protected:Nn \_@@_sdefinition_start: { - \stex_par:\noindent\titleemph{Definition\tl_if_empty:NF \sdefinitiontitle { - ~(\sdefinitiontitle) - }~} -} -\cs_new_protected:Nn \_@@_sdefinition_end: {\stex_par:\medskip} - -\newcommand\stexpatchdefinition[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sdefinition_start: { #2 } - \tl_set:Nn \_@@_sdefinition_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sdefinition_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sdefinition_#1_end:\endcsname{ #3 } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\inlinedef} -% inline: -% \begin{macrocode} -\keys_define:nn {stex / inlinedef }{ - type .str_set_x:N = \sdefinitiontype, - id .str_set_x:N = \sdefinitionid, - for .clist_set:N = \l_@@_sdefinition_for_clist , - name .str_set_x:N = \sdefinitionname -} -\cs_new_protected:Nn \_@@_inlinedef_args:n { - \str_clear:N \sdefinitiontype - \str_clear:N \sdefinitionid - \str_clear:N \sdefinitionname - \clist_clear:N \l_@@_sdefinition_for_clist - \keys_set:nn { stex / inlinedef }{ #1 } -} -\NewDocumentCommand \inlinedef { O{} m } { - \begingroup - \_@@_inlinedef_args:n{ #1 } - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - \stex_reactivate_macro:N \varbindforall - \stex_ref_new_doc_target:n \sdefinitionid - \stex_if_smsmode:TF{\stex_suppress_html:n { - \str_if_empty:NF \sdefinitionname { \stex_symdecl_do:nn{}{\sdefinitionname} } - }}{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sdefinition_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \clist_set_from_seq:NN \l_@@_sdefinition_for_clist \l_tmpb_seq - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{definition}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sdefinitiontype { - \stex_annotate_invisible:nnn{typestrings}{\sdefinitiontype}{} - } - #2 - \str_if_empty:NF \sdefinitionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sdefinitionname}} - \stex_annotate_invisible:nnn{statementname}{\sdefinitionname}{} - } - } - } - \endgroup - \stex_smsmode_do: -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Assertions} -% -% \begin{environment}{sassertion} -% \begin{macrocode} - -\keys_define:nn {stex / sassertion }{ - type .str_set_x:N = \sassertiontype, - id .str_set_x:N = \sassertionid, - title .tl_set:N = \sassertiontitle , - for .clist_set:N = \l_@@_sassertion_for_clist , - name .str_set_x:N = \sassertionname -} -\cs_new_protected:Nn \_@@_sassertion_args:n { - \str_clear:N \sassertiontype - \str_clear:N \sassertionid - \str_clear:N \sassertionname - \clist_clear:N \l_@@_sassertion_for_clist - \tl_clear:N \sassertiontitle - \keys_set:nn { stex / sassertion }{ #1 } -} - -%\tl_new:N \g_@@_aftergroup_tl - -\NewDocumentEnvironment{sassertion}{O{}}{ - \_@@_sassertion_args:n{ #1 } - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_reactivate_macro:N \varbindforall - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sassertion_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{assertion}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sassertiontype { - \stex_annotate_invisible:nnn{type}{\sassertiontype}{} - } - \str_if_empty:NF \sassertionname { - \stex_annotate_invisible:nnn{statementname}{\sassertionname}{} - } - \clist_set:No \l_tmpa_clist \sassertiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sassertion_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sassertion_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sassertion_start: - }{ - \l_tmpa_tl - } - } - \str_if_empty:NTF \sassertionid { - \str_if_empty:NF \sassertionname { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sassertionid - } - \stex_smsmode_do: -}{ - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sassertiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sassertion_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sassertion_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sassertion_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\stexpatchassertion} -% \begin{macrocode} - -\cs_new_protected:Nn \_@@_sassertion_start: { - \stex_par:\noindent\titleemph{Assertion~\tl_if_empty:NF \sassertiontitle { - (\sassertiontitle) - }~} -} -\cs_new_protected:Nn \_@@_sassertion_end: {\stex_par:\medskip} - -\newcommand\stexpatchassertion[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sassertion_start: { #2 } - \tl_set:Nn \_@@_sassertion_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sassertion_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sassertion_#1_end:\endcsname{ #3 } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\inlineass} -% inline: -% \begin{macrocode} -\keys_define:nn {stex / inlineass }{ - type .str_set_x:N = \sassertiontype, - id .str_set_x:N = \sassertionid, - for .clist_set:N = \l_@@_sassertion_for_clist , - name .str_set_x:N = \sassertionname -} -\cs_new_protected:Nn \_@@_inlineass_args:n { - \str_clear:N \sassertiontype - \str_clear:N \sassertionid - \str_clear:N \sassertionname - \clist_clear:N \l_@@_sassertion_for_clist - \keys_set:nn { stex / inlineass }{ #1 } -} -\NewDocumentCommand \inlineass { O{} m } { - \begingroup - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_reactivate_macro:N \varbindforall - \_@@_inlineass_args:n{ #1 } - \str_if_empty:NTF \sassertionid { - \str_if_empty:NF \sassertionname { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sassertionid - } - - \stex_if_smsmode:TF{ - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - } - }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sassertion_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{assertion}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sassertiontype { - \stex_annotate_invisible:nnn{typestrings}{\sassertiontype}{} - } - #2 - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - \stex_annotate_invisible:nnn{statementname}{\sassertionname}{} - } - } - } - \endgroup - \stex_smsmode_do: -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Examples} -% -% \begin{environment}{sexample} -% \begin{macrocode} - -\keys_define:nn {stex / sexample }{ - type .str_set_x:N = \exampletype, - id .str_set_x:N = \sexampleid, - title .tl_set:N = \sexampletitle, - name .str_set_x:N = \sexamplename , - for .clist_set:N = \l_@@_sexample_for_clist, -} -\cs_new_protected:Nn \_@@_sexample_args:n { - \str_clear:N \sexampletype - \str_clear:N \sexampleid - \str_clear:N \sexamplename - \tl_clear:N \sexampletitle - \clist_clear:N \l_@@_sexample_for_clist - \keys_set:nn { stex / sexample }{ #1 } -} - -\NewDocumentEnvironment{sexample}{O{}}{ - \_@@_sexample_args:n{ #1 } - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sexample_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{example}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sexampletype { - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - \str_if_empty:NF \sexamplename { - \stex_annotate_invisible:nnn{statementname}{\sexamplename}{} - } - \clist_set:No \l_tmpa_clist \sexampletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sexample_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sexample_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sexample_start: - }{ - \l_tmpa_tl - } - } - \str_if_empty:NF \sexampleid { - \stex_ref_new_doc_target:n \sexampleid - } - \stex_smsmode_do: -}{ - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sexamplename}} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sexampletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sexample_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sexample_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sexample_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\stexpatchexample} -% \begin{macrocode} - -\cs_new_protected:Nn \_@@_sexample_start: { - \stex_par:\noindent\titleemph{Example~\tl_if_empty:NF \sexampletitle { - (\sexampletitle) - }~} -} -\cs_new_protected:Nn \_@@_sexample_end: {\stex_par:\medskip} - -\newcommand\stexpatchexample[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sexample_start: { #2 } - \tl_set:Nn \_@@_sexample_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sexample_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sexample_#1_end:\endcsname{ #3 } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\inlineex} -% inline: -% \begin{macrocode} -\keys_define:nn {stex / inlineex }{ - type .str_set_x:N = \sexampletype, - id .str_set_x:N = \sexampleid, - for .clist_set:N = \l_@@_sexample_for_clist , - name .str_set_x:N = \sexamplename -} -\cs_new_protected:Nn \_@@_inlineex_args:n { - \str_clear:N \sexampletype - \str_clear:N \sexampleid - \str_clear:N \sexamplename - \clist_clear:N \l_@@_sexample_for_clist - \keys_set:nn { stex / inlineex }{ #1 } -} -\NewDocumentCommand \inlineex { O{} m } { - \begingroup - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \_@@_inlineex_args:n{ #1 } - \str_if_empty:NF \sexampleid { - \stex_ref_new_doc_target:n \sexampleid - } - \stex_if_smsmode:TF{ - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\examplename}} - } - }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sexample_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{example}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sexampletype { - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - #2 - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sexamplename}} - \stex_annotate_invisible:nnn{statementname}{\sexamplename}{} - } - } - } - \endgroup - \stex_smsmode_do: -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Logical Paragraphs} -% -% \begin{environment}{sparagraph} -% \begin{macrocode} -\keys_define:nn { stex / sparagraph} { - id .str_set_x:N = \sparagraphid , - title .tl_set:N = \l_stex_sparagraph_title_tl , - type .str_set_x:N = \sparagraphtype , - for .clist_set:N = \l_@@_sparagraph_for_clist , - from .tl_set:N = \sparagraphfrom , - to .tl_set:N = \sparagraphto , - start .tl_set:N = \l_stex_sparagraph_start_tl , - name .str_set:N = \sparagraphname , - imports .tl_set:N = \l_@@_sparagraph_imports_tl -} - -\cs_new_protected:Nn \stex_sparagraph_args:n { - \tl_clear:N \l_stex_sparagraph_title_tl - \tl_clear:N \sparagraphfrom - \tl_clear:N \sparagraphto - \tl_clear:N \l_stex_sparagraph_start_tl - \tl_clear:N \l_@@_sparagraph_imports_tl - \str_clear:N \sparagraphid - \str_clear:N \sparagraphtype - \clist_clear:N \l_@@_sparagraph_for_clist - \str_clear:N \sparagraphname - \keys_set:nn { stex / sparagraph }{ #1 } -} -\newif\if@in@omtext\@in@omtextfalse - -\NewDocumentEnvironment {sparagraph} { O{} } { - \stex_sparagraph_args:n { #1 } - \tl_if_empty:NTF \l_stex_sparagraph_start_tl { - \tl_set_eq:NN \sparagraphtitle \l_stex_sparagraph_title_tl - }{ - \tl_set_eq:NN \sparagraphtitle \l_stex_sparagraph_start_tl - } - \@in@omtexttrue - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{paragraph}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sparagraphtype { - \stex_annotate_invisible:nnn{typestrings}{\sparagraphtype}{} - } - \str_if_empty:NF \sparagraphfrom { - \stex_annotate_invisible:nnn{from}{\sparagraphfrom}{} - } - \str_if_empty:NF \sparagraphto { - \stex_annotate_invisible:nnn{to}{\sparagraphto}{} - } - \str_if_empty:NF \sparagraphname { - \stex_annotate_invisible:nnn{statementname}{\sparagraphname}{} - } - \clist_set:No \l_tmpa_clist \sparagraphtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \sparagraphtype { - \tl_if_exist:cT {_@@_sparagraph_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sparagraph_##1_start:}} - } - } - \stex_csl_to_imports:No \usemodule \l_@@_sparagraph_imports_tl - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sparagraph_start: - }{ - \l_tmpa_tl - } - } - \clist_set:No \l_tmpa_clist \sparagraphtype - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}} - { - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - } - \str_if_empty:NTF \sparagraphid { - \str_if_empty:NTF \sparagraphname { - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sparagraphid - } - \exp_args:NNx - \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \clist_map_inline:Nn \l_@@_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - } - } - } - \stex_smsmode_do: - \ignorespacesandpars -}{ - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sparagraphtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sparagraph_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sparagraph_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sparagraph_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} - } -} -% \end{macrocode} -% \end{environment} -% -% \begin{macro}{\stexpatchparagraph} -% \begin{macrocode} - -\cs_new_protected:Nn \_@@_sparagraph_start: { - \stex_par:\noindent\tl_if_empty:NTF \l_stex_sparagraph_start_tl { - \tl_if_empty:NF \l_stex_sparagraph_title_tl { - \titleemph{\l_stex_sparagraph_title_tl}:~ - } - }{ - \titleemph{\l_stex_sparagraph_start_tl}~ - } -} -\cs_new_protected:Nn \_@@_sparagraph_end: {\stex_par:\medskip} - -\newcommand\stexpatchparagraph[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_sparagraph_start: { #2 } - \tl_set:Nn \_@@_sparagraph_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_sparagraph_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_sparagraph_#1_end:\endcsname{ #3 } - } -} - -\keys_define:nn { stex / inlinepara} { - id .str_set_x:N = \sparagraphid , - type .str_set_x:N = \sparagraphtype , - for .clist_set:N = \l_@@_sparagraph_for_clist , - from .tl_set:N = \sparagraphfrom , - to .tl_set:N = \sparagraphto , - name .str_set:N = \sparagraphname -} -\cs_new_protected:Nn \_@@_inlinepara_args:n { - \tl_clear:N \sparagraphfrom - \tl_clear:N \sparagraphto - \str_clear:N \sparagraphid - \str_clear:N \sparagraphtype - \clist_clear:N \l_@@_sparagraph_for_clist - \str_clear:N \sparagraphname - \keys_set:nn { stex / inlinepara }{ #1 } -} -\NewDocumentCommand \inlinepara { O{} m } { - \begingroup - \_@@_inlinepara_args:n{ #1 } - \clist_set:No \l_tmpa_clist \sparagraphtype - \str_if_empty:NTF \sparagraphid { - \str_if_empty:NTF \sparagraphname { - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sparagraphid - } - \stex_if_smsmode:TF{ - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l_@@_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{paragraph}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sparagraphtype { - \stex_annotate_invisible:nnn{typestrings}{\sparagraphtype}{} - } - \str_if_empty:NF \sparagraphfrom { - \stex_annotate_invisible:nnn{from}{\sparagraphfrom}{} - } - \str_if_empty:NF \sparagraphto { - \stex_annotate_invisible:nnn{to}{\sparagraphto}{} - } - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_annotate_invisible:nnn{statementname}{\sparagraphname}{} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \clist_map_inline:Nn \l_tmpb_seq { - \stex_ref_new_sym_target:n {##1} - } - } - #2 - } - } - \endgroup - \stex_smsmode_do: -} - -% \end{macrocode} -% \end{macro} -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex - -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx deleted file mode 100644 index e5e7982abc6..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-symbols.dtx +++ /dev/null @@ -1,1613 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Symbols -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-symbols} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \tableofcontents -% -% \input{../../doc/packages/stex-symbols} -% \fi -% -% \begin{documentation}\label{pkg:symbols:doc} -% \changes{3.1.0}{2022/03/03}{Introduced sequence variables} -% \changes{3.1.0}{2022/03/01}{Fixed bug with precedences in variables} -% \changes{3.1.0}{2022/03/01}{Introduced \detokenize{\varemph, \varemph@uri}} -% -% Code related to symbol declarations and notations -% -% \section{Macros and Environments}\label{pkg:symbols:doc:macros} -% -% \begin{function}{\symdecl} -% \begin{syntax} \cs{symdecl}\Arg{macroname}|[|\meta{args}|]| \end{syntax} -% Declares a new symbol with semantic macro \cs{macroname}. Optional -% arguments are: -% \begin{itemize} -% \item |name|: An (\omdoc) name. By default equal to \meta{macroname}. -% \item |type|: An (ideally semantic) term, representing a \emph{type}. Not used by \sTeX, but -% passed on to \mmt for semantic services. -% \item |def|: An (ideally semantic) term, representing a \emph{definiens}. Not used by \sTeX, but -% passed on to \mmt for semantic services. -% \item |args|: Specifies the ``signature'' of the semantic macro. -% Can be either an integer $0 \leq n \leq 9$, or a (more precise) -% sequence of the following characters: -% \begin{itemize} -% \item[|i|] a ``normal'' argument, e.g. -% |\symdecl{plus}[args=ii]| allows for |\plus{2}{2}|. -% \item[|a|] an \emph{associative} argument; i.e. a sequence of -% arbitrarily many arguments provided as a comma-separated list, -% e.g. -% |\symdecl{plus}[args=a]| allows for |\plus{2,2,2}|. -% \item[|b|] a \emph{variable} argument. Is treated by \sTeX -% like an |i|-argument, but an application is turned into -% an |OMBind| in \omdoc, binding the provided variable -% in the subsequent arguments of the operator; e.g. -% |\symdecl{forall}[args=bi]| allows for |\forall{x\in\Nat}{x\geq0}|. -% \end{itemize} -% \end{itemize} -% \end{function} -% -% \begin{function}{\stex_symdecl_do:n} -% Implements the core functionality of \cs{symdecl}, and is -% called by \cs{symdecl} and \cs{symdef}. -% -% Ultimately stores the symbol \meta{URI} in the property -% list |\l_stex_symdecl_|\meta{URI}|_prop| with fields: -% \begin{itemize} -% \item |name| (string), -% \item |module| (string), -% \item |notations| (sequence of strings; initially empty), -% \item |type| (token list), -% \item |args| (string of |i|s, |a|s and |b|s), -% \item |arity| (integer string), -% \item |assocs| (integer string; number of associative arguments), -% \end{itemize} -% \end{function} -% -% \begin{function}{\stex_all_symbols:n} -% Iterates over all currently available symbols. -% Requires two |\seq_map_break:| to break fully. -% \end{function} -% -% \begin{function}{\stex_get_symbol:n} -% Computes the full URI of a symbol from a macro argument, e.g. -% the macro name, the macro itself, the full URI... -% \end{function} -% -% \begin{function}{\notation} -% \begin{syntax} \cs{notation}|[|\meta{args}|]|\Arg{symbol}\Arg{notations$^+$} \end{syntax} -% Introduces a new notation for \meta{symbol}, see \cs{stex_notation_do:nn} -% \end{function} -% -% \begin{function}{\stex_notation_do:nn} -% \begin{syntax} \cs{stex_notation_do:nn}\Arg{URI}\Arg{notations$^+$}\end{syntax} -% -% Implements the core functionality of \cs{notation}, and is -% called by \cs{notation} and \cs{symdef}. -% -% Ultimately stores the notation in the property -% list\\ |\g_stex_notation_|\meta{URI}|#|\meta{variant}|#|^^A -% \meta{lang}|_prop| with fields: -% \begin{itemize} -% \item |symbol| (URI string), -% \item |language| (string), -% \item |variant| (string), -% \item |opprec| (integer string), -% \item |argprecs| (sequence of integer strings) -% \end{itemize} -% \end{function} -% -% \begin{function}{\symdef} -% \begin{syntax} \cs{symdef}|[|\meta{args}|]|\Arg{symbol}\Arg{notations$^+$} \end{syntax} -% Combines \cs{symdecl} and \cs{notation} by introducing a new -% symbol and assigning a new notation for it. -% \end{function} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:symbols:impl} -% -% \section{\sTeX-Symbols Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% symbols.dtx %%%%%%%%%%%%% - -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/wrongargs}{ - args~value~in~symbol~declaration~for~#1~ - needs~to~be~i,~a,~b~or~B,~but~#2~given -} -\msg_new:nnn{stex}{error/unknownsymbol}{ - No~symbol~#1~found! -} -\msg_new:nnn{stex}{error/seqlength}{ - Expected~#1~arguments;~got~#2! -} -\msg_new:nnn{stex}{error/unknownnotation}{ - Unknown~notation~#1~for~#2! -} -% \end{macrocode} -% -% \subsection{Symbol Declarations} -% \begin{macrocode} -%<@@=stex_symdecl> -% \end{macrocode} -% -% \begin{macro}{\stex_all_symbols:n} -% Map over all available symbols -% \begin{macrocode} -\cs_new_protected:Nn \stex_all_symbols:n { - \def \_@@_all_symbols_cs ##1 {#1} - \seq_map_inline:Nn \l_stex_all_modules_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \_@@_all_symbols_cs{##1?####1} - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\STEXsymbol} -% \begin{macrocode} -\NewDocumentCommand \STEXsymbol { m } { - \stex_get_symbol:n { #1 } - \exp_args:No - \stex_invoke_symbol:n { \l_stex_get_symbol_uri_str } -} -% \end{macrocode} -% \end{macro} -% -% |symdecl| arguments: -% -% \begin{macrocode} -\keys_define:nn { stex / symdecl } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - type .tl_set:N = \l_stex_symdecl_type_tl , - deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , - align .str_set:N = \l_stex_symdecl_align_str , % TODO(?) - gfc .str_set:N = \l_stex_symdecl_gfc_str , % TODO(?) - def .tl_set:N = \l_stex_symdecl_definiens_tl , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} -} - -\bool_new:N \l_stex_symdecl_make_macro_bool - -\cs_new_protected:Nn \_@@_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_deprecate_str - \str_clear:N \l_stex_symdecl_reorder_str - \str_clear:N \l_stex_symdecl_assoctype_str - \bool_set_false:N \l_stex_symdecl_local_bool - \tl_clear:N \l_stex_symdecl_type_tl - \tl_clear:N \l_stex_symdecl_definiens_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - - \keys_set:nn { stex / symdecl } { #1 } -} -% \end{macrocode} -% -% \begin{macro}{\symdecl} -% -% Parses the optional arguments and passes them on to -% \cs{stex_symdecl_do:} (so that \cs{symdef} -% can do the same) -% -% \begin{macrocode} - -\NewDocumentCommand \symdecl { s m O{}} { - \_@@_args:n { #3 } - \IfBooleanTF #1 { - \bool_set_false:N \l_stex_symdecl_make_macro_bool - } { - \bool_set_true:N \l_stex_symdecl_make_macro_bool - } - \stex_symdecl_do:n { #2 } - \stex_smsmode_do: -} - -\cs_new_protected:Nn \stex_symdecl_do:nn { - \_@@_args:n{#1} - \bool_set_false:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n{#2} -} - -\stex_deactivate_macro:Nn \symdecl {module~environments} -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\stex_symdecl_do:n} -% \begin{macrocode} -\cs_new_protected:Nn \stex_symdecl_do:n { - \stex_if_in_module:F { - % TODO throw error? some default namespace? - } - - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } - } - - \prop_if_exist:cT { l_stex_symdecl_ - \l_stex_current_module_str ? - \l_stex_symdecl_name_str - _prop - }{ - % TODO throw error (beware of circular dependencies) - } - - \prop_clear:N \l_tmpa_prop - \prop_put:Nnx \l_tmpa_prop { module } { \l_stex_current_module_str } - \seq_clear:N \l_tmpa_seq - \prop_put:Nno \l_tmpa_prop { name } \l_stex_symdecl_name_str - \prop_put:Nno \l_tmpa_prop { type } \l_stex_symdecl_type_tl - - \str_if_empty:NT \l_stex_symdecl_deprecate_str { - \str_if_empty:NF \l_stex_module_deprecate_str { - \str_set_eq:NN \l_stex_symdecl_deprecate_str \l_stex_module_deprecate_str - } - } - \prop_put:Nno \l_tmpa_prop { deprecate } \l_stex_symdecl_deprecate_str - - \exp_args:No \stex_add_constant_to_current_module:n { - \l_stex_symdecl_name_str - } - - % arity/args - \int_zero:N \l_tmpb_int - - \bool_set_true:N \l_tmpa_bool - \str_map_inline:Nn \l_stex_symdecl_args_str { - \token_case_meaning:NnF ##1 { - 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} - {\tl_to_str:n i} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n b} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n a} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - {\tl_to_str:n B} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - }{ - \msg_error:nnxx{stex}{error/wrongargs}{ - \l_stex_current_module_str ? - \l_stex_symdecl_name_str - }{##1} - } - } - - \bool_if:NTF \l_tmpa_bool { - % possibly numeric - \str_if_empty:NTF \l_stex_symdecl_args_str { - \prop_put:Nnn \l_tmpa_prop { args } {} - \prop_put:Nnn \l_tmpa_prop { arity } { 0 } - }{ - \int_set:Nn \l_tmpa_int { \l_stex_symdecl_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } { \int_use:N \l_tmpa_int } - \str_clear:N \l_tmpa_str - \int_step_inline:nn \l_tmpa_int { - \str_put_right:Nn \l_tmpa_str i - } - \prop_put:Nnx \l_tmpa_prop { args } { \l_tmpa_str } - } - } { - \prop_put:Nnx \l_tmpa_prop { args } { \l_stex_symdecl_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } - { \str_count:N \l_stex_symdecl_args_str } - } - \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int } - - \tl_if_empty:NTF \l_stex_symdecl_definiens_tl { - \prop_put:Nnx \l_tmpa_prop { defined }{ false } - }{ - \prop_put:Nnx \l_tmpa_prop { defined }{ true } - } - - % argnames - - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { - \clist_if_empty:NTF \l_stex_symdecl_argnames_clist { - \clist_put_right:Nn \l_tmpa_clist {##1} - }{ - \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl - \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} - } - } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} - - % semantic macro - - \bool_if:NT \l_stex_symdecl_make_macro_bool { - \exp_args:Nx \stex_do_up_to_module:n { - \tl_set:cn { #1 } { \stex_invoke_symbol:n { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }} - } - } - - \stex_debug:nn{symbols}{New~symbol:~ - \l_stex_current_module_str ? \l_stex_symdecl_name_str^^J - Type:~\exp_not:o { \l_stex_symdecl_type_tl }^^J - Args:~\prop_item:Nn \l_tmpa_prop { args }^^J - Definiens:~\exp_not:o {\l_stex_symdecl_definiens_tl} - } - - % circular dependencies require this: - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {symdecl} { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } { - \tl_if_empty:NF \l_stex_symdecl_type_tl { - \stex_annotate_invisible:nnn{type}{}{$\l_stex_symdecl_type_tl$} - } - \stex_annotate_invisible:nnn{args}{\prop_item:Nn \l_tmpa_prop { args }}{} - \stex_annotate_invisible:nnn{macroname}{#1}{} - \tl_if_empty:NF \l_stex_symdecl_definiens_tl { - \stex_annotate_invisible:nnn{definiens}{} - {$\l_stex_symdecl_definiens_tl$} - } - \str_if_empty:NF \l_stex_symdecl_assoctype_str { - \stex_annotate_invisible:nnn{assoctype}{\l_stex_symdecl_assoctype_str}{} - } - \str_if_empty:NF \l_stex_symdecl_reorder_str { - \stex_annotate_invisible:nnn{reorderargs}{\l_stex_symdecl_reorder_str}{} - } - } - } - \prop_if_exist:cF { - l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - _prop - } { - \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x { - \_@@_restore_symbol:nnnnnnnn - {\l_stex_symdecl_name_str} - { \prop_item:Nn \l_tmpa_prop {args} } - { \prop_item:Nn \l_tmpa_prop {arity} } - { \prop_item:Nn \l_tmpa_prop {assocs} } - { \prop_item:Nn \l_tmpa_prop {defined} } - {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} } - {\l_stex_current_module_str} - { \prop_item:Nn \l_tmpa_prop {argnames} } - } - } -} -\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnnn { - \prop_clear:N \l_tmpa_prop - \prop_put:Nnn \l_tmpa_prop { module } { #7 } - \prop_put:Nnn \l_tmpa_prop { name } { #1} - \prop_put:Nnn \l_tmpa_prop { args } {#2} - \prop_put:Nnn \l_tmpa_prop { arity } { #3 } - \prop_put:Nnn \l_tmpa_prop { assocs } { #4 } - \prop_put:Nnn \l_tmpa_prop { defined } { #5 } - \prop_put:Nnn \l_tmpa_prop { argnames } { #8 } - \tl_if_empty:nF{#6}{ - \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}} - } - \prop_set_eq:cN{l_stex_symdecl_ \detokenize{#7 ? #1} _prop}\l_tmpa_prop - \seq_clear:c{l_stex_symdecl_ \detokenize{#7 ? #1} _notations} -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\textsymdecl} -% \begin{macrocode} - -\keys_define:nn { stex / textsymdecl } { - name .str_set_x:N = \l_@@_name_str , - type .tl_set:N = \l_@@_type_tl -} - -\cs_new_protected:Nn \_stex_textsymdecl_args:n { - \str_clear:N \l_@@_name_str - \tl_clear:N \l_@@_type_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - \keys_set:nn { stex / textsymdecl } { #1 } -} - -\NewDocumentCommand \textsymdecl {m O{} m} { - \_stex_textsymdecl_args:n { #2 } - \str_if_empty:NTF \l_@@_name_str { - \_@@_args:n{name=#1,#2} - }{ - \_@@_args:n{#2} - } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n{#1-sym} - \stex_execute_in_module:n{ - \cs_set_nopar:cpn{#1name}{ - \ifvmode\hbox_unpack:N\c_empty_box\fi - \ifmmode\hbox{#3}\else#3\fi\xspace - } - \cs_set_nopar:cpn{#1}{ - \ifmmode\csname#1-sym\expandafter\endcsname\else - \ifvmode\hbox_unpack:N\c_empty_box\fi - \symref{#1-sym}{#3}\expandafter\xspace - \fi - } - } - \stex_execute_in_module:x{ - \__stex_notation_restore_notation:nnnnn - {\l_stex_current_module_str?\tl_if_empty:NTF\l_@@_name_str{#1}\l_@@_name_str} - {}{0} - {\exp_not:n{\STEXInternalTermMathOMSiiii{\STEXInternalCurrentSymbolStr}{}{\neginfprec}{ - \comp{\hbox{#3}}\STEXInternalSymbolAfterInvokationTL - }}} - {} - } - \stex_smsmode_do: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_get_symbol:n} -% -% \begin{macrocode} -\str_new:N \l_stex_get_symbol_uri_str - -\cs_new_protected:Nn \stex_get_symbol:n { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \_@@_get_symbol_from_cs: - }{ - % argument is a string - % is it a command name? - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N \l_tmpa_tl - } \stex_invoke_symbol:n { - \_@@_get_symbol_from_cs: - }{ - \_@@_get_symbol_from_string:n { #1 } - } - } { - \_@@_get_symbol_from_string:n { #1 } - } - }{ - % argument is not a command name - \_@@_get_symbol_from_string:n { #1 } - % \l_stex_all_symbols_seq - } - } - \str_if_eq:eeF { - \prop_item:cn { - l_stex_symdecl_\l_stex_get_symbol_uri_str _prop - }{ deprecate } - }{}{ - \msg_warning:nnxx{stex}{warning/deprecated}{ - Symbol~\l_stex_get_symbol_uri_str - }{ - \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{ deprecate } - } - } -} - -\cs_new_protected:Nn \_@@_get_symbol_from_string:n { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownsymbol}{#1} - } - \str_set:Nn \l_tmpa_str { #1 } - - %\int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - - \str_if_in:NnTF \l_tmpa_str ? { - \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \str_set:Nx \l_tmpb_str {\seq_use:Nn \l_tmpa_seq ?} - }{ - \str_clear:N \l_tmpb_str - } - \str_if_empty:NTF \l_tmpb_str { - \seq_map_inline:Nn \l_stex_all_modules_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str { - \seq_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 } - } - }} - } - } - } - }{ - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpb_str } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_if_eq:eeT{ \l_tmpb_str }{ \str_range:nnn {##1}{-\l_tmpa_int}{-1}}{ - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str { - \seq_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 } - } - }} - } - } - } - } - } - - \l_tmpa_tl -} - -\cs_new_protected:Nn \_@@_get_symbol_from_cs: { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \tl_if_single:NTF \l_tmpa_tl { - \exp_args:No \tl_if_head_is_group:nTF \l_tmpa_tl { - \exp_after:wN \str_set:Nn \exp_after:wN - \l_stex_get_symbol_uri_str \l_tmpa_tl - }{ - % TODO - % tail is not a single group - } - }{ - % TODO - % tail is not a single group - } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Notations} -% \begin{macrocode} -%<@@=stex_notation> -% \end{macrocode} -% -% |notation| arguments: -% -% \begin{macrocode} -\keys_define:nn { stex / notation } { -% lang .tl_set_x:N = \l_@@_lang_str , - variant .tl_set_x:N = \l_@@_variant_str , - prec .str_set_x:N = \l_@@_prec_str , - op .tl_set:N = \l_@@_op_tl , - primary .bool_set:N = \l_@@_primary_bool , - primary .default:n = {true} , - hints .str_set_x:N = \l_@@_hints_str, - unknown .code:n = \str_set:Nx - \l_@@_variant_str \l_keys_key_str -} - -\cs_new_protected:Nn \_stex_notation_args:n { -% \str_clear:N \l_@@_lang_str - \str_clear:N \l_@@_variant_str - \str_clear:N \l_@@_prec_str - \str_clear:N \l_@@_hints_str - \tl_clear:N \l_@@_op_tl - \bool_set_false:N \l_@@_primary_bool - - \keys_set:nn { stex / notation } { #1 } -} -% \end{macrocode} -% -% -% -% \begin{macro}{\notation} -% \begin{macrocode} -\NewDocumentCommand \notation { s m O{}} { - \_stex_notation_args:n { #3 } - \tl_clear:N \l_stex_symdecl_definiens_tl - \stex_get_symbol:n { #2 } - \tl_set:Nn \l_stex_notation_after_do_tl { - \_@@_final: - \IfBooleanTF#1{ - \stex_setnotation:n {\l_stex_get_symbol_uri_str} - }{} - \stex_smsmode_do:\ignorespacesandpars - } - \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l_@@_variant_str } - { \l_@@_prec_str} -} -\stex_deactivate_macro:Nn \notation {module~environments} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\stex_notation_do:nnnnn} -% \begin{macrocode} -\seq_new:N \l_@@_precedences_seq -\tl_new:N \l_@@_opprec_tl -\int_new:N \l_@@_currarg_int -\tl_new:N \STEXInternalSymbolAfterInvokationTL - -\cs_new_protected:Nn \stex_notation_do:nnnnn { - \let\STEXInternalCurrentSymbolStr\relax - \seq_clear:N \l_@@_precedences_seq - \tl_clear:N \l_@@_opprec_tl - \str_set:Nx \l_@@_args_str { #1 } - \str_set:Nx \l_@@_arity_str { #2 } - \str_set:Nx \l_@@_suffix_str { #3 } - \str_set:Nx \l_@@_prec_str { #4 } - - % precedences - \str_if_empty:NTF \l_@@_prec_str { - \int_compare:nNnTF \l_@@_arity_str = 0 { - \tl_set:No \l_@@_opprec_tl { \neginfprec } - }{ - \tl_set:Nn \l_@@_opprec_tl { 0 } - } - } { - \str_if_eq:onTF \l_@@_prec_str {nobrackets}{ - \tl_set:No \l_@@_opprec_tl { \neginfprec } - \int_step_inline:nn { \l_@@_arity_str } { - \exp_args:NNo - \seq_put_right:Nn \l_@@_precedences_seq { \infprec } - } - }{ - \seq_set_split:NnV \l_tmpa_seq ; \l_@@_prec_str - \seq_pop_left:NNTF \l_tmpa_seq \l_tmpa_str { - \tl_set:No \l_@@_opprec_tl { \l_tmpa_str } - \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_str { - \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn - \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str } - \seq_map_inline:Nn \l_tmpa_seq { - \seq_put_right:Nn \l_@@_precedences_seq { ##1 } - } - } - }{ - \int_compare:nNnTF \l_@@_arity_str = 0 { - \tl_set:No \l_@@_opprec_tl { \infprec } - }{ - \tl_set:No \l_@@_opprec_tl { 0 } - } - } - } - } - - \seq_set_eq:NN \l_tmpa_seq \l_@@_precedences_seq - \int_step_inline:nn { \l_@@_arity_str } { - \seq_pop_left:NNF \l_tmpa_seq \l_tmpb_str { - \exp_args:NNo - \seq_put_right:No \l_@@_precedences_seq { - \l_@@_opprec_tl - } - } - } - \tl_clear:N \l_stex_notation_dummyargs_tl - - \int_compare:nNnTF \l_@@_arity_str = 0 { - \exp_args:NNe - \cs_set:Npn \l_stex_notation_macrocode_cs { - \STEXInternalTermMathOMSiiii { \STEXInternalCurrentSymbolStr } - { \l_@@_suffix_str } - { \l_@@_opprec_tl } - { \exp_not:n { #5 } } - } - \l_stex_notation_after_do_tl - }{ - \str_if_in:NnTF \l_@@_args_str b { - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l_@@_arity_str } { { - \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr } - { \l_@@_suffix_str } - { \l_@@_opprec_tl } - { \exp_not:n { #5 } } - }} - }{ - \str_if_in:NnTF \l_@@_args_str B { - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l_@@_arity_str } { { - \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr } - { \l_@@_suffix_str } - { \l_@@_opprec_tl } - { \exp_not:n { #5 } } - } } - }{ - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l_@@_arity_str } { { - \STEXInternalTermMathOMAiiii { \STEXInternalCurrentSymbolStr } - { \l_@@_suffix_str } - { \l_@@_opprec_tl } - { \exp_not:n { #5 } } - } } - } - } - - \str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str - \int_zero:N \l_@@_currarg_int - \seq_set_eq:NN \l_@@_remaining_precs_seq \l_@@_precedences_seq - \_@@_arguments: - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_arguments:} -% -% Takes care of annotating the arguments in a -% notation macro -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_arguments: { - \int_incr:N \l_@@_currarg_int - \str_if_empty:NTF \l_@@_remaining_args_str { - \l_stex_notation_after_do_tl - }{ - \str_set:Nx \l_tmpa_str { \str_head:N \l_@@_remaining_args_str } - \str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str } - \str_if_eq:VnTF \l_tmpa_str a { - \_@@_argument_assoc:nn{a} - }{ - \str_if_eq:VnTF \l_tmpa_str B { - \_@@_argument_assoc:nn{B} - }{ - \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpb_str - \tl_put_right:Nx \l_stex_notation_dummyargs_tl { - { \STEXInternalTermMathArgiii - { \l_tmpa_str\int_use:N \l_@@_currarg_int } - { \l_tmpb_str } - { ####\int_use:N \l_@@_currarg_int } - } - } - \_@@_arguments: - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_argument_assoc:nn} -% \begin{macrocode} -\cs_new_protected:Nn \_@@_argument_assoc:nn { - - \cs_generate_from_arg_count:NNnn \l_tmpa_cs \cs_set:Npn - {\l_@@_arity_str}{ - #2 - } - \int_zero:N \l_tmpa_int - \tl_clear:N \l_tmpa_tl - \str_map_inline:Nn \l_@@_args_str { - \int_incr:N \l_tmpa_int - \tl_put_right:Nx \l_tmpa_tl { - \str_if_eq:nnTF {##1}{a}{ {} }{ - \str_if_eq:nnTF {##1}{B}{ {} }{ - {\_stex_term_arg:nn{##1\int_use:N \l_tmpa_int}{################ \int_use:N \l_tmpa_int}} - } - } - } - } - \exp_after:wN\exp_after:wN\exp_after:wN \def - \exp_after:wN\exp_after:wN\exp_after:wN \l_tmpa_cs - \exp_after:wN\exp_after:wN\exp_after:wN ## - \exp_after:wN\exp_after:wN\exp_after:wN 1 - \exp_after:wN\exp_after:wN\exp_after:wN ## - \exp_after:wN\exp_after:wN\exp_after:wN 2 - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN { - \exp_after:wN \l_tmpa_cs \l_tmpa_tl - } - } - - \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str - \tl_put_right:Nx \l_stex_notation_dummyargs_tl { { - \STEXInternalTermMathAssocArgiiiii - { \int_use:N \l_@@_currarg_int } - { \l_tmpa_str } - { ####\int_use:N \l_@@_currarg_int } - { \l_tmpa_cs {####1} {####2} } - {#1} - } } - \_@@_arguments: -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_@@_final:} -% -% Called after processing all notation arguments -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_restore_notation:nnnnn { - \cs_generate_from_arg_count:cNnn{stex_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs} - \cs_set_nopar:Npn {#3}{#4} - \tl_if_empty:nF {#5}{ - \tl_set:cn{stex_op_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs}{ \comp{ #5 } } - } - \seq_if_exist:cT { l_stex_symdecl_\detokenize{#1} _notations }{ - \seq_put_right:cx { l_stex_symdecl_\detokenize{#1} _notations } { \detokenize{#2} } - } -} - -\cs_new_protected:Nn \_@@_final: { - - \stex_execute_in_module:x { - \_@@_restore_notation:nnnnn - {\l_stex_get_symbol_uri_str} - {\l_@@_suffix_str} - {\l_@@_arity_str} - { - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL} - } - {\exp_args:No \exp_not:n \l_@@_op_tl } - } - - \stex_debug:nn{symbols}{ - Notation~\l_@@_suffix_str - ~for~\l_stex_get_symbol_uri_str^^J - Operator~precedence:~\l_@@_opprec_tl^^J - Argument~precedences:~ - \seq_use:Nn \l_@@_precedences_seq {,~}^^J - Notation: \cs_meaning:c { - stex_notation_ \l_stex_get_symbol_uri_str \c_hash_str - \l_@@_suffix_str - _cs - } - } - % HTML annotations - \stex_if_do_html:T { - \stex_annotate_invisible:nnn { notation } - { \l_stex_get_symbol_uri_str } { - \stex_annotate_invisible:nnn { notationfragment } - { \l_@@_suffix_str }{} - \stex_annotate_invisible:nnn { precedence } - { \l_@@_prec_str }{} - - \int_zero:N \l_tmpa_int - \str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \l_@@_arity_str }{ - \int_incr:N \l_tmpa_int - \str_set:Nx \l_tmpb_str { \str_head:N \l_@@_remaining_args_str } - \str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str } - \str_if_eq:VnTF \l_tmpb_str a { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \str_if_eq:VnTF \l_tmpb_str B { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{} - } } - } - } - } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {\l_stex_get_symbol_uri_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_notation_ \STEXInternalCurrentSymbolStr - \c_hash_str \l_@@_suffix_str _cs - } } { \l_tmpa_tl } $ - } - \tl_if_empty:NF \l_@@_op_tl { - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $\l_@@_op_tl$ - } - } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\setnotation} -% \begin{macrocode} -\keys_define:nn { stex / setnotation } { -% lang .tl_set_x:N = \l_@@_lang_str , - variant .tl_set_x:N = \l_@@_variant_str , - unknown .code:n = \str_set:Nx - \l_@@_variant_str \l_keys_key_str -} - -\cs_new_protected:Nn \_stex_setnotation_args:n { - % \str_clear:N \l_@@_lang_str - \str_clear:N \l_@@_variant_str - \keys_set:nn { stex / setnotation } { #1 } -} - -\cs_new_protected:Nn \_@@_setnotation:nn { - \seq_if_exist:cT{l_stex_symdecl_#1_notations}{ - \seq_remove_all:cn { l_stex_symdecl_#1 _notations }{ #2 } - \seq_put_left:cn { l_stex_symdecl_#1 _notations }{ #2 } - } -} - -\cs_new_protected:Nn \stex_setnotation:n { - \exp_args:Nnx \seq_if_in:cnTF { l_stex_symdecl_#1 _notations } - { \l_@@_variant_str }{ - \stex_execute_in_module:x{ \_@@_setnotation:nn {#1}{\l_@@_variant_str} } - \stex_debug:nn {notations}{ - Setting~default~notation~ - {\l_@@_variant_str }~for~ - #1 \\ - \expandafter\meaning\csname - l_stex_symdecl_#1 _notations\endcsname - } - }{ - \msg_error:nnxx{stex}{unknownnotation}{\l_@@_variant_str}{#1} - } -} - -\NewDocumentCommand \setnotation {m m} { - \stex_get_symbol:n { #1 } - \_stex_setnotation_args:n { #2 } - \stex_setnotation:n{\l_stex_get_symbol_uri_str} - \stex_smsmode_do:\ignorespacesandpars -} - -\cs_new_protected:Nn \stex_copy_notations:nn { - \stex_debug:nn {notations}{ - Copying~notations~from~#2~to~#1\\ - \seq_use:cn{l_stex_symdecl_#2_notations}{,~} - } - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } } { - \tl_put_right:Nn \l_tmpa_tl { {######## ##1} } - } - \seq_map_inline:cn {l_stex_symdecl_#2_notations}{\begingroup - \stex_debug:nn{Here}{Here:~##1} - \cs_set_eq:Nc \l_tmpa_cs { stex_notation_ #2 \c_hash_str ##1 _cs } - \edef \l_tmpa_tl { - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN \l_tmpa_cs \l_tmpa_tl - } - } - - \exp_after:wN \def \exp_after:wN \l_tmpa_tl - \exp_after:wN ####\exp_after:wN 1 \exp_after:wN ####\exp_after:wN 2 - \exp_after:wN { \l_tmpa_tl } - - \edef \l_tmpa_tl { - \exp_after:wN \exp_not:n \exp_after:wN { - \l_tmpa_tl {######## 1}{######## 2} - } - } - - \stex_debug:nn{Here}{Here:~\expandafter\detokenize\expandafter{\l_tmpa_tl}} - - \stex_execute_in_module:x { - \_@@_restore_notation:nnnnn - {#1}{##1} - { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } } - { \exp_after:wN\exp_not:n\exp_after:wN{\l_tmpa_tl} } - { - \cs_if_exist:cT{stex_op_notation_ #2\c_hash_str ##1 _cs}{ - \exp_args:NNo\exp_args:No\exp_not:n{\csname stex_op_notation_ #2\c_hash_str ##1 _cs\endcsname} - } - } - }\endgroup - } -} - -\NewDocumentCommand \copynotation {m m} { - \stex_get_symbol:n { #1 } - \str_set_eq:NN \l_tmpa_str \l_stex_get_symbol_uri_str - \stex_get_symbol:n { #2 } - \exp_args:Noo - \stex_copy_notations:nn \l_tmpa_str \l_stex_get_symbol_uri_str - \stex_smsmode_do:\ignorespacesandpars -} - -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\symdef} -% \begin{macrocode} -\keys_define:nn { stex / symdef } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - type .tl_set:N = \l_stex_symdecl_type_tl , - def .tl_set:N = \l_stex_symdecl_definiens_tl , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - op .tl_set:N = \l_@@_op_tl , - % lang .str_set_x:N = \l_@@_lang_str , - variant .str_set_x:N = \l_@@_variant_str , - prec .str_set_x:N = \l_@@_prec_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, - unknown .code:n = \str_set:Nx - \l_@@_variant_str \l_keys_key_str -} - -\cs_new_protected:Nn \_@@_symdef_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_assoctype_str - \str_clear:N \l_stex_symdecl_reorder_str - \bool_set_false:N \l_stex_symdecl_local_bool - \tl_clear:N \l_stex_symdecl_type_tl - \tl_clear:N \l_stex_symdecl_definiens_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - % \str_clear:N \l_@@_lang_str - \str_clear:N \l_@@_variant_str - \str_clear:N \l_@@_prec_str - \tl_clear:N \l_@@_op_tl - - \keys_set:nn { stex / symdef } { #1 } -} - -\NewDocumentCommand \symdef { m O{} } { - \_@@_symdef_args:n { #2 } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n { #1 } - \tl_set:Nn \l_stex_notation_after_do_tl { - \_@@_final: - \stex_smsmode_do:\ignorespacesandpars - } - \str_set:Nx \l_stex_get_symbol_uri_str { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } - \exp_args:Nx \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l_@@_variant_str } - { \l_@@_prec_str} -} -\stex_deactivate_macro:Nn \symdef {module~environments} - -\keys_define:nn { stex / mmtdef } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - op .tl_set:N = \l_@@_op_tl , - % lang .str_set_x:N = \l_@@_lang_str , - variant .str_set_x:N = \l_@@_variant_str , - prec .str_set_x:N = \l_@@_prec_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, - unknown .code:n = \str_set:Nx - \l_@@_variant_str \l_keys_key_str -} -\cs_new_protected:Nn \_stex_mmtdef_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_assoctype_str - \str_clear:N \l_stex_symdecl_reorder_str - \bool_set_false:N \l_stex_symdecl_local_bool - \clist_clear:N \l_stex_symdecl_argnames_clist - % \str_clear:N \l_@@_lang_str - \str_clear:N \l_@@_variant_str - \str_clear:N \l_@@_prec_str - \tl_clear:N \l_@@_op_tl - - \keys_set:nn { stex / mmtdef } { #1 } -} - -\NewDocumentCommand \mmtdef {m O{} }{ - \_stex_mmtdef_args:n{ #2 } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } - } - %\tl_set:Nx \l_stex_symdecl_definiens_tl { - % \stex_annotate:nnn{ OMID }{ - % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - % }{} - %} - \stex_symdecl_do:n { #1 } - \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ - \stex_annotate:nnn{ OMID }{ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }{}, - \stex_annotate:nnn{ OMID }{ - \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - }{} - } - \tl_set:Nn \l_stex_notation_after_do_tl { - \_@@_final: - \stex_smsmode_do:\ignorespacesandpars - } - \str_set:Nx \l_stex_get_symbol_uri_str { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } - \exp_args:Nx \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l_@@_variant_str } - { \l_@@_prec_str} -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Variables} -% -% \begin{macrocode} -%<@@=stex_variables> - -\keys_define:nn { stex / vardef } { - name .str_set_x:N = \l_@@_name_str , - args .str_set_x:N = \l_@@_args_str , - type .tl_set:N = \l_@@_type_tl , - def .tl_set:N = \l_@@_def_tl , - op .tl_set:N = \l_@@_op_tl , - prec .str_set_x:N = \l_@@_prec_str , - reorder .str_set_x:N = \l_@@_reorder_str , - argnames .clist_set:N = \l_@@_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_@@_assoctype_str {\l_keys_choice_tl}}, - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l_@@_bind_str {\l_keys_choice_tl}} -} - -\cs_new_protected:Nn \_@@_args:n { - \str_clear:N \l_@@_name_str - \str_clear:N \l_@@_args_str - \str_clear:N \l_@@_prec_str - \str_clear:N \l_@@_assoctype_str - \str_clear:N \l_@@_reorder_str - \str_clear:N \l_@@_bind_str - \tl_clear:N \l_@@_type_tl - \tl_clear:N \l_@@_def_tl - \tl_clear:N \l_@@_op_tl - \clist_clear:N \l_@@_argnames_clist - - \keys_set:nn { stex / vardef } { #1 } -} - -\NewDocumentCommand \_@@_do_simple:nnn { m O{}} { - \_@@_args:n {#2} - \str_if_empty:NT \l_@@_name_str { - \str_set:Nx \l_@@_name_str { #1 } - } - \prop_clear:N \l_tmpa_prop - \prop_put:Nno \l_tmpa_prop { name } \l_@@_name_str - - \int_zero:N \l_tmpb_int - \bool_set_true:N \l_tmpa_bool - \str_map_inline:Nn \l_@@_args_str { - \token_case_meaning:NnF ##1 { - 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} - {\tl_to_str:n i} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n b} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n a} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - {\tl_to_str:n B} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - }{ - \msg_error:nnxx{stex}{error/wrongargs}{ - variable~\l_@@_name_str - }{##1} - } - } - \bool_if:NTF \l_tmpa_bool { - % possibly numeric - \str_if_empty:NTF \l_@@_args_str { - \prop_put:Nnn \l_tmpa_prop { args } {} - \prop_put:Nnn \l_tmpa_prop { arity } { 0 } - }{ - \int_set:Nn \l_tmpa_int { \l_@@_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } { \int_use:N \l_tmpa_int } - \str_clear:N \l_tmpa_str - \int_step_inline:nn \l_tmpa_int { - \str_put_right:Nn \l_tmpa_str i - } - \str_set_eq:NN \l_@@_args_str \l_tmpa_str - \prop_put:Nnx \l_tmpa_prop { args } { \l_@@_args_str } - } - } { - \prop_put:Nnx \l_tmpa_prop { args } { \l_@@_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } - { \str_count:N \l_@@_args_str } - } - \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int } - \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l_@@_name_str } } - - % argnames - - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { - \clist_if_empty:NTF \l_@@_argnames_clist { - \clist_put_right:Nn \l_tmpa_clist {##1} - }{ - \clist_pop:NN \l_@@_argnames_clist \l_tmpa_tl - \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} - } - } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} - - - \prop_set_eq:cN { l_stex_symdecl_var://\l_@@_name_str _prop} \l_tmpa_prop - - \tl_if_empty:NF \l_@@_op_tl { - \cs_set:cpx { - stex_var_op_notation_ \l_@@_name_str _cs - } { \exp_not:N\comp{ \exp_args:No \exp_not:n { \l_@@_op_tl } } } - } - - \tl_set:Nn \l_stex_notation_after_do_tl { - \exp_args:Nne \use:nn { - \cs_generate_from_arg_count:cNnn { stex_var_notation_\l_@@_name_str _cs } - \cs_set:Npn { \prop_item:Nn \l_tmpa_prop { arity } } - } {{ - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL} - }} - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {vardecl}{\l_@@_name_str}{ - \stex_annotate_invisible:nnn { precedence } - { \l_@@_prec_str }{} - \tl_if_empty:NF \l_@@_type_tl {\stex_annotate_invisible:nnn{type}{}{$\l_@@_type_tl$}} - \stex_annotate_invisible:nnn{args}{ \l_@@_args_str }{} - \stex_annotate_invisible:nnn{macroname}{#1}{} - \tl_if_empty:NF \l_@@_def_tl { - \stex_annotate_invisible:nnn{definiens}{} - {$\l_@@_def_tl$} - } - \str_if_empty:NF \l_@@_assoctype_str { - \stex_annotate_invisible:nnn{assoctype}{\l_@@_assoctype_str}{} - } - \str_if_empty:NF \l_@@_reorder_str { - \stex_annotate_invisible:nnn{reorderargs}{\l_@@_reorder_str}{} - } - \int_zero:N \l_tmpa_int - \str_set_eq:NN \l_@@_remaining_args_str \l_@@_args_str - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \prop_item:Nn \l_tmpa_prop { arity } }{ - \int_incr:N \l_tmpa_int - \str_set:Nx \l_tmpb_str { \str_head:N \l_@@_remaining_args_str } - \str_set:Nx \l_@@_remaining_args_str { \str_tail:N \l_@@_remaining_args_str } - \str_if_eq:VnTF \l_tmpb_str a { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \str_if_eq:VnTF \l_tmpb_str B { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{} - } } - } - } - } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {var://\l_@@_name_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_var_notation_\l_@@_name_str _cs - } } { \l_tmpa_tl } $ - } - \tl_if_empty:NF \l_@@_op_tl { - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $\l_@@_op_tl$ - } - } - } - \str_if_empty:NF \l_@@_bind_str { - \stex_annotate_invisible:nnn {bindtype}{\l_@@_bind_str,\l_@@_name_str}{} - } - }\ignorespacesandpars - } - - \stex_notation_do:nnnnn { \l_@@_args_str } { \prop_item:Nn \l_tmpa_prop { arity } } {}{ \l_@@_prec_str} -} - -\cs_new:Nn \_stex_reset:N { - \tl_if_exist:NTF #1 { - \def \exp_not:N #1 { \exp_args:No \exp_not:n #1 } - }{ - \let \exp_not:N #1 \exp_not:N \undefined - } -} - -\NewDocumentCommand \_@@_do_complex:nn { m m }{ - \clist_set:Nx \l_@@_names { \tl_to_str:n {#1} } - \exp_args:Nnx \use:nn { - % TODO - \stex_annotate_invisible:nnn {vardecl}{\clist_use:Nn\l_@@_names,}{ - #2 - } - }{ - \_stex_reset:N \varnot - \_stex_reset:N \vartype - \_stex_reset:N \vardefi - } -} - -\NewDocumentCommand \vardef { s } { - \IfBooleanTF#1 { - \_@@_do_complex:nn - }{ - \_@@_do_simple:nnn - } -} - -\NewDocumentCommand \svar { O{} m }{ - \tl_if_empty:nTF {#1}{ - \str_set:Nn \l_tmpa_str { #2 } - }{ - \str_set:Nn \l_tmpa_str { #1 } - } - \_stex_term_omv:nn { - var://\l_tmpa_str - }{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nx \STEXInternalCurrentSymbolStr { var://\l_tmpa_str } - \comp{ #2 } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } - } -} - - - -\keys_define:nn { stex / varseq } { - name .str_set_x:N = \l_@@_name_str , - args .int_set:N = \l_@@_args_int , - type .tl_set:N = \l_@@_type_tl , - mid .tl_set:N = \l_@@_mid_tl , - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l_@@_bind_str {\l_keys_choice_tl}} -} - -\cs_new_protected:Nn \_@@_seq_args:n { - \str_clear:N \l_@@_name_str - \int_set:Nn \l_@@_args_int 1 - \tl_clear:N \l_@@_type_tl - \str_clear:N \l_@@_bind_str - - \keys_set:nn { stex / varseq } { #1 } -} - -\NewDocumentCommand \varseq {m O{} m m m}{ - \_@@_seq_args:n { #2 } - \str_if_empty:NT \l_@@_name_str { - \str_set:Nx \l_@@_name_str { #1 } - } - \prop_clear:N \l_tmpa_prop - \prop_put:Nnx \l_tmpa_prop { arity }{\int_use:N \l_@@_args_int} - - \seq_set_from_clist:Nn \l_tmpa_seq {#3} - \int_compare:nNnF {\seq_count:N \l_tmpa_seq} = \l_@@_args_int { - \msg_error:nnxx{stex}{error/seqlength} - {\int_use:N \l_@@_args_int} - {\seq_count:N \l_tmpa_seq} - } - \seq_set_from_clist:Nn \l_tmpb_seq {#4} - \int_compare:nNnF {\seq_count:N \l_tmpb_seq} = \l_@@_args_int { - \msg_error:nnxx{stex}{error/seqlength} - {\int_use:N \l_@@_args_int} - {\seq_count:N \l_tmpb_seq} - } - \prop_put:Nnn \l_tmpa_prop {starts} {#3} - \prop_put:Nnn \l_tmpa_prop {ends} {#4} - - \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs} - \cs_set:Npn {\int_use:N \l_@@_args_int} { #5 } - - % argnames - - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\l_@@_args_int} { - \clist_put_right:Nn \l_tmpa_clist {##1} - } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} - - - - - \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}} - \int_step_inline:nn \l_@@_args_int { - \tl_put_right:Nx \l_tmpa_tl { {\seq_item:Nn \l_tmpa_seq {##1}} } - } - \tl_set:Nx \l_tmpa_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpa_tl}} - \tl_put_right:Nn \l_tmpa_tl {,\ellipses,} - \tl_if_empty:NF \l_@@_mid_tl { - \tl_put_right:No \l_tmpa_tl \l_@@_mid_tl - \tl_put_right:Nn \l_tmpa_tl {,\ellipses,} - } - \exp_args:NNo \tl_set:No \l_tmpb_tl {\use:c{stex_varseq_\l_@@_name_str _cs}} - \int_step_inline:nn \l_@@_args_int { - \tl_put_right:Nx \l_tmpb_tl { {\seq_item:Nn \l_tmpb_seq {##1}} } - } - \tl_set:Nx \l_tmpb_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpb_tl}} - \tl_put_right:No \l_tmpa_tl \l_tmpb_tl - - - \prop_put:Nno \l_tmpa_prop { notation }\l_tmpa_tl - - \tl_set:cx {#1} {\stex_invoke_sequence:n {\l_@@_name_str}} - - \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}} - - \int_step_inline:nn \l_@@_args_int { - \tl_set:Nx \l_tmpa_tl {\exp_args:No \exp_not:n \l_tmpa_tl { - \STEXInternalTermMathArgiii{i##1}{0}{\exp_not:n{####}##1} - }} - } - - \tl_set:Nx \l_tmpa_tl { - \STEXInternalTermMathOMAiiii { varseq://\l_@@_name_str}{}{0}{ - \exp_args:NNo \exp_args:No \exp_not:n {\l_tmpa_tl} - } - } - - \tl_set:No \l_tmpa_tl { \exp_after:wN { \l_tmpa_tl \STEXInternalSymbolAfterInvokationTL} } - - \exp_args:Nno \use:nn { - \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs} - \cs_set:Npn {\int_use:N \l_@@_args_int}}{\l_tmpa_tl} - - \stex_debug:nn{sequences}{New~Sequence:~ - \expandafter\meaning\csname stex_varseq_\l_@@_name_str _cs\endcsname\\~\\ - \prop_to_keyval:N \l_tmpa_prop - } - \prop_set_eq:cN {l_stex_symdecl_varseq://\l_@@_name_str _prop}\l_tmpa_prop - - \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l_@@_name_str}{ - \tl_if_empty:NF \l_@@_type_tl { - \stex_annotate:nnn {type}{}{$\l_@@_type_tl$} - } - \stex_annotate:nnn {args}{\int_use:N \l_@@_args_int}{} - \str_if_empty:NF \l_@@_bind_str { - \stex_annotate:nnn {bindtype}{\l_@@_bind_str}{} - } - \stex_annotate:nnn{startindex}{}{$#3$} - \stex_annotate:nnn{endindex}{}{$#4$} - - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn \l_@@_args_int { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{##1}{} - } } - } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {varseq://\l_@@_name_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_varseq_\l_@@_name_str _cs - } } { \l_tmpa_tl } $ - } - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $ \prop_item:Nn \l_tmpa_prop { notation } $ - } - - }} - - \ignorespacesandpars -} - - -\keys_define:nn { stex / mmtdecl } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} -} - -\cs_new_protected:Nn \_stex_mmtdecl_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_deprecate_str - \str_clear:N \l_stex_symdecl_reorder_str - \str_clear:N \l_stex_symdecl_assoctype_str - \bool_set_false:N \l_stex_symdecl_local_bool - \clist_clear:N \l_stex_symdecl_argnames_clist - - \keys_set:nn { stex / symdecl } { #1 } -} - -\NewDocumentCommand \mmtdecl { s m O{}} { - \_stex_mmtdecl_args:n{#3} - \IfBooleanTF #1 { - \bool_set_false:N \l_stex_symdecl_make_macro_bool - } { - \bool_set_true:N \l_stex_symdecl_make_macro_bool - } - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } - } - %\tl_set:Nx \l_stex_symdecl_definiens_tl { - % \stex_annotate:nnn{ OMID }{ - % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - % }{} - %} - \stex_symdecl_do:n{#2} - \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ - \stex_annotate:nnn{ OMID }{ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }{}, - \stex_annotate:nnn{ OMID }{ - \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - }{} - } - \stex_smsmode_do: -} - -\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments} -\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments} - -% \end{macrocode} -% -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex - -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: diff --git a/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx b/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx deleted file mode 100644 index 500372bcb46..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex-terms.dtx +++ /dev/null @@ -1,1202 +0,0 @@ -% \iffalse meta-comment -% An Infrastructure for Semantic Macros and Module Scoping -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ -% -% TODO update copyright -% -%<*driver> -\def\libfolder#1{../../lib/#1} -\input{../../doc/stex-docheader} - -\begin{document} - \DocInput{\jobname.dtx} -\end{document} -%</driver> -% \fi -% -% \title{ \sTeX-Terms -% \thanks{Version {\fileversion} (last revised {\filedate})} -% } -% -% \author{Michael Kohlhase, Dennis Müller\\ -% FAU Erlangen-Nürnberg\\ -% \url{http://kwarc.info/} -% } -% -% \maketitle -% -%\ifinfulldoc\else -% This is the documentation for the \pkg{stex-terms} package. -% For a more high-level introduction, -% see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the -% \href{\basedocurl/stex.pdf}{full \sTeX documentation}. -% -% \input{../../doc/packages/stex-terms} -% \fi -% -% \begin{documentation}\label{pkg:terms:doc} -% \changes{3.1.0}{2022/03/01}{!-Notation now works for symbols with arity=0 without needing an op-notation} -% \changes{3.1.0}{2022/03/01}{Introduced \detokenize{\varemph, \varemph@uri}} -% \changes{3.1.0}{2022/02/28}{Fixed bug with \detokenize{\STEXInternalCurrentSymbolStr} in variable annotations} -% -% Code related to symbolic expressions, typesetting notations, -% notation components, etc. -% -% \section{Macros and Environments}\label{pkg:terms:doc:macros} -% -% \begin{function}{\STEXsymbol} -% Uses \cs{stex_get_symbol:n} to find the symbol denoted by -% the first argument and passes the result on to -% \cs{stex_invoke_symbol:n} -% \end{function} -% -% \begin{function}{\symref} -% \begin{syntax} \cs{symref}\Arg{symbol}\Arg{text} \end{syntax} -% shortcut for \cs{STEXsymbol}\Arg{symbol}|![|\meta{text}|]| -% \end{function} -% -% \begin{function}{\stex_invoke_symbol:n} -% Executes a semantic macro. Outside of math mode or if followed by |*|, -% it continues to \cs{stex_term_custom:nn}. In math mode, -% it uses the default or optionally provided notation of -% the associated symbol. -% -% If followed by |!|, it will invoke the symbol \emph{itself} -% rather than its application (and continue to -% \cs{stex_term_custom:nn}), i.e. it allows to refer to -% |\plus![addition]| as an operation, rather than -% |\plus[addition of]{some}{terms}|. -% \end{function} -% -% \begin{function}{\STEXInternalTermMathOMSiiii,\STEXInternalTermMathOMAiiii,\STEXInternalTermMathOMBiiii} -% \begin{syntax} \meta{URI}\meta{fragment}\meta{precedence}\meta{body} \end{syntax} -% -% Annotates \meta{body} as an \omdoc-term (|OMID|, |OMA| or |OMBIND|, respectively) -% with head symbol \meta{URI}, generated -% by the specific notation \meta{fragment} with (upwards) operator precedence -% \meta{precedence}. Inserts parentheses according to -% the current downwards precedence and operator precedence. -% \end{function} -% -% \begin{function}{\STEXInternalTermMathArgiii} -% \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{body} \end{syntax} -% Annotates \meta{body} as the \meta{int}th argument of the current |OMA| or |OMBIND|, -% with (downwards) argument precedence \meta{prec}. -% \end{function} -% -% \begin{function}{\STEXInternalTermMathAssocArgiiiii} -% \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{notation}\meta{type}\meta{body} \end{syntax} -% Annotates \meta{body} as the \meta{int}th (associative) \emph{sequence} argument -% (as comma-separated list of terms) of the current |OMA| or |OMBIND|, -% with (downwards) argument precedence \meta{prec} and associative -% notation \meta{notation}. -% -% \end{function} -% -% \begin{variable}{\infprec, \neginfprec} -% Maximal and minimal notation precedences. -% \end{variable} -% -% \begin{function}{\dobrackets} -% \begin{syntax} \cs{dobrackets} \Arg{body} \end{syntax} -% Puts \meta{body} in parentheses; scaled if in display mode -% unscaled otherwise. Uses the current \sTeX brackets (by default |(| and |)|), -% which can be changed temporarily using \cs{withbrackets}. -% \end{function} -% -% \begin{function}{\withbrackets} -% \begin{syntax} \cs{withbrackets} \meta{left} \meta{right} \Arg{body} \end{syntax} -% Temporarily (i.e. within \meta{body}) sets the brackets used by \sTeX for automated -% bracketing (by default |(| and |)|) to \meta{left} and \meta{right}. -% -% Note that \meta{left} and \meta{right} need to be allowed -% after \cs{left} and \cs{right} in displaymode. -% \end{function} -% -% \begin{function}{\stex_term_custom:nn} -% \begin{syntax} \cs{stex_term_custom:nn}\Arg{URI}\Arg{args}\end{syntax} -% Implements custom one-time notation. -% Invoked by \cs{stex_invoke_symbol:n} in text mode, or if -% followed by |*| in math mode, or whenever followed by |!|. -% \end{function} -% -% \begin{function}{\comp, \compemph,\compemph@uri, \defemph, \defemph@uri, \symrefemph,\symrefemph@uri,\varemph,\varemph@uri} -% \begin{syntax} \cs{comp}\Arg{args}\end{syntax} -% Marks \meta{args} as a notation component of the current symbol for -% highlighting, linking, etc. -% -% The precise behavior is governed by \cs{@comp}, which takes as -% additional argument the URI of the current symbol. By default, -% \cs{@comp} adds the URI as a PDF tooltip and colors the highlighted part -% in blue. -% -% \cs{@defemph} behaves like \cs{@comp}, and can be similarly redefined, -% but marks an expression as \emph{definiendum} (used by \cs{definiendum}) -% \end{function} -% -% \begin{function}{\STEXinvisible} -% Exports its argument as \omdoc (invisible), but does -% not produce PDF output. Useful e.g. for semantic macros -% that take arguments that are not part of the symbolic -% notation. -% \end{function} -% -% \begin{function}{\ellipses} -% TODO -% \end{function} -% -% \end{documentation} -% -% \begin{implementation}\label{pkg:terms:impl} -% -% \section{\sTeX-Terms Implementation} -% -% \begin{macrocode} -%<*package> - -%%%%%%%%%%%%% terms.dtx %%%%%%%%%%%%% - -%<@@=stex_terms> -% \end{macrocode} -% -% Warnings and error messages -% -% \begin{macrocode} -\msg_new:nnn{stex}{error/nonotation}{ - Symbol~#1~invoked,~but~has~no~notation#2! -} -\msg_new:nnn{stex}{error/notationarg}{ - Error~in~parsing~notation~#1 -} -\msg_new:nnn{stex}{error/noop}{ - Symbol~#1~has~no~operator~notation~for~notation~#2 -} -\msg_new:nnn{stex}{error/notallowed}{ - Symbol~invokation~#1~not~allowed~in~notation~component~of~#2 -} -\msg_new:nnn{stex}{error/doubleargument}{ - Argument~#1~of~symbol~#2~already~assigned -} -\msg_new:nnn{stex}{error/overarity}{ - Argument~#1~invalid~for~symbol~#2~with~arity~#3 -} - -% \end{macrocode} -% \subsection{Symbol Invocations} -% -% -% \begin{macro}{\stex_invoke_symbol:n} -% -% Invokes a semantic macro -% -% \begin{macrocode} - - -\bool_new:N \l_stex_allow_semantic_bool -\bool_set_true:N \l_stex_allow_semantic_bool - -\cs_new_protected:Nn \stex_invoke_symbol:n { - \ifvmode\indent\fi - \bool_if:NTF \l_stex_allow_semantic_bool { - \str_if_eq:eeF { - \prop_item:cn { - l_stex_symdecl_#1_prop - }{ deprecate } - }{}{ - \msg_warning:nnxx{stex}{warning/deprecated}{ - Symbol~#1 - }{ - \prop_item:cn {l_stex_symdecl_#1_prop}{ deprecate } - } - } - \if_mode_math: - \exp_after:wN \_@@_invoke_math:n - \else: - \exp_after:wN \_@@_invoke_text:n - \fi: { #1 } - }{ - \msg_error:nnxx{stex}{error/notallowed}{#1}{\STEXInternalCurrentSymbolStr} - } -} - -\cs_new_protected:Nn \_@@_invoke_text:n { - \peek_charcode_remove:NTF ! { - \_@@_invoke_op_custom:nn {#1} - }{ - \_@@_invoke_custom:nn {#1} - } -} - -\cs_new_protected:Nn \_@@_invoke_math:n { - \peek_charcode_remove:NTF ! { - % operator - \peek_charcode_remove:NTF * { - % custom op - \_@@_invoke_op_custom:nn {#1} - }{ - % op notation - \peek_charcode:NTF [ { - \_@@_invoke_op_notation:nw {#1} - }{ - \_@@_invoke_op_notation:nw {#1}[] - } - } - }{ - \peek_charcode_remove:NTF * { - \_@@_invoke_custom:nn {#1} - % custom - }{ - % normal - \peek_charcode:NTF [ { - \_@@_invoke_notation:nw {#1} - }{ - \_@@_invoke_notation:nw {#1}[] - } - } - } -} - - -\cs_new_protected:Nn \_@@_invoke_op_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \stex_mathml_intent:nn{#1}{ - \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{ - \comp{ #2 } - } - } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } -} - -\keys_define:nn { stex / terms } { -% lang .tl_set_x:N = \l_stex_notation_lang_str , - variant .tl_set_x:N = \l_stex_notation_variant_str , - unknown .code:n = \str_set:Nx - \l_stex_notation_variant_str \l_keys_key_str -} - -\cs_new_protected:Nn \_@@_args:n { - % \str_clear:N \l_stex_notation_lang_str - \str_clear:N \l_stex_notation_variant_str - - \keys_set:nn { stex / terms } { #1 } -} - -\cs_new_protected:Nn \stex_find_notation:nn { - \_@@_args:n { #2 } - \seq_if_empty:cTF { - l_stex_symdecl_ #1 _notations - } { - \msg_error:nnxx{stex}{error/nonotation}{#1}{s} - } { - \str_if_empty:NTF \l_stex_notation_variant_str { - \seq_get_left:cN {l_stex_symdecl_#1_notations}\l_stex_notation_variant_str - }{ - \seq_if_in:cxTF {l_stex_symdecl_#1_notations}{ - \l_stex_notation_variant_str - }{ - % \str_set:Nx \l_stex_notation_variant_str { \l_stex_notation_variant_str \c_hash_str \l_stex_notation_lang_str } - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str - } - } - } - } -} - -\cs_new_protected:Npn \_@@_invoke_op_notation:nw #1 [#2] { - \exp_args:Nnx \use:nn { - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \stex_find_notation:nn { #1 }{ #2 } - \bool_set_false:N \l_stex_allow_semantic_bool - \cs_if_exist:cTF { - stex_op_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs - }{ - \_stex_term_oms:nnn { #1 }{ - #1 \c_hash_str \l_stex_notation_variant_str - }{ - \use:c{stex_op_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} - } - }{ - \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_#1_prop}{arity}} = 0{ - \cs_if_exist:cTF { - stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs - }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str - } - } - }{ - \msg_error:nnxx{stex}{error/noop}{#1}{\l_stex_notation_variant_str} - } - } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } -} - -\cs_new_protected:Npn \_@@_invoke_notation:nw #1 [#2] { - \stex_find_notation:nn { #1 }{ #2 } - \cs_if_exist:cTF { - stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs - }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str - } - } -} - -\prop_new:N \l_@@_custom_args_prop -\clist_new:N \l_stex_argnames_seq -\seq_new:N \l_@@_tmp_seq - -\cs_new_protected:Nn\_@@_custom_comp:n{\bool_set_false:N \l_stex_allow_semantic_bool\_comp{#1}\bool_set_true:N \l_stex_allow_semantic_bool} - -\cs_new_protected:Nn \_@@_invoke_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_@@_custom_comp:n} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \prop_clear:N \l_@@_custom_args_prop - \prop_put:Nnn \l_@@_custom_args_prop {currnum} {1} - \prop_get:cnN { - l_stex_symdecl_#1 _prop - }{ args } \l_tmpa_str - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \prop_put:Nno \l_@@_custom_args_prop {args} \l_tmpa_str - \tl_set:Nn \arg { \_@@_arg: } - \str_if_empty:NTF \l_tmpa_str { - \stex_mathml_intent:nn{#1}{ - \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2} - } - }{ - \seq_clear:N \l_@@_tmp_seq - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l_@@_tmp_tl + - } - \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl - } - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l_@@_tmp_seq , - ) - }{ - \str_if_in:NnTF \l_tmpa_str b { - \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - }{ - \str_if_in:NnTF \l_tmpa_str B { - \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - }{ - \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - } - } - } - } - % TODO check that all arguments exist - }{ - \_stex_reset:N \l_stex_argnames_seq - \_stex_reset:N \STEXInternalCurrentSymbolStr - \_stex_reset:N \arg - \_stex_reset:N \comp - \_stex_reset:N \l_@@_custom_args_prop - %\bool_set_true:N \l_stex_allow_semantic_bool - } -} - -\NewDocumentCommand \_@@_arg: { s O{} m}{ - \tl_if_empty:nTF {#2}{ - \int_set:Nn \l_tmpa_int {\prop_item:Nn \l_@@_custom_args_prop {currnum}} - \bool_set_true:N \l_tmpa_bool - \bool_do_while:Nn \l_tmpa_bool { - \exp_args:NNx \prop_if_in:NnTF \l_@@_custom_args_prop {\int_use:N \l_tmpa_int} { - \int_incr:N \l_tmpa_int - }{ - \bool_set_false:N \l_tmpa_bool - } - } - }{ - \int_set:Nn \l_tmpa_int { #2 } - } - \str_set:Nx \l_tmpa_str {\prop_item:Nn \l_@@_custom_args_prop {args} } - \int_compare:nNnT \l_tmpa_int > {\str_count:N \l_tmpa_str} { - \msg_error:nnxxx{stex}{error/overarity} - {\int_use:N \l_tmpa_int} - {\STEXInternalCurrentSymbolStr} - {\str_count:N \l_tmpa_str} - } - \str_set:Nx \l_tmpa_str {\str_item:Nn \l_tmpa_str \l_tmpa_int} - \exp_args:NNx \prop_if_in:NnT \l_@@_custom_args_prop {\int_use:N \l_tmpa_int} { - \bool_lazy_any:nF { - {\str_if_eq_p:Vn \l_tmpa_str {a}} - {\str_if_eq_p:Vn \l_tmpa_str {B}} - }{ - \msg_error:nnxx{stex}{error/doubleargument} - {\int_use:N \l_tmpa_int} - {\STEXInternalCurrentSymbolStr} - } - } - \exp_args:NNx \prop_put:Nnn \l_@@_custom_args_prop {\int_use:N \l_tmpa_int} {\ignorespaces#3} - \bool_if:NTF \l_stex_allow_semantic_bool \use_i:nn { - \bool_set_true:N \l_stex_allow_semantic_bool - \use:nn - } - { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ - \IfBooleanTF#1{ - \stex_annotate_invisible:n { %TODO - \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} - } - }{ %TODO - \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} - } - }} - {\bool_set_false:N \l_stex_allow_semantic_bool} -} - - -\cs_new_protected:Nn \_stex_term_arg:nn { - \bool_set_true:N \l_stex_allow_semantic_bool - \stex_annotate:nnn{ arg }{ #1 }{ #2 } - \bool_set_false:N \l_stex_allow_semantic_bool -} - -\cs_new_protected:Npn \STEXInternalTermMathArgiii #1#2#3 { - \exp_args:Nnx \use:nn - { \int_set:Nn \l_@@_downprec { #2 } - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ - \_stex_term_arg:nn { #1 }{ #3 } - } - } - { \int_set:Nn \exp_not:N \l_@@_downprec { \int_use:N \l_@@_downprec } } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\STEXInternalTermMathAssocArgiiiii} -% \begin{macrocode} -\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiiii #1#2#3#4#5 { - \cs_set:Npn \l_tmpa_cs ##1 ##2 { #4 } - \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#5#1}{#2}} - \tl_if_empty:nTF { #3 }{ - \STEXInternalTermMathArgiii{#5#1}{#2}{} - }{ - \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #3 }}{ - \expandafter\if\expandafter\relax\noexpand#3 - \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_maybe_sequence:Nnn#3{#1}{#5}} - \else - \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5}} - \fi - \l_tmpa_tl - }{ - \_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5} - } - } -} - -\cs_new_protected:Nn \_@@_math_assoc_arg_maybe_sequence:Nnn { - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N #1 } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N #1 - } \stex_invoke_sequence:n { - \tl_set:Nx \l_tmpa_tl {\tl_tail:N #1} - \str_set:Nx \l_tmpa_str {\exp_after:wN \use:n \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\prop_item:cn {l_stex_symdecl_varseq://\l_tmpa_str _prop}{notation}} - \exp_args:NNo \seq_set_from_clist:Nn \l_tmpa_seq \l_tmpa_tl - \tl_set:Nx \l_tmpa_tl {{\exp_not:N \exp_not:n{ - \exp_not:n{\exp_args:Nnx \use:nn} { - \exp_not:n { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr - } {varseq://\l_tmpa_str} - \exp_not:n{ ##1 } - }{ - \exp_not:n { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } - } - }}} - \exp_args:Nno \use:n {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl - \seq_reverse:N \l_tmpa_seq - \seq_pop:NN \l_tmpa_seq \l_tmpa_tl - \seq_map_inline:Nn \l_tmpa_seq { - \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl { - \exp_args:Nno - \l_tmpa_cs { ##1 } \l_tmpa_tl - } - } - \tl_set:Nx \l_tmpa_tl { - \_stex_term_omv:nn {varseq://\l_tmpa_str}{ - \exp_args:No \exp_not:n \l_tmpa_tl - } - } - \exp_args:No\l_tmpb_tl\l_tmpa_tl - }{ - \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3} - } - } { - \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3} - } - -} - -\cs_new_protected:Nn \_@@_math_assoc_arg_simple:nnn { - \clist_set:Nn \l_tmpa_clist{ #2 } - \int_compare:nNnTF { \clist_count:N \l_tmpa_clist } < 2 { - \tl_set:Nn \l_tmpa_tl { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{ #2 } } - } - }{ - \clist_reverse:N \l_tmpa_clist - \clist_pop:NN \l_tmpa_clist \l_tmpa_tl - \tl_set:Nx \l_tmpa_tl { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{ - \exp_args:No \exp_not:n \l_tmpa_tl - } - }} - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl { - \exp_args:Nno - \l_tmpa_cs { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{##1} - } - } \l_tmpa_tl - } - } - } - \exp_args:No\l_tmpb_tl\l_tmpa_tl -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Terms} -% -% Precedences: -% \begin{variable}{\infprec, \neginfprec, \l_@@_downprec} -% \begin{macrocode} -\tl_const:Nx \infprec {\int_use:N \c_max_int} -\tl_const:Nx \neginfprec {-\int_use:N \c_max_int} -\int_new:N \l_@@_downprec -\int_set_eq:NN \l_@@_downprec \infprec -% \end{macrocode} -% \end{variable} -% -% Bracketing: -% -% \begin{variable}{\l_@@_left_bracket_str, \l_@@_right_bracket_str} -% \begin{macrocode} -\tl_set:Nn \l_@@_left_bracket_str ( -\tl_set:Nn \l_@@_right_bracket_str ) -% \end{macrocode} -% \end{variable} -% -% \begin{macro}{\_@@_maybe_brackets:nn} -% -% Compares precedences and insert brackets accordingly -% -% \begin{macrocode} -\cs_new_protected:Nn \_@@_maybe_brackets:nn { - \bool_if:NTF \l_@@_brackets_done_bool { - \bool_set_false:N \l_@@_brackets_done_bool - #2 - } { - \int_compare:nNnTF { #1 } > \l_@@_downprec { - \bool_if:NTF \l_stex_inparray_bool { #2 }{ - \stex_debug:nn{dobrackets}{\number#1 > \number\l_@@_downprec; \detokenize{#2}} - \dobrackets { #2 } - } - }{ #2 } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\dobrackets} -% \begin{macrocode} -\bool_new:N \l_@@_brackets_done_bool -%\RequirePackage{scalerel} -\cs_new_protected:Npn \dobrackets #1 { - %\ThisStyle{\if D\m@switch - % \exp_args:Nnx \use:nn - % { \exp_after:wN \left\l_@@_left_bracket_str #1 } - % { \exp_not:N\right\l_@@_right_bracket_str } - % \else - \exp_args:Nnx \use:nn - { - \bool_set_true:N \l_@@_brackets_done_bool - \int_set:Nn \l_@@_downprec \infprec - \l_@@_left_bracket_str - #1 - } - { - \bool_set_false:N \l_@@_brackets_done_bool - \l_@@_right_bracket_str - \int_set:Nn \l_@@_downprec { \int_use:N \l_@@_downprec } - } - %\fi} -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\withbrackets} -% \begin{macrocode} -\cs_new_protected:Npn \withbrackets #1 #2 #3 { - \exp_args:Nnx \use:nn - { - \tl_set:Nx \l_@@_left_bracket_str { #1 } - \tl_set:Nx \l_@@_right_bracket_str { #2 } - #3 - } - { - \tl_set:Nn \exp_not:N \l_@@_left_bracket_str - {\l_@@_left_bracket_str} - \tl_set:Nn \exp_not:N \l_@@_right_bracket_str - {\l_@@_right_bracket_str} - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\STEXinvisible} -% \begin{macrocode} -\cs_new_protected:Npn \STEXinvisible #1 { - \stex_annotate_invisible:n { #1 } -} -% \end{macrocode} -% \end{macro} -% -% \omdoc terms: -% -% \begin{macro}{\STEXInternalTermMathOMSiiii} -% \begin{macrocode} -\cs_new_protected:Nn \_stex_term_oms:nnn { - \stex_annotate:nnn{ OMID }{ #2 }{ - #3 - } -} - -\cs_new_protected:Npn \STEXInternalTermMathOMSiiii #1#2#3#4 { - \_@@_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{#1} { - \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 } - } - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\_stex_term_math_omv:nn} -% \begin{macrocode} -\cs_new_protected:Nn \_stex_term_omv:nn { - \stex_annotate:nnn{ OMV }{ #1 }{ - #2 - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\STEXInternalTermMathOMAiiii} -% \begin{macrocode} -\cs_new_protected:Nn \_stex_term_oma:nnn { - \stex_annotate:nnn{ OMA }{ #2 }{ - #3 - } -} - -\cs_new_protected:Npn \STEXInternalTermMathOMAiiii #1#2#3#4 { - \exp_args:Nnx \use:nn { - \seq_clear:N \l_@@_tmp_seq - \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l_@@_tmp_tl + - } - \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl - } - } - \_@@_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l_@@_tmp_seq , - ) - }{ - \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 } - } - } - }{ - \_stex_reset:N \l_stex_argnames_seq - } -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\STEXInternalTermMathOMBiiii} -% \begin{macrocode} -\cs_new_protected:Nn \_stex_term_ombind:nnn { - \stex_annotate:nnn{ OMBIND }{ #2 }{ - #3 - } -} - -\cs_new_protected:Npn \STEXInternalTermMathOMBiiii #1#2#3#4 { - \exp_args:Nnx \use:nn { - \seq_clear:N \l_@@_tmp_seq - \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l_@@_tmp_tl + - } - \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl - } - } - \_@@_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l_@@_tmp_seq , - ) - }{ - \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 } - } - } - }{ - \_stex_reset:N \l_stex_argnames_seq - } -} -% \end{macrocode} -% \end{macro} -% -% -% -% \begin{macro}{\symref,\symname} -% \begin{macrocode} -\cs_new:Nn \stex_capitalize:n { \uppercase{#1} } - -\keys_define:nn { stex / symname } { - pre .tl_set_x:N = \l_@@_pre_tl , - post .tl_set_x:N = \l_@@_post_tl , - root .tl_set_x:N = \l_@@_root_tl -} - -\cs_new_protected:Nn \stex_symname_args:n { - \tl_clear:N \l_@@_post_tl - \tl_clear:N \l_@@_pre_tl - \tl_clear:N \l_@@_root_str - \keys_set:nn { stex / symname } { #1 } -} - -\NewDocumentCommand \symref { m m }{ - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \STEXsymbol{#1}!{ #2 } - \let\compemph@uri\compemph_uri_prev: -} - -\NewDocumentCommand \synonym { O{} m m}{ - \stex_symname_args:n { #1 } - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - % TODO - \STEXsymbol{#2}!{\l_@@_pre_tl #3 \l_@@_post_tl} - \let\compemph@uri\compemph_uri_prev: -} - -\NewDocumentCommand \symname { O{} m }{ - \stex_symname_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \exp_args:NNx \use:nn - \stex_invoke_symbol:n { { \l_stex_get_symbol_uri_str }!\ifmmode*\fi{ - \l_@@_pre_tl \l_tmpa_str \l_@@_post_tl - } } - \let\compemph@uri\compemph_uri_prev: -} - -\NewDocumentCommand \Symname { O{} m }{ - \stex_symname_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \exp_args:NNx \use:nn - \stex_invoke_symbol:n { { \l_stex_get_symbol_uri_str }!\ifmmode*\fi{ - \exp_after:wN \stex_capitalize:n \l_tmpa_str - \l_@@_post_tl - } } - \let\compemph@uri\compemph_uri_prev: -} -% \end{macrocode} -% \end{macro} -% -% -% \subsection{Notation Components} -% \begin{macrocode} -%<@@=stex_notationcomps> -% \end{macrocode} -% -% \begin{macro}{\comp,\compemph@uri,\compemph,\defemph,\defemph@uri,\symrefemph,\symrefemph@uri,\varemph,\varemph@uri} -% \begin{macrocode} -\cs_new_protected:Npn \_comp #1 { - \str_if_empty:NF \STEXInternalCurrentSymbolStr { - \stex_html_backend:TF { - \stex_annotate:nnn { comp }{ \STEXInternalCurrentSymbolStr }{ #1 } - }{ - \exp_args:Nnx \compemph@uri { #1 } { \STEXInternalCurrentSymbolStr } - } - } -} - -\cs_new_protected:Npn \_varcomp #1 { - \str_if_empty:NF \STEXInternalCurrentSymbolStr { - \stex_html_backend:TF { - \stex_annotate:nnn { varcomp }{ \STEXInternalCurrentSymbolStr }{ #1 } - }{ - \exp_args:Nnx \varemph@uri { #1 } { \STEXInternalCurrentSymbolStr } - } - } -} - -\def\comp{\_comp} - -\cs_new_protected:Npn \compemph@uri #1 #2 { - \compemph{ #1 } -} - - -\cs_new_protected:Npn \compemph #1 { - #1 -} - -\cs_new_protected:Npn \defemph@uri #1 #2 { - \defemph{#1} -} - -\cs_new_protected:Npn \defemph #1 { - \textbf{#1} -} - -\cs_new_protected:Npn \symrefemph@uri #1 #2 { - \symrefemph{#1} -} - -\cs_new_protected:Npn \symrefemph #1 { - \emph{#1} -} - -\cs_new_protected:Npn \varemph@uri #1 #2 { - \varemph{#1} -} - -\cs_new_protected:Npn \varemph #1 { - #1 -} -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\ellipses} -% \begin{macrocode} -\NewDocumentCommand \ellipses {} { \ldots } -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\parray,\prmatrix,\parrayline,\parraylineh,\parraycell} -% \begin{macrocode} -\bool_new:N \l_stex_inparray_bool -\bool_set_false:N \l_stex_inparray_bool -\NewDocumentCommand \parray { m m } { - \begingroup - \bool_set_true:N \l_stex_inparray_bool - \begin{array}{#1} - #2 - \end{array} - \endgroup -} - -\NewDocumentCommand \prmatrix { m } { - \begingroup - \bool_set_true:N \l_stex_inparray_bool - \begin{matrix} - #1 - \end{matrix} - \endgroup -} - -\def \maybephline { - \bool_if:NT \l_stex_inparray_bool {\hline} -} - -\def \parrayline #1 #2 { - #1 #2 \bool_if:NT \l_stex_inparray_bool {\\} -} - -\def \pmrow #1 { \parrayline{}{ #1 } } - -\def \parraylineh #1 #2 { - #1 #2 \bool_if:NT \l_stex_inparray_bool {\\\hline} -} - -\def \parraycell #1 { - #1 \bool_if:NT \l_stex_inparray_bool {&} -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Variables} -% \begin{macrocode} -%<@@=stex_variables> -% \end{macrocode} -% -% \begin{macro}{\stex_invoke_variable:n} -% -% Invokes a variable -% -% \begin{macrocode} -\cs_new_protected:Nn \stex_invoke_variable:n { - \if_mode_math: - \exp_after:wN \_@@_invoke_math:n - \else: - \exp_after:wN \_@@_invoke_text:n - \fi: {#1} -} - -\cs_new_protected:Nn \_@@_invoke_text:n { - \peek_charcode_remove:NTF ! { - \_@@_invoke_op_custom:nn {#1} - }{ - \_@@_invoke_custom:nn {#1} - } -} - - -\cs_new_protected:Nn \_@@_invoke_math:n { - \peek_charcode_remove:NTF ! { - \peek_charcode_remove:NTF ! { - \peek_charcode:NTF [ { - % TODO throw error - }{ - \_@@_invoke_op_custom:nn - } - }{ - \_@@_invoke_op:n { #1 } - } - }{ - \peek_charcode_remove:NTF * { - \_@@_invoke_custom:nn { #1 } - }{ - \_@@_invoke_math_ii:n { #1 } - } - } -} - -\cs_new_protected:Nn \_@@_invoke_op_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \_stex_term_omv:nn {var://#1}{ - \comp{ #2 } - } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } -} - -\cs_new_protected:Nn \_@@_invoke_op:n { - \cs_if_exist:cTF { - stex_var_op_notation_ #1 _cs - }{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \_stex_term_omv:nn { var://#1 }{ - \use:c{stex_var_op_notation_ #1 _cs } - } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } - }{ - \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_var://#1_prop}{arity}} = 0{ - \_@@_invoke_math_ii:n {#1} - }{ - \msg_error:nnxx{stex}{error/noop}{variable~#1}{} - } - } -} - -\cs_new_protected:Npn \_@@_invoke_math_ii:n #1 { - \cs_if_exist:cTF { - stex_var_notation_#1_cs - }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_var_notation_#1_cs} - }{ - \msg_error:nnxx{stex}{error/nonotation}{variable~#1}{s} - } -} - -\cs_new_protected:Nn \_@@_invoke_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \prop_clear:N \l__stex_terms_custom_args_prop - \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1} - \prop_get:cnN { - l_stex_symdecl_var://#1 _prop - }{ args } \l_tmpa_str - \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str - \tl_set:Nn \arg { \__stex_terms_arg: } - \str_if_empty:NTF \l_tmpa_str { - \_stex_term_omv:nn {var://#1}{\ignorespaces#2} - }{ - \str_if_in:NnTF \l_tmpa_str b { - \_stex_term_ombind:nnn {var://#1}{}{\ignorespaces#2} - }{ - \str_if_in:NnTF \l_tmpa_str B { - \_stex_term_ombind:nnn {var://#1}{}{\ignorespaces#2} - }{ - \_stex_term_oma:nnn {var://#1}{}{\ignorespaces#2} - } - } - } - % TODO check that all arguments exist - }{ - \_stex_reset:N \STEXInternalCurrentSymbolStr - \_stex_reset:N \arg - \_stex_reset:N \comp - \_stex_reset:N \l__stex_terms_custom_args_prop - %\bool_set_true:N \l_stex_allow_semantic_bool - } -} -% \end{macrocode} -% \end{macro} -% -% \subsection{Sequences} -% \begin{macrocode} -%<@@=stex_sequences> - -\cs_new_protected:Nn \stex_invoke_sequence:n { - \peek_charcode_remove:NTF ! { - \_stex_term_omv:nn {varseq://#1}{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1} - \prop_item:cn{l_stex_symdecl_varseq://#1_prop}{notation} - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } - } - }{ - \bool_set_false:N \l_stex_allow_semantic_bool - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1} - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \use:c { stex_varseq_#1_cs } - } -} -% \end{macrocode} - -% \begin{macrocode} -%</package> -% \end{macrocode} -% -% \end{implementation} -% \ifinfulldoc\else\printbibliography\fi -% -% \PrintIndex - -% \endinput -% Local Variables: -% mode: doctex -% TeX-master: t -% End: diff --git a/Master/texmf-dist/source/latex/stex/stex/stex.ins b/Master/texmf-dist/source/latex/stex/stex/stex.ins deleted file mode 100644 index 0ca62264cb2..00000000000 --- a/Master/texmf-dist/source/latex/stex/stex/stex.ins +++ /dev/null @@ -1,46 +0,0 @@ - %% -%% This file generates files required to use the ed package. -%% At your command prompt write -%% -%% latex stex.ins -%% -%% Copyright (c) 2021 Michael Kohlhase -%% -%% This file is distributed under the terms of the LaTeX Project Public -%% License from CTAN archives in directory macros/latex/base/lppl.txt. -%% Either version 1.0 or, at your option, any later version. -%% -\input docstrip -\preamble -\endpreamble - -\keepsilent -\askforoverwritefalse - -\generate{ - \file{stex.cls}{\from{stex-basics.dtx}{cls}} - \file{stex.sty}{ - \from{stex-basics.dtx}{package} - \from{stex-mathhub.dtx}{package} - \from{stex-references.dtx}{package} - \from{stex-modules.dtx}{package} - \from{stex-inheritance.dtx}{package} - \from{stex-symbols.dtx}{package} - \from{stex-terms.dtx}{package} - \from{stex-features.dtx}{package} - \from{stex-statements.dtx}{package} - \from{stex-proofs.dtx}{package} - % ... - \from{stex-metatheory.dtx}{package} - \from{stex-others.dtx}{package} - } -} - -\Msg{*} -\Msg{* You probably need to move the generated style files into a directory searched by TeX.} -\Msg{*} -\Msg{* And don't forget to refresh your filename database} -\Msg{* if your TeX distribution uses such a database.} -\Msg{*} - -\endbatchfile diff --git a/Master/texmf-dist/source/latex/stex/tikzinput.dtx b/Master/texmf-dist/source/latex/stex/tikzinput.dtx new file mode 100644 index 00000000000..988d483b126 --- /dev/null +++ b/Master/texmf-dist/source/latex/stex/tikzinput.dtx @@ -0,0 +1,114 @@ +% \iffalse meta-comment +% An Infrastructure for Semantic Macros and Module Scoping +% Copyright (c) 2019 Michael Kohlhase, all rights reserved +% this file is released under the +% LaTeX Project Public License (LPPL) +% +% The original of this file is in the public repository at +% http://github.com/sLaTeX/sTeX/ +% +% TODO update copyright +% +%<*driver> +\def\stexdocpath{../doc} +\input{\stexdocpath/stex-docheader} +\stextoptitle{Tikzinput: Treating TIKZ code as images}{tikzinput} +\docmodule +%</driver> +% \fi +% +% \begin{stexmanual} +% \begin{sfragment}{Tikzinput Manual} + % \input{\stexdocpath/packages/stex-tikzinput} +% \end{sfragment} +% \end{stexmanual} +% +% \begin{documentation} +% \begin{sfragment}{Tikzinput Documentation} +% TODO +% \end{sfragment} +% \end{documentation} +% +% \begin{implementation}\label{pkg:tikzinput:impl} +% +% \begin{sfragment}{Tikzinput Implementation} +% +% \begin{macrocode} +%<@@=tikzinput> +%<*package> + +%%%%%%%%%%%%% tikzinput.dtx %%%%%%%%%%%%% + +% \end{macrocode} +% +% \begin{macrocode} +\ProvidesExplPackage{tikzinput}{2023/03/19}{3.3.0}{tikzinput package} +\RequirePackage{l3keys2e} + +\keys_define:nn { tikzinput } { + image .bool_set:N = \c_tikzinput_image_bool, + image .default:n = false , + unknown .code:n = {} +} + +\ProcessKeysOptions { tikzinput } + +\bool_if:NTF \c_tikzinput_image_bool { + \RequirePackage{graphicx} + + \providecommand\usetikzlibrary[]{} + \newcommand\tikzinput[2][]{\includegraphics[#1]{#2}} +}{ + \RequirePackage{tikz} + \RequirePackage{standalone} + + \newcommand \tikzinput [2] [] { + \setkeys{Gin}{#1} + \ifx \Gin@ewidth \Gin@exclamation + \ifx \Gin@eheight \Gin@exclamation + \input { #2 } + \else + \resizebox{!}{ \Gin@eheight }{ + \input { #2 } + } + \fi + \else + \ifx \Gin@eheight \Gin@exclamation + \resizebox{ \Gin@ewidth }{!}{ + \input { #2 } + } + \else + \resizebox{ \Gin@ewidth }{ \Gin@eheight }{ + \input { #2 } + } + \fi + \fi + } +} + +\newcommand \ctikzinput [2] [] { + \begin{center} + \tikzinput [#1] {#2} + \end{center} +} +% \end{macrocode} +% +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \end{sfragment} +% \end{implementation} +% +\endinput +% Local Variables: +% mode: doctex +% TeX-master: t +% End: + +% LocalWords: libfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight +% LocalWords: ctikzinput mhpath pgfkeys@spdef pgfutil@empty 1@atcode catcode l_tmpa_str +% LocalWords: pgfutil@InputIfFileExists libusetikzlibrary msg_error:nnn notinarchive +% LocalWords: seq_clear:N seq_set_eq:NN l_tmpa_seq c_stex_mathhub_seq seq_set_split:NnV +% LocalWords: l_tmpb_seq seq_if_empty_p:N tikzlibrary seq_put_right:No seq_pop_left:NN diff --git a/Master/texmf-dist/tex/latex/stex/document-structure.sty b/Master/texmf-dist/tex/latex/stex/document-structure.sty deleted file mode 100644 index 246d94e18f4..00000000000 --- a/Master/texmf-dist/tex/latex/stex/document-structure.sty +++ /dev/null @@ -1,263 +0,0 @@ -%% -%% This is file `document-structure.sty', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% document-structure.dtx (with options: `package') -%% -\ProvidesExplPackage{document-structure}{2022/09/14}{3.2.0}{Modular Document Structure} -\RequirePackage{l3keys2e} - -\keys_define:nn{ document-structure }{ - class .str_set_x:N = \c_document_structure_class_str, - topsect .str_set_x:N = \c_document_structure_topsect_str, - unknown .code:n = { - \PassOptionsToClass{\CurrentOption}{stex} - \PassOptionsToClass{\CurrentOption}{tikzinput} - } -} -\ProcessKeysOptions{ document-structure } -\str_if_empty:NT \c_document_structure_class_str { - \str_set:Nn \c_document_structure_class_str {article} -} -\str_if_empty:NT \c_document_structure_topsect_str { - \str_set:Nn \c_document_structure_topsect_str {section} -} -\RequirePackage{xspace} -\RequirePackage{comment} -\RequirePackage{stex} -\AddToHook{begindocument}{ -\ltx@ifpackageloaded{babel}{ - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ - \makeatletter\input{document-structure-ngerman.ldf}\makeatother - } - }{} -} -\int_new:N \l_document_structure_section_level_int -\str_case:VnF \c_document_structure_topsect_str { - {part}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - {chapter}{ - \int_set:Nn \l_document_structure_section_level_int {1} - } -}{ - \str_case:VnF \c_document_structure_class_str { - {book}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - {report}{ - \int_set:Nn \l_document_structure_section_level_int {0} - } - }{ - \int_set:Nn \l_document_structure_section_level_int {2} - } -} -\def\current@section@level{document}% -\newcommand\currentsectionlevel{\lowercase\expandafter{\current@section@level}\xspace}% -\newcommand\Currentsectionlevel{\expandafter\MakeUppercase\current@section@level\xspace}% -\cs_new_protected:Npn \skipfragment { - \ifcase\l_document_structure_section_level_int - \or\stepcounter{part} - \or\stepcounter{chapter} - \or\stepcounter{section} - \or\stepcounter{subsection} - \or\stepcounter{subsubsection} - \or\stepcounter{paragraph} - \or\stepcounter{subparagraph} - \fi -} -\newcommand\at@begin@blindsfragment[1]{} -\newenvironment{blindfragment} -{ - \int_incr:N\l_document_structure_section_level_int - \at@begin@blindsfragment\l_document_structure_section_level_int -}{} -\newcommand\sfragment@nonum[2]{ - \ifx\hyper@anchor\@undefined\else\phantomsection\fi - \addcontentsline{toc}{#1}{#2}\@nameuse{#1}*{#2} -} -\newcommand\sfragment@num[2]{ - \tl_if_empty:NTF \l__document_structure_sfragment_short_tl { - \@nameuse{#1}{#2} - }{ - \cs_if_exist:NTF\rdfmeta@sectioning{ - \@nameuse{rdfmeta@#1@old}[\l__document_structure_sfragment_short_tl]{#2} - }{ - \@nameuse{#1}[\l__document_structure_sfragment_short_tl]{#2} - } - } -} -\keys_define:nn { document-structure / sfragment }{ - id .str_set_x:N = \l__document_structure_sfragment_id_str, - date .str_set_x:N = \l__document_structure_sfragment_date_str, - creators .clist_set:N = \l__document_structure_sfragment_creators_clist, - contributors .clist_set:N = \l__document_structure_sfragment_contributors_clist, - srccite .tl_set:N = \l__document_structure_sfragment_srccite_tl, - type .tl_set:N = \l__document_structure_sfragment_type_tl, - short .tl_set:N = \l__document_structure_sfragment_short_tl, - intro .tl_set:N = \l__document_structure_sfragment_intro_tl, - imports .tl_set:N = \l__document_structure_sfragment_imports_tl, - loadmodules .bool_set:N = \l__document_structure_sfragment_loadmodules_bool -} -\cs_new_protected:Nn \__document_structure_sfragment_args:n { - \str_clear:N \l__document_structure_sfragment_id_str - \str_clear:N \l__document_structure_sfragment_date_str - \clist_clear:N \l__document_structure_sfragment_creators_clist - \clist_clear:N \l__document_structure_sfragment_contributors_clist - \tl_clear:N \l__document_structure_sfragment_srccite_tl - \tl_clear:N \l__document_structure_sfragment_type_tl - \tl_clear:N \l__document_structure_sfragment_short_tl - \tl_clear:N \l__document_structure_sfragment_imports_tl - \tl_clear:N \l__document_structure_sfragment_intro_tl - \bool_set_false:N \l__document_structure_sfragment_loadmodules_bool - \keys_set:nn { document-structure / sfragment } { #1 } -} -\newif\if@mainmatter\@mainmattertrue -\newcommand\at@begin@sfragment[3][]{} -\keys_define:nn { document-structure / sectioning }{ - name .str_set_x:N = \l__document_structure_sect_name_str , - ref .str_set_x:N = \l__document_structure_sect_ref_str , - clear .bool_set:N = \l__document_structure_sect_clear_bool , - clear .default:n = {true} , - num .bool_set:N = \l__document_structure_sect_num_bool , - num .default:n = {true} -} -\cs_new_protected:Nn \__document_structure_sect_args:n { - \str_clear:N \l__document_structure_sect_name_str - \str_clear:N \l__document_structure_sect_ref_str - \bool_set_false:N \l__document_structure_sect_clear_bool - \bool_set_false:N \l__document_structure_sect_num_bool - \keys_set:nn { document-structure / sectioning } { #1 } -} -\newcommand\omdoc@sectioning[3][]{ - \__document_structure_sect_args:n {#1 } - \let\omdoc@sect@name\l__document_structure_sect_name_str - \bool_if:NT \l__document_structure_sect_clear_bool { \cleardoublepage } - \if@mainmatter% numbering not overridden by frontmatter, etc. - \bool_if:NTF \l__document_structure_sect_num_bool { - \sfragment@num{#2}{#3} - }{ - \sfragment@nonum{#2}{#3} - } - \def\current@section@level{\omdoc@sect@name} - \else - \sfragment@nonum{#2}{#3} - \fi -}% if@mainmatter -\newcommand\sfragment@redefine@addtocontents[1]{% -}% hypreref.sty loaded? -\newenvironment{sfragment}[2][]% keys, title -{ - \__document_structure_sfragment_args:n { #1 }%\sref@target% - \stex_csl_to_imports:No \usemodule \l__document_structure_sfragment_imports_tl - - \bool_if:NT \l__document_structure_sfragment_loadmodules_bool { - \sfragment@redefine@addtocontents{ - %\@ifundefined{module@id}\used@modules% - %{\@ifundefined{module@\module@id @path}{\used@modules}\module@id} - } - } - - \stex_document_title:n { #2 } - - \int_incr:N\l_document_structure_section_level_int - \ifcase\l_document_structure_section_level_int - \or\omdoc@sectioning[name=\omdoc@part@kw,clear,num]{part}{#2} - \or\omdoc@sectioning[name=\omdoc@chapter@kw,clear,num]{chapter}{#2} - \or\omdoc@sectioning[name=\omdoc@section@kw,num]{section}{#2} - \or\omdoc@sectioning[name=\omdoc@subsection@kw,num]{subsection}{#2} - \or\omdoc@sectioning[name=\omdoc@subsubsection@kw,num]{subsubsection}{#2} - \or\omdoc@sectioning[name=\omdoc@paragraph@kw,ref=this \omdoc@paragraph@kw]{paragraph}{#2} - \or\omdoc@sectioning[name=\omdoc@subparagraph@kw,ref=this \omdoc@subparagraph@kw]{paragraph}{#2} - \fi - \at@begin@sfragment[#1]\l_document_structure_section_level_int{#2} - \str_if_empty:NF \l__document_structure_sfragment_id_str { - \stex_ref_new_doc_target:n\l__document_structure_sfragment_id_str - } -}% for customization -{} -\newcommand\omdoc@part@kw{Part} -\newcommand\omdoc@chapter@kw{Chapter} -\newcommand\omdoc@section@kw{Section} -\newcommand\omdoc@subsection@kw{Subsection} -\newcommand\omdoc@subsubsection@kw{Subsubsection} -\newcommand\omdoc@paragraph@kw{paragraph} -\newcommand\omdoc@subparagraph@kw{subparagraph} -\providecommand\printindex{\IfFileExists{\jobname.ind}{\input{\jobname.ind}}{}} -\cs_if_exist:NTF\frontmatter{ - \let\__document_structure_orig_frontmatter\frontmatter - \let\frontmatter\relax -}{ - \tl_set:Nn\__document_structure_orig_frontmatter{ - \clearpage - \@mainmatterfalse - \pagenumbering{roman} - } -} -\cs_if_exist:NTF\backmatter{ - \let\__document_structure_orig_backmatter\backmatter - \let\backmatter\relax -}{ - \tl_set:Nn\__document_structure_orig_backmatter{ - \clearpage - \@mainmatterfalse - \pagenumbering{roman} - } -} -\newenvironment{frontmatter}{ - \__document_structure_orig_frontmatter -}{ - \cs_if_exist:NTF\mainmatter{ - \mainmatter - }{ - \clearpage - \@mainmattertrue - \pagenumbering{arabic} - } -} -\newenvironment{backmatter}{ - \__document_structure_orig_backmatter -}{ - \cs_if_exist:NTF\mainmatter{ - \mainmatter - }{ - \clearpage - \@mainmattertrue - \pagenumbering{arabic} - } -} -\@mainmattertrue\pagenumbering{arabic} -\def \c__document_structure_document_str{document} -\newcommand\afterprematurestop{} -\def\prematurestop@endsfragment{ - \unless\ifx\@currenvir\c__document_structure_document_str - \expandafter\expandafter\expandafter\end\expandafter\expandafter\expandafter{\expandafter\@currenvir\expandafter} - \expandafter\prematurestop@endsfragment - \fi -} -\providecommand\prematurestop{ - \message{Stopping~sTeX~processing~prematurely} - \prematurestop@endsfragment - \afterprematurestop - \end{document} -} -\RequirePackage{etoolbox} -\newcommand\setSGvar[1]{\@namedef{sTeX@Gvar@#1}} -\newrobustcmd\useSGvar[1]{% - \@ifundefined{sTeX@Gvar@#1} - {\PackageError{document-structure} - {The sTeX Global variable #1 is undefined} - {set it with \protect\setSGvar}} -\@nameuse{sTeX@Gvar@#1}} -\newrobustcmd\ifSGvar[3]{\def\@test{#2}% - \@ifundefined{sTeX@Gvar@#1} - {\PackageError{document-structure} - {The sTeX Global variable #1 is undefined} - {set it with \protect\setSGvar}} - {\expandafter\ifx\csname sTeX@Gvar@#1\endcsname\@test #3\fi}} -\endinput -%% -%% End of file `document-structure.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty b/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty index 85fd253eebe..0e172c8fee3 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty +++ b/Master/texmf-dist/tex/latex/stex/etc/beamerthemesTeX.sty @@ -3,13 +3,14 @@ \ProvidesPackage{beamerthemesTeX} \typeout{Beamer sTeX theme} \RequirePackage{xspace} -\RequirePackage{xcolor} -\RequirePackage{stex} +\RequirePackage{stex,notesslides,tikzinput} \ExplSyntaxOn \protected\def\stexbeamerthm#1#2#3#4#5#6#7#8{ - \newcounter{#1} - \tl_if_empty:nF{#4}{ + \tl_if_empty:nTF{#4}{ + \newcounter{#1} + }{ + \newcounter{#1}[#4] \tl_set:cn{the#1}{ \use:c{the#4}.\arabic{#1} } @@ -26,42 +27,174 @@ \refstepcounter{#1} \noindent#7{ #6~\use:c{the#1} - \tl_if_empty:cF{s#2title}{ - {}~(\csname s#2title\endcsname) + \tl_if_empty:NF\thistitle{ + {}~(\thistitle) }. } #8 }{\par} - \csname stexpatch#2\endcsname[#3]{\begin{#1}}{\end{#1}} + \csname stexstyle#2\endcsname[#3]{\begin{#1}}{\end{#1}} +} + +\cs_set_protected:Nn \stex_beamertheme_do_en: { + \def\stex@theorem@kw{Theorem} + \def\stex@observation@kw{Observation} + \def\stex@corollary@kw{Corollary} + \def\stex@lemma@kw{Lemma} + \def\stex@axiom@kw{Axiom} + \def\stex@remark@kw{Remark} + \def\stex@example@kw{Example} + \def\stex@definition@kw{Definition} +} + +\cs_set_protected:Nn \stex_beamertheme_do_de: { + \def\stex@theorem@kw{Satz} + \def\stex@observation@kw{Beobachtung} + \def\stex@corollary@kw{Korollar} + \def\stex@lemma@kw{Lemma} + \def\stex@axiom@kw{Axiom} + \def\stex@remark@kw{Bemerkung} + \def\stex@example@kw{Beispiel} + \def\stex@definition@kw{Definition} +} + + +\AtBeginDocument{ + \cs_if_exist:NTF\iflanguage{ + \cs_if_exist:NT \l@english { + \iflanguage{english}{ + \stex_beamertheme_do_en: + }{} + } + \cs_if_exist:NT \l@ngerman { + \iflanguage{ngerman}{ + \stex_beamertheme_do_de: + }{} + } + }{ + \stex_beamertheme_do_en: + } } \ExplSyntaxOff -\stexbeamerthm{theorem}{assertion}{theorem}{section}{}{Theorem}\textbf\itshape -\stexbeamerthm{observation}{assertion}{observation}{section}{theorem}{Observation}\textbf\itshape -\stexbeamerthm{corollary}{assertion}{corollary}{section}{theorem}{Corollary}\textbf\itshape -\stexbeamerthm{lemma}{assertion}{lemma}{section}{theorem}{Lemma}\textbf\itshape -\stexbeamerthm{axiom}{assertion}{axiom}{section}{theorem}{Axiom}\textbf\itshape -\stexbeamerthm{remark}{assertion}{remark}{section}{theorem}{Remark}\emph{} -\stexpatchparagraph[remark]{\begin{remark}}{\end{remark}} -\stexbeamerthm{example}{example}{}{section}{theorem}{Example}\textbf{} -\stexbeamerthm{definition}{definition}{}{section}{theorem}{Definition}\textbf{} +\stexbeamerthm{theorem}{assertion}{theorem}{section}{}{\stex@theorem@kw}\textbf\itshape +\stexbeamerthm{observation}{assertion}{observation}{section}{theorem}{\stex@observation@kw}\textbf\itshape +\stexbeamerthm{corollary}{assertion}{corollary}{section}{theorem}{\stex@corollary@kw}\textbf\itshape +\stexbeamerthm{lemma}{assertion}{lemma}{section}{theorem}{\stex@lemma@kw}\textbf\itshape +\stexbeamerthm{axiom}{assertion}{axiom}{section}{theorem}{\stex@axiom@kw}\textbf\itshape +\stexbeamerthm{remark}{assertion}{remark}{section}{theorem}{\stex@remark@kw}\emph{} +\stexstyleparagraph[remark]{\begin{remark}}{\end{remark}} +\stexbeamerthm{example}{example}{}{section}{theorem}{\stex@example@kw}\textbf{} +\stexbeamerthm{definition}{definition}{}{section}{theorem}{\stex@definition@kw}\textbf{} +\def\notesslidestitleemph#1{ + \textcolor{blue}{\Large\bf\sf#1}% + \vskip0.1\baselineskip + \leaders\vrule width \textwidth + \vskip0.4pt% + \nointerlineskip +} -% THEME -\mode -<presentation> +\newlength{\slidelogoheight} -\sffamily +\ExplSyntaxOn +\bool_if:NTF \c_notesslides_notes_bool { + \setlength{\slidelogoheight}{.4cm} +}{ + \setlength{\slidelogoheight}{.25cm} +} \ifcsname slidelogo\endcsname\else - \newsavebox\slidelogo - \sbox\slidelogo{\sTeX} + \newsavebox{\slidelogo} + \sbox{\slidelogo}{\sTeX} \fi +\newrobustcmd{\setslidelogo}[2][]{ + \tl_if_empty:nTF{#1}{ + \sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{#2}} + }{ + \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,archive=#1]{#2}} + } +} + +\newrobustcmd{\setsource}[1]{\def\source{#1}} + +\def\copyrightnotice{% + \footnotesize\copyright :\hspace{.3ex}% + \ifcsname source\endcsname\source\else% + \ifcsname c_notesslides_shortauthor\endcsname\c_notesslides_shortauthor\else% + \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}% + ?source/author?\fi% + \fi} + +\newsavebox{\cclogo} +\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}} +\newif\ifcchref\cchreffalse + +\AtBeginDocument{ + \@ifpackageloaded{hyperref}{\cchreftrue}{\cchreffalse} +} + +\def\licensing{ + \ifcchref + \href{http://creativecommons.org/licenses/by-sa/2.5/}{\usebox{\cclogo}} + \else + {\usebox{\cclogo}} + \fi +} + +\newrobustcmd{\setlicensing}[2][]{ + \def\@url{#1} + \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{#2}} + \ifx\@url\@empty + \def\licensing{{\usebox{\cclogo}}} + \else + \def\licensing{ + \ifcchref + \href{#1}{\usebox{\cclogo}} + \else + {\usebox{\cclogo}} + \fi + } + \fi +} + +\newrobustcmd\notesslides@slidelabel{ + \vbox to \slidelogoheight{ + \vss\hbox to \slidewidth + {\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}} + } +} + +\define@key{Gin}{label}{\def\@currentlabel{\arabic{slide}}\label{#1}} + %% Logo images \pgfdeclareimage[height=2ex]{instlogo}{sTeX-logo} \pgfdeclareimage[height=2ex]{cclogo}{stex-cc_somerights} +\ExplSyntaxOff + +\def\notesslidesfooter{ + \usebox\slidelogo + \hspace*{1cm}\insertshortauthor: \insertshorttitle\hfill{}% + \insertframenumber\hfill\insertshortdate + \hspace*{1cm}\pgfuseimage{cclogo}% +} + +% THEME +\mode +<presentation> + +\def\notesslidestitleemph#1{ + \textcolor{blue}{\Large\bf\sf#1}% + \vskip-.1\baselineskip + \leaders\vrule width \paperwidth\vskip0.4pt% + \vskip0pt% + \nointerlineskip +} + +\notesslidesfont + %% A simple frame title with a long rule under it. \setbeamertemplate{frametitle}{% \usebeamerfont{frametitle}\insertframetitle\strut% @@ -74,9 +207,8 @@ %% A Footer line with a Institution and CC logos \setbeamertemplate{footline}[text line]{% \usebeamercolor[fg]{titlelike} - \usebox\slidelogo\hspace*{1cm}\insertshortauthor: \insertshorttitle\hfill{}% - \insertframenumber\hfill\insertshortdate\hspace*{1cm}\pgfuseimage{cclogo}% - } + \notesslidesfooter +} %% Turn off the navigation symbols \setbeamertemplate{navigation symbols}{} @@ -100,24 +232,25 @@ %% set the colors for sTeX content highlighting -\def\compemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi} -\def\symrefemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi} -\def\defemph#1{\ifcsname textcolor\endcsname\textcolor{magenta}{#1}\else\textbf{#1}\fi} -\def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi} -\def\titleemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else\textbf{#1}\fi} +\definecolor{steelblue}{rgb}{0.27, 0.51, 0.71} + +\def\compemph#1{\textcolor{steelblue}{#1}} +\def\symrefemph#1{\textcolor{steelblue}{#1}} +\def\defemph#1{\textcolor{magenta}{#1}} +\def\varemph#1{\textcolor{gray}{#1}} %% set PDF tooltips \RequirePackage{pdfcomment} \protected\def\compemph@uri#1#2{% \pdftooltip{% - \srefsymuri{#2}{\compemph{#1}}% + \compemph{#1}%\srefsymuri{#2}{\compemph{#1}}% }{% URI:~\detokenize{#2}% }% } \protected\def\symrefemph@uri#1#2{% \pdftooltip{% - \srefsymuri{#2}{\symrefemph{#1}}% + \symrefemph{#1}%\srefsymuri{#2}{\symrefemph{#1}}% }{% URI:~\detokenize{#2}% }% @@ -135,4 +268,4 @@ }{% Variable~\detokenize{#2}% }% -}
\ No newline at end of file +} diff --git a/Master/texmf-dist/tex/latex/stex/etc/hwexam-default.header b/Master/texmf-dist/tex/latex/stex/etc/hwexam-default.header index f3ee390bf90..d36a97c7187 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/hwexam-default.header +++ b/Master/texmf-dist/tex/latex/stex/etc/hwexam-default.header @@ -10,13 +10,15 @@ Matriculation Number:\hspace*{2cm}\strut\\[1ex] Write the solutions to the sheet. \noindent -The estimated time for solving this exam is {\theassignment@totalmin} minutes, -leaving you {\check@time} minutes for revising your exam. +The estimated time for solving this exam is {\hwexam@totalmin} minutes, +leaving you {\hwexam@checktime} minutes for revising your exam. \noindent -You can reach {\theassignment@totalpts} points if you solve all problems. -You will only need {\testheading@reqpts} points for a perfect score, i.e. -{\bonus@pts} points are bonus points. +You can reach {\hwexam@totalpts} points if you solve all problems. +\if@bonuspoints +You will only need {\hwexam@reqpts} points for a perfect score, i.e. +{\hwexam@bonuspts} points are bonus points. +\fi \vfill \begin{center} { @@ -26,5 +28,5 @@ You will only need {\testheading@reqpts} points for a perfect score, i.e. get stuck on one problem. }\vfill -\resizebox{\textwidth}{!}{\correction@table}\\[3ex] +\correction@table\\[3ex] \end{center}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/lststex.sty b/Master/texmf-dist/tex/latex/stex/etc/lststex.sty index 2b0f7a9b2e9..423e0b4a20a 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/lststex.sty +++ b/Master/texmf-dist/tex/latex/stex/etc/lststex.sty @@ -31,6 +31,133 @@ \define@key{stexlisting}{id}{\def\sref@id{#1}} \define@key{stexlisting}{id}{\def\stexlst@id{#1}} +\definecolor{semanticmacrocolor}{HTML}{008800} + +\lstdefinelanguage{sTeX}{ + sensitive=true, + numbers=left, + numbersep=3pt, + xleftmargin=3pt, + alsoother={$()$}, + alsoletter={\\}, + escapechar=|, + %moredelim = [s][\itshape]{$}{$}, + %moredelim = [s][\itshape\bfseries]{\\[}{\\]}, + classoffset=0,keywordstyle=\bfseries,morekeywords={ + \\begin,\\end,\\ExplSyntaxOn,\\ExplSyntaxOff,\\documentclass, + \\usepackage,\\def,\\[,\\],\\else,\\fi, + \\newcommand, \\renewcommand, \\let,\$ + }, + classoffset=1,keywordstyle=\itshape\color{semanticmacrocolor},morekeywords={ + % semantic macros + }, + classoffset=2,keywordstyle=\color{blue},morekeywords={ + \\symdecl,\\symdef,\\notation,\\vardef,\\varseq, + \\textsymdecl, \\renamedecl, \\assign, \\setnotation, + \\STEXexport + }, + classoffset=3,keywordstyle=\color{orange},morekeywords={ + \\importmodule,\\usemodule,\\libinput,\\inputref,\\mhinput, + \\libusepackage,\\addmhbibresource,\\ifinputref,\\copymod, + \\ifstexhtml, \\IfInputref,\\requiremodule,\\realize,\\usestructure + }, + classoffset=4,keywordstyle=\color{purple},morekeywords={ + \\definiendum,\\definame,\\Definame,\\symref,\\symname,\\comp,\\this, + \\compemph,\\definiens,\\svar,\\infprec,\\neginfprec,\\ellipses, + \\Symname,\\arg,\\yield,\\assumption,\\spfstep,\\eqstep,\\conclude, + \\symref,\\sn,\\sr,\\sns,\\Sn,\\Sns,\\defnotation,\\symuse,\\maincomp, + \\argsep,\\argmap,\\argarraymap,\\conclusion + }, + classoffset=5,keywordstyle=\color{magenta},morekeywords={ + smodule,sdefinition,sassertion,sparagraph,sexample, + sproof,subproof,spfcases,spfcase,spfstep,spfcomment,spfblock, + \\spfidea,\\spfsketch,\\spfcasesketch,\\sproofend, + \\spfjust,\\premise,\\justarg,\\inlinedef,\\inlineex,\\inlineass, + \\varbind, + copymodule,interpretmodule,mathstructure,sexample,extstructure, + extstructure*,realization + }, + classoffset=6,keywordstyle=\color{cyan},morekeywords={ + sfragment,blindfragment,\\skipfragment, + \\currentsectionlevel,\\Currentsectionlevel,\\setsectionlevel, + \\prematurestop,\\afterprematurestop, + \\setSGvar,\\useSGvar,\\ifSGvar,\\sref,\\sreflabel,\\extref,\\srefsetin, + \\srefsym,\\srefsymuri + }, + classoffset=7,keywordstyle=\color{brown},morekeywords={ + frame,note,\\ifnotes,\\setslidelogo,\\setsource,\\setlicensing + slides,notes,sectocframes,frameimages,fiboxed, + nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion, + \\frameimage,\\mhframeimage,\\textwarning, + \\activateexcursion,\\printexcursion,\\excursionref,\\excursiongroup + }, + classoffset=8,keywordstyle=\color{red},morekeywords={ + frame,note + }, + classoffset=9,keywordstyle=\color{gray},morekeywords={ + % variables + } +} + +\ExplSyntaxOn + +\lstnewenvironment{stexcode}[1][]{ + \_lststex_parse_args:n{#1} + \exp_args:No \lstset\l_lststex_return_tl +}{} + +\newcommand\stexcodeinline[1][]{ + \_lststex_parse_args:n{#1} + \exp_args:Nno \use:nn{\lstinline[} \l_lststex_return_tl ] +} + +\keys_define:nn{ lststex }{ + symbols .code:n = { + \clist_map_inline:nn{#1}{ + \clist_put_right:Nn \l_lststex_symbols_clist {##1} + \clist_put_right:Nn \l_lststex_symbols_clist {\\##1} + } + }, + variables .code:n = { + \clist_map_inline:nn{#1}{ + \clist_put_right:Nn \l_lststex_variables_clist {##1} + \clist_put_right:Nn \l_lststex_variables_clist {\\##1} + } + }, + unknown .code:n = { + \tl_if_empty:nTF{#1}{ + \exp_args:NNo \clist_put_right:Nn \l_lststex_pass_on_args_clist \l_keys_key_str + }{ + \exp_args:NNx \clist_put_right:Nn \l_lststex_pass_on_args_clist { + \l_keys_key_str = \exp_not:n{{#1}} + } + } + } +} + +\cs_new_protected:Nn \_lststex_parse_args:n { + \clist_clear:N \l_lststex_pass_on_args_clist + \clist_put_right:Nn \l_lststex_pass_on_args_clist {language=sTeX} + \clist_clear:N \l_lststex_symbols_clist + \clist_clear:N \l_lststex_variables_clist + \keys_set:nn { lststex }{ #1 } + \tl_set:Nx \l_lststex_return_tl { + \exp_args:No \exp_not:n \l_lststex_pass_on_args_clist + \clist_if_empty:NF \l_lststex_symbols_clist { + ,classoffset=1,morekeywords={ + \exp_args:No \exp_not:n \l_lststex_symbols_clist + } + } + \clist_if_empty:NF \l_lststex_variables_clist { + ,classoffset=9,morekeywords={ + \exp_args:No \exp_not:n \l_lststex_variables_clist + } + } + } +} + +\ExplSyntaxOff + % LocalWords: lstdefinelanguage morekeywords morecomment moretexcs defin sref % LocalWords: twindef atwindef definalt twindefalt atwindefalt termref lstset % LocalWords: basicstyle scriptsize fullflexible lineskip aboveskip belowskip diff --git a/Master/texmf-dist/tex/latex/stex/etc/rustex.sty b/Master/texmf-dist/tex/latex/stex/etc/rustex.sty index dafcc184eb5..8ddab958653 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/rustex.sty +++ b/Master/texmf-dist/tex/latex/stex/etc/rustex.sty @@ -34,26 +34,24 @@ \prg_return_false: \fi: } - \cs_new_protected:Npn\rustex_direct_HTML:n #1 { - \rustex_if:T {\cs:w rustex@directHTML\cs_end:{#1}} - } - \cs_new_protected:Npn\rustex_annotate_HTML_begin:n #1 { - \rustex_if:T {\cs:w rustex@annotateHTML\cs_end:{#1}} - } - \cs_new_protected:Nn\rustex_annotate_HTML_end: { - \rustex_if:T {\cs:w rustex@annotateHTMLEnd\cs_end:} - } - \cs_new_protected:Npn\rustex_annotate_HTML:nn #1 #2 { - \rustex_if:TF { + \rustex_if:TF { + \cs_new_protected:Nn\rustex_direct_HTML:n { + \cs:w rustex@directHTML\cs_end:{#1} + } + \cs_set_eq:Nc\rustex_annotate_HTML_begin:n {rustex@annotateHTML} + \cs_set_eq:Nc\rustex_annotate_HTML_end: {rustex@annotateHTMLEnd} + \cs_new_protected:Nn\rustex_annotate_HTML:nn { \rustex_annotate_HTML_begin:n{#1} #2 \rustex_annotate_HTML_end: - }{#2} - } - \cs_new_protected:Npn\rustex_add_Namespace:nn #1 #2 { - \rustex_if:T { - \cs:w rustex@addNamespaceAbbrev\cs_end:{#1}{#2} } + \cs_set_eq:Nc\rustex_add_Namespace:nn{rustex@addNamespaceAbbrev} + }{ + \cs_new_protected:Nn\rustex_direct_HTML:n {} + \cs_new_protected:Nn\rustex_annotate_HTML_begin:n {} + \cs_new_protected:Nn\rustex_annotate_HTML_end: {} + \cs_new_protected:Nn\rustex_annotate_HTML:nn {#2} + \cs_new_protected:Nn\rustex_add_Namespace:nn {} } \ExplSyntaxOff \fi diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-latexml.cfg b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-latexml.cfg index 1cb4e31d3a8..0979b9713e9 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-latexml.cfg +++ b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-latexml.cfg @@ -1,56 +1,28 @@ -\ifcsname if@latexml\endcsname\else -\expandafter\newif\csname if@latexml\endcsname\@latexmlfalse -\fi +\RequirePackage{latexml} \tl_const:Nx \c_stex_html_emptyarg_tl {~} +\cs_new_protected:Nn \_stex_html_checkempty:n { + \tl_set:Nn \l_stex_html_arg_tl { #1 } + \tl_if_empty:NT \l_stex_html_arg_tl { + \tl_set_eq:NN \l_stex_html_arg_tl \c_stex_html_emptyarg_tl + } +} \prg_new_conditional:Nnn \latexml_if: {p, T, F, TF} { - \if@latexml + \iflatexml \expandafter\prg_return_true: \else: \expandafter\prg_return_false: \fi: } -\cs_new_protected:Nn \stex_annotate:nnn { - \_stex_html_checkempty:n { #3 } - \mode_if_math:TF { - \cs:w latexml@annotate@math\cs_end:{#1}{#2}{ - \tl_use:N \l_stex_html_arg_tl - } - }{ - \cs:w latexml@annotate@text\cs_end:{#1}{#2}{ - \tl_use:N \l_stex_html_arg_tl - } - } -} - -\cs_new_protected:Nn \stex_annotate_invisible:n { - \_stex_html_checkempty:n { #1 } - \mode_if_math:TF { - \cs:w latexml@invisible@math\cs_end:{ - \tl_use:N \l_stex_html_arg_tl - } - } { - \cs:w latexml@invisible@text\cs_end:{ - \tl_use:N \l_stex_html_arg_tl - } - } -} - -\cs_new_protected:Nn \stex_annotate_invisible:nnn { - \_stex_html_checkempty:n { #3 } - \cs:w latexml@annotate@invisible\cs_end:{#1}{#2}{ - \tl_use:N \l_stex_html_arg_tl - } -} - -\NewDocumentEnvironment{stex_annotate_env} { m m } { - \par\begin{latexml@annotateenv}{#1}{#2} -}{ - \par\end{latexml@annotateenv} -} +\cs_new_protected:Nn \stex_annotate:nnn {#3} +\cs_new_protected:Nn \stex_mathml_intent:nn { #2 } +\cs_new_protected:Nn \stex_mathml_arg:nn { #2 } +\cs_new_protected:Nn \stex_annotate_invisible:n {} +\cs_new_protected:Nn \stex_annotate_invisible:nnn {} +\NewDocumentEnvironment{stex_annotate_env} { m m } {}{} -\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} { +\prg_new_conditional:Nnn \stex_if_html_backend: {p, T, F, TF} { \prg_return_true: }
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg index 484f930db6d..dd992d79d0f 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg +++ b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-pdflatex.cfg @@ -1,12 +1,10 @@ -\tl_const:Nx \c_stex_html_emptyarg_tl {~} - -\cs_new_protected:Nn \stex_annotate:nnn {#3} +\cs_new_protected:Nn \stex_annotate:nn {#2} \cs_new_protected:Nn \stex_mathml_intent:nn { #2 } \cs_new_protected:Nn \stex_mathml_arg:nn { #2 } \cs_new_protected:Nn \stex_annotate_invisible:n {} -\cs_new_protected:Nn \stex_annotate_invisible:nnn {} -\NewDocumentEnvironment{stex_annotate_env} { m m } {}{} +\cs_new_protected:Nn \stex_annotate_invisible:nn {} +\NewDocumentEnvironment{stex_annotate_env} { m } {}{} -\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} { +\prg_new_conditional:Nnn \stex_if_html_backend: {p, T, F, TF} { \prg_return_false: }
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg index c9ad36613bc..f04aa450f0b 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg +++ b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-rustex.cfg @@ -1,69 +1,78 @@ \RequirePackage{rustex} -\rustex_add_Namespace:nn{stex}{http://kwarc.info/ns/sTeX} +\rustex_add_Namespace:nn{shtml}{http://kwarc.info/ns/SHTML} \rustex_add_Namespace:nn{mmt}{http://uniformal.github.io/MMT} -\tl_const:Nx \c_stex_html_emptyarg_tl { - \rustex_direct_HTML:n { \c_ampersand_str \c_hash_str 8205; } +\protected\def\stex_par:{\par} + +\cs_new:Nn \rustex_keyvals_do:nn { + #1="#2"~ } -\cs_new_protected:Nn \stex_annotate:nnn { - \_stex_html_checkempty:n { #3 } - \rustex_annotate_HTML:nn { - property="stex:#1" ~ - resource="#2" - } { - \mode_if_vertical:TF{ - \tl_use:N \l_stex_html_arg_tl\stex_par: - }{ - \tl_use:N \l_stex_html_arg_tl - } - } +\tl_const:Nn \c_stex_html_emptyarg_tl { + \mode_if_math:TF{ + \rustex_direct_HTML:n { <mi></mi> } + }{ + \rustex_direct_HTML:n { \c_ampersand_str \c_hash_str 8205; } + } } -\cs_new_protected:Nn \stex_mathml_intent:nn { - \rustex_annotate_HTML:nn { - mml:intent="#1" - }{ #2 } +\cs_new_protected:Nn \_stex_html_checkempty:n { + \tl_if_empty:nTF {#1} { + \c_stex_html_emptyarg_tl + }{ #1 } } -\cs_new_protected:Nn \stex_mathml_arg:nn { - \rustex_annotate_HTML:nn { - mml:arg="#1" - }{ #2 } + +\cs_new_protected:Nn \stex_annotate:nn { + \tl_if_empty:nF{#1}{ + \mode_if_vertical:T{\hbox_unpack:N\c_empty_box} + } + \exp_args:Ne \rustex_annotate_HTML:nn { + \keyval_parse:NNn\TODO\rustex_keyvals_do:nn{#1} + }{ + \_stex_html_checkempty:n { #2 } + } } \cs_new_protected:Nn \stex_annotate_invisible:n { - \_stex_html_checkempty:n { #1 } + \tl_if_eq:nnT{#1}{\stex_annotate_invisible:n}{ + \errmessage{^^J + Illegal~argument~for~HTML~annotation^^J^^J + This~is~likely~due~to~a~missing~argument~ + to~a~semantic~macro~somewhere + } + } \rustex_annotate_HTML:nn { - stex:visible="false" ~ + shtml:visible="false" ~ style:display="none" - } { - \ifmmode\tl_use:N \l_stex_html_arg_tl\else\hbox{\tl_use:N \l_stex_html_arg_tl}\fi + } { + %\mode_if_math:F\hbox{ + \_stex_html_checkempty:n { #1 } + %} } } -\cs_new_protected:Nn \stex_annotate_invisible:nnn { - \_stex_html_checkempty:n { #3 } - \rustex_annotate_HTML:nn { - property="stex:#1" ~ - resource="#2" ~ - stex:visible="false" ~ - style:display="none" - } { - \ifmmode\tl_use:N \l_stex_html_arg_tl\else\hbox{\tl_use:N \l_stex_html_arg_tl}\fi +\cs_new_protected:Nn \stex_annotate_invisible:nn { + \exp_args:Ne \rustex_annotate_HTML:nn { + shtml:visible="false" ~ + style:display="none" ~ + \keyval_parse:NNn\TODO\rustex_keyvals_do:nn{#1} + } { + %\mode_if_math:F\hbox{ + \_stex_html_checkempty:n { #2 } + %} } } -\NewDocumentEnvironment{stex_annotate_env} { m m } { +\NewDocumentEnvironment{stex_annotate_env} { m } { \stex_par: - \rustex_annotate_HTML_begin:n { - property="stex:#1" ~ - resource="#2" + \exp_args:Ne \rustex_annotate_HTML_begin:n { + \keyval_parse:NNn\TODO\rustex_keyvals_do:nn{#1} } }{ \stex_par: \rustex_annotate_HTML_end: } -\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} { +\prg_new_conditional:Nnn \stex_if_html_backend: {p, T, F, TF} { \prg_return_true: }
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg index b4c39b50b70..3f3c21886d1 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg +++ b/Master/texmf-dist/tex/latex/stex/etc/stex-backend-tex4ht.cfg @@ -8,6 +8,6 @@ \cs_new_protected:Nn \stex_annotate_invisible:nnn {} % TODO \NewDocumentEnvironment{stex_annotate_env} { m m } {}{} % TODO -\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} { +\prg_new_conditional:Nnn \stex_if_html_backend: {p, T, F, TF} { \prg_return_true: }
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex-highlighting.sty b/Master/texmf-dist/tex/latex/stex/etc/stex-highlighting.sty new file mode 100644 index 00000000000..0cd04872a12 --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/etc/stex-highlighting.sty @@ -0,0 +1,58 @@ +%\RequirePackage{xcolor} +\RequirePackage{pdfcomment} + +\def\compemph#1{% + \ifcsname textcolor\endcsname + \textcolor{blue}{#1}% + \else + #1% + \fi +} +\def\symrefemph#1{% + \ifcsname textcolor\endcsname + \textcolor{teal}{#1}% + \else#1\fi +} +\def\defemph#1{% + \ifcsname textcolor\endcsname + \textcolor{magenta}{% + \ifmmode + \else\expandafter\textbf + \fi{#1}% + }% + \else + \ifmmode + \else\expandafter\textbf + \fi{#1}% + \fi +} +\def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi} + +\protected\def\compemph@uri#1#2{% + \pdftooltip{% + \srefsymuri{#2}{\compemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% +} +\protected\def\symrefemph@uri#1#2{% + \pdftooltip{% + \srefsymuri{#2}{\symrefemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% + } +\protected\def\defemph@uri#1#2{% + \pdftooltip{% + \defemph{#1}% + }{% + URI:~\detokenize{#2}% + }% +} +\protected\def\varemph@uri#1#2{% + \pdftooltip{% + \varemph{#1}% + }{% + Variable~\detokenize{#2}% + }% +} diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex.cls.ltxml b/Master/texmf-dist/tex/latex/stex/etc/stex.cls.ltxml new file mode 100644 index 00000000000..6915d0db92a --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/etc/stex.cls.ltxml @@ -0,0 +1,10 @@ +package LaTeXML::Package::Pool; +use strict; +use warnings; +use LaTeXML::Package; + +RequirePackage('xparse'); + +InputDefinitions('stex', type => 'cls', noltxml => 1); + +1;
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stex.sty.ltxml b/Master/texmf-dist/tex/latex/stex/etc/stex.sty.ltxml new file mode 100644 index 00000000000..44e30b44c5a --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/etc/stex.sty.ltxml @@ -0,0 +1,23 @@ +package LaTeXML::Package::Pool; +use strict; +use warnings; +use LaTeXML::Package; + +RequirePackage('xparse'); + +DefPrimitive('\csname stex_kpsewhich:Nn\endcsname Token {}',sub { + my ($stomach, $target, $value) = @_; + $value = ToString(Expand($value)); + my $out = ToString(`kpsewhich $value`); + $out =~ s/^\s+//; + $out =~ s/\s+$//; + Note("Here: $value => $out"); + my @ret = Explode($out); + DefMacroI($target, undef, Tokens(@ret)); +},locked=>1); + +\DefMacroI('\stex@backend',undef,Explode("latexml")); + +InputDefinitions('stex', type => 'sty', noltxml => 1); + +1;
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty b/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty index c81b6358dfa..4b89af5b393 100644 --- a/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty +++ b/Master/texmf-dist/tex/latex/stex/etc/stexthm.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage{stexthm}{2022/02/24}{3.0.0}{Default Typesetting for sTeX Statements} +\ProvidesExplPackage{stexthm}{2023/03/19}{3.3.0}{Default Typesetting for sTeX Statements} \RequirePackage{stex} \RequirePackage{amsthm} @@ -6,84 +6,52 @@ \ExplSyntaxOn -\declaretheorem[parent=section]{theorem} -\stexpatchassertion[theorem] -{\ifx\sassertiontitle\@empty\begin{theorem}\else\exp_args:Nno\use:nn{\begin{theorem}[}\sassertiontitle]\fi} -{\end{theorem}} - -\declaretheorem[sibling=theorem]{observation} -\stexpatchassertion[observation] -{\ifx\sassertiontitle\@empty\begin{observation}\else\exp_args:Nno\use:nn{\begin{observation}[}\sassertiontitle]\fi} -{\end{observation}} - -\declaretheorem[sibling=theorem]{corollary} -\stexpatchassertion[corollary] -{\ifx\sassertiontitle\@empty\begin{corollary}\else\exp_args:Nno\use:nn{\begin{corollary}[}\sassertiontitle]\fi} -{\end{corollary}} - -\declaretheorem[sibling=theorem]{lemma} -\stexpatchassertion[lemma] -{\ifx\sassertiontitle\@empty\begin{lemma}\else\exp_args:Nno\use:nn{\begin{lemma}[}\sassertiontitle]\fi} -{\end{lemma}} - -\declaretheorem[sibling=theorem]{axiom} -\stexpatchassertion[axiom] -{\ifx\sassertiontitle\@empty\begin{axiom}\else\exp_args:Nno\use:nn{\begin{axiom}[}\sassertiontitle]\fi} -{\end{axiom}} - -\declaretheorem[sibling=theorem,style=remark]{remark} -\stexpatchassertion[remark] -{\ifx\sassertiontitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sassertiontitle]\fi} -{\end{remark}} -\stexpatchparagraph[remark] -{\ifx\sparagraphtitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sparagraphtitle]\fi} -{\end{remark}} - -\declaretheorem[sibling=theorem,style=definition]{example} -\stexpatchexample -{\ifx\sexampletitle\@empty\begin{example}\else\exp_args:Nno\use:nn{\begin{example}[}\sexampletitle]\fi} -{\end{example}} - -\declaretheorem[sibling=theorem,style=definition]{definition} -\stexpatchdefinition -{\ifx\sdefinitiontitle\@empty\begin{definition}\else\exp_args:Nno\use:nn{\begin{definition}[}\sdefinitiontitle]\fi} - {\end{definition}} - -\ExplSyntaxOff - -\RequirePackage{xcolor} +\cs_new_protected:Nn \_@@_stex_patch_env:nnn { + \cs_if_exist:cF {#1}{ + \declaretheorem[#2]{#1} + } + \clist_map_inline:nn{#3}{ + \use:c{stexstyle##1}[#1]{ + \tl_if_empty:NTF\thistitle{ + \begin{#1} + }{ + \begin{#1}[\thistitle] + } + }{ \end{#1} } + } +} -\def\compemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else#1\fi} -\def\symrefemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else#1\fi} -\def\defemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{\textbf{#1}}\else\textbf{#1}\fi} -\def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi} +\_@@_stex_patch_env:nnn{theorem}{parent=section}{assertion} +\_@@_stex_patch_env:nnn{observation}{sibling=theorem}{assertion} +\_@@_stex_patch_env:nnn{corollary}{sibling=theorem}{assertion} +\_@@_stex_patch_env:nnn{lemma}{sibling=theorem}{assertion} +\_@@_stex_patch_env:nnn{axiom}{sibling=theorem}{assertion} +\_@@_stex_patch_env:nnn{remark}{sibling=theorem}{assertion,paragraph} -\RequirePackage{pdfcomment} -\protected\def\compemph@uri#1#2{% - \pdftooltip{% - \srefsymuri{#2}{\compemph{#1}}% - }{% - URI:~\detokenize{#2}% - }% +\cs_if_exist:cF {example}{ + \declaretheorem[sibling=theorem,style=definition]{example} } -\protected\def\symrefemph@uri#1#2{% - \pdftooltip{% - \srefsymuri{#2}{\symrefemph{#1}}% - }{% - URI:~\detokenize{#2}% - }% - } -\protected\def\defemph@uri#1#2{% - \pdftooltip{% - \defemph{#1}% - }{% - URI:~\detokenize{#2}% - }% +\stexstyleexample{ + \tl_if_empty:NTF\thistitle{ + \begin{example} + }{ + \begin{example}[\thistitle] + } +}{ + \end{example} } -\protected\def\varemph@uri#1#2{% - \pdftooltip{% - \varemph{#1}% - }{% - Variable~\detokenize{#2}% - }% + +\cs_if_exist:cF {definition}{ + \declaretheorem[sibling=theorem,style=definition]{definition} } +\stexstyledefinition{ + \tl_if_empty:NTF\thistitle{ + \begin{definition} + }{ + \begin{definition}[\thistitle] + } +}{ + \end{definition} +} + +\ExplSyntaxOff
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/hwexam.sty b/Master/texmf-dist/tex/latex/stex/hwexam.sty index f7f7e27947b..2492e8db4c2 100644 --- a/Master/texmf-dist/tex/latex/stex/hwexam.sty +++ b/Master/texmf-dist/tex/latex/stex/hwexam.sty @@ -6,289 +6,175 @@ %% %% hwexam.dtx (with options: `package') %% -\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams} +\ProvidesExplPackage{hwexam}{2023/03/19}{3.3.0}{homework assignments and exams} \RequirePackage{l3keys2e} -\newif\iftest\testfalse -\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}} -\newif\ifmultiple\multiplefalse -\DeclareOption{multiple}{\multipletrue} -\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}} -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}} -\ProcessOptions -\RequirePackage{keyval}[1997/11/10] +\keys_define:nn {hwexam / pkg}{ +multiple .default:n = { false }, +multiple .bool_set:N = \c_hwexam_multiple_bool, +unknown .code:n = { +\PassOptionsToPackage{\CurrentOption}{problem} +} +} +\ProcessKeysOptions{ hwexam /pkg } \RequirePackage{problem} -\newcommand\hwexam@assignment@kw{Assignment} -\newcommand\hwexam@given@kw{Given} -\newcommand\hwexam@due@kw{Due} -\newcommand\hwexam@testemptypage@kw{This~page~was~intentionally~left~blank~for~extra~space} -\newcommand\hwexam@minutes@kw{minutes} -\newcommand\correction@probs@kw{prob.} -\newcommand\correction@pts@kw{total} -\newcommand\correction@reached@kw{reached} -\newcommand\correction@sum@kw{Sum} -\newcommand\correction@grade@kw{grade} -\newcommand\correction@forgrading@kw{To~be~used~for~grading,~do~not~write~here} \AddToHook{begindocument}{ +\ExplSyntaxOn\makeatletter +\input{hwexam-english.ldf} \ltx@ifpackageloaded{babel}{ -\makeatletter \clist_set:Nx \l_tmpa_clist {\bbl@loaded} \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ - \input{hwexam-ngerman.ldf} +\input{hwexam-ngerman.ldf} } \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ - \input{hwexam-finnish.ldf} +\input{hwexam-finnish.ldf} } \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ - \input{hwexam-french.ldf} +\input{hwexam-french.ldf} } \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ - \input{hwexam-russian.ldf} +\input{hwexam-russian.ldf} } -\makeatother }{} -} +\makeatother\ExplSyntaxOff +} +\stex_keys_define:nnnn{ assignment }{ + \tl_clear:N \l_stex_key_number_tl +\tl_clear:N \l_stex_key_given_tl +\tl_clear:N \l_stex_key_due_tl +}{ + number .tl_set:N = \l_stex_key_number_tl, + given .tl_set:N = \l_stex_key_given_tl, + due .tl_set:N = \l_stex_key_due_tl, +unknown .code:n = {} +}{id,title,style} \newcounter{assignment} -\keys_define:nn { hwexam / assignment } { -id .str_set_x:N = \l__problems_assign_id_str, -number .int_set:N = \l__problems_assign_number_int, -title .tl_set:N = \l__problems_assign_title_tl, -type .tl_set:N = \l__problems_assign_type_tl, -given .tl_set:N = \l__problems_assign_given_tl, -due .tl_set:N = \l__problems_assign_due_tl, -loadmodules .code:n = { -\bool_set_true:N \l__problems_assign_loadmodules_bool -} -} -\cs_new_protected:Nn \__problems_assignment_args:n { -\str_clear:N \l__problems_assign_id_str -\int_set:Nn \l__problems_assign_number_int {-1} -\tl_clear:N \l__problems_assign_title_tl -\tl_clear:N \l__problems_assign_type_tl -\tl_clear:N \l__problems_assign_given_tl -\tl_clear:N \l__problems_assign_due_tl -\bool_set_false:N \l__problems_assign_loadmodules_bool -\keys_set:nn { hwexam / assignment }{ #1 } -} -\newcommand\given@due[2]{ -\bool_lazy_all:nF { -{\tl_if_empty_p:V \l__problems_inclassign_given_tl} -{\tl_if_empty_p:V \l__problems_assign_given_tl} -{\tl_if_empty_p:V \l__problems_inclassign_due_tl} -{\tl_if_empty_p:V \l__problems_assign_due_tl} -}{ #1 } - -\tl_if_empty:NTF \l__problems_inclassign_given_tl { -\tl_if_empty:NF \l__problems_assign_given_tl { -\hwexam@given@kw\xspace\l__problems_assign_given_tl -} -}{ -\hwexam@given@kw\xspace\l__problems_inclassign_given_tl -} - -\bool_lazy_or:nnF { -\bool_lazy_and_p:nn { -\tl_if_empty_p:V \l__problems_inclassign_due_tl -}{ -\tl_if_empty_p:V \l__problems_assign_due_tl -} -}{ -\bool_lazy_and_p:nn { -\tl_if_empty_p:V \l__problems_inclassign_due_tl -}{ -\tl_if_empty_p:V \l__problems_assign_due_tl -} -}{ ,~ } - -\tl_if_empty:NTF \l__problems_inclassign_due_tl { -\tl_if_empty:NF \l__problems_assign_due_tl { -\hwexam@due@kw\xspace \l__problems_assign_due_tl -} -}{ -\hwexam@due@kw\xspace \l__problems_inclassign_due_tl -} - -\bool_lazy_all:nF { -{ \tl_if_empty_p:V \l__problems_inclassign_given_tl } -{ \tl_if_empty_p:V \l__problems_assign_given_tl } -{ \tl_if_empty_p:V \l__problems_inclassign_due_tl } -{ \tl_if_empty_p:V \l__problems_assign_due_tl } -}{ #2 } -} -\newcommand\assignment@title[3]{ -\tl_if_empty:NTF \l__problems_inclassign_title_tl { -\tl_if_empty:NTF \l__problems_assign_title_tl { -#1 -}{ -#2\l__problems_assign_title_tl#3 -} -}{ -#2\l__problems_inclassign_title_tl#3 -} -} -\newcommand\assignment@number{ -\int_compare:nNnTF \l__problems_inclassign_number_int = {-1} { -\int_compare:nNnTF \l__problems_assign_number_int = {-1} { -\arabic{assignment} -} { -\int_use:N \l__problems_assign_number_int -} -}{ -\int_use:N \l__problems_inclassign_number_int -} -} -\newenvironment{assignment}[1][]{ -\__problems_assignment_args:n { #1 } -\int_compare:nNnTF \l__problems_assign_number_int = {-1} { -\global\stepcounter{assignment} -}{ -\global\setcounter{assignment}{\int_use:N\l__problems_assign_number_int} -} +\stex_new_stylable_env:nnnnnnn {assignment}{O{}}{ + \cs_if_exist:NTF \l_hwexam_includeassignment_keys_tl { + \tl_put_left:Nn \l_hwexam_includeassignment_keys_tl {#1,} + \exp_args:Nno \stex_keys_set:nn{assignment}{ + \l_hwexam_includeassignment_keys_tl + } + }{ + \stex_keys_set:nn{assignment}{#1} + } +\tl_if_empty:NF \l_stex_key_number_tl { +\global\setcounter{assignment}{\int_eval:n{\l_stex_key_number_tl-1}} +} +\global\refstepcounter{assignment} \setcounter{sproblem}{0} -\renewcommand\prob@label[1]{\assignment@number.##1} -\def\current@section@level{\document@hwexamtype} -\begin{@assignment} +\def\thesproblem{\theassignment.\arabic{sproblem}} +\stex_style_apply: +\_stex_do_id: }{ -\end{@assignment} -} -\def\ass@title{ -{\protect\document@hwexamtype}~\arabic{assignment} -\assignment@title{}{\;(}{)\;} -- \given@due{}{} -} -\ifmultiple -\newenvironment{@assignment}{ -\bool_if:NTF \l__problems_assign_loadmodules_bool { -\begin{sfragment}[loadmodules]{\ass@title} +\stex_style_apply: }{ -\begin{sfragment}{\ass@title} +\par\begin{center} +\textbf{\Large\assignmentautorefname~\theassignment +\tl_if_empty:NF \l_stex_key_title_tl { +{~}--~\l_stex_key_title_tl } -}{ -\end{sfragment} +}\par\smallskip +\textbf{ +\tl_if_empty:NF \l_stex_key_given_tl { +\hwexam@kw@given:~\l_stex_key_given_tl\quad } -\else -\newenvironment{@assignment}{ -\begin{center}\bf -\Large\@title\strut\\ -\document@hwexamtype~\arabic{assignment}\assignment@title{\;}{:\;}{\\} -\large\given@due{--\;}{\;--} -\end{center} -}{} -\fi% multiple -\keys_define:nn { hwexam / inclassignment } { -number .int_set:N = \l__problems_inclassign_number_int, -title .tl_set:N = \l__problems_inclassign_title_tl, -type .tl_set:N = \l__problems_inclassign_type_tl, -given .tl_set:N = \l__problems_inclassign_given_tl, -due .tl_set:N = \l__problems_inclassign_due_tl, -mhrepos .str_set_x:N = \l__problems_inclassign_mhrepos_str +\tl_if_empty:NF \l_stex_key_due_tl { +\hwexam@kw@due:~\l_stex_key_due_tl\quad } -\cs_new_protected:Nn \__problems_inclassignment_args:n { -\int_set:Nn \l__problems_inclassign_number_int {-1} -\tl_clear:N \l__problems_inclassign_title_tl -\tl_clear:N \l__problems_inclassign_type_tl -\tl_clear:N \l__problems_inclassign_given_tl -\tl_clear:N \l__problems_inclassign_due_tl -\str_clear:N \l__problems_inclassign_mhrepos_str -\keys_set:nn { hwexam / inclassignment }{ #1 } } -\__problems_inclassignment_args:n {} - -\newcommand\inputassignment[2][]{ -\__problems_inclassignment_args:n { #1 } -\str_if_empty:NTF \l__problems_inclassign_mhrepos_str { -\input{#2} +\end{center} +\par\bigskip }{ -\stex_in_repository:nn{\l__problems_inclassign_mhrepos_str}{ -\input{\mhpath{\l__problems_inclassign_mhrepos_str}{#2}} -} -} -\__problems_inclassignment_args:n {} -} -\newcommand\includeassignment[2][]{ -\newpage -\inputassignment[#1]{#2} +\par\pagebreak +}{} +\NewDocumentCommand\includeassignment{O{} m}{ +\group_begin: +\tl_set:Nn \l_hwexam_includeassignment_keys_tl {#1} +\stex_keys_set:nn{includeproblem}{#1} +\exp_args:Nno \use:nn{\inputref[}\l_stex_key_mhrepos_str]{#2} +\group_end: +} +\prop_new:N \c__problems_problems_prop +\tl_set:Nn \c__problems_total_mins_tl {0} +\tl_set:Nn \c__problems_total_pts_tl {0} +\int_new:N \c__problems_total_problems_int +\cs_set_protected:Npn \problem@restore #1 #2 #3 { +\int_gincr:N \c__problems_total_problems_int +\prop_gput:Nnn \c__problems_problems_prop {#1}{{#2}{#3}} +\tl_gset:Nx \c__problems_total_pts_tl { \int_eval:n { \c__problems_total_pts_tl + #2 }} +\tl_gset:Nx \c__problems_total_mins_tl { \int_eval:n { \c__problems_total_mins_tl + #2 }} } -\ExplSyntaxOff -\newcommand\quizheading[1]{% -\def\@tas{#1}% -\large\noindent NAME: \hspace{8cm} MAILBOX:\\[2ex]% -\ifx\@tas\@empty\else% -\noindent TA:~\@for\@I:=\@tas\do{{\Large$\Box$}\@I\hspace*{1em}}\\[2ex]% -\fi% +\newcommand\correction@table{ +\int_compare:nNnT \c__problems_total_problems_int = 0 { +\int_incr:N \c__problems_total_problems_int +\prop_put:Nnn \c__problems_problems_prop {~}{{~}{~}} +} +\tl_clear:N \l_tmpa_tl +\tl_clear:N \l_tmpb_tl +\tl_clear:N \l_tmpc_tl +\prop_map_inline:Nn \c__problems_problems_prop { +\tl_put_right:Nn \l_tmpa_tl { ##1 & } +\tl_put_right:Nx \l_tmpb_tl { \use_i:nn ##2 & } +\tl_put_right:Nn \l_tmpc_tl { & } } -\ExplSyntaxOn - +\resizebox{\textwidth}{!}{% +\exp_args:Nne \begin{tabular}{|l|*{\int_use:N \c__problems_total_problems_int}{c|}c||l|}\hline +&\exp_args:Ne \multicolumn{\int_eval:n{ \c__problems_total_problems_int + 1}}{c||} +{\footnotesize\hwexam@kw@forgrading} &\\\hline +\hwexam@kw@probs & \l_tmpa_tl \hwexam@kw@sum & \hwexam@kw@grade\\\hline +\hwexam@kw@pts & \l_tmpb_tl \c__problems_total_pts_tl & \\\hline +\hwexam@kw@reached & \l_tmpc_tl & \\[.7cm]\hline +\end{tabular}}} \def\hwexamheader{\input{hwexam-default.header}} \def\hwexamminutes{ -\tl_if_empty:NTF \testheading@duration { -{\testheading@min}~\hwexam@minutes@kw +\tl_if_empty:NTF \hwexam@duration { +{\hwexam@min}~\hwexam@minutes@kw }{ -\testheading@duration +\hwexam@duration } } -\keys_define:nn { hwexam / testheading } { -min .tl_set:N = \testheading@min, -duration .tl_set:N = \testheading@duration, -reqpts .tl_set:N = \testheading@reqpts, -tools .tl_set:N = \testheading@tools -} -\cs_new_protected:Nn \__problems_testheading_args:n { -\tl_clear:N \testheading@min -\tl_clear:N \testheading@duration -\tl_clear:N \testheading@reqpts -\tl_clear:N \testheading@tools -\keys_set:nn { hwexam / testheading }{ #1 } -} +\stex_keys_define:nnnn{ hwexam / testheading }{ +\tl_clear:N \hwexam@min +\tl_clear:N \hwexam@duration +\tl_clear:N \hwexam@reqpts +\tl_clear:N \hwexam@tools +}{ +min .tl_set:N = \hwexam@min, +duration .tl_set:N = \hwexam@duration, +reqpts .tl_set:N = \hwexam@reqpts, +tools .tl_set:N = \hwexam@tools +}{} + \newenvironment{testheading}[1][]{ -\__problems_testheading_args:n{ #1 } -\newcount\check@time\check@time=\testheading@min -\advance\check@time by -\theassignment@totalmin +\stex_keys_set:nn { hwexam / testheading}{#1} + +\tl_set_eq:NN \hwexam@totalpts \c__problems_total_pts_tl +\tl_set_eq:NN \hwexam@totalmin \c__problems_total_mins_tl +\tl_set:Nx \hwexam@checktime {\int_eval:n { \hwexam@min - \hwexam@totalmin }} + \newif\if@bonuspoints -\tl_if_empty:NTF \testheading@reqpts { +\tl_if_empty:NTF \hwexam@reqpts { \@bonuspointsfalse }{ -\newcount\bonus@pts -\bonus@pts=\theassignment@totalpts -\advance\bonus@pts by -\testheading@reqpts -\edef\bonus@pts{\the\bonus@pts} +\tl_set:Nx \hwexam@bonuspts { +\int_eval:n{\hwexam@totalpts - \hwexam@reqpts} +} \@bonuspointstrue } -\edef\check@time{\the\check@time} \makeatletter\hwexamheader\makeatother }{ \newpage } -\renewcommand\@problem[3]{ -\stepcounter{assignment@probs} -\def\__problemspts{#2} -\ifx\__problemspts\@empty\else -\addtocounter{assignment@totalpts}{#2} -\fi -\def\__problemsmin{#3}\ifx\__problemsmin\@empty\else\addtocounter{assignment@totalmin}{#3}\fi -\xdef\correction@probs{\correction@probs & #1}% -\xdef\correction@pts{\correction@pts & #2} -\xdef\correction@reached{\correction@reached &} +\newcommand\testemptypage[1][]{% +\bool_if:NT \c__problems_test_bool {\ \vfill\begin{center}\hwexam@kw@testemptypage\end{center}\eject} } -\newcounter{assignment@probs} -\newcounter{assignment@totalpts} -\newcounter{assignment@totalmin} -\def\correction@probs{\correction@probs@kw} -\def\correction@pts{\correction@pts@kw} -\def\correction@reached{\correction@reached@kw} -\stepcounter{assignment@probs} -\newcommand\correction@table{ -\resizebox{\textwidth}{!}{% -\begin{tabular}{|l|*{\theassignment@probs}{c|}|l|}\hline% -&\multicolumn{\theassignment@probs}{c||}%| -{\footnotesize\correction@forgrading@kw} &\\\hline -\correction@probs & \correction@sum@kw & \correction@grade@kw\\\hline -\correction@pts &\theassignment@totalpts & \\\hline -\correction@reached & & \\[.7cm]\hline -\end{tabular}}} +\newcommand\testspace[1]{\bool_if:NT \c__problems_test_bool {\vspace*{#1}}} +\newcommand\testnewpage{\bool_if:NT \c__problems_test_bool {\newpage}} \endinput %% %% End of file `hwexam.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/img/stex-experimental.png b/Master/texmf-dist/tex/latex/stex/img/stex-experimental.png Binary files differnew file mode 100644 index 00000000000..10435e8dbf4 --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/img/stex-experimental.png diff --git a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-english.ldf b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-english.ldf new file mode 100644 index 00000000000..e6c4e138859 --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-english.ldf @@ -0,0 +1,11 @@ +\tl_set:Nn\assignmentautorefname{Assignment} +\tl_set:Nn\hwexam@kw@given{Given} +\tl_set:Nn\hwexam@kw@due{Due} +\tl_set:Nn\hwexam@kw@testemptypage{This~page~was~intentionally~left~blank~for~extra~space} +\tl_set:Nn\hwexam@minutes@kw{minutes} +\tl_set:Nn\hwexam@kw@probs{prob.} +\tl_set:Nn\hwexam@kw@pts{total} +\tl_set:Nn\hwexam@kw@reached{reached} +\tl_set:Nn\hwexam@kw@sum{Sum} +\tl_set:Nn\hwexam@kw@grade{grade} +\tl_set:Nn\hwexam@kw@forgrading{To~be~used~for~grading,~do~not~write~here}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-finnish.ldf b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-finnish.ldf index 92454d2b2c2..9b465e674a6 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-finnish.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-finnish.ldf @@ -7,15 +7,13 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsfinnish{ -\def\hwexam@assignment@kw{Kotitehtävä} -\def\hwexam@given@kw{Annettu} -\def\hwexam@due@kw{Palautettava} -\def\correction@forgrading@kw{Käytetään arvosteluun, älä kirjoita tähän!} -\def\hwexam@testemptypage@kw{Tämä sivu on tarkoituksellisesti tyhjä} -\def\correction@probs@kw{Tehtävä}% -\def\correction@pts@kw{Maksimi}% -\def\correction@reached@kw{Pisteet}% -\def\correction@sum@kw{Summa}% -\def\correction@grade@kw{Arvosana}% -} +\tl_set:Nn\assignmentautorefname{Kotitehtävä} +\tl_set:Nn\hwexam@given@kw{Annettu} +\tl_set:Nn\hwexam@due@kw{Palautettava} +\tl_set:Nn\correction@forgrading@kw{Käytetään~arvosteluun,~älä~kirjoita~tähän!} +\tl_set:Nn\hwexam@testemptypage@kw{Tämä~sivu~on~tarkoituksellisesti~tyhjä} +\tl_set:Nn\correction@probs@kw{Tehtävä}% +\tl_set:Nn\correction@pts@kw{Maksimi}% +\tl_set:Nn\correction@reached@kw{Pisteet}% +\tl_set:Nn\correction@sum@kw{Summa}% +\tl_set:Nn\correction@grade@kw{Arvosana}%
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-french.ldf b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-french.ldf index 23992740cda..cc79e4c916b 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-french.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-french.ldf @@ -7,15 +7,13 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsfrench{ -\def\hwexam@assignment@kw{Devoir} -\def\hwexam@given@kw{Distribué} -\def\hwexam@due@kw{À rendre} -\def\correction@forgrading@kw{Réservé pour la correction} -\def\hwexam@testemptypage@kw{Page laissée blanche exprès} -\def\correction@probs@kw{Pb}% -\def\correction@pts@kw{pt}% -\def\correction@reached@kw{Score}% -\def\correction@sum@kw{Total}% -\def\correction@grade@kw{Note}% -} +\tl_set:Nn\assignmentautorefname{Devoir} +\tl_set:Nn\hwexam@given@kw{Distribué} +\tl_set:Nn\hwexam@due@kw{À~rendre} +\tl_set:Nn\correction@forgrading@kw{Réservé~pour~la~correction} +\tl_set:Nn\hwexam@testemptypage@kw{Page~laissée~blanche~exprès} +\tl_set:Nn\correction@probs@kw{Pb}% +\tl_set:Nn\correction@pts@kw{pt}% +\tl_set:Nn\correction@reached@kw{Score}% +\tl_set:Nn\correction@sum@kw{Total}% +\tl_set:Nn\correction@grade@kw{Note}% diff --git a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-ngerman.ldf b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-ngerman.ldf index 31af25aba81..04116d6dfa1 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-ngerman.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-ngerman.ldf @@ -6,16 +6,14 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsngerman{ -\def\hwexam@assignment@kw{Hausaufgabe} -\def\hwexam@given@kw{Ausgegeben} -\def\hwexam@due@kw{Abgabetermin} -\def\hwexam@minutes@kw{Minuten} -\def\correction@forgrading@kw{Nur zur Korrektur, bitte freilassen!} -\def\hwexam@testemptypage@kw{Diese Seite wurde für mehr Platz absichtlich leer gelassen.} -\def\correction@probs@kw{Aufgabe}% -\def\correction@pts@kw{M\"oglich}% -\def\correction@reached@kw{Erreicht}% -\def\correction@sum@kw{Summe}% -\def\correction@grade@kw{Note}% -} +\tl_set:Nn\assignmentautorefname{Hausaufgabe} +\tl_set:Nn\hwexam@given@kw{Ausgegeben} +\tl_set:Nn\hwexam@due@kw{Abgabetermin} +\tl_set:Nn\hwexam@minutes@kw{Minuten} +\tl_set:Nn\correction@forgrading@kw{Nur~zur~Korrektur,~bitte~freilassen!} +\tl_set:Nn\hwexam@testemptypage@kw{Diese~Seite~wurde~für~mehr~Platz~absichtlich~leer~gelassen.} +\tl_set:Nn\correction@probs@kw{Aufgabe}% +\tl_set:Nn\correction@pts@kw{M\"oglich}% +\tl_set:Nn\correction@reached@kw{Erreicht}% +\tl_set:Nn\correction@sum@kw{Summe}% +\tl_set:Nn\correction@grade@kw{Note}%
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-russian.ldf b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-russian.ldf index 6da7c9e8cb9..2edd2305731 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/hwexam-russian.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/hwexam-russian.ldf @@ -6,15 +6,13 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsrussian{ -\def\hwexam@assignment@kw{Домашнее задание} -\def\hwexam@given@kw{Дано} -\def\hwexam@due@kw{Дата сдачи} -\def\correction@forgrading@kw{Для исправлений. Пожалуйста, оставьте свободное место!} -\def\hwexam@testemptypage@kw{Эта страница преднамеренно оставлена пустой для дополнительных записей.} -\def\correction@probs@kw{Задание}% -\def\correction@pts@kw{Максимальный балл}% -\def\correction@reached@kw{Ваш балл}% -\def\correction@sum@kw{Общий балл}% -\def\correction@grade@kw{Отметка}% -} +\tl_set:Nn\assignmentautorefname{Домашнее~задание} +\tl_set:Nn\hwexam@given@kw{Дано} +\tl_set:Nn\hwexam@due@kw{Дата~сдачи} +\tl_set:Nn\correction@forgrading@kw{Для~исправлений.~Пожалуйста,~оставьте~свободное~место!} +\tl_set:Nn\hwexam@testemptypage@kw{Эта~страница~преднамеренно~оставлена~пустой~для~дополнительных~записей.} +\tl_set:Nn\correction@probs@kw{Задание}% +\tl_set:Nn\correction@pts@kw{Максимальный~балл}% +\tl_set:Nn\correction@reached@kw{Ваш~балл}% +\tl_set:Nn\correction@sum@kw{Общий~балл}% +\tl_set:Nn\correction@grade@kw{Отметка}% diff --git a/Master/texmf-dist/tex/latex/stex/ldf/problem-english.ldf b/Master/texmf-dist/tex/latex/stex/ldf/problem-english.ldf new file mode 100644 index 00000000000..bd202814e60 --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/ldf/problem-english.ldf @@ -0,0 +1,9 @@ +\tl_set:Nn \sproblemautorefname{Problem} +\tl_set:Nn \problem@kw@solution{Solution} +\tl_set:Nn \problem@kw@hint{Hint} +\tl_set:Nn \problem@kw@note{Note} +\tl_set:Nn \problem@kw@grading{Grading} +\tl_set:Nn \problem@kw@points{pt} +\tl_set:Nn \problem@kw@minutes{min} +\tl_set:Nn \problem@kw@correct{Correct} +\tl_set:Nn \problem@kw@wrong{Wrong}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/ldf/problem-finnish.ldf b/Master/texmf-dist/tex/latex/stex/ldf/problem-finnish.ldf index 3619f283a02..11fc490c4a5 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/problem-finnish.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/problem-finnish.ldf @@ -7,7 +7,12 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsfinnish{ -\def\prob@problem@kw{Tehtävä} -\def\prob@solution@kw{Ratkaisu} -} +\tl_set:Nn \sproblemautorefname{Tehtävä} +\tl_set:Nn \problem@kw@solution{Ratkaisu} +\tl_set:Nn \problem@kw@hint{Hint} +\tl_set:Nn \problem@kw@note{Note} +\tl_set:Nn \problem@kw@grading{Grading} +\tl_set:Nn \problem@kw@points{pt} +\tl_set:Nn \problem@kw@minutes{min} +\tl_set:Nn \problem@kw@correct{Correct} +\tl_set:Nn \problem@kw@wrong{Wrong} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/problem-french.ldf b/Master/texmf-dist/tex/latex/stex/ldf/problem-french.ldf index 80d577c4813..bdcae874b25 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/problem-french.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/problem-french.ldf @@ -7,7 +7,12 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsfrench{ -\def\prob@problem@kw{Problème} -\def\prob@solution@kw{Solution} -} +\tl_set:Nn \sproblemautorefname{Problème} +\tl_set:Nn \problem@kw@solution{Solution} +\tl_set:Nn \problem@kw@hint{Hint} +\tl_set:Nn \problem@kw@note{Note} +\tl_set:Nn \problem@kw@grading{Grading} +\tl_set:Nn \problem@kw@points{pt} +\tl_set:Nn \problem@kw@minutes{min} +\tl_set:Nn \problem@kw@correct{Correct} +\tl_set:Nn \problem@kw@wrong{Wrong} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf b/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf index 6cadab08509..07475557833 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/problem-ngerman.ldf @@ -6,14 +6,13 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsngerman{ -\def\prob@problem@kw{Aufgabe} -\def\prob@solution@kw{Lösung} -\def\prob@hint@kw{Hinweis} -\def\prob@note@kw{Bemerkung} -\def\prob@note@kw{Bewertung} -\def\prob@pt@kw{Pkt} -\def\prob@min@kw{Min} -\def\prob@correct@kw{Korrekt} -\def\prob@wrong@kw{Falsch} -} +\tl_set:Nn \sproblemautorefname{Aufgabe} +\tl_set:Nn \problem@kw@solution{Lösung} +\tl_set:Nn \problem@kw@hint{Hinweis} +\tl_set:Nn \problem@kw@note{Bemerkung} +\tl_set:Nn \problem@kw@grading{Bewertung} +\tl_set:Nn \problem@kw@points{Pkt} +\tl_set:Nn \problem@kw@minutes{Min} +\tl_set:Nn \problem@kw@correct{Korrekt} +\tl_set:Nn \problem@kw@wrong{Falsch} + diff --git a/Master/texmf-dist/tex/latex/stex/ldf/problem-russian.ldf b/Master/texmf-dist/tex/latex/stex/ldf/problem-russian.ldf index d27d8ffabc3..f0a08c77616 100644 --- a/Master/texmf-dist/tex/latex/stex/ldf/problem-russian.ldf +++ b/Master/texmf-dist/tex/latex/stex/ldf/problem-russian.ldf @@ -6,11 +6,12 @@ % The original of this file is in the public repository at % http://github.com/sLaTeX/sTeX/ -\g@addto@macro\captionsrussian{ -\def\prob@problem@kw{Задание} -\def\prob@solution@kw{Решение} -\def\prob@hint@kw{Подсказка} -\def\prob@note@kw{Примечание} -\def\prob@pt@kw{бл} -\def\prob@min@kw{мин} -} +\tl_set:Nn \sproblemautorefname{Задание} +\tl_set:Nn \problem@kw@solution{Решение} +\tl_set:Nn \problem@kw@hint{Подсказка} +\tl_set:Nn \problem@kw@note{Примечание} +\tl_set:Nn \problem@kw@grading{Grading} +\tl_set:Nn \problem@kw@points{бл} +\tl_set:Nn \problem@kw@minutes{мин} +\tl_set:Nn \problem@kw@correct{Correct} +\tl_set:Nn \problem@kw@wrong{Wrong}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/ldf/sproof-finnish.ldf b/Master/texmf-dist/tex/latex/stex/ldf/sproof-finnish.ldf deleted file mode 100644 index 3ab1f02690c..00000000000 --- a/Master/texmf-dist/tex/latex/stex/ldf/sproof-finnish.ldf +++ /dev/null @@ -1,14 +0,0 @@ -% Finnish Language Bindings for the sTeX sproof package -% Translations thanks to Jukka Kohonen <jukka.kohonen@aalto.fi> -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ - -\g@addto@macro\captionsfinnish{ -\def\spf@proofsketch@kw{Todistusidea} -\def\spf@proof@kw{Todistus} -\def\spf@step@kw{Askel} -} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/sproof-french.ldf b/Master/texmf-dist/tex/latex/stex/ldf/sproof-french.ldf deleted file mode 100644 index 8425e0d4a84..00000000000 --- a/Master/texmf-dist/tex/latex/stex/ldf/sproof-french.ldf +++ /dev/null @@ -1,14 +0,0 @@ -% French Language Bindings for the sTeX sproof package -% Translations thanks to Samuel Lelièvre <samuel.lelievre@gmail.com> -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ - -\g@addto@macro\captionsfrench{ -\def\spf@proofsketch@kw{Esquisse de démonstration} -\def\spf@proof@kw{Démonstration} -\def\spf@step@kw{Étape} -} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/sproof-ngerman.ldf b/Master/texmf-dist/tex/latex/stex/ldf/sproof-ngerman.ldf deleted file mode 100644 index 5bd1024ebab..00000000000 --- a/Master/texmf-dist/tex/latex/stex/ldf/sproof-ngerman.ldf +++ /dev/null @@ -1,13 +0,0 @@ -% German Language Bindings for the sTeX sproof package -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ - -\g@addto@macro\captionsngerman{ -\def\spf@proofsketch@kw{Beweisskizze} -\def\spf@proof@kw{Beweis} -\def\spf@step@kw{Schritt} -} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/sproof-russian.ldf b/Master/texmf-dist/tex/latex/stex/ldf/sproof-russian.ldf deleted file mode 100644 index 314cee130b2..00000000000 --- a/Master/texmf-dist/tex/latex/stex/ldf/sproof-russian.ldf +++ /dev/null @@ -1,13 +0,0 @@ -% Russian Language Bindings for the sTeX sproof package -% Copyright (c) 2019 Michael Kohlhase, all rights reserved -% this file is released under the -% LaTeX Project Public License (LPPL) -% -% The original of this file is in the public repository at -% http://github.com/sLaTeX/sTeX/ - -\g@addto@macro\captionsrussian{ -\def\spf@proofsketch@kw{Набросок доказательства} -\def\spf@proof@kw{Доказательство} -\def\spf@step@kw{Шаг} -} diff --git a/Master/texmf-dist/tex/latex/stex/ldf/stex-en.ldf b/Master/texmf-dist/tex/latex/stex/ldf/stex-en.ldf new file mode 100644 index 00000000000..1501a92c826 --- /dev/null +++ b/Master/texmf-dist/tex/latex/stex/ldf/stex-en.ldf @@ -0,0 +1,134 @@ +\msg_set:nnn{stex}{error/unknownlanguage}{ + Unknown~language:~#1 +} +\msg_set:nnn{stex}{warning/nomathhub}{ + MATHHUB~system~variable~not~found~and~no~ + \tl_to_str:n{\mathhub}-value~set! +} +\msg_set:nnn{stex}{error/deactivated-macro}{ + The~\tl_to_str:n{#1}~command~is~only~allowed~in~#2! +} +\msg_set:nnn{stex}{error/metagroup/missing}{ + No~metagroup~by~ID~#1 +} +\msg_set:nnn{stex}{error/noarchive}{ + No~archive~#1~found~in~#2 +} +\msg_set:nnn{stex}{error/notinarchive}{ + Not~currently~in~an~archive,~but~\tl_to_str:n{#1}~ + needs~one! +} +\msg_set:nnn{stex}{error/nofile}{ + \tl_to_str:n{#1}~could~not~find~file~#2 +} +\msg_set:nnn{stex}{error/twofiles}{ + \tl_to_str:n{#1}~found~two~candidates~for~#2 +} +\msg_set:nnn{stex}{error/invalid-uri}{ + Invalid~URI:~#1~(#2) +} +\msg_set:nnn{stex}{error/misused-uri}{ + Misused~URI:~#1 +} +\msg_set:nnn{stex}{error/invalid-dpath}{ + Not~a~namespace~URI:~#1 +} +\msg_set:nnn{stex}{error/extrefmissing}{ + Missing~in~or~cite~value~for~\detokenize{\extref}! +} +\msg_set:nnn{stex}{warning/smsmissing}{ + .sref~file~#1~doesn't~exist! +} +\msg_set:nnn{stex}{warning/smslabelmissing}{ + No~label~#2~in~.sref~file~#1! +} +\msg_set:nnn{stex}{error/unknownmodule}{ + No~module~#1~found +} +\msg_set:nnn{stex}{error/unknownstructure}{ + No~mathstructure~#1~found +} +\msg_set:nnn{stex}{error/syntax}{ + Syntax~error:~#1 +} +\msg_set:nnn{stex}{error/siglanguage}{ + Module~#1~declares~signature~#2,~but~does~not~ + declare~its~language +} +\msg_set:nnn{stex}{warning/deprecated}{ + #1~is~deprecated;~please~use~#2~instead! +} +\msg_set:nnn{stex}{error/conflictingmodules}{ + Conflicting~imports~for~module~#1 +} +\msg_set:nnn{stex}{error/misused-importmodule}{ + Misused~Importmodule~statement:~#1 +} +\msg_set:nnn{stex}{error/wrongargs}{ + args~value~in~symbol~declaration~for~#1~ + needs~to~be~i,~a,~b~or~B,~but~#2~given +} +\msg_set:nnn{stex}{error/unknownsymbol}{ + No~symbol~#1~found! +} +\msg_set:nnn{stex}{error/seqlength}{ + Expected~#1~arguments;~got~#2! +} +\msg_set:nnn{stex}{error/unknownnotation}{ + Unknown~notation~#1~for~#2! +} +\msg_set:nnn{stex}{error/nonotation}{ + Symbol~#1~invoked,~but~has~no~notation#2! +} +\msg_set:nnn{stex}{error/notationarg}{ + Error~in~parsing~notation~#1 +} +\msg_set:nnn{stex}{error/noop}{ + Symbol~#1~has~no~operator~notation~for~notation~#2 +} +\msg_set:nnn{stex}{error/notallowed}{ + Symbol~invokation~#1~not~allowed~in~notation~component~of~#2 +} +\msg_set:nnn{stex}{error/doubleargument}{ + Argument~#1~of~symbol~#2~already~assigned +} +\msg_set:nnn{stex}{error/overarity}{ + Argument~#1~invalid~for~symbol~#2~with~arity~#3 +} +\msg_set:nnn{stex}{error/notikz}{ + #1~requires~tikz~to~be~loaded +} +\msg_set:nnn{stex}{error/unknownsymbolin}{ + No~symbol~#1~found~in~#2! +} +\msg_set:nnn{stex}{error/symbolalreadydefined}{ + Symbol~#1~in~#2~already~defined! +} +\msg_set:nnn{stex}{error/assocarg}{ + First~argument~of~#1~needs~to~be~an~a-mode~or~B-mode~argument +} +\msg_set:nnn{stex}{error/invalidarg}{ + Invalid~argument~#1~(already~provided~or~does~not~exist~ + for~#2) +} +\msg_set:nnn{stex}{error/needsdefiniens}{ + Symbol~#1~needs~to~be~defined~in~#2 +} +\msg_set:nnn{stex}{error/unknownfield}{ + mathstructure~(instance)~has~no~component~"#1" +} +\msg_set:nnn{stex}{error/unknownfieldass}{ + mathstructure~has~no~component~"#1";~can~not~assign +} +\msg_set:nnn{stex}{error/definiensfor}{ + \definiens~macro:~unclear~which~symbol~is~being~defined +} +\msg_set:nnn{stex}{error/conclusionfor}{ + \conclusion~macro:~unclear~which~assertion~is~being~concluded +} +\msg_set:nnn{stex}{error/nomorphism}{ + No~morphism~#1~found~in~domain~of~morphism +} +\str_set:Nn \spfsketchenvautorefname {Proof~sketch} +\str_set:Nn \sproofautorefname {Proof} +\str_set:Nn \spfstepautorefname {Proof~step}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/stex/notesslides.cls b/Master/texmf-dist/tex/latex/stex/notesslides.cls index 9de67664bfb..bff44ffc3a2 100644 --- a/Master/texmf-dist/tex/latex/stex/notesslides.cls +++ b/Master/texmf-dist/tex/latex/stex/notesslides.cls @@ -6,60 +6,47 @@ %% %% notesslides.dtx (with options: `cls') %% -\ProvidesExplClass{notesslides}{2022/09/14}{3.2.0}{notesslides Class} +\ProvidesExplClass{notesslides}{2023/03/19}{3.3.0}{notesslides Class} \RequirePackage{l3keys2e} +\str_const:Nn \c__notesslides_class_str {article} + \keys_define:nn{notesslides / cls}{ class .str_set_x:N = \c__notesslides_class_str, - notes .bool_set:N = \c__notesslides_notes_bool , - slides .code:n = { \bool_set_false:N \c__notesslides_notes_bool }, - docopt .str_set_x:N = \c__notesslides_docopt_str, + notes .bool_set:N = \c_notesslides_notes_bool , + slides .code:n = { \bool_set_false:N \c_notesslides_notes_bool }, + %docopt .str_set_x:N = \c__notesslides_docopt_str, unknown .code:n = { - \PassOptionsToPackage{\CurrentOption}{document-structure} \PassOptionsToClass{\CurrentOption}{beamer} + \PassOptionsToClass{\CurrentOption}{\c__notesslides_class_str} \PassOptionsToPackage{\CurrentOption}{notesslides} \PassOptionsToPackage{\CurrentOption}{stex} } } \ProcessKeysOptions{ notesslides / cls } -\str_if_empty:NF \c__notesslides_class_str { - \PassOptionsToPackage{class=\c__notesslides_class_str}{document-structure} -} - -\exp_args:No \str_if_eq:nnT\c__notesslides_class_str{book}{ - \PassOptionsToPackage{defaulttopsect=part}{notesslides} -} -\exp_args:No \str_if_eq:nnT\c__notesslides_class_str{report}{ - \PassOptionsToPackage{defaulttopsect=part}{notesslides} -} - \RequirePackage{stex} -\stex_html_backend:T { - \bool_set_true:N\c__notesslides_notes_bool +\stex_if_html_backend:T { + \bool_set_true:N\c_notesslides_notes_bool } -\bool_if:NTF \c__notesslides_notes_bool { +\bool_if:NTF \c_notesslides_notes_bool { \PassOptionsToPackage{notes=true}{notesslides} - \message{notesslides.cls:~Formatting~course~materials~in~notes~mode} + \message{notesslides.cls:~Formatting~document~in~notes~mode} }{ \PassOptionsToPackage{notes=false}{notesslides} - \message{notesslides.cls:~Formatting~course~materials~in~slides~mode} + \message{notesslides.cls:~Formatting~document~in~slides~mode} } -\bool_if:NTF \c__notesslides_notes_bool { - \str_if_empty:NT \c__notesslides_class_str { - \str_set:Nn \c__notesslides_class_str {article} - } - \exp_after:wN\LoadClass\exp_after:wN[\c__notesslides_docopt_str] - {\c__notesslides_class_str} + +\bool_if:NTF \c_notesslides_notes_bool { + \LoadClass{\c__notesslides_class_str} }{ \LoadClass[10pt,notheorems,xcolor={dvipsnames,svgnames}]{beamer} - \newcounter{Item} - \newcounter{paragraph} - \newcounter{subparagraph} - \newcounter{Hfootnote} + %\newcounter{Item} + %\newcounter{paragraph} + %\newcounter{subparagraph} + %\newcounter{Hfootnote} } -\RequirePackage{document-structure} \RequirePackage{notesslides} \endinput %% diff --git a/Master/texmf-dist/tex/latex/stex/notesslides.sty b/Master/texmf-dist/tex/latex/stex/notesslides.sty index 3d853b27552..796f1cd718b 100644 --- a/Master/texmf-dist/tex/latex/stex/notesslides.sty +++ b/Master/texmf-dist/tex/latex/stex/notesslides.sty @@ -6,459 +6,415 @@ %% %% notesslides.dtx (with options: `package') %% -\ProvidesExplPackage{notesslides}{2022/09/14}{3.2.0}{notesslides Package} +\ProvidesExplPackage{notesslides}{2023/03/19}{3.3.0}{notesslides Package} \RequirePackage{l3keys2e} \keys_define:nn{notesslides / pkg}{ - topsect .str_set_x:N = \c__notesslides_topsect_str, - defaulttopsect .str_set_x:N = \c__notesslides_defaulttopsec_str, - notes .bool_set:N = \c__notesslides_notes_bool , - slides .code:n = { \bool_set_false:N \c__notesslides_notes_bool }, - sectocframes .bool_set:N = \c__notesslides_sectocframes_bool , - frameimages .bool_set:N = \c__notesslides_frameimages_bool , - fiboxed .bool_set:N = \c__notesslides_fiboxed_bool , - noproblems .bool_set:N = \c__notesslides_noproblems_bool, + notes .bool_set:N = \c_notesslides_notes_bool , + slides .code:n = { \bool_set_false:N \c_notesslides_notes_bool }, + sectocframes .bool_set:N = \c_notesslides_sectocframes_bool , + topsect .str_set_x:N = \c_notesslides_topsect_str, unknown .code:n = { - \PassOptionsToClass{\CurrentOption}{stex} - \PassOptionsToClass{\CurrentOption}{tikzinput} + \PassOptionsToPackage{\CurrentOption}{stex} + \PassOptionsToPackage{\CurrentOption}{tikzinput} } } \ProcessKeysOptions{ notesslides / pkg } \RequirePackage{stex} -\stex_html_backend:T { - \bool_set_true:N\c__notesslides_notes_bool +\stex_if_html_backend:T { + \bool_set_true:N\c_notesslides_notes_bool +} + +\cs_set:Npn \sectiontitleemph #1 { + \textbf{\Large #1} } \newif\ifnotes -\bool_if:NTF \c__notesslides_notes_bool { +\bool_if:NTF \c_notesslides_notes_bool { \notestrue + \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor} + \RequirePackage[noamsthm,hyperref]{beamerarticle} + \RequirePackage{mdframed} + \str_if_empty:NTF \c_notesslides_topsect_str{ + %\setsectionlevel{section} + } { + \exp_args:No \setsectionlevel \c_notesslides_topsect_str + } }{ \notesfalse + + \cs_new_protected:Nn \__notesslides_do_sectocframes: { + \cs_set_protected:Nn \__notesslides_do_label:n { + \str_case:nnF{##1}{ + {part} { + \tl_set:Nx\l__notesslides_num{\thepart} + \tl_set:cx{@ @ label}{ + \cs_if_exist:NTF\parttitlename{\exp_not:N\parttitlename}{\exp_not:N\partname}{}~\l__notesslides_num\\} + } + {chapter} { + \tl_set:Nx\l__notesslides_num{\thechapter} + \tl_set:cx{@ @ label}{ + \cs_if_exist:NTF\chaptertitlename{\exp_not:N\chaptertitlename}{\exp_not:N\chaptername}{}~\l__notesslides_num\\} + } + {section} { + \tl_set:Nx\l__notesslides_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection} + \tl_set:cx{@ @ label}{\l__notesslides_num\quad} + } + {subsection} { + \tl_set:Nx\l__notesslides_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection} + \tl_set:cx{@ @ label}{\l__notesslides_num\quad} + } + {subsubsection} { + \tl_set:Nx\l__notesslides_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection} + \tl_set:cx{@ @ label}{\l__notesslides_num\quad} + } + {paragraph} { + \tl_set:Nx\l__notesslides_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph} + \tl_set:cx{@ @ label}{\l__notesslides_num\quad} + } + }{ + \tl_set:Nx\l__notesslides_num{\cs_if_exist:NT\thechapter{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph.\thesubparagraph} + \tl_set:cx{@ @ label}{\l__notesslides_num\quad} + } + } + \cs_set_protected:Nn \_sfragment_do_level:nn { + \tl_if_exist:cT{c@##1}{\stepcounter{##1}} + \addcontentsline{toc}{##1}{\protect\numberline{\use:c{the##1}}##2} + \__notesslides_do_label:n{##1} + \pdfbookmark[\int_use:N \l_stex_docheader_sect]{\l__notesslides_num\ ##2}{##1.\l__notesslides_num} + \begin{frame}[noframenumbering] + \vfill\centering + \sectiontitleemph{ + \use:c{@ @ label} ##2 + } + \end{frame} + \int_incr:N \l_stex_docheader_sect + \tl_set:Nn \stex_current_section_level{##1} + } + } + + \AtBeginDocument{ + \str_if_empty:NTF \c_notesslides_topsect_str { + \setsectionlevel{section} + } { + \exp_args:No \setsectionlevel \c_notesslides_topsect_str + \exp_args:No \str_if_eq:nnTF \c_notesslides_topsect_str {chapter} { + \__notesslides_define_chapter: + }{ + \exp_args:No \str_if_eq:nnT \c_notesslides_topsect_str {part} { + \__notesslides_define_chapter: + \__notesslides_define_part: + } + } + } + } + + \bool_if:NT \c_notesslides_sectocframes_bool { + \__notesslides_do_sectocframes: + } } -\str_if_empty:NTF \c__notesslides_topsect_str { - \str_set_eq:NN \__notesslidestopsect \c__notesslides_defaulttopsec_str -}{ - \str_set_eq:NN \__notesslidestopsect \c__notesslides_topsect_str +\cs_new_protected:Nn \__notesslides_define_chapter: { + \cs_if_exist:NF \chaptername { + \cs_set_protected:Npn \chaptername {Chapter} + } + \cs_if_exist:NF \chapter { + \cs_set_protected:Npn \chapter {INVALID} + } + \cs_if_exist:NF \c@chapter { + \newcounter{chapter}\counterwithin*{section}{chapter} + } } -\PassOptionsToPackage{topsect=\__notesslidestopsect}{document-structure} -\bool_if:NT \c__notesslides_notes_bool { - \RequirePackage{a4wide} - \RequirePackage{marginnote} - \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor} - \RequirePackage{mdframed} - \RequirePackage[noxcolor,noamsthm]{beamerarticle} - \RequirePackage[bookmarks,bookmarksopen,bookmarksnumbered,breaklinks,hidelinks]{hyperref} + +\cs_new_protected:Nn \__notesslides_define_part: { + \cs_if_exist:NF \partname { + \cs_set_protected:Npn \partname {Part} + } + \cs_if_exist:NF \part { + \cs_set_protected:Npn \part {INVALID} + } + \cs_if_exist:NF \c@part { + \newcounter{part}\counterwithin*{chapter}{part} + } } -\RequirePackage{stex-tikzinput} -\RequirePackage{comment} -\RequirePackage{url} -\RequirePackage{graphicx} -\RequirePackage{pgf} -\RequirePackage{bookmark} -\bool_if:NT \c__notesslides_notes_bool { +\def \c__notesslides_document_str{document} +\newcommand\afterprematurestop{} +\def\prematurestop@endsfragment{ + \unless\ifx\@currenvir\c__notesslides_document_str + \expandafter\expandafter\expandafter\end\expandafter\expandafter\expandafter{\expandafter\@currenvir\expandafter} + \expandafter\prematurestop@endsfragment + \fi +} +\providecommand\prematurestop{ + \stex_if_html_backend:F{ + \message{Stopping~sTeX~processing~prematurely} + \prematurestop@endsfragment + \afterprematurestop + \end{document} + } +} +\bool_if:NT \c_notesslides_notes_bool { \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}} } \NewDocumentCommand \libusetheme {O{} m} { \libusepackage[#1]{beamertheme#2} } - -\newcounter{slide} \newlength{\slidewidth}\setlength{\slidewidth}{13.5cm} \newlength{\slideheight}\setlength{\slideheight}{9cm} -\bool_if:NTF \c__notesslides_notes_bool { - \renewenvironment{note}{\ignorespaces}{} +\ifnotes + +\newlength{\slideframewidth} +\setlength{\slideframewidth}{1.5pt} +\cs_new_protected:Nn \__notesslides_do_yes_param:Nn { + \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{ + \bool_set_true:N #1 + }{ + \bool_set_false:N #1 + } +} + +\stex_keys_define:nnnn{notesslides / frame}{ + \str_clear:N \l__notesslides_frame_label_str + \bool_set_true:N \l__notesslides_frame_allowframebreaks_bool + \bool_set_true:N \l__notesslides_frame_allowdisplaybreaks_bool + \bool_set_true:N \l__notesslides_frame_fragile_bool + \bool_set_true:N \l__notesslides_frame_shrink_bool + \bool_set_true:N \l__notesslides_frame_squeeze_bool + \bool_set_true:N \l__notesslides_frame_t_bool }{ - \excludecomment{note} -} -\bool_if:NT \c__notesslides_notes_bool { - \newlength{\slideframewidth} - \setlength{\slideframewidth}{1.5pt} - \cs_new_protected:Nn \__notesslides_do_yes_param:Nn { - \exp_args:Nx \str_if_eq:nnTF { \str_uppercase:n{ #2 } }{ yes }{ - \bool_set_true:N #1 - }{ - \bool_set_false:N #1 + label .str_set_x:N = \l__notesslides_frame_label_str, + allowframebreaks .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowframebreaks_bool { #1 } + }, + allowdisplaybreaks .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowdisplaybreaks_bool { #1 } + }, + fragile .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_fragile_bool { #1 } + }, + shrink .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_shrink_bool { #1 } + }, + squeeze .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_squeeze_bool { #1 } + }, + t .code:n = { + \__notesslides_do_yes_param:Nn \l__notesslides_frame_t_bool { #1 } + }, + unknown .code:n = {} +}{} +\cs_new_protected:Nn \__notesslides_setup_itemize: { + \def\itemize@level{outer} + \def\itemize@outer{outer} + \def\itemize@inner{inner} + %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}} + \renewenvironment{itemize}{ + \ifx\itemize@level\itemize@outer + \def\itemize@label{$\rhd$} + \fi + \ifx\itemize@level\itemize@inner + \def\itemize@label{$\scriptstyle\rhd$} + \fi + \begin{list} + {\itemize@label} + {\setlength{\labelsep}{.3em} + \setlength{\labelwidth}{.5em} + \setlength{\leftmargin}{1.5em} } + \edef\itemize@level{\itemize@inner} + }{ + \end{list} } - \keys_define:nn{notesslides / frame}{ - label .str_set_x:N = \l__notesslides_frame_label_str, - allowframebreaks .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowframebreaks_bool { #1 } - }, - allowdisplaybreaks .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_allowdisplaybreaks_bool { #1 } - }, - fragile .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_fragile_bool { #1 } - }, - shrink .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_shrink_bool { #1 } - }, - squeeze .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_squeeze_bool { #1 } - }, - t .code:n = { - \__notesslides_do_yes_param:Nn \l__notesslides_frame_t_bool { #1 } - }, - unknown .code:n = {} +} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \__notesslides_frame_box_begin: { + \vbox\bgroup + \begin{stex_annotate_env}{shtml:frame={}} + \mdf@patchamsthm\notesslidesfont } - \cs_new_protected:Nn \__notesslides_frame_args:n { - \str_clear:N \l__notesslides_frame_label_str - \bool_set_true:N \l__notesslides_frame_allowframebreaks_bool - \bool_set_true:N \l__notesslides_frame_allowdisplaybreaks_bool - \bool_set_true:N \l__notesslides_frame_fragile_bool - \bool_set_true:N \l__notesslides_frame_shrink_bool - \bool_set_true:N \l__notesslides_frame_squeeze_bool - \bool_set_true:N \l__notesslides_frame_t_bool - \keys_set:nn { notesslides / frame }{ #1 } + \cs_new_protected:Nn \__notesslides_frame_box_end: { + %^^A \notesslides@slidelabel + \medskip\par\noindent\tiny\notesslidesfooter + \end{stex_annotate_env}\egroup } - \renewenvironment{frame}[1][]{ - \__notesslides_frame_args:n{#1} - \sffamily - \stepcounter{slide} - \def\@currentlabel{\theslide} - \str_if_empty:NF \l__notesslides_frame_label_str { - \label{\l__notesslides_frame_label_str} - } - \def\itemize@level{outer} - \def\itemize@outer{outer} - \def\itemize@inner{inner} - \renewcommand\newpage{\addtocounter{framenumber}{1}} - %\newcommand\metakeys@show@keys[2]{\marginnote{{\scriptsize ##2}}} - \renewenvironment{itemize}{ - \ifx\itemize@level\itemize@outer - \def\itemize@label{$\rhd$} - \fi - \ifx\itemize@level\itemize@inner - \def\itemize@label{$\scriptstyle\rhd$} - \fi - \begin{list} - {\itemize@label} - {\setlength{\labelsep}{.3em} - \setlength{\labelwidth}{.5em} - \setlength{\leftmargin}{1.5em} - } - \edef\itemize@level{\itemize@inner} - }{ - \end{list} - } - \stex_html_backend:TF { - \begin{stex_annotate_env}{frame}{}\vbox\bgroup - \mdf@patchamsthm - }{ - \begin{mdframed}[linewidth=\slideframewidth,skipabove=1ex,skipbelow=1ex,userdefinedwidth=\slidewidth,align=center]\sf - } - }{ - \stex_html_backend:TF { - \miko@slidelabel\egroup\end{stex_annotate_env} - }{\medskip\miko@slidelabel\end{mdframed}} +}{ + \cs_new_protected:Nn \__notesslides_frame_box_begin: { + \begin{mdframed}[ + linewidth=\slideframewidth, + skipabove=1ex, + skipbelow=1ex, + userdefinedwidth=\slidewidth, + align=center + ]\notesslidesfont } - \renewcommand{\frametitle}[1]{ - \stex_document_title:n { #1 } - {\Large\bf\sf\color{blue}{#1}}\medskip + \cs_new_protected:Nn \__notesslides_frame_box_end: { + \medskip\par\noindent\tiny\notesslidesfooter%^^A\notesslides@slidelabel + \end{mdframed} } } -\bool_if:NT \c__notesslides_notes_bool { - \newcommand\pause{} -} -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{nparagraph}[1][]{\begin{sparagraph}[#1]}{\end{sparagraph}} +\renewenvironment{frame}[1][]{ + \stex_keys_set:nn{notesslides / frame}{#1} + \stepcounter{framenumber} + \renewcommand\newpage{\addtocounter{framenumber}{1}} + \def\@currentlabel{\theframenumber} + \str_if_empty:NF \l__notesslides_frame_label_str { + \label{\l__notesslides_frame_label_str} + } + \__notesslides_setup_itemize: + \__notesslides_frame_box_begin: }{ - \excludecomment{nparagraph} + \__notesslides_frame_box_end: } -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{nfragment}[2][]{\begin{sfragment}[#1]{#2}}{\end{sfragment}} -}{ - \excludecomment{nfragment} +\renewcommand{\frametitle}[1]{ + \stexdoctitle { #1 } + \notesslidestitleemph{#1}\medskip } -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{ndefinition}[1][]{\begin{sdefinition}[#1]}{\end{sdefinition}} +\newcommand\pause{} +\renewenvironment{columns}[1][]{ + \par\noindent + \begin{minipage} + \slidewidth\centering\leavevmode }{ - \excludecomment{ndefinition} + \end{minipage}\par\noindent } -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{nassertion}[1][]{\begin{sassertion}[#1]}{\end{sassertion}} +\newsavebox\columnbox +\renewenvironment<>{column}[2][]{ + \begin{lrbox}{\columnbox} + \begin{minipage}{#2} }{ - \excludecomment{nassertion} + \end{minipage} + \end{lrbox}\usebox\columnbox } -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{nproof}[2][]{\begin{sproof}[#1]{#2}}{\end{sproof}} +\fi +\bool_if:NTF \c_notesslides_notes_bool { + \renewenvironment{note}{\ignorespaces}{} }{ - \excludecomment{nproof} + \renewenvironment{note}{\setbox \l_tmpa_box\vbox\bgroup}{\egroup} } -\bool_if:NTF \c__notesslides_notes_bool { - \newenvironment{nexample}[1][]{\begin{sexample}[#1]}{\end{sexample}} -}{ - \excludecomment{nexample} -} -\def\inputref@preskip{\smallskip} -\def\inputref@postskip{\medskip} -\let\orig@inputref\inputref -\def\inputref{\@ifstar\ninputref\orig@inputref} -\newcommand\ninputref[2][]{ - \bool_if:NT \c__notesslides_notes_bool { - \orig@inputref[#1]{#2} +\cs_new_protected:Nn \__notesslides_notes_env:nnnn { + \bool_if:NTF \c_notesslides_notes_bool { + \newenvironment{#1}#2{#3}{#4} + }{ + \newenvironment{#1}#2{ + \cs_set:Npn \__notesslides_eat: ####1 \end ####2 { + \str_if_eq:nnTF{#1}{####2}{ + \end{#1} + }{ + \__notesslides_eat: + } + } + \__notesslides_eat: + %\setbox\l_tmpa_box\vbox\bgroup#3 + }{ + %#4\egroup + } } } -\newlength{\slidelogoheight} + +\__notesslides_notes_env:nnnn{nparagraph}{[1][]}{\begin{sparagraph}[#1]}{\end{sparagraph}} +\__notesslides_notes_env:nnnn{nfragment}{[2][]}{\begin{sfragment}[#1]{#2}}{\end{sfragment}} +\__notesslides_notes_env:nnnn{ndefinition}{[1][]}{\begin{sdefinition}[#1]}{\end{sdefinition}} +\__notesslides_notes_env:nnnn{nassertion}{[1][]}{\begin{sassertion}[#1]}{\end{sassertion}} +\__notesslides_notes_env:nnnn{nproof}{[2][]}{\begin{sproof}[#1]{#2}}{\end{sproof}} +\__notesslides_notes_env:nnnn{nexample}{[1][]}{\begin{sexample}[#1]}{\end{sexample}} \RequirePackage{graphicx} -\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} -\providecommand\mhgraphics[2][]{ - \def\Gin@mhrepos{}\setkeys{Gin}{#1} - \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}} +\NewDocumentCommand\frameimage{s O{} m}{ + \IfBooleanTF #1 { + \begin{frame}[plain] + }{ + \begin{frame} + } + \bool_if:NTF \c_notesslides_notes_bool { + \slidewidth=\dimexpr\slidewidth-(2\slideframewidth)\relax + }{ + \slidewidth=\textwidth\relax + } + \def\Gin@ewidth{}\setkeys{Gin}{#2} + \tl_if_empty:NTF \Gin@ewidth { + \mhgraphics[width=\slidewidth,#2]{#3} + }{ + \mhgraphics[#2]{#3} + } + \end{frame} } - -\bool_if:NTF \c__notesslides_notes_bool { - \setlength{\slidelogoheight}{.4cm} +\cs_set_eq:NN\__notesslides_inputref:\inputref +\cs_set_protected:Npn\inputref{\@ifstar\ninputref\__notesslides_inputref:} +\bool_if:NTF \c_notesslides_notes_bool { + \newcommand\ninputref[2][]{ + \__notesslides_inputref:[#1]{#2} + } }{ - \setlength{\slidelogoheight}{.25cm} + \newcommand\ninputref[2][]{} } -\ifcsname slidelogo\endcsname\else - \newsavebox{\slidelogo} - \sbox{\slidelogo}{\sTeX} -\fi -\newrobustcmd{\setslidelogo}[2][]{ - \tl_if_empty:nTF{#1}{ - \sbox{\slidelogo}{\includegraphics[height=\slidelogoheight]{#2}} - }{ - \sbox{\slidelogo}{\mhgraphics[height=\slidelogoheight,mhrepos=#1]{#2}} - } +\def\notesslidestitleemph#1{ + {\Large\bf\sf#1} + \vskip0.1\baselineskip + \leaders\vrule width \textwidth + \vskip0.4pt% + \nointerlineskip } -\bool_if:NT \c__notesslides_notes_bool { + +\def\notesslidesfooter{} + +\let\notesslidesfont\sffamily + +\bool_if:NT \c_notesslides_notes_bool { \def\author{\@dblarg\ns@author} \long\def\ns@author[#1]#2{% - \def\c__notesslides_shortauthor{#1}% + \tl_if_empty:nTF{#1}{ + \def\beamer@shortauthor{#2} + }{ + \def\beamer@shortauthor{#1} + } \def\@author{#2} } -} -\newrobustcmd{\setsource}[1]{\def\source{#1}} -\def\copyrightnotice{% - \footnotesize\copyright :\hspace{.3ex}% - \ifcsname source\endcsname\source\else% - \ifcsname c__notesslides_shortauthor\endcsname\c__notesslides_shortauthor\else% - \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}% - ?source/author?\fi% - \fi} -\newsavebox{\cclogo} -\sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}} -\newif\ifcchref\cchreffalse -\AtBeginDocument{ - \@ifpackageloaded{hyperref}{\cchreftrue}{\cchreffalse} -} -\def\licensing{ - \ifcchref - \href{http://creativecommons.org/licenses/by-sa/2.5/}{\usebox{\cclogo}} - \else - {\usebox{\cclogo}} - \fi -} -\newrobustcmd{\setlicensing}[2][]{ - \def\@url{#1} - \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{#2}} - \ifx\@url\@empty - \def\licensing{{\usebox{\cclogo}}} - \else - \def\licensing{ - \ifcchref - \href{#1}{\usebox{\cclogo}} - \else - {\usebox{\cclogo}} - \fi + \def\title{\@dblarg\ns@title} + \long\def\ns@title[#1]#2{% + \tl_if_empty:nTF{#1}{ + \def\beamer@shorttitle{#2} + }{ + \def\beamer@shorttitle{#1} } - \fi -} -\newrobustcmd\miko@slidelabel{ - \vbox to \slidelogoheight{ - \vss\hbox to \slidewidth - {\licensing\hfill\copyrightnotice\hfill\arabic{slide}\hfill\usebox{\slidelogo}} + \def\@title{#2} + \stexdoctitle{#2} } -} -\def\Gin@mhrepos{} -\define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} -\define@key{Gin}{label}{\def\@currentlabel{\arabic{slide}}\label{#1}} -\newrobustcmd\frameimage[2][]{ - \stepcounter{slide} - \bool_if:NT \c__notesslides_frameimages_bool { - \def\Gin@ewidth{}\setkeys{Gin}{#1} - \bool_if:NF \c__notesslides_notes_bool { \vfill } - \begin{center} - \bool_if:NTF \c__notesslides_fiboxed_bool { - \fbox{ - \ifx\Gin@ewidth\@empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[width=\slidewidth,#1]{#2} - \else - \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \else% Gin@ewidth empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[#1]{#2} - \else - \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \fi% Gin@ewidth empty - } - }{ - \ifx\Gin@ewidth\@empty - \ifx\Gin@mhrepos\@empty - \mhgraphics[width=\slidewidth,#1]{#2} - \else - \mhgraphics[width=\slidewidth,#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \ifx\Gin@mhrepos\@empty - \mhgraphics[#1]{#2} - \else - \mhgraphics[#1,mhrepos=\Gin@mhrepos]{#2} - \fi - \fi% Gin@ewidth empty - } - \end{center} - \par\strut\hfill{\footnotesize Slide \arabic{slide}}% - \bool_if:NF \c__notesslides_notes_bool { \vfill } + \def\insertshortauthor{ + \hbox\bgroup\def\\{}\cs_if_exist:NT\beamer@shortauthor\beamer@shortauthor\egroup } -} % ifmks@sty@frameimages -\stex_html_backend:F { - \bool_if:NT \c__notesslides_sectocframes_bool { - \str_if_eq:VnTF \__notesslidestopsect{part}{ - \newcounter{chapter}\counterwithin*{section}{chapter} - }{ - \str_if_eq:VnT\__notesslidestopsect{chapter}{ - \newcounter{chapter}\counterwithin*{section}{chapter} - } - } + \def\insertshorttitle{ + \hbox\bgroup\def\\{}\cs_if_exist:NT\beamer@shorttitle\beamer@shorttitle\egroup } -} -\def\part@prefix{} -\@ifpackageloaded{document-structure}{}{ - \str_case:VnF \__notesslidestopsect { - {part}{ - \int_set:Nn \l_document_structure_section_level_int {0} - \def\thesection{\arabic{chapter}.\arabic{section}} - \def\part@prefix{\arabic{chapter}.} - } - {chapter}{ - \int_set:Nn \l_document_structure_section_level_int {1} - \def\thesection{\arabic{chapter}.\arabic{section}} - \def\part@prefix{\arabic{chapter}.} - } + \stex_if_html_backend:TF{ + \def\insertframenumber{\stex_annotate:nn{shtml:framenumber={}}{}} }{ - \int_set:Nn \l_document_structure_section_level_int {2} - \def\part@prefix{} + \def\insertframenumber{\@arabic\c@framenumber} } -} - -\bool_if:NF \c__notesslides_notes_bool { % only in slides - \renewenvironment{sfragment}[2][]{ - \__document_structure_sfragment_args:n { #1 } - \int_incr:N \l_document_structure_section_level_int - \bool_if:NT \c__notesslides_sectocframes_bool { - \stepcounter{slide} - \begin{frame}[noframenumbering] - \vfill\Large\centering - \red{ - \ifcase\l_document_structure_section_level_int\or - \stepcounter{part} - \def\__notesslideslabel{{\omdoc@part@kw}~\Roman{part}} - \addcontentsline{toc}{part}{\protect\numberline{\thepart}#2} - \pdfbookmark[0]{\thepart\ #2}{part.\thepart} - \def\currentsectionlevel{\omdoc@part@kw} - \or - \stepcounter{chapter} - \def\__notesslideslabel{{\omdoc@chapter@kw}~\arabic{chapter}} - \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#2} - \pdfbookmark[1]{\thechapter\ #2}{chapter.\cs_if_exist:cT{thepart}\thepart.\thechapter} - \def\currentsectionlevel{\omdoc@chapter@kw} - \or - \stepcounter{section} - \def\__notesslideslabel{\part@prefix\arabic{section}} - \addcontentsline{toc}{section}{\protect\numberline{\thesection}#2} - \pdfbookmark[2]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection\ #2} - {section.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection} - \def\currentsectionlevel{\omdoc@section@kw} - \or - \stepcounter{subsection} - \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}} - \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#2} - \pdfbookmark[3]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection\ #2} - {subsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection} - \def\currentsectionlevel{\omdoc@subsection@kw} - \or - \stepcounter{subsubsection} - \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}} - \addcontentsline{toc}{subsubsection}{\protect\numberline{\thesubsubsection}#2} - \pdfbookmark[4]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection\ #2} - {subsubsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection} - \def\currentsectionlevel{\omdoc@subsubsection@kw} - \or - \stepcounter{paragraph} - \def\__notesslideslabel{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}} - \addcontentsline{toc}{paragraph}{\protect\numberline{\theparagraph}#2} - \pdfbookmark[5]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph\ #2} - {paragraph.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection.\theparagraph} - \def\currentsectionlevel{\omdoc@paragraph@kw} - \else - \def\__notesslideslabel{} - \def\currentsectionlevel{\omdoc@paragraph@kw} - \fi% end ifcase - \__notesslideslabel\quad #2% - }% - \vfill% - \end{frame}% - } - \str_if_empty:NF \l__document_structure_sfragment_id_str { - \stex_ref_new_doc_target:n\l__document_structure_sfragment_id_str - } - }{} -} -\def\inserttheorembodyfont{\normalfont} - -\AddToHook{begindocument}{ % this does not work for some reasone - \setbeamertemplate{theorems}[ams style] -} -\bool_if:NT \c__notesslides_notes_bool { - \renewenvironment{columns}[1][]{% - \par\noindent% - \begin{minipage}% - \slidewidth\centering\leavevmode% - }{% - \end{minipage}\par\noindent% - }% - \newsavebox\columnbox% - \renewenvironment<>{column}[2][]{% - \begin{lrbox}{\columnbox}\begin{minipage}{#2}% - }{% - \end{minipage}\end{lrbox}\usebox\columnbox% - }% -} -\bool_if:NTF \c__notesslides_noproblems_bool { - \newenvironment{problems}{}{} -}{ - \excludecomment{problems} + \def\insertshortdate{\today} } \gdef\printexcursions{} \newcommand\excursionref[2]{% label, text - \bool_if:NT \c__notesslides_notes_bool { + \bool_if:NT \c_notesslides_notes_bool { \begin{sparagraph}[title=Excursion] #2 \sref[fallback=the appendix]{#1}. \end{sparagraph} } } \newcommand\activate@excursion[2][]{ - \gappto\printexcursions{\inputref[#1]{#2}} + \tl_gput_right:Nn\printexcursions{\inputref[#1]{#2}} } \newcommand\excursion[4][]{% repos, label, path, text - \bool_if:NT \c__notesslides_notes_bool { - \activate@excursion[#1]{#3}\excursionref{#2}{#4} + \bool_if:NT \c_notesslides_notes_bool { + \activate@excursion[#1]{#3} + \excursionref{#2}{#4} } } \keys_define:nn{notesslides / excursiongroup }{ id .str_set_x:N = \l__notesslides_excursion_id_str, intro .tl_set:N = \l__notesslides_excursion_intro_tl, - mhrepos .str_set_x:N = \l__notesslides_excursion_mhrepos_str + archive .str_set_x:N = \l__notesslides_excursion_mhrepos_str } \cs_new_protected:Nn \__notesslides_excursion_args:n { \tl_clear:N \l__notesslides_excursion_intro_tl @@ -468,19 +424,35 @@ } \newcommand\excursiongroup[1][]{ \__notesslides_excursion_args:n{ #1 } - \ifdefempty\printexcursions{}% only if there are excursions - {\begin{note} - \begin{sfragment}[#1]{Excursions}% + \tl_if_empty:NF\printexcursions + {\IfInputref{}{\begin{note} + \begin{sfragment}{Excursions}% TODO pass on id \ifdefempty\l__notesslides_excursion_intro_tl{}{ - \inputref[\l__notesslides_excursion_mhrepos_str]{ + \exp_args:NNe \use:nn \inputref{[\l__notesslides_excursion_mhrepos_str]{ \l__notesslides_excursion_intro_tl - } + }} } \printexcursions% \end{sfragment} - \end{note}} + \end{note}}} } \ifcsname beameritemnestingprefix\endcsname\else\def\beameritemnestingprefix{}\fi +\prop_new:N \g__notesslides_variables_prop +\cs_set_protected:Npn \setSGvar #1 #2 { + \prop_gput:Nnn \g__notesslides_variables_prop {#1}{#2} +} +\cs_set_protected:Npn \useSGvar #1 { + \prop_item:Nn \g__notesslides_variables_prop {#1} +} +\cs_set_protected:Npn \ifSGvar #1 #2 #3 { + \prop_get:NnNF \g__notesslides_variables_prop {#1} \l__notesslides_tmp { + \PackageError{document-structure} + {The sTeX Global variable #1 is undefined} + {set it with \protect\setSGvar}\TODO better error + } + \tl_if_eq:NnT \l__notesslides_tmp {#2}{ #3 } +} + \endinput %% %% End of file `notesslides.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/problem.sty b/Master/texmf-dist/tex/latex/stex/problem.sty index de10c534970..49f8ae43bac 100644 --- a/Master/texmf-dist/tex/latex/stex/problem.sty +++ b/Master/texmf-dist/tex/latex/stex/problem.sty @@ -6,9 +6,8 @@ %% %% problem.dtx (with options: `package') %% -\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems} +\ProvidesExplPackage{problem}{2023/03/19}{3.3.0}{Semantic Markup for Problems} \RequirePackage{l3keys2e} -\RequirePackage{amssymb}% for \Box \keys_define:nn { problem / pkg }{ notes .default:n = { true }, @@ -23,8 +22,8 @@ pts .bool_set:N = \c__problems_pts_bool, min .default:n = { true }, min .bool_set:N = \c__problems_min_bool, - boxed .default:n = { true }, - boxed .bool_set:N = \c__problems_boxed_bool, + %boxed .default:n = { true }, + %boxed .bool_set:N = \c__problems_boxed_bool, test .default:n = { true }, test .bool_set:N = \c__problems_test_bool, unknown .code:n = { @@ -40,20 +39,10 @@ \solutionsfalse } \RequirePackage{stex} -\RequirePackage{comment} -\bool_if:NT \c__problems_boxed_bool { \RequirePackage{mdframed} } -\def\prob@problem@kw{Problem} -\def\prob@solution@kw{Solution} -\def\prob@hint@kw{Hint} -\def\prob@note@kw{Note} -\def\prob@gnote@kw{Grading} -\def\prob@pt@kw{pt} -\def\prob@min@kw{min} -\def\prob@correct@kw{Correct} -\def\prob@wrong@kw{Wrong} \AddToHook{begindocument}{ + \ExplSyntaxOn\makeatletter + \input{problem-english.ldf} \ltx@ifpackageloaded{babel}{ - \makeatletter \clist_set:Nx \l_tmpa_clist {\bbl@loaded} \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ \input{problem-ngerman.ldf} @@ -67,291 +56,357 @@ \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ \input{problem-russian.ldf} } - \makeatother }{} + \makeatother\ExplSyntaxOff } -\keys_define:nn{ problem / problem }{ - id .str_set_x:N = \l__problems_prob_id_str, - pts .tl_set:N = \l__problems_prob_pts_tl, - min .tl_set:N = \l__problems_prob_min_tl, - title .tl_set:N = \l__problems_prob_title_tl, - type .tl_set:N = \l__problems_prob_type_tl, - imports .tl_set:N = \l__problems_prob_imports_tl, - name .str_set_x:N = \l__problems_prob_name_str, - refnum .int_set:N = \l__problems_prob_refnum_int -} -\cs_new_protected:Nn \__problems_prob_args:n { - \str_clear:N \l__problems_prob_id_str - \str_clear:N \l__problems_prob_name_str - \tl_clear:N \l__problems_prob_pts_tl - \tl_clear:N \l__problems_prob_min_tl - \tl_clear:N \l__problems_prob_title_tl - \tl_clear:N \l__problems_prob_type_tl - \tl_clear:N \l__problems_prob_imports_tl - \int_zero_new:N \l__problems_prob_refnum_int - \keys_set:nn { problem / problem }{ #1 } - \int_compare:nNnT \l__problems_prob_refnum_int = 0 { - \let\l__problems_prob_refnum_int\undefined - } -} +\stex_keys_define:nnnn{ problem }{ + \tl_set:Nn \l_stex_key_pts_tl 0 + \tl_set:Nn \l_stex_key_min_tl 0 + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_mhrepos_str +}{ + pts .tl_set:N = \l_stex_key_pts_tl, + min .tl_set:N = \l_stex_key_min_tl, + name .str_set:N = \l_stex_key_name_str, + archive .str_set:N = \l_stex_key_mhrepos_str, + creators .code:n = {} + %imports .tl_set:N = \l__problems_prob_imports_tl, + %refnum .int_set:N = \l__problems_prob_refnum_int, +}{id,title,style,uses} \newcounter{sproblem}[section] -\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}} -\def\theplainsproblem{\arabic{sproblem}} -\def\thesproblem{\thesection.\theplainsproblem} -\newcommand\prob@label[1]{\thesection.#1} -\newcommand\prob@number{ - \int_if_exist:NTF \l__problems_inclprob_refnum_int { - \prob@label{\int_use:N \l__problems_inclprob_refnum_int } +\newcommand\numberproblemsin[1]{ + \@addtoreset{sproblem}{#1} + \def\thesproblem{\arabic{#1}.\arabic{sproblem}} +} +\numberproblemsin{section} +\newcounter{pts} +\newcounter{min} +\stex_new_stylable_env:nnnnnnn {problem} {O{}}{ + \cs_if_exist:NTF \l_problem_inputproblem_keys_tl { + \tl_put_left:Nn \l_problem_inputproblem_keys_tl {#1,} + \exp_args:Nno \stex_keys_set:nn{problem}{ + \l_problem_inputproblem_keys_tl + } }{ - \int_if_exist:NTF \l__problems_prob_refnum_int { - \prob@label{\int_use:N \l__problems_prob_refnum_int } - }{ - \prob@label\theplainsproblem + \stex_keys_set:nn{problem}{#1} + } + \refstepcounter{sproblem} + \str_if_empty:NT \l_stex_key_name_str { + \stex_file_split_off_lang:NN \l__problems_path_seq \g_stex_current_file + \seq_get_right:NN \l__problems_path_seq \l_stex_key_name_str + } + + \exp_args:No \stex_module_setup:n \l_stex_key_name_str + + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:problem={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={\l_stex_key_sig_str} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} + } + } + \stex_annotate_invisible:n{} + \tl_if_empty:NF \l_stex_key_title_tl { + \exp_args:No \stexdoctitle \l_stex_key_title_tl } } -} -\def\sproblemautorefname{\prob@problem@kw} -\newcommand\prob@title[3]{% - \tl_if_exist:NTF \l__problems_inclprob_title_tl { - #2 \l__problems_inclprob_title_tl #3 - }{ - \tl_if_empty:NTF \l__problems_prob_title_tl { - #1 - }{ - #2 \l__problems_prob_title_tl #3 + \stex_if_smsmode:F { + \str_set_eq:NN \thismoduleuri \l_stex_current_module_str + \tl_set_eq:NN \thismodulename \l_stex_key_name_str + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \stex_style_apply: + \addtocounter{pts}{\l_stex_key_pts_tl} + \addtocounter{min}{\l_stex_key_min_tl} + \_stex_do_id: + \__problems_record_problem: + } + \stex_reactivate_macro:N \solution + \stex_reactivate_macro:N \mcb + \stex_reactivate_macro:N \fillinsol + \stex_smsmode_do: +}{ + \stex_close_module: + \stex_if_smsmode:F \stex_style_apply: + \stex_if_do_html:T{ \end{stex_annotate_env} } +}{ + \par\noindent\problemheader + \bool_if:NT \c__problems_pts_bool { + \marginpar{\l_stex_key_pts_tl{}~\problem@kw@points\smallskip} + } + \bool_if:NT \c__problems_min_bool { + \marginpar{\l_stex_key_min_tl{}~\problem@kw@minutes\smallskip} + } + \\ + \stex_ignore_spaces_and_pars: +}{ + \par\bigskip +}{s} +\stex_sms_allow_env:n{sproblem} + +\tl_set:Nn \problemheader { + \textbf{\sproblemautorefname{~}\thesproblem + \tl_if_empty:NF \thistitle { + {~}(\thistitle) } } } -\def\prob@heading{ - {\prob@problem@kw}\ \prob@number\prob@title{~}{~(}{)\strut} - %\sref@label@id{\prob@problem@kw~\prob@number}{} -} -\newenvironment{sproblem}[1][]{ - \__problems_prob_args:n{#1}%\sref@target% - \@in@omtexttrue% we are in a statement (for inline definitions) - \refstepcounter{sproblem}\record@problem - \def\current@section@level{\prob@problem@kw} - \str_if_empty:NT \l__problems_prob_name_str { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_get_left:NN \l_tmpa_seq \l__problems_prob_name_str +\cs_new_protected:Nn \__problems_record_problem: { + \exp_args:NNe \iow_now:Nn \@auxout { + \problem@restore {\thesproblem}{\l_stex_key_pts_tl}{\l_stex_key_min_tl} } +} - \stex_if_do_html:T{ - \tl_if_empty:NF \l__problems_prob_title_tl { - \exp_args:No \stex_document_title:n \l__problems_prob_title_tl - } - } +\cs_new_protected:Npn \problem@restore #1 #2 #3 {} +\stex_keys_define:nnnn{ includeproblem }{ + \str_clear:N \l_stex_key_mhrepos_str +}{ + archive .str_set:N = \l_stex_key_mhrepos_str, + unknown .code:n = {} +}{} - \exp_args:Nno\stex_module_setup:nn{type=problem}\l__problems_prob_name_str +\NewDocumentCommand\includeproblem{O{} m}{ + \group_begin: + \tl_set:Nn \l_problem_inputproblem_keys_tl {#1} + \stex_keys_set:nn{includeproblem}{#1} + \exp_args:Nno \use:nn{\inputref[}\l_stex_key_mhrepos_str]{#2} + \group_end: +} - \stex_reactivate_macro:N \STEXexport - \stex_reactivate_macro:N \importmodule - \stex_reactivate_macro:N \symdecl - \stex_reactivate_macro:N \notation - \stex_reactivate_macro:N \symdef +\int_new:N \g_problem_id_counter - \stex_if_do_html:T{ - \begin{stex_annotate_env} {problem} { - \l_stex_module_ns_str ? \l_stex_module_name_str +\cs_new_protected:Nn \__problems_solution_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + SOLUTION_\int_use:N \g_problem_id_counter } - - \stex_annotate_invisible:nnn{header}{} { - \stex_annotate:nnn{language}{ \l_stex_module_lang_str }{} - \stex_annotate:nnn{signature}{ \l_stex_module_sig_str }{} - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \stex_annotate:nnn{metatheory}{ \l_stex_module_meta_str }{} - } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:solution=\l_stex_key_id_str } } + \stex_style_apply: +} - \stex_csl_to_imports:No \importmodule \l__problems_prob_imports_tl - - \tl_if_exist:NTF \l__problems_inclprob_type_tl { - \tl_set_eq:NN \sproblemtype \l__problems_inclprob_type_tl +\stex_new_stylable_env:nnnnnnn { solution }{ O{} }{ + \stex_if_do_html:TF{ + \__problems_solution_start:n{#1} }{ - \tl_set_eq:NN \sproblemtype \l__problems_prob_type_tl + \ifsolutions + \__problems_solution_start:n{#1} + \else + \setbox\l_tmpa_box\vbox\bgroup + \fi } - \str_if_exist:NTF \l__problems_inclprob_id_str { - \str_set_eq:NN \sproblemid \l__problems_inclprob_id_str +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} }{ - \str_set_eq:NN \sproblemid \l__problems_prob_id_str + \ifsolutions + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + \else + \egroup + \fi } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Solution\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__problems_sproblem_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_start:}} - } +\stex_deactivate_macro:Nn \solution {sproblem~environments} +\cs_new_protected:Npn \startsolutions{ + \global\solutionstrue +} +\cs_new_protected:Npn \stopsolutions{ + \global\solutionsfalse +} +\cs_new_protected:Nn \__problems_hint_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + HINT_\int_use:N \g_problem_id_counter + } + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:problemhint=\l_stex_key_id_str } - \tl_if_empty:NTF \l_tmpa_tl { - \__problems_sproblem_start: + } + \stex_style_apply: +} + +\stex_new_stylable_env:nnnnnnn { hint }{ O{} }{ + \stex_if_do_html:TF{ + \__problems_hint_start:n{#1} + }{ + \bool_if:NTF \c__problems_hints_bool { + \__problems_hint_start:n{#1} }{ - \l_tmpa_tl + \setbox\l_tmpa_box\vbox\bgroup } } - \stex_ref_new_doc_target:n \sproblemid - \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars }{ - \__stex_modules_end_module: - \stex_if_smsmode:F{ - \clist_set:No \l_tmpa_clist \sproblemtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__problems_sproblem_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__problems_sproblem_##1_end:}} + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} + }{ + \bool_if:NTF \c__problems_hints_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__problems_sproblem_end: }{ - \l_tmpa_tl + \egroup + } + } +}{ + \par\smallskip\hrule\smallskip + \noindent\emph{Hint\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +\cs_new_protected:Nn \__problems_exnote_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + EXNOTE_\int_use:N \g_problem_id_counter } } \stex_if_do_html:T{ - \end{stex_annotate_env} + \begin{stex_annotate_env}{ + shtml:problemnote=\l_stex_key_id_str + } } - - \smallskip + \stex_style_apply: } -\seq_put_right:Nx\g_stex_smsmode_allowedenvs_seq{\tl_to_str:n{sproblem}} - -\cs_new_protected:Nn \__problems_sproblem_start: { - \par\noindent\textbf\prob@heading\show@pts\show@min\\\ignorespacesandpars -} -\cs_new_protected:Nn \__problems_sproblem_end: {\par\smallskip} - -\newcommand\stexpatchproblem[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__problems_sproblem_start: { #2 } - \tl_set:Nn \__problems_sproblem_end: { #3 } +\stex_new_stylable_env:nnnnnnn { exnote }{ O{} }{ + \stex_if_do_html:TF{ + \__problems_exnote_start:n{#1} + }{ + \bool_if:NTF \c__problems_notes_bool { + \__problems_exnote_start:n{#1} }{ - \exp_after:wN \tl_set:Nn \csname __problems_sproblem_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __problems_sproblem_#1_end:\endcsname{ #3 } - } -} - -\bool_if:NT \c__problems_boxed_bool { - \surroundwithmdframed{problem} -} -\def\record@problem{ - \protected@write\@auxout{} - { - \string\@problem{\prob@number} - { - \tl_if_exist:NTF \l__problems_inclprob_pts_tl { - \l__problems_inclprob_pts_tl - }{ - \l__problems_prob_pts_tl - } - }% - { - \tl_if_exist:NTF \l__problems_inclprob_min_tl { - \l__problems_inclprob_min_tl - }{ - \l__problems_prob_min_tl - } + \setbox\l_tmpa_box\vbox\bgroup } } -} -\def\@problem#1#2#3{} -\keys_define:nn { problem / solution }{ - id .str_set_x:N = \l__problems_solution_id_str , - for .str_set_x:N = \l__problems_solution_for_str , - type .str_set_x:N = \l__problems_solution_type_str , - title .tl_set:N = \l__problems_solution_title_tl -} -\cs_new_protected:Nn \__problems_solution_args:n { - \str_clear:N \l__problems_solution_id_str - \str_clear:N \l__problems_solution_type_str - \str_clear:N \l__problems_solution_for_str - \tl_clear:N \l__problems_solution_title_tl - \keys_set:nn { problem / solution }{ #1 } -} -\box_new:N \l__problems_solution_box -\newenvironment{solution}[1][]{ - \__problems_solution_args:n{#1} - \stex_html_backend:TF{ - \stex_if_do_html:T{ - \begin{stex_annotate_env}{solution}{} - \str_if_empty:NF \l__problems_solution_type_str { - \par\noindent - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - \noindent\textbf{Solution\tl_if_empty:NF\l__problems_solution_title_tl{~(\l__problems_solution_title_tl)}: }~ - } +}{ + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} }{ - \setbox\l__problems_solution_box\vbox\bgroup - \par\smallskip\hrule\smallskip - \noindent\textbf{Solution\tl_if_empty:NF\l__problems_solution_title_tl{~(\l__problems_solution_title_tl)}: }~ + \bool_if:NTF \c__problems_notes_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \egroup + } } }{ - \stex_html_backend:TF{ - \stex_if_do_html:T{ - \end{stex_annotate_env} + \par\smallskip\hrule\smallskip + \noindent\emph{Note\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +%% \begin{environment}{gnote} +\cs_new_protected:Nn \__problems_gnote_start:n { + \str_set:Nn \l_stex_key_title_tl {#1} + \str_set:Nn \l_stex_key_id_str {#1} + \str_if_empty:NT \l_stex_key_id_str { + \int_gincr:N \g_problem_id_counter + \str_set:Nx \l_stex_key_id_str { + GNOTE_\int_use:N \g_problem_id_counter } - }{ - \smallskip\hrule - \egroup - \bool_if:NT \c__problems_solutions_bool { - \strut\par\noindent - \box\l__problems_solution_box + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{ + shtml:problemgnote=\l_stex_key_id_str } } + \stex_style_apply: } -\newcommand\startsolutions{ - \bool_set_true:N \c__problems_solutions_bool - \solutionstrue -} -\newcommand\stopsolutions{\bool_set_false:N \c__problems_solutions_bool \solutionsfalse}%\excludecomment{solution}} -\bool_if:NTF \c__problems_notes_bool { - \newenvironment{exnote}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@note@kw :~ }\small +\stex_new_stylable_env:nnnnnnn { gnote }{ O{} }{ + \stex_if_do_html:TF{ + \__problems_gnote_start:n{#1} }{ - \smallskip\hrule + \bool_if:NTF \c__problems_gnotes_bool { + \__problems_gnote_start:n{#1} + }{ + \setbox\l_tmpa_box\vbox\bgroup + } } }{ - \excludecomment{exnote} -} -\bool_if:NTF \c__problems_notes_bool { - \newenvironment{hint}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@hint@kw :~ }\small - }{ - \smallskip\hrule - } - \newenvironment{exhint}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@hint@kw :~ }\small + \stex_if_do_html:TF{ + \stex_style_apply: + \end{stex_annotate_env} }{ - \smallskip\hrule + \bool_if:NTF \c__problems_gnotes_bool { + \stex_style_apply: + \stex_if_do_html:T{ + \end{stex_annotate_env} + } + }{ + \egroup + } } }{ - \excludecomment{hint} - \excludecomment{exhint} + \par\smallskip\hrule\smallskip + \noindent\emph{Grading\str_if_empty:NF \l_stex_key_title_tl{ + {~}\l_stex_key_title_tl + } :~} +}{ + \par\smallskip\hrule +}{} +\def\pts#1{ + \bool_if:NT \c__problems_pts_bool { + \marginpar{#1~\problem@kw@points} + } } -\bool_if:NTF \c__problems_notes_bool { - \newenvironment{gnote}[1][]{ - \par\smallskip\hrule\smallskip - \noindent\textbf{\prob@gnote@kw :~ }\small - }{ - \smallskip\hrule +\def\min#1{ + \bool_if:NT \c__problems_min_bool { + \marginpar{#1~\problem@kw@minutes} } -}{ - \excludecomment{gnote} } -\newenvironment{mcb}{ +\newenvironment{mcb}{\par + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:multiple-choice-block={}} + } + \stex_deactivate_macro:Nn \mcb {sproblem~environments} + \stex_deactivate_macro:Nn \solution {sproblem~environments} + \stex_reactivate_macro:N \mcc \begin{enumerate} }{ \end{enumerate} + \stex_if_do_html:T{ + \end{stex_annotate_env} + } } +\stex_deactivate_macro:Nn \mcb {sproblem~environments} \cs_new_protected:Nn \__problems_do_yes_param:Nn { \exp_args:Nx \str_if_eq:nnTF { \str_lowercase:n{ #2 } }{ yes }{ \bool_set_true:N #1 @@ -359,184 +414,74 @@ \bool_set_false:N #1 } } -\keys_define:nn { problem / mcc }{ - id .str_set_x:N = \l__problems_mcc_id_str , - feedback .tl_set:N = \l__problems_mcc_feedback_tl , +\stex_keys_define:nnnn{mcc}{ + \tl_clear:N \l_stex_key_feedback_tl + \bool_set_false:N \l_stex_key_T_bool + \tl_clear:N \l_stex_key_Ttext_tl + \tl_clear:N \l_stex_key_Ftext_tl +}{ + feedback .tl_set:N = \l_stex_key_feedback_tl , T .default:n = { false } , - T .bool_set:N = \l__problems_mcc_t_bool , + T .bool_set:N = \l_stex_key_T_bool , F .default:n = { false } , - F .bool_set:N = \l__problems_mcc_f_bool , - Ttext .tl_set:N = \l__problems_mcc_Ttext_tl , - Ftext .tl_set:N = \l__problems_mcc_Ftext_tl -} -\cs_new_protected:Nn \l__problems_mcc_args:n { - \str_clear:N \l__problems_mcc_id_str - \tl_clear:N \l__problems_mcc_feedback_tl - \bool_set_false:N \l__problems_mcc_t_bool - \bool_set_false:N \l__problems_mcc_f_bool - \tl_clear:N \l__problems_mcc_Ttext_tl - \tl_clear:N \l__problems_mcc_Ftext_tl - \str_clear:N \l__problems_mcc_id_str - \keys_set:nn { problem / mcc }{ #1 } -} -\def\mccTrueText{\textbf{\prob@correct@kw!~}} -\def\mccFalseText{\textbf{\prob@wrong@kw!~}} -\newcommand\mcc[2][]{ - \l__problems_mcc_args:n{ #1 } - \item[$\Box$] #2 - \bool_if:NT \c__problems_solutions_bool{ - \\ - \bool_if:NT \l__problems_mcc_t_bool { - \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccTrueText\l__problems_mcc_Ttext_tl - } - \bool_if:NT \l__problems_mcc_f_bool { - \tl_if_empty:NTF\l__problems_mcc_Ttext_tl\mccFalseText\l__problems_mcc_Ftext_tl - } - \tl_if_empty:NF \l__problems_mcc_feedback_tl { - \emph{\l__problems_mcc_feedback_tl} - } - } -} %solutions -\newcommand\fillinsol[2][]{% - \def\@test{#1} - \quad% - \ifsolutions\textcolor{red}{#1!}\else% - \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}% - \fi} + F .code:n = {\bool_set_false:N \l_stex_key_T_bool} , + Ttext .tl_set:N = \l_stex_key_Ttext_tl , + Ftext .tl_set:N = \l_stex_key_Ftext_tl , +}{id} -\keys_define:nn{ problem / inclproblem }{ - id .str_set_x:N = \l__problems_inclprob_id_str, - pts .tl_set:N = \l__problems_inclprob_pts_tl, - min .tl_set:N = \l__problems_inclprob_min_tl, - title .tl_set:N = \l__problems_inclprob_title_tl, - refnum .int_set:N = \l__problems_inclprob_refnum_int, - type .tl_set:N = \l__problems_inclprob_type_tl, - mhrepos .str_set_x:N = \l__problems_inclprob_mhrepos_str -} -\cs_new_protected:Nn \__problems_inclprob_args:n { - \str_clear:N \l__problems_prob_id_str - \tl_clear:N \l__problems_inclprob_pts_tl - \tl_clear:N \l__problems_inclprob_min_tl - \tl_clear:N \l__problems_inclprob_title_tl - \tl_clear:N \l__problems_inclprob_type_tl - \int_zero_new:N \l__problems_inclprob_refnum_int - \str_clear:N \l__problems_inclprob_mhrepos_str - \keys_set:nn { problem / inclproblem }{ #1 } - \tl_if_empty:NT \l__problems_inclprob_pts_tl { - \let\l__problems_inclprob_pts_tl\undefined - } - \tl_if_empty:NT \l__problems_inclprob_min_tl { - \let\l__problems_inclprob_min_tl\undefined - } - \tl_if_empty:NT \l__problems_inclprob_title_tl { - \let\l__problems_inclprob_title_tl\undefined - } - \tl_if_empty:NT \l__problems_inclprob_type_tl { - \let\l__problems_inclprob_type_tl\undefined - } - \int_compare:nNnT \l__problems_inclprob_refnum_int = 0 { - \let\l__problems_inclprob_refnum_int\undefined +\tl_set:Nn \problem_mcc_box_tl { + \ltx@ifpackageloaded{amssymb}{$\square$}{ + \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} } } - -\cs_new_protected:Nn \__problems_inclprob_clear: { - \let\l__problems_inclprob_id_str\undefined - \let\l__problems_inclprob_pts_tl\undefined - \let\l__problems_inclprob_min_tl\undefined - \let\l__problems_inclprob_title_tl\undefined - \let\l__problems_inclprob_type_tl\undefined - \let\l__problems_inclprob_refnum_int\undefined - \let\l__problems_inclprob_mhrepos_str\undefined -} -\__problems_inclprob_clear: - -\newcommand\includeproblem[2][]{ - \__problems_inclprob_args:n{ #1 } - \exp_args:No \stex_in_repository:nn\l__problems_inclprob_mhrepos_str{ - \stex_html_backend:TF { - \str_clear:N \l_tmpa_str - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - \stex_annotate_invisible:nnn{includeproblem}{ - \l_tmpa_str / #2 - }{} +\newcommand\mcc[2][]{ + \stex_keys_set:nn{mcc}{#1}\par + \tl_set:Nn \l_tmpb_tl {~--~ + \bool_if:NTF \l_stex_key_T_bool { + \tl_if_empty:NTF \l_stex_key_Ttext_tl \problem@kw@correct \l_stex_key_Ttext_tl }{ - \begingroup - \inputreftrue - \tl_if_empty:nTF{ ##1 }{ - \input{#2} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - } - \endgroup - } - } - \__problems_inclprob_clear: -} -\AddToHook{enddocument}{ - \bool_if:NT \c__problems_pts_bool { - \message{Total:~\arabic{pts}~points} - } - \bool_if:NT \c__problems_min_bool { - \message{Total:~\arabic{min}~minutes} - } -} -\def\pts#1{ - \bool_if:NT \c__problems_pts_bool { - \marginpar{#1~\prob@pt@kw} - } -} -\def\min#1{ - \bool_if:NT \c__problems_min_bool { - \marginpar{#1~\prob@min@kw} - } -} -\newcounter{pts} -\def\show@pts{ - \tl_if_exist:NTF \l__problems_inclprob_pts_tl { - \bool_if:NT \c__problems_pts_bool { - \marginpar{\l__problems_inclprob_pts_tl\ \prob@pt@kw\smallskip} - \addtocounter{pts}{\l__problems_inclprob_pts_tl} + \tl_if_empty:NTF \l_stex_key_Ftext_tl \problem@kw@wrong \l_stex_key_Ftext_tl } - }{ - \tl_if_exist:NT \l__problems_prob_pts_tl { - \bool_if:NT \c__problems_pts_bool { - \tl_if_empty:NT\l__problems_prob_pts_tl{ - \tl_set:Nn \l__problems_prob_pts_tl {0} - } - \marginpar{\l__problems_prob_pts_tl\ \prob@pt@kw\smallskip} - \addtocounter{pts}{\l__problems_prob_pts_tl} - } + \tl_if_empty:NF \l_stex_key_feedback_tl { + \\\emph{\l_stex_key_feedback_tl} } } -} -\newcounter{min} -\def\show@min{ - \tl_if_exist:NTF \l__problems_inclprob_min_tl { - \bool_if:NT \c__problems_min_bool { - \marginpar{\l__problems_inclprob_pts_tl\ min} - \addtocounter{min}{\l__problems_inclprob_min_tl} + \tl_set:Nn \l_tmpa_tl { + #2 + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:mcc-solution={}}{\l_tmpb_tl} + }{ + \ifsolutions\l_tmpb_tl\fi } + } + \item[\problem_mcc_box_tl]{}~ + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:mcc={ + \bool_if:NTF \l_stex_key_T_bool {true}{false} + }}{\l_tmpa_tl} + }{\l_tmpa_tl} +} +\stex_deactivate_macro:Nn \mcc {mcb~environments} +\newcommand\fillinsol[2][]{ + \quad + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:fillinsol={}}{ \_stex_annotate_force_break:n{#2} } }{ - \tl_if_exist:NT \l__problems_prob_min_tl { - \bool_if:NT \c__problems_min_bool { - \tl_if_empty:NT\l__problems_prob_min_tl{ - \tl_set:Nn \l__problems_prob_min_tl {0} + \ifsolutions + \textcolor{red}{\fbox{#2}} + \else + \fbox{ + \tl_if_empty:nTF{#1}{ + \phantom{\huge{#2}} + }{ + \hspace{#1} } - \marginpar{\l__problems_prob_min_tl\ min} - \addtocounter{min}{\l__problems_prob_min_tl} } - } + \fi } + \quad } -\newcommand\testspace[1]{\bool_if:NT \c__problems_boxed_bool {\vspace*{#1}}} -\newcommand\testnewpage{\bool_if:NT \c__problems_boxed_bool {\newpage}} -\newcommand\testemptypage[1][]{% -\bool_if:NT \c__problems_boxed_bool {\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else}} -\newcommand\testsmallspace{\testspace{1cm}} -\newcommand\testmedspace{\testspace{2cm}} -\newcommand\testbigspace{\testspace{3cm}} +\stex_deactivate_macro:Nn \fillinsol {sproblem~environments} \endinput %% %% End of file `problem.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty b/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty deleted file mode 100644 index ac5bd7e45e3..00000000000 --- a/Master/texmf-dist/tex/latex/stex/stex-tikzinput.sty +++ /dev/null @@ -1,78 +0,0 @@ -%% -%% This is file `stex-tikzinput.sty', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% tikzinput.dtx (with options: `stex') -%% -\ProvidesExplPackage{stex-tikzinput}{2022/09/14}{3.2.0}{stex-tikzinput} -\RequirePackage{stex} -\RequirePackage{tikzinput} - -\newcommand\mhtikzinput[2][]{% - \def\Gin@mhrepos{}\setkeys{Gin}{#1}% - \stex_in_repository:nn\Gin@mhrepos{ - \tikzinput[#1]{\mhpath{##1}{#2}} - } -} -\newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}} - -\cs_new_protected:Nn \__tikzinput_usetikzlibrary:nn { - \pgfkeys@spdef\pgf@temp{#1} - \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} - \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$} - \catcode`\@=11 - \catcode`\|=12 - \catcode`\$=3 - \pgfutil@InputIfFileExists{#2}{}{} - \catcode`\@=\csname tikz@library@#1@atcode\endcsname - \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname -} - -\newcommand\libusetikzlibrary[1]{ - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libusetikzlibrary - } - \seq_clear:N \l__tikzinput_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / tikzlibrary #1 .code.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l__tikzinput_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str - } - - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / tikzlibrary #1 .code.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l__tikzinput_libinput_files_seq \l_tmpa_str - }{} - - \seq_if_empty:NTF \l__tikzinput_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex} - }{ - \int_compare:nNnTF {\seq_count:N \l__tikzinput_libinput_files_seq} = 1 { - \seq_map_inline:Nn \l__tikzinput_libinput_files_seq { - \__tikzinput_usetikzlibrary:nn{#1}{ ##1 } - } - }{ - \msg_error:nnxx{stex}{error/twofiles}{\exp_not:N\libusetikzlibrary}{tikzlibrary #1 .code.tex} - } - } -} - - -\endinput -%% -%% End of file `stex-tikzinput.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/stex.cls b/Master/texmf-dist/tex/latex/stex/stex.cls index 994fa41cbf0..3303869ef9a 100644 --- a/Master/texmf-dist/tex/latex/stex/stex.cls +++ b/Master/texmf-dist/tex/latex/stex/stex.cls @@ -4,48 +4,19 @@ %% %% The original source files were: %% -%% stex-basics.dtx (with options: `cls') +%% stex.dtx (with options: `cls') %% - -%%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% +%%%%%%%%%%%%% stex.dtx %%%%%%%%%%%%% \RequirePackage{expl3,l3keys2e} -\ProvidesExplClass{stex}{2022/09/14}{3.2.0}{sTeX document class} +\ProvidesExplClass{stex}{2023/03/19}{3.3.0}{sTeX document class} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}} \ProcessOptions -\bool_set_true:N \c_stex_document_class_bool - \RequirePackage{stex} -\stex_html_backend:TF { - \LoadClass{article} -}{ - \LoadClass[border=1px,varwidth,crop=false]{standalone} - \setlength\textwidth{15cm} -} -\RequirePackage{standalone} - -\clist_if_empty:NT \c_stex_languages_clist { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { - \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str - } - } - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \prop_if_in:NoT \c_stex_languages_prop \l_tmpa_str { - \stex_debug:nn{language} {Language~\l_tmpa_str~ - inferred~from~file~name} - \exp_args:NNo \stex_set_language:Nn \l_tmpa_str \l_tmpa_str - } - } -} +\LoadClass{article} \endinput %% %% End of file `stex.cls'. diff --git a/Master/texmf-dist/tex/latex/stex/stex.sty b/Master/texmf-dist/tex/latex/stex/stex.sty index 3f23bb2557e..6921cd06d61 100644 --- a/Master/texmf-dist/tex/latex/stex/stex.sty +++ b/Master/texmf-dist/tex/latex/stex/stex.sty @@ -4,130 +4,94 @@ %% %% The original source files were: %% -%% stex-basics.dtx (with options: `package') -%% stex-mathhub.dtx (with options: `package') -%% stex-references.dtx (with options: `package') -%% stex-modules.dtx (with options: `package') -%% stex-inheritance.dtx (with options: `package') -%% stex-symbols.dtx (with options: `package') -%% stex-terms.dtx (with options: `package') -%% stex-features.dtx (with options: `package') -%% stex-statements.dtx (with options: `package') -%% stex-proofs.dtx (with options: `package') -%% stex-metatheory.dtx (with options: `package') -%% stex-others.dtx (with options: `package') +%% stex.dtx (with options: `package') %% - -%%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% - \RequirePackage{expl3,l3keys2e,ltxcmds} -\ProvidesExplPackage{stex}{2022/09/14}{3.2.0}{sTeX package} - -\bool_if_exist:NF \c_stex_document_class_bool { - \bool_set_false:N \c_stex_document_class_bool - \RequirePackage{standalone} -} - -\message{^^J*~This~is~sTeX~version~3.2.0~*^^J} - - -\keys_define:nn { stex } { - debug .clist_set:N = \c_stex_debug_clist , - lang .clist_set:N = \c_stex_languages_clist , - mathhub .tl_set_x:N = \mathhub , - usesms .bool_set:N = \c_stex_persist_mode_bool , - writesms .bool_set:N = \c_stex_persist_write_mode_bool , - image .bool_set:N = \c_tikzinput_image_bool, - unknown .code:n = {} -} -\ProcessKeysOptions { stex } +\ProvidesExplPackage{stex}{2023/03/19}{3.3.0}{sTeX package} \RequirePackage{stex-logo} % externalized for backwards-compatibility reasons -\msg_new:nnn{stex}{error/unknownlanguage}{ - Unknown~language:~#1 -} -\msg_new:nnn{stex}{warning/nomathhub}{ - MATHHUB~system~variable~not~found~and~no~ - \detokenize{\mathhub}-value~set! +\RequirePackage{standalone} + +\message{^^J*~This~is~sTeX~version~3.3.0~*^^J} +\keys_define:nn { stex / package } { + debug .str_set_x:N = \c_stex_debug_clist , + lang .clist_set:N = \c_stex_languages_clist , + mathhub .tl_set_x:N = \mathhub , + usesms .bool_set:N = \c_stex_persist_mode_bool , + writesms .bool_set:N = \c_stex_persist_write_mode_bool , + checkterms .bool_set:N = \c_stex_check_terms_bool , + image .bool_set:N = \c_tikzinput_image_bool, + unknown .code:n = {} +} +\exp_args:NNo \clist_set:Nn \c_stex_debug_clist \c_stex_debug_clist +\ProcessKeysOptions { stex / package } +\input{stex-en.ldf} +\cs_set_eq:NN \stex_undefined: \undefined +\cs_new_protected:Nn \stex_kpsewhich:Nn {\group_begin: + \catcode`\ =12 + \sys_get_shell:nnN { kpsewhich ~ #2 } { } \l_tmpa_tl + \tl_gset_eq:NN \l_tmpa_tl \l_tmpa_tl + \group_end: + \exp_args:NNo\str_set:Nn #1 {\l_tmpa_tl} + \tl_trim_spaces:N #1 } -\msg_new:nnn{stex}{error/deactivated-macro}{ - The~\detokenize{#1}~command~is~only~allowed~in~#2! +\sys_if_platform_windows:TF{ + \cs_new_protected:Nn \stex_get_env:Nn {\group_begin: + \escapechar=-1\catcode`\\=12 + \exp_args:NNe \stex_kpsewhich:Nn #1 {-expand-var~\c_percent_str#2\c_percent_str} + \exp_args:NNx\use:nn\group_end:{ + \str_set:Nn \exp_not:N #1 { #1 } + } + } +}{ + \cs_new_protected:Nn \stex_get_env:Nn { + \stex_kpsewhich:Nn #1 {-var-value~#2} + } } \cs_new_protected:Nn \stex_debug:nn { - \clist_if_in:NnTF \c_stex_debug_clist { all } { - \msg_set:nnn{stex}{debug / #1}{ - \\Debug~#1:~#2\\ - } - \msg_none:nn{stex}{debug / #1} + \exp_args:NNo \clist_if_in:NnTF \c_stex_debug_clist { \tl_to_str:n{all} }{ + \__stex_debug_:nn{#1}{#2} }{ - \clist_if_in:NnT \c_stex_debug_clist { #1 } { - \msg_set:nnn{stex}{debug / #1}{ - \\Debug~#1:~#2\\ - } - \msg_none:nn{stex}{debug / #1} + \exp_args:NNo \clist_if_in:NnT \c_stex_debug_clist { \tl_to_str:n{#1} }{ + \__stex_debug_:nn{#1}{#2} } } } -\clist_if_in:NnTF \c_stex_debug_clist {all} { - \msg_redirect_module:nnn{ stex }{ none }{ term } -}{ - \clist_map_inline:Nn \c_stex_debug_clist { - \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term } - } -} -\stex_debug:nn{log}{debug~mode~on} -\tl_new:N \l_stex_html_arg_tl -\cs_new_protected:Nn \_stex_html_checkempty:n { - \tl_set:Nn \l_stex_html_arg_tl { #1 } - \tl_if_empty:NT \l_stex_html_arg_tl { - \tl_set_eq:NN \l_stex_html_arg_tl \c_stex_html_emptyarg_tl +\cs_new_protected:Nn \__stex_debug_:nn { + \msg_set:nnn{stex}{debug / #1}{ + \\Debug~#1:~#2\\ } + \msg_none:nn{stex}{debug / #1} } -\bool_new:N \_stex_html_do_output_bool -\bool_set_true:N \_stex_html_do_output_bool -\prg_new_conditional:Nnn \stex_if_do_html: {p,T,F,TF} { - \bool_if:nTF \_stex_html_do_output_bool - \prg_return_true: \prg_return_false: +\cs_new_protected:Nn \stex_fatal_error:n { + \msg_error:nn{stex}{#1}\input{Fatal~Error!!} } -\cs_new_protected:Nn \stex_suppress_html:n { - \exp_args:Nne \use:nn { - \bool_set_false:N \_stex_html_do_output_bool - #1 - }{ - \stex_if_do_html:T { - \bool_set_true:N \_stex_html_do_output_bool - } - } +\cs_new_protected:Nn \stex_fatal_error:nnn { + \msg_error:nnn{stex}{#1}{#2}{#3}\input{Fatal~Error!!} } -\ifcsname if@rustex\endcsname\else - \expandafter\newif\csname if@rustex\endcsname - \@rustexfalse -\fi -\ifcsname if@latexml\endcsname\else - \expandafter\newif\csname if@latexml\endcsname - \@latexmlfalse -\fi -\tl_if_exist:NF\stex@backend{ - \if@rustex - \def\stex@backend{rustex} - \else - \if@latexml - \def\stex@backend{latexml} - \else - \cs_if_exist:NTF\HCode{ - \def\stex@backend{tex4ht} - }{ - \def\stex@backend{pdflatex} - } - \fi - \fi +\cs_generate_variant:Nn \stex_fatal_error:nnn {nxx} +\stex_get_env:Nn\__stex_debug_env_str{STEX_DEBUG} +\str_if_empty:NTF\__stex_debug_env_str { + \clist_set_eq:NN \l__stex_debug_cl \c_stex_debug_clist +}{ + \clist_set:No \l__stex_debug_cl {\__stex_debug_env_str} +} +\clist_clear:N \c_stex_debug_clist +\clist_map_inline:Nn \l__stex_debug_cl { + \exp_args:NNo \clist_put_right:Nn \c_stex_debug_clist + { \tl_to_str:n{#1} } } -\input{stex-backend-\stex@backend.cfg} - -\newif\ifstexhtml -\stex_html_backend:TF\stexhtmltrue\stexhtmlfalse +\exp_args:NNo \clist_if_in:NnTF \c_stex_debug_clist {\tl_to_str:n{all}} { + \msg_redirect_module:nnn{ stex }{ none }{ term } + \stex_debug:nn{all}{Logging~everything!} +}{ + \clist_map_inline:Nn \c_stex_debug_clist { + \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term } + \stex_debug:nn{#1}{Logging~#1} + } +} \exp_args:NNx \prop_const_from_keyval:Nn \c_stex_languages_prop { \tl_to_str:n { en = english , de = ngerman , @@ -151,1073 +115,1616 @@ turkish = tr , french = fr }} -\cs_new_protected:Nn \stex_set_language:Nn { - \str_set:Nx \l_tmpa_str {#2} - \prop_get:NoNT \c_stex_languages_prop \l_tmpa_str #1 { - \ifx\@onlypreamble\@notprerr +\str_new:N \l_stex_current_language_str +\cs_new_protected:Nn \stex_set_language:n { + \str_set:Nn \l_stex_current_language_str { #1 } + \prop_if_in:NnTF \c_stex_languages_prop {#1} { + \tl_set_rescan:Nnx \l__stex_lang_lang_str {}{\prop_item:Nn \c_stex_languages_prop {#1}} + \cs_if_eq:NNTF\@onlypreamble\@notprerr{ \ltx@ifpackageloaded{babel}{ - \exp_args:No \selectlanguage #1 + \exp_args:No\selectlanguage\l__stex_lang_lang_str }{} - \else - \exp_args:No \str_if_eq:nnTF #1 {turkish} { - \RequirePackage[#1,shorthands=:!]{babel} - }{ - \RequirePackage[#1]{babel} + }{ + \ltx@ifpackageloaded{babel}{}{ + \str_if_eq:nnTF {#1} {tr} { + \RequirePackage[turkish,shorthands=:!]{babel} + }{ + \RequirePackage[\l__stex_lang_lang_str]{babel} + } } - \fi + } + }{ + \msg_error:nnx{stex}{error/unknownlanguage}{#1} + } +} +\cs_generate_variant:Nn \stex_set_language:n {x,o} +\cs_new_protected:Nn \stex_language_from_file: { + \seq_get_right:NN \g_stex_current_file \l_tmpa_str + \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str + \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % = ".tex/.dtx/.sty" + \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { + \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { + \exp_args:No \str_if_eq:nnF \l_tmpa_str {ltx} { + \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str + } + } + } + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> + \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language + \seq_pop_right:NN \l_tmpa_seq \l__stex_lang_str + \str_if_eq:NNF \l__stex_lang_str \l_stex_current_language_str { + \exp_args:NNo \prop_if_in:NnT \c_stex_languages_prop \l__stex_lang_str { + \stex_set_language:o \l__stex_lang_str + } + } + \stex_debug:nn{lang} {Language~\l_stex_current_language_str~ + inferred~from~file~name} } } - \clist_if_empty:NF \c_stex_languages_clist { - \bool_set_false:N \l_tmpa_bool - \clist_clear:N \l_tmpa_clist + \bool_set_false:N \l__stex_lang_turkish_bool + \seq_clear:N \l_tmpa_seq \clist_map_inline:Nn \c_stex_languages_clist { \str_set:Nx \l_tmpa_str {#1} \str_if_eq:nnT {#1}{tr}{ - \bool_set_true:N \l_tmpa_bool + \bool_set_true:N \l__stex_lang_turkish_bool } \prop_get:NoNTF \c_stex_languages_prop \l_tmpa_str \l_tmpa_str { - \clist_put_right:No \l_tmpa_clist \l_tmpa_str + \tl_set_rescan:Nno \l_tmpa_str {} \l_tmpa_str + \seq_put_right:No \l_tmpa_seq \l_tmpa_str } { \msg_error:nnx{stex}{error/unknownlanguage}{\l_tmpa_str} } } - \stex_debug:nn{lang} {Languages:~\clist_use:Nn \l_tmpa_clist {,~} } - \bool_if:NTF \l_tmpa_bool { - \RequirePackage[\clist_use:Nn \l_tmpa_clist,,shorthands=:!]{babel} + \stex_debug:nn{lang} {Languages:~\seq_use:Nn \l_tmpa_seq {,~} } + \bool_if:NTF \l__stex_lang_turkish_bool { + \exp_args:NNe \use:nn \RequirePackage + {[main=\seq_use:Nn \l_tmpa_seq, ,shorthands=:!]}{babel} }{ - \RequirePackage[\clist_use:Nn \l_tmpa_clist,]{babel} + \exp_args:NNe \use:nn \RequirePackage + {[main=\seq_use:Nn \l_tmpa_seq, ]}{babel} } } +\cs_new_protected:Npn \stex_pseudogroup:nn { + \exp_args:Nne \use:nn +} +\cs_new:Nn \stex_pseudogroup_restore:N { + \tl_if_exist:NTF #1 { + \tl_set:Nn \exp_not:N #1 { \exp_args:No \exp_not:n #1 } + }{ + \cs_undefine:N \exp_not:N #1 + } +} +\cs_new_protected:Nn \stex_pseudogroup_with:nn { + \tl_map_inline:nn{#1}{ + \cs_set_eq:cN{__stex_groups_\tl_to_str:n{##1}}##1 + } + #2 + \tl_map_inline:nn{#1}{ + \cs_set_eq:Nc##1{__stex_groups_\tl_to_str:n{##1}} + \cs_undefine:c{__stex_groups_\tl_to_str:n{##1}} + } +} +\seq_new:N \l__stex_groups_ids_seq +\cs_new_protected:Nn \stex_metagroup_new:n { + \str_set:cx{l__stex_groups_#1_int} {\int_use:N\currentgrouplevel} + \seq_put_right:Nn \l__stex_groups_ids_seq {#1} +} +\cs_generate_variant:Nn \stex_metagroup_new:n {o} +\prg_new_conditional:Nnn \__stex_groups_exists:n {TF} { + \str_if_exist:cTF{l__stex_groups_#1_int} + \prg_return_true: \prg_return_false: +} -\AtBeginDocument{ - \stex_html_backend:T { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be language - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \stex_debug:nn{basics} {Language~\l_tmpa_str~ - inferred~from~file~name} - \stex_annotate_invisible:nnn{language}{ \l_tmpa_str }{} +\cs_new_protected:Nn \stex_metagroup_do_in:nn { + \__stex_groups_exists:nTF{#1}{ + \__stex_groups_do_in:nn{#1}{#2} + }{ + \msg_error:nnn{stex}{error/metagroup/missing}{#1} + } +} +\cs_generate_variant:Nn \stex_metagroup_do_in:nn {nx} + +\cs_new_protected:Nn \__stex_groups_do_in:nn { + \exp_args:Nnx\stex_debug:nn{metagroup}{adding~to~\detokenize{#1}:^^J\tl_to_str:n{#2}} + \tl_set:Nn\__stex_groups_tmp{#2} + \exp_args:Nx \int_compare:nNnF {\use:c{l__stex_groups_#1_int}} + = \currentgrouplevel { + \tl_if_exist:cTF{g__stex_groups_#1_\the\currentgrouplevel _content}{ + \exp_args:Nno \tl_gput_right:cn{g__stex_groups_#1_\the\currentgrouplevel _content} + }{ + \exp_args:Nno \tl_gset:cn{g__stex_groups_#1_\the\currentgrouplevel _content} + }\__stex_groups_tmp + \bool_if_exist:cF {l__stex_groups_\the\currentgrouplevel _bool} { + \group_insert_after:N \__stex_groups_do: + \bool_set_true:c {l__stex_groups_\the\currentgrouplevel _bool} + } + } + \__stex_groups_tmp +} + +\cs_new_protected:Nn \__stex_groups_do: { + \seq_map_inline:Nn \l__stex_groups_ids_seq { + \tl_if_exist:cT{g__stex_groups_##1_\int_eval:n{\currentgrouplevel+1}_content}{ + \exp_args:NNno \exp_args:Nno \__stex_groups_do_in:nn{##1}{ + \csname g__stex_groups_##1_\int_eval:n{\currentgrouplevel+1}_content\endcsname + } + \cs_undefine:c{g__stex_groups_##1_\int_eval:n{\currentgrouplevel+1}_content} + } + \bool_if_exist:cF {l__stex_groups_\int_eval:n\currentgrouplevel _bool} { + \group_insert_after:N \__stex_groups_do: + \bool_set_true:c {l__stex_groups_\int_eval:n\currentgrouplevel _bool} + } + } +} +\bool_new:N \_stex_html_do_output_bool +\bool_set_true:N \_stex_html_do_output_bool + +\prg_new_conditional:Nnn \stex_if_do_html: {p,T,F,TF} { + \bool_if:nTF \_stex_html_do_output_bool + \prg_return_true: \prg_return_false: +} +\cs_new_protected:Nn \stex_suppress_html:n { + \stex_pseudogroup:nn{ + \bool_set_false:N \_stex_html_do_output_bool + #1 + }{ + \stex_if_do_html:T { + \bool_set_true:N \_stex_html_do_output_bool } } } +\ifcsname if@rustex\endcsname\else + \expandafter\newif\csname if@rustex\endcsname + \@rustexfalse +\fi -\bool_if:NTF \c_stex_persist_mode_bool { - \def \stex_persist:n #1 {} - \def \stex_persist:x #1 {} +\stex_get_env:Nn\__stex_annotate_env_str{STEX_FORCE_PDF} +\exp_args:No \str_if_eq:nnTF \__stex_annotate_env_str {true} { + \def\stex@backend{pdflatex} }{ - \bool_if:NTF \c_stex_persist_write_mode_bool { - \iow_new:N \c__stex_persist_iow - \iow_open:Nn \c__stex_persist_iow{\jobname.sms} - \AtEndDocument{ - \iow_close:N \c__stex_persist_iow + \tl_if_exist:NF\stex@backend{ + \if@rustex + \def\stex@backend{rustex} + \else + \cs_if_exist:NTF\HCode{ + \def\stex@backend{tex4ht} + }{ + \def\stex@backend{pdflatex} + } + \fi } - \cs_new_protected:Nn \stex_persist:n { - \tl_set:Nn \l_tmpa_tl { #1 } - \regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl - \regex_replace_all:nnN { \ } { \~ } \l_tmpa_tl - \exp_args:NNo \iow_now:Nn \c__stex_persist_iow \l_tmpa_tl +} + +\input{stex-backend-\stex@backend.cfg} + +\newif\ifstexhtml +\stex_if_html_backend:TF { + \stexhtmltrue + \bool_set_true:N \_stex_html_do_output_bool +}{ + \stexhtmlfalse + \bool_set_false:N \_stex_html_do_output_bool +} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_annotate_force_break:n { + \stex_annotate_invisible:n{~} + #1 + \stex_annotate_invisible:n{~} } - \cs_generate_variant:Nn \stex_persist:n {x} - }{ - \def \stex_persist:n #1 {} - \def \stex_persist:x #1 {} +}{ + \cs_new_protected:Nn \_stex_annotate_force_break:n { #1 } +} +\stex_if_html_backend:TF { + \cs_new_protected:Npn \mmlintent #1 #2 { + \stex_annotate:nn{mml:intent={#1}}{#2} + } + \cs_new_protected:Npn \mmlarg #1 #2 { + \stex_annotate:nn{mml:arg={#1}}{#2} } +}{ + \cs_new_protected:Npn \mmlintent #1 #2 { #2 } + \cs_new_protected:Npn \mmlarg #1 #2 { #2 } } + \cs_new_protected:Nn \stex_deactivate_macro:Nn { - \exp_after:wN\let\csname \detokenize{#1} - orig\endcsname#1 - \def#1{ + \tl_set_eq:cN{\tl_to_str:n{#1}~-~orig}#1 + \tl_set:Nn#1{ \msg_error:nnnn{stex}{error/deactivated-macro}{\detokenize{#1}}{#2} } } \cs_new_protected:Nn \stex_reactivate_macro:N { - \exp_after:wN\let\exp_after:wN#1\csname \detokenize{#1} - orig\endcsname + \exp_after:wN\let\exp_after:wN#1\csname \detokenize{#1}~-~orig\endcsname } -\protected\def\ignorespacesandpars{ +\protected\def\stex_ignore_spaces_and_pars:{ \begingroup\catcode13=10\relax \@ifnextchar\par{ - \endgroup\expandafter\ignorespacesandpars\@gobble + \endgroup\expandafter\stex_ignore_spaces_and_pars:\@gobble }{ \endgroup } } +\cs_new_nopar:Nn \stex_keys_define:nnnn { + \tl_gset:cn {__stex_aux_keys_#1_pre_tl}{#2} + \tl_gset:cn {__stex_aux_keys_#1_def_tl}{#3} + \tl_if_empty:nF{#4}{ + \clist_map_inline:nn{#4}{ + \tl_set_eq:Nc \l__stex_aux_tl {__stex_aux_keys_##1_pre_tl} + \tl_gput_left:co{__stex_aux_keys_#1_pre_tl} \l__stex_aux_tl + \tl_set_eq:Nc \l__stex_aux_tl {__stex_aux_keys_##1_def_tl} + \tl_gput_left:cn{__stex_aux_keys_#1_def_tl} , + \tl_gput_left:co{__stex_aux_keys_#1_def_tl} \l__stex_aux_tl + } + } + \tl_set_eq:Nc \l__stex_aux_tl {__stex_aux_keys_#1_def_tl} + \exp_args:Nno \keys_define:nn {stex / #1} {\l__stex_aux_tl} +} +\cs_new_nopar:Nn \stex_keys_set:nn { + \use:c{__stex_aux_keys_#1_pre_tl} + \keys_set:nn {stex / #1} { #2 } +} +\stex_keys_define:nnnn{archive file}{ + \str_clear:N \l_stex_key_archive_str + \str_clear:N \l_stex_key_file_str +}{ + archive .str_set_x:N = \l_stex_key_archive_str , + file .str_set_x:N = \l_stex_key_file_str +}{} -\cs_new_protected:Nn \stex_copy_control_sequence:NNN { - \tl_set:Nx \_tmp_args_tl {\cs_argument_spec:N #2} - \exp_args:NNo \tl_remove_all:Nn \_tmp_args_tl \c_hash_str - \int_set:Nn \l_tmpa_int {\tl_count:N \_tmp_args_tl} +\stex_keys_define:nnnn{id}{ + \str_clear:N \l_stex_key_id_str +}{ + id .str_set_x:N = \l_stex_key_id_str +}{} - \tl_clear:N \_tmp_args_tl - \int_step_inline:nn \l_tmpa_int { - \tl_put_right:Nx \_tmp_args_tl {{\exp_not:n{####}\exp_not:n{##1}}} - } +\stex_keys_define:nnnn{title}{ + \tl_clear:N \l_stex_key_title_tl +}{ + title .tl_set:N = \l_stex_key_title_tl +}{} - \tl_set:Nn #3 {\cs_generate_from_arg_count:NNnn #1 \cs_set:Npn} - \tl_put_right:Nx #3 { {\int_use:N \l_tmpa_int}{ - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN #2 \_tmp_args_tl +\stex_keys_define:nnnn{style}{ + \clist_clear:N \l_stex_key_style_clist +}{ + style .clist_set:N = \l_stex_key_style_clist +}{} + +\stex_keys_define:nnnn{deprecate}{ + \str_clear:N \l_stex_key_deprecate_str +}{ + deprecate .str_set_x:N = \l_stex_key_deprecate_str +}{} + +\stex_keys_define:nnnn{uses}{}{ + uses .code:n = { + \clist_map_inline:nn{#1}{ + \stex_str_if_starts_with:nnTF{##1}[{ + \__stex_aux_split_at_bracket:w ##1 \_stex_end: + }{ + \usemodule{##1} } - }} + } + } +}{} + +\cs_new_protected:Npn \__stex_aux_split_at_bracket:w [ #1 ] #2 \_stex_end: { + \usemodule[#1]{#2} +} +\cs_new:Nn \_stex_do_deprecation:n { + \str_if_empty:NF \l_stex_key_deprecate_str { + \msg_warning:nnxx{stex}{warning/deprecated}{#1}{\l_stex_key_deprecate_str} + } +} +\cs_new_protected:Nn \_stex_do_id: { + \stex_if_smsmode:F { + \str_if_empty:NF \l_stex_key_id_str { + \exp_args:No \stex_ref_new_doc_target:n \l_stex_key_id_str + } + } +} +\cs_new_protected:Nn \stex_new_stylable_cmd:nnnn { + \exp_after:wN \newcommand \cs:w stexstyle#1 \cs_end:[2][]{ + \__stex_aux_patch:nnn{#1}{##1}{##2} + } + \exp_after:wN \NewDocumentCommand\cs:w #1\cs_end:{#2}{ + \cs_set:Npn \stex_style_apply: { + \__stex_aux_apply_patch:n{#1} + } + #3 + } + \tl_set:cn {__stex_aux_style_#1:} { #4 } } -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {cNN} -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {NcN} -\cs_generate_variant:Nn \stex_copy_control_sequence:NNN {ccN} -\cs_new_protected:Nn \stex_copy_control_sequence_ii:NNN { - \tl_set:Nx \_tmp_args_tl {\cs_argument_spec:N #2} - \exp_args:NNo \tl_remove_all:Nn \_tmp_args_tl \c_hash_str - \int_set:Nn \l_tmpa_int {\tl_count:N \_tmp_args_tl} +\cs_new_protected:Nn \__stex_aux_apply_patch:n { + \clist_if_empty:NTF \l_stex_key_style_clist { + \tl_clear:N \thisstyle + \use:c{__stex_aux_style_#1:} + }{ + \clist_get:NN \l_stex_key_style_clist \thisstyle + \tl_if_exist:cTF{__stex_aux_style_#1_\thisstyle :}{ + \use:c{__stex_aux_style_#1_\thisstyle :} + }{ + \use:c{__stex_aux_style_#1:} + } + } +} - \tl_clear:N \_tmp_args_tl - \int_step_inline:nn \l_tmpa_int { - \tl_put_right:Nx \_tmp_args_tl {{\exp_not:n{########}\exp_not:n{##1}}} +\cs_new_protected:Nn \__stex_aux_patch:nnn { + \str_if_empty:nTF {#2}{ + \tl_set:cn{__stex_aux_style_#1:}{#3} + }{ + \tl_set:cn{__stex_aux_style_#1_#2:}{#3} } +} - \edef \_tmp_args_tl { - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN #2 \_tmp_args_tl +\cs_new_protected:Nn \stex_new_stylable_env:nnnnnnn { + \exp_after:wN \newcommand \cs:w stexstyle#1 \cs_end:[3][]{ + \__stex_aux_patch:nnnn{#1}{##1}{##2}{##3} + } + \NewDocumentEnvironment{#7#1}{#2}{ + \cs_set:Npn \stex_style_apply: { + \__stex_aux_apply_patch_begin:n{#1} + } + #3 + }{ + \cs_set:Npn \stex_style_apply: { + \__stex_aux_apply_patch_end:n{#1} } + #4 } + \tl_set:cn {__stex_aux_style_#1_start:} { #5 } + \tl_set:cn {__stex_aux_style_#1_end:} { #6 } +} - \exp_after:wN \def \exp_after:wN \_tmp_args_tl - \exp_after:wN ##\exp_after:wN 1 \exp_after:wN ##\exp_after:wN 2 - \exp_after:wN { \_tmp_args_tl } +\cs_new_protected:Nn \__stex_aux_patch:nnnn { + \str_if_empty:nTF {#2}{ + \tl_set:cn{__stex_aux_style_#1_start:}{#3} + \tl_set:cn{__stex_aux_style_#1_end:}{#4} + }{ + \tl_set:cn{__stex_aux_style_#1_#2_start:}{#3} + \tl_set:cn{__stex_aux_style_#1_#2_end:}{#4} + } +} - \edef \_tmp_args_tl { - \exp_after:wN \exp_not:n \exp_after:wN { - \_tmp_args_tl {####1}{####2} +\cs_new_protected:Nn \__stex_aux_apply_patch_begin:n { + \clist_if_empty:NTF \l_stex_key_style_clist { + \tl_clear:N \thisstyle + \use:c{__stex_aux_style_#1_start:} + }{ + \clist_get:NN \l_stex_key_style_clist \thisstyle + \stex_debug:nn{styling}{dominant~style:~\thisstyle} + \tl_if_exist:cTF{__stex_aux_style_#1_\thisstyle _start:}{ + \use:c{__stex_aux_style_#1_\thisstyle _start:} + }{ + \use:c{__stex_aux_style_#1_start:} } } +} - \tl_set:Nn #3 {\cs_generate_from_arg_count:NNnn #1 \cs_set:Npn} - \tl_put_right:Nx #3 { {\int_use:N \l_tmpa_int}{ - \exp_after:wN\exp_not:n\exp_after:wN{\_tmp_args_tl} - }} +\cs_new_protected:Nn \__stex_aux_apply_patch_end:n { + \tl_if_empty:NTF \thisstyle { + \use:c{__stex_aux_style_#1_end:} + }{ + \tl_if_exist:cTF{__stex_aux_style_#1_\thisstyle _end:}{ + \use:c{__stex_aux_style_#1_\thisstyle _end:} + }{ + \use:c{__stex_aux_style_#1_end:} + } + } +} +\prg_new_conditional:Nnn \stex_str_if_ends_with:nn {p,T,F,TF} { + \exp_args:Ne \str_if_eq:nnTF { + \str_range:nnn{#1}{- \str_count:n{#2}}{-1} + }{#2}\prg_return_true: \prg_return_false: +} +\prg_new_conditional:Nnn \stex_str_if_starts_with:nn {p,T,F,TF} { + \exp_args:Ne \str_if_eq:nnTF { + \str_range:nnn{#1}{1}{\str_count:n{#2}} + }{#2}\prg_return_true: \prg_return_false: +} +\cs_new:Npn \__stex_aux_start:#1\__stex_aux_end: {\exp_not:n{#1}} +\cs_new_protected:Nn \__stex_aux_end: {} +\cs_new:Nn \stex_macro_body:N { + \exp_args:Nne\use:nn{\exp_after:wN \__stex_aux_start: #1}{ + \__stex_aux_args:e {\cs_parameter_spec:N #1}\__stex_aux_end: + } } -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {cNN} -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {NcN} -\cs_generate_variant:Nn \stex_copy_control_sequence_ii:NNN {ccN} -\NewDocumentCommand \MMTrule {m m}{ - \seq_set_split:Nnn \l_tmpa_seq , {#2} - \int_zero:N \l_tmpa_int - \stex_annotate_invisible:nnn{mmtrule}{scala://#1}{ - \seq_if_empty:NF \l_tmpa_seq { - $\seq_map_inline:Nn \l_tmpa_seq { - \int_incr:N \l_tmpa_int - \stex_annotate:nnn{arg}{i\int_use:N \l_tmpa_int}{##1} - }$ +\cs_new:Nn \__stex_aux_args:n { + \tl_if_empty:nF{#1}{ + {##\exp_args:Ne \tl_head:n {\tl_tail:n {#1}}} + \__stex_aux_args:e {\exp_args:Ne\tl_tail:n{\tl_tail:n{#1}}} + } +} +\cs_generate_variant:Nn \__stex_aux_args:n {e} +\cs_new:Nn \stex_macro_definition:N { + \__stex_aux_prefix:e {\cs_prefix_spec:N #1} + \def\exp_not:N #1 + \__stex_aux_params:e {\cs_parameter_spec:N #1} + { + \stex_macro_body:N #1 + } +} + +\cs_new:Nn \__stex_aux_prefix:n { + \tl_if_empty:nF{#1}{ + \str_if_eq:eeTF { + \tl_range:nnn{#1}{1}{10}~ + }{\tl_to_str:n{\protected}}{ + \protected + \__stex_aux_prefix_long:e { + \str_range:nnn{#1}{11}{-1} + } + }{ + \__stex_aux_prefix_long:n {#1} } } } +\cs_generate_variant:Nn \__stex_aux_prefix:n {e} -\NewDocumentCommand \MMTinclude {m}{ - \stex_annotate_invisible:nnn{import}{#1}{} +\cs_new:Nn \__stex_aux_prefix_long:n { + \tl_if_empty:nF{#1}{ + \str_if_eq:eeT { + \tl_range:nnn{#1}{1}{10}~ + }{\tl_to_str:n{\long}}{\long} + } } +\cs_generate_variant:Nn \__stex_aux_prefix_long:n {e} -\tl_new:N \g_stex_document_title -\cs_new_protected:Npn \STEXtitle #1 { - \tl_if_empty:NT \g_stex_document_title { - \tl_gset:Nn \g_stex_document_title { #1 } +\cs_new:Nn \__stex_aux_params:n { + \tl_if_empty:nF{#1}{ + \exp_args:NNe \str_if_eq:VnTF \c_hash_str {\tl_head:n{#1}}{ + #### + }{ + \tl_head:n{#1} + } + \__stex_aux_params:e {\tl_tail:n{#1}} } } -\cs_new_protected:Nn \stex_document_title:n { - \tl_if_empty:NT \g_stex_document_title { - \tl_gset:Nn \g_stex_document_title { #1 } - \stex_annotate_invisible:n{\noindent - \stex_annotate:nnn{doctitle}{}{ #1 } - \par} +\cs_generate_variant:Nn \__stex_aux_params:n {e} +\stex_get_env:Nn\__stex_persist_env_str{STEX_USESMS} +\str_if_empty:NF\__stex_persist_env_str{ + \exp_args:No \str_if_eq:nnF \__stex_persist_env_str{false}{ + \bool_set_true:N \c_stex_persist_mode_bool } } -\AtBeginDocument { - \let \STEXtitle \stex_document_title:n - \tl_if_empty:NF \g_stex_document_title { - \stex_annotate_invisible:n{\noindent - \stex_annotate:nnn{doctitle}{}{ \g_stex_document_title } - \par} - } - \let\_stex_maketitle:\maketitle - \def\maketitle{ - \tl_if_empty:NF \@title { - \exp_args:No \stex_document_title:n \@title +\stex_get_env:Nn\__stex_persist_env_str{STEX_WRITESMS} +\str_if_empty:NF\__stex_persist_env_str{ + \exp_args:No \str_if_eq:nnF \__stex_persist_env_str{false}{ + \bool_set_true:N \c_stex_persist_write_mode_bool + } +} +\iow_new:N \c__stex_persist_sms_iow + +\bool_if:NTF \c_stex_persist_write_mode_bool { + \stex_if_html_backend:TF{ + \cs_new:Npn \stex_persist:n #1 {} + \cs_new:Npn \stex_persist:e #1 {} + }{ + \cs_new_protected:Nn \stex_persist:n { + \iow_now:Nn \c__stex_persist_sms_iow {#1} } - \_stex_maketitle: + \cs_generate_variant:Nn \stex_persist:n {e} } +}{ + \cs_new:Npn \stex_persist:n #1 {} + \cs_new:Npn \stex_persist:e #1 {} } -\cs_new_protected:Nn \stex_par: { - \mode_if_vertical:F{ - \if@minipage\else\if@nobreak\else\par\fi\fi +\cs_new_protected:Nn \__stex_persist_load_file:n { + \file_if_exist:nT{#1}{ + \group_begin: + \cs_set:Npn \stex_persist:n ##1 {} + \cs_set:Npn \stex_persist:e ##1 {} + \stex_debug:nn{persist}{restoring~from~sms~file} + \catcode`\ =10\relax + \cs:w @ @ input \cs_end:#1\relax + \group_end: } } +\cs_new_protected:Nn \__stex_persist_write_only: { + \iow_open:Nn \c__stex_persist_sms_iow {\jobname.sms} + \AtEndDocument{ \iow_close:N \c__stex_persist_sms_iow } +} -%%%%%%%%%%%%% mathhub.dtx %%%%%%%%%%%%% +\cs_new_protected:Nn \__stex_persist_read_and_write: { + \file_if_exist:nTF{\jobname.sms}{ + \ior_open:Nn \g_tmpa_ior {\jobname.sms} + \iow_open:Nn \g_tmpa_iow {\jobname.sms2} + \ior_str_map_inline:Nn \g_tmpa_ior { + \iow_now:Nn \g_tmpa_iow {##1} + } + \iow_close:N \g_tmpa_iow + \ior_close:N \g_tmpa_ior + \__stex_persist_write_only: + \ior_open:Nn \g_tmpa_ior {\jobname.sms2} + \ior_str_map_inline:Nn \g_tmpa_ior { + \iow_now:Nn \c__stex_persist_sms_iow {##1} + } + \ior_close:N \g_tmpa_ior + \__stex_persist_load_file:n{\jobname.sms2} + }\__stex_persist_write_only: +} -\msg_new:nnn{stex}{error/norepository}{ - No~archive~#1~found~in~#2 +\cs_new_protected:Nn \_stex_persist_read_now: { + \bool_if:NTF \c_stex_persist_mode_bool { + \bool_if:NTF \c_stex_persist_write_mode_bool + \__stex_persist_read_and_write: + { + \__stex_persist_load_file:n{\jobname.sms} + } + }{ + \bool_if:NT \c_stex_persist_write_mode_bool \__stex_persist_write_only: + } } -\msg_new:nnn{stex}{error/notinarchive}{ - Not~currently~in~an~archive,~but~\detokenize{#1}~ - needs~one! +\cs_new_protected:Nn \stex_file_set:Nn { + \str_if_empty:nTF {#2} { \seq_clear:N #1 }{ + \exp_args:NNno \seq_set_split:Nnn #1 / { \tl_to_str:n{#2} } + } } -\msg_new:nnn{stex}{error/nofile}{ - \detokenize{#1}~could~not~find~file~#2 +\cs_generate_variant:Nn \stex_file_set:Nn {No, Nx} +\sys_if_platform_windows:TF{ + \cs_new_protected:Npn \__stex_path_win_take:w #1#2#3 \__stex_path_: { + \str_set:Nn \l__stex_path_win_drive {#1#2} + \str_set:Nn \l__stex_path_str{#3} + } + \cs_new_protected:Nn \stex_file_resolve:Nn { + \str_set:Nn \l__stex_path_str {#2} + \str_clear:N \l__stex_path_win_drive + \exp_args:NNo \str_replace_all:Nnn \l__stex_path_str \c_backslash_str / + \exp_args:Nx \str_if_eq:nnT {\str_item:Nn \l__stex_path_str 2} : { + \exp_after:wN \__stex_path_win_take:w \l__stex_path_str \__stex_path_: + } + \stex_file_set:No #1 \l__stex_path_str + \__stex_path_canonicalize:N #1 + \str_if_empty:NF \l__stex_path_win_drive { + \seq_pop_left:NN #1 \l__stex_path_str + \seq_put_left:No #1 \l__stex_path_win_drive + } + %\stex_debug:nn{files}{Set~\tl_to_str:n{#1}~to~\stex_file_use:N #1} + } +}{ + \cs_new_protected:Nn \stex_file_resolve:Nn { + \str_set:Nn \l__stex_path_str {#2} + \stex_file_set:No #1 \l__stex_path_str + \__stex_path_canonicalize:N #1 + % \stex_debug:nn{files}{Set~\tl_to_str:n{#1}~to~\stex_file_use:N #1} + } } -\msg_new:nnn{stex}{error/twofiles}{ - \detokenize{#1}~found~two~candidates~for~#2 +\cs_generate_variant:Nn \stex_file_resolve:Nn {No, Nx} + +\cs_new_protected:Nn \__stex_path_canonicalize:N { + \seq_if_empty:NF #1 { + \seq_pop:NN #1 \l__stex_path_str + \seq_clear:N \l__stex_path_seq + \str_if_empty:NTF \l__stex_path_str { + \seq_map_function:NN #1 \__stex_path_dodots:n + \seq_put_left:Nn \l__stex_path_seq {} + }{ + \seq_push:No #1 \l__stex_path_str + \seq_map_function:NN #1 \__stex_path_dodots:n + } + \seq_set_eq:NN #1 \l__stex_path_seq + } } -\cs_new_protected:Nn \stex_path_from_string:Nn { - \stex_debug:nn{files}{#2} - \str_set:Nx \l_tmpa_str { #2 } - \str_if_empty:NTF \l_tmpa_str { - \seq_clear:N #1 - }{ - \exp_args:NNNo \seq_set_split:Nnn #1 / { \l_tmpa_str } - \sys_if_platform_windows:T{ - \seq_clear:N \l_tmpa_tl - \seq_map_inline:Nn #1 { - \seq_set_split:Nnn \l_tmpb_tl \c_backslash_str { ##1 } - \seq_concat:NNN \l_tmpa_tl \l_tmpa_tl \l_tmpb_tl + +\cs_new_protected:Nn \__stex_path_dodots:n { + \str_if_empty:nF{#1}{ + \str_if_eq:nnF {#1} {.} { + \str_if_eq:nnTF {#1} {..} { + \seq_if_empty:NF \l__stex_path_seq { + \seq_pop_right:NN \l__stex_path_seq \l__stex_path_str + } + }{ + \seq_put_right:Nn \l__stex_path_seq {#1} } - \seq_set_eq:NN #1 \l_tmpa_tl } - \stex_path_canonicalize:N #1 } - \stex_debug:nn{files}{Yields: \stex_path_to_string:N#1} } -\cs_new_protected:Nn \stex_path_to_string:NN { - \exp_args:NNe \str_set:Nn #2 { \seq_use:Nn #1 / } +\sys_if_platform_windows:TF { + \prg_new_conditional:Nnn \stex_if_file_absolute:N {p, T, F, TF} { + \seq_if_empty:NTF #1 \prg_return_false: { + \tl_set:Nx \l__stex_path_maybewin_str {\seq_item:Nn #1 1} + \exp_args:No \tl_if_empty:nTF \l__stex_path_maybewin_str \prg_return_true: { + \exp_args:Nx \str_if_eq:nnTF {\str_item:Nn \l__stex_path_maybewin_str 2} : + \prg_return_true: \prg_return_false: + } + } + } +}{ + \prg_new_conditional:Nnn \stex_if_file_absolute:N {p, T, F, TF} { + \seq_if_empty:NTF #1 \prg_return_false: { + \exp_args:Nx \tl_if_empty:nTF {\seq_item:Nn #1 1} + \prg_return_true: \prg_return_false: + } + } } - -\cs_new:Nn \stex_path_to_string:N { +\cs_new:Nn \stex_file_use:N { \seq_use:Nn #1 / } -\str_const:Nn \c__stex_path_dot_str {.} -\str_const:Nn \c__stex_path_up_str {..} -\cs_new_protected:Nn \stex_path_canonicalize:N { - \seq_if_empty:NF #1 { - \seq_clear:N \l_tmpa_seq - \seq_get_left:NN #1 \l_tmpa_tl - \str_if_empty:NT \l_tmpa_tl { - \seq_put_right:Nn \l_tmpa_seq {} - } - \seq_map_inline:Nn #1 { - \str_set:Nn \l_tmpa_tl { ##1 } - \str_if_eq:NNF \l_tmpa_tl \c__stex_path_dot_str { - \str_if_eq:NNTF \l_tmpa_tl \c__stex_path_up_str { - \seq_if_empty:NTF \l_tmpa_seq { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \c__stex_path_up_str - } - }{ - \seq_get_right:NN \l_tmpa_seq \l_tmpa_tl - \str_if_eq:NNTF \l_tmpa_tl \c__stex_path_up_str { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \c__stex_path_up_str - } - }{ - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_tl - } - } +\prg_new_protected_conditional:Nnn \stex_if_file_starts_with:NN {T,F,TF} { + \seq_set_eq:NN \l__stex_path_a_seq #1 + \seq_set_eq:NN \l__stex_path_b_seq #2 + \tl_clear:N \l__stex_path_return_tl + \bool_while_do:nn{ + \bool_not_p:n{ + \bool_lazy_any_p:n{ + {\seq_if_empty_p:N \l__stex_path_a_seq} + {\seq_if_empty_p:N \l__stex_path_b_seq} + {\bool_not_p:n{\tl_if_empty_p:N \l__stex_path_return_tl}} + } + } + }{ + \seq_pop_left:NN \l__stex_path_a_seq \l__stex_path_a_tl + \seq_pop_left:NN \l__stex_path_b_seq \l__stex_path_b_tl + \str_if_eq:NNF \l__stex_path_a_tl \l__stex_path_b_tl { + \tl_set:Nn \l__stex_path_return_tl {\prg_return_false:} + } + } + \tl_if_empty:NTF \l__stex_path_return_tl { + \seq_if_empty:NTF \l__stex_path_b_seq \prg_return_true: \prg_return_false: + } \l__stex_path_return_tl +} +\cs_new_protected:Nn \stex_file_split_off_ext:NN { + \seq_set_eq:NN #1 #2 + \seq_pop_right:NN #1 \l__stex_path_str + \seq_set_split:NnV \l__stex_path_seq . \l__stex_path_str + \seq_pop_right:NN \l__stex_path_seq \l__stex_path_str + \seq_put_right:Nx #1 {\seq_use:Nn \l__stex_path_seq .} +} +\cs_new_protected:Nn \stex_file_split_off_lang:NN { + \seq_set_eq:NN #1 #2 + \seq_pop_right:NN #1 \l__stex_path_str + \seq_set_split:NnV \l__stex_path_seq . \l__stex_path_str + \seq_pop_right:NN \l__stex_path_seq \l__stex_path_str + + \seq_pop_right:NN \l__stex_path_seq \l__stex_path_str + \exp_args:NNo \prop_if_in:NnF \c_stex_languages_prop \l__stex_path_str { + \seq_put_right:No \l__stex_path_seq \l__stex_path_str + } + + \seq_put_right:Nx #1 {\seq_use:Nn \l__stex_path_seq .} +} +\cs_set_protected:Nn \__stex_path_auth:n { + \msg_error:nnx{stex}{error/misused-uri}{\tl_to_str:n{#1}} +} +\cs_set_eq:NN \__stex_path_path:n \__stex_path_auth:n +\cs_set_eq:NN \__stex_path_module:n \__stex_path_auth:n +\cs_set_eq:NN \__stex_path_name:n \__stex_path_auth:n + +\cs_set_protected:Nn \stex_map_uri:Nnnnn{ + \stex_pseudogroup_with:nn{\__stex_path_auth:n\__stex_path_path:n\__stex_path_module:n\__stex_path_name:n}{ + \cs_set:Npn \__stex_path_auth:n ##1 {#2} + \cs_set:Npn \__stex_path_path:n ##1 {#3} + \cs_set:Npn \__stex_path_module:n ##1 {#4} + \cs_set:Npn \__stex_path_name:n ##1 {#5} + #1 + } +} +\str_set:Nx\__stex_path_colonslash{\c_colon_str/} +\cs_new_protected:Nn \__stex_path_uri_set:NnN { + \str_if_empty:nTF {#2} { + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{empty} + }{ + \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn #1 \__stex_path_colonslash { \tl_to_str:n{#2} } + \seq_pop_left:NN #1 \l__stex_path_auth_str + \seq_if_empty:NTF #1 { + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{missing~authority} + }{ + \exp_args:NNnx \seq_set_split:Nnn #1 ? {\exp_args:NNo \seq_use:Nn #1 \__stex_path_colonslash } + \seq_pop_left:NN #1 \l__stex_path_path + #3 \l__stex_path_path \l__stex_path_path + \seq_if_empty:NTF #1 { + \exp_args:NNo \__stex_path_uri_set:Nnxnn #1 \l__stex_path_auth_str + {\stex_file_use:N \l__stex_path_path} {} {} + }{ + \seq_pop_left:NN #1 \l__stex_path_mod + \seq_if_empty:NTF #1 { + \exp_args:NNo \__stex_path_uri_set:Nnxon #1 \l__stex_path_auth_str + {\stex_file_use:N \l__stex_path_path} \l__stex_path_mod {} }{ - \str_if_empty:NF \l_tmpa_tl { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { \l_tmpa_tl } + \seq_pop_left:NN #1 \l__stex_path_name + \seq_if_empty:NTF #1 { + \exp_args:NNo \__stex_path_uri_set:Nnxon #2 \l__stex_path_auth_str + {\stex_file_use:N \l__stex_path_path} \l__stex_path_mod \l__stex_path_name + }{ + \msg_error:nnxx{stex}{error/invalid-uri}{\tl_to_str:n{#2}}{too~many~?s} } } } } - \seq_gset_eq:NN #1 \l_tmpa_seq } + \stex_debug:nn{uris}{Set~\tl_to_str:n{#1}~to~\stex_uri_use:N #1} } -\prg_new_conditional:Nnn \stex_path_if_absolute:N {p, T, F, TF} { - \seq_if_empty:NTF #1 { - \prg_return_false: + +\cs_new_protected:Nn \__stex_path_uri_set:Nnnnn{ + \tl_set:Nn #1 { + \__stex_path_auth:n{ #2 } + \__stex_path_path:n{ #3 } + \__stex_path_module:n{ #4 } + \__stex_path_name:n{ #5 } + } +} +\cs_generate_variant:Nn\__stex_path_uri_set:Nnnnn {Nnxnn,Nnxon,Nnxoo} + +\cs_new_protected:Nn \stex_uri_set:Nn { + \__stex_path_uri_set:NnN #1 {#2} \stex_file_set:No +} +\cs_generate_variant:Nn \stex_uri_set:Nn {No, Nx} +\cs_new_protected:Nn \stex_uri_resolve:Nn { + \__stex_path_uri_set:NnN #1 {#2} \stex_file_resolve:No +} +\cs_generate_variant:Nn \stex_uri_resolve:Nn {No, Nx} +\cs_new:Npn \__stex_path_uri_use:w \__stex_path_auth:n #1 \__stex_path_path:n #2 \__stex_path_module:n #3 \__stex_path_name:n #4 { + #1\c_colon_str/ #2 \tl_if_empty:nF { #3 }{ ? #3 + \tl_if_empty:nF { #4 }{ ? #4 } } +} +\cs_new:Nn \stex_uri_use:N { + \exp_args:Ne \cs_if_eq:NNTF { \tl_head:N #1 } \__stex_path_auth:n { + \exp_after:wN \__stex_path_uri_use:w #1 }{ - \seq_get_left:NN #1 \l_tmpa_tl - \sys_if_platform_windows:TF{ - \str_if_in:NnTF \l_tmpa_tl {:}{ - \prg_return_true: - }{ - \prg_return_false: - } - }{ - \str_if_empty:NTF \l_tmpa_tl { - \prg_return_true: - }{ - \prg_return_false: + \msg_error:nnnn{stex}{error/invalid-uri}{#1}{Not~a~URI} + } +} +\cs_new_protected:Npn \stex_uri_from_repo_file_nolang:NNNn { + \__stex_path_from_repo_file:NNNNn \stex_file_split_off_lang:NN +} +\cs_new_protected:Npn \stex_uri_from_repo_file:NNNn { + \__stex_path_from_repo_file:NNNNn \stex_file_split_off_ext:NN +} + +\cs_new_protected:Nn \__stex_path_from_repo_file:NNNNn { + #1 \l__stex_path_file #4 + \prop_if_exist:NTF #3 { + \str_clear:N \l__stex_path_uri + \prop_get:NnNF #3 {#5} \l__stex_path_uri { + \prop_get:NnNF #3 {ns} \l__stex_path_uri { + \__stex_path_uri_set:Nnxnn #2 {file} + {\stex_file_use:N \l__stex_path_file} {} {} } } + \str_if_empty:NF \l__stex_path_uri {\__stex_path_relativize:N #2} + }{ + \exp_args:NNx \__stex_path_uri_set:Nnxnn #2 {\tl_to_str:n{file}} + {\stex_file_use:N \l__stex_path_file} {} {} } } -\str_new:N\l_stex_kpsewhich_return_str -\cs_new_protected:Nn \stex_kpsewhich:n {\begingroup - \catcode`\ =12 - \sys_get_shell:nnN { kpsewhich ~ #1 } { } \l_tmpa_tl - \tl_gset_eq:NN \l_tmpa_tl \l_tmpa_tl - \endgroup - \exp_args:NNo\str_set:Nn\l_stex_kpsewhich_return_str{\l_tmpa_tl} - \tl_trim_spaces:N \l_stex_kpsewhich_return_str + +\cs_new_protected:Nn \__stex_path_relativize:N { + \seq_set_eq:NN \l__stex_path_seq \l__stex_path_file + \seq_map_inline:Nn \c_stex_mathhub_file { % mathhub path + \seq_pop_left:NN \l__stex_path_seq \l__stex_path_tl + } + \stex_file_set:Nx \l__stex_path_path {\prop_item:Nn \l_stex_current_archive_prop {id} } + \seq_map_inline:Nn \l__stex_path_path { % id + \seq_pop_left:NN \l__stex_path_seq \l__stex_path_tl + } + \seq_pop_left:NN \l__stex_path_seq \l__stex_path_tl % source + + \stex_uri_set:Nx #1 { \l__stex_path_uri / \stex_file_use:N \l__stex_path_seq } +} +\cs_new_protected:Nn \stex_uri_from_current_file:Nn { + \stex_debug:nn{docuri}{Here:~\stex_file_use:N \g_stex_current_file} + \stex_uri_from_repo_file:NNNn #1 \l_stex_current_archive_prop + \g_stex_current_file {#2} + \stex_debug:nn{docuri}{resolved:~\stex_uri_use:N #1} +} +\cs_new_protected:Nn \stex_uri_from_current_file_nolang:Nn { + \stex_uri_from_repo_file_nolang:NNNn #1 \l_stex_current_archive_prop + \g_stex_current_file {#2} +} +\cs_new_protected:Nn \stex_uri_add_module:NNn { + \exp_args:Ne \cs_if_eq:NNTF { \tl_head:N #2 } \__stex_path_auth:n { + \stex_pseudogroup_with:nn + {\__stex_path_auth:n\__stex_path_path:n\__stex_path_module:n\__stex_path_name:n} + { + \cs_set:Npn \__stex_path_module:n ##1 { + \tl_if_empty:nTF{##1}{ + \exp_not:N \__stex_path_module:n {#3} + }{ + \msg_error:nnn{stex}{error/invalid-dpath}{#2} + } + } + \cs_set:Npn \__stex_path_name:n ##1 { + \tl_if_empty:nTF{##1}{ + \exp_not:N \__stex_path_name:n {} + }{ + \msg_error:nnn{stex}{error/invalid-dpath}{#2} + } + } + \tl_set:Nx #1 {#2} + } + }{ + \msg_error:nnnn{stex}{error/invalid-uri}{#2}{Not~a~URI} + } +} +\cs_generate_variant:Nn \stex_uri_add_module:NNn {NNo} +\tl_new:N \l_stex_current_doc_uri +\cs_new_protected:Nn \stex_set_document_uri: { + \stex_uri_from_current_file:Nn \l_stex_current_doc_uri {narr} + %\stex_debug:nn{sref}{Document~URI:~\stex_uri_use:N \l_stex_current_doc_uri} +} +\cs_new_protected:Nn \stex_set_current_namespace: { + \stex_uri_from_current_file_nolang:Nn \l_stex_current_ns_uri {source-base} + %\stex_debug:nn{modules}{Namespace~URI:~\stex_uri_use:N \l_stex_current_ns_uri} } \sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str CD\c_percent_str} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} + \stex_get_env:Nn\l__stex_path_str{CD} }{ - \stex_kpsewhich:n{-var-value~PWD} + \stex_get_env:Nn\l__stex_path_str{PWD} } +\stex_file_resolve:No \c_stex_pwd_file \l__stex_path_str +\seq_set_eq:NN \c_stex_main_file \c_stex_pwd_file +\seq_put_right:Nx \c_stex_main_file {\jobname\tl_to_str:n{.tex}} -\stex_path_from_string:Nn\c_stex_pwd_seq\l_stex_kpsewhich_return_str -\stex_path_to_string:NN\c_stex_pwd_seq\c_stex_pwd_str -\stex_debug:nn {mathhub} {PWD:~\str_use:N\c_stex_pwd_str} -\seq_gclear_new:N\g__stex_files_stack -\str_set:Nx \c_stex_mainfile_str {\c_stex_pwd_str/\jobname.tex} -\stex_path_from_string:Nn \c_stex_mainfile_seq - \c_stex_mainfile_str -\seq_gclear_new:N\g_stex_currentfile_seq +\stex_debug:nn {files} {PWD:~\stex_file_use:N \c_stex_pwd_file} +\seq_gclear_new:N\g__stex_path_stack +\seq_gclear_new:N\g_stex_current_file \cs_new_protected:Nn \stex_filestack_push:n { - \stex_path_from_string:Nn\g_stex_currentfile_seq{#1} - \stex_path_if_absolute:NF\g_stex_currentfile_seq{ - \stex_path_from_string:Nn\g_stex_currentfile_seq{ - \c_stex_pwd_str/#1 + \stex_str_if_ends_with:nnTF {#1}{.tex}{ + \stex_file_resolve:No \g_stex_current_file {#1} + }{ + \stex_file_resolve:No \g_stex_current_file {#1.tex} + } + \stex_if_file_absolute:NF \g_stex_current_file { + \stex_file_resolve:Nx \g_stex_current_file { + \stex_file_use:N \c_stex_pwd_file / \stex_file_use:N \g_stex_current_file } } - \seq_gset_eq:NN\g_stex_currentfile_seq\g_stex_currentfile_seq - \exp_args:NNo\seq_gpush:Nn\g__stex_files_stack\g_stex_currentfile_seq - \stex_get_document_uri: + \seq_gset_eq:NN \g_stex_current_file \g_stex_current_file + \exp_args:NNx \seq_gpush:Nn \g__stex_path_stack {\stex_file_use:N \g_stex_current_file} + \_stex_every_file: +} + +\cs_new_protected:Nn \_stex_every_file: { + \stex_set_document_uri: + \stex_language_from_file: + \stex_set_current_namespace: } \cs_new_protected:Nn \stex_filestack_pop: { - \seq_if_empty:NF\g__stex_files_stack{ - \seq_gpop:NN\g__stex_files_stack\l_tmpa_seq + \seq_if_empty:NF \g__stex_path_stack { + \seq_gpop:NN \g__stex_path_stack \l__stex_path_str } - \seq_if_empty:NTF\g__stex_files_stack{ - \seq_gset_eq:NN\g_stex_currentfile_seq\c_stex_mainfile_seq + \seq_if_empty:NTF \g__stex_path_stack { + \seq_gset_eq:NN \g_stex_current_file \c_stex_main_file }{ - \seq_get:NN\g__stex_files_stack\l_tmpa_seq - \seq_gset_eq:NN\g_stex_currentfile_seq\l_tmpa_seq + \seq_get:NN \g__stex_path_stack \l__stex_path_str + \exp_args:NNo \stex_file_set:Nn \g_stex_current_file \l__stex_path_str + \seq_gset_eq:NN \g_stex_current_file \g_stex_current_file } - \stex_get_document_uri: + \_stex_every_file: } -\AddToHook{file/before}{ - \tl_if_empty:NTF\CurrentFilePath{ - \stex_filestack_push:n{\CurrentFile} - }{ - \stex_filestack_push:n{\CurrentFilePath/\CurrentFile} + +\cs_new_protected:Nn \stex_input_with_hooks:n { + \tl_set:Nn \l__stex_path_do_hooks_pre_tl { + \tl_gset:Nn \l__stex_path_do_hooks_pre_tl {} + \stex_debug:nn{HERE}{Hook~for~#1^^J\meaning\CurrentFilePath^^J\CurrentFile} + \tl_if_empty:NTF\CurrentFilePath{ + \exp_args:No \stex_filestack_push:n {\CurrentFile} + }{ + \exp_args:Ne \stex_filestack_push:n { \CurrentFilePath / \CurrentFile } + } } -} -\AddToHook{file/after}{ + \input{#1} + \stex_debug:nn{HERE}{Hook~end~for~#1} \stex_filestack_pop: } +\tl_new:N \l__stex_path_do_hooks_pre_tl {} + +\AddToHook{file/before}{ + \l__stex_path_do_hooks_pre_tl +} + +\sys_if_platform_windows:TF{ + \stex_get_env:Nn \l__stex_mathhub_str {homedrive\c_percent_str\c_percent_str homepath} +}{ + \stex_get_env:Nn \l__stex_mathhub_str {HOME} +} +\stex_file_resolve:No \c_stex_home_file \l__stex_mathhub_str + \str_if_empty:NTF\mathhub{ - \sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str MATHHUB\c_percent_str} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:NNx\str_if_eq:onT\l_stex_kpsewhich_return_str{\c_percent_str MATHHUB\c_percent_str}{\str_clear:N\l_stex_kpsewhich_return_str} - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} - }{ - \stex_kpsewhich:n{-var-value~MATHHUB} - } - \str_set_eq:NN\c_stex_mathhub_str\l_stex_kpsewhich_return_str - - \str_if_empty:NT \c_stex_mathhub_str { - \sys_if_platform_windows:TF{ - \begingroup\escapechar=-1\catcode`\\=12 - \exp_args:Nx\stex_kpsewhich:n{-var-value~HOME} - \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ - \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} - }{ - \stex_kpsewhich:n{-var-value~HOME} - } - \ior_open:NnT \g_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{ - \begingroup\escapechar=-1\catcode`\\=12 - \ior_str_get:NN \g_tmpa_ior \l_tmpa_str - \sys_if_platform_windows:T{ - \exp_args:NNx\str_replace_all:Nnn\l_tmpa_str{\c_backslash_str}/ - } - \str_gset_eq:NN \c_stex_mathhub_str\l_tmpa_str - \endgroup + \stex_get_env:Nn \l__stex_mathhub_str {MATHHUB} + \str_if_empty:NTF \l__stex_mathhub_str { + \ior_open:NnTF \g_tmpa_ior{\stex_file_use:N \c_stex_home_file/.stex/mathhub.path}{ + \group_begin: + \escapechar=-1\catcode`\\=12 + \ior_str_get:NN \g_tmpa_ior \l__stex_mathhub_str + \str_gset_eq:NN \l__stex_mathhub_str \l__stex_mathhub_str + \group_end: \ior_close:N \g_tmpa_ior + \stex_debug:nn{mathhub}{MathHub~directory~determined~from~home~directory} + }{ + \str_clear:N \l__stex_mathhub_str } - } - \str_if_empty:NTF\c_stex_mathhub_str{ - \msg_warning:nn{stex}{warning/nomathhub} }{ - \stex_debug:nn{mathhub}{MathHub:~\str_use:N\c_stex_mathhub_str} - \exp_args:NNo \stex_path_from_string:Nn\c_stex_mathhub_seq\c_stex_mathhub_str + \stex_debug:nn{mathhub}{MathHub~directory~determined~from~environment~variable} } }{ - \stex_path_from_string:Nn \c_stex_mathhub_seq \mathhub - \stex_path_if_absolute:NF \c_stex_mathhub_seq { - \exp_args:NNx \stex_path_from_string:Nn \c_stex_mathhub_seq { - \c_stex_pwd_str/\mathhub + \str_set_eq:NN \l__stex_mathhub_str \mathhub +} + +\str_if_empty:NTF \l__stex_mathhub_str { + \msg_warning:nn{stex}{warning/nomathhub} + \exp_args:NNe \stex_file_set:Nn \c_stex_mathhub_file {\stex_file_use:N \c_stex_home_file \tl_to_str:n{/MathHub}} + \seq_clear:N \c_stex_mathhub_file +}{ + \stex_file_resolve:No \c_stex_mathhub_file \l__stex_mathhub_str + \stex_if_file_absolute:NF \c_stex_mathhub_file { + \exp_args:NNe \stex_file_resolve:Nn \c_stex_mathhub_file { + \stex_file_use:N \c_stex_main_file / .. / \l__stex_mathhub_str } } - \stex_path_to_string:NN\c_stex_mathhub_seq\c_stex_mathhub_str - \stex_debug:nn{mathhub} {MathHub:~\str_use:N\c_stex_mathhub_str} } -\cs_new_protected:Nn \__stex_mathhub_do_manifest:n { - \prop_if_exist:cF {c_stex_mathhub_#1_manifest_prop} { - \str_set:Nx \l_tmpa_str { #1 } - \prop_new:c { c_stex_mathhub_#1_manifest_prop } - \seq_set_split:NnV \l_tmpa_seq / \l_tmpa_str - \seq_concat:NNN \l_tmpa_seq \c_stex_mathhub_seq \l_tmpa_seq - \__stex_mathhub_find_manifest:N \l_tmpa_seq - \seq_if_empty:NTF \l__stex_mathhub_manifest_file_seq { - \msg_error:nnxx{stex}{error/norepository}{#1}{ - \stex_path_to_string:N \c_stex_mathhub_str - } - \input{Fatal~Error!} - } { - \exp_args:No \__stex_mathhub_parse_manifest:n { \l_tmpa_str } - } + +\exp_args:NNe \str_set:Nn \mathhub {\stex_file_use:N \c_stex_mathhub_file} +\stex_debug:nn{mathhub}{MATHHUB:~\mathhub} +\cs_new_protected:Nn \stex_set_current_archive:n { + \stex_require_archive:n { #1 } + \stex_debug:nn{mathhub}{switching~to~archive~#1} + \prop_set_eq:Nc \l_stex_current_archive_prop { + c_stex_mathhub_#1_manifest_prop } } -\seq_new:N\l__stex_mathhub_manifest_file_seq -\cs_new_protected:Nn \__stex_mathhub_find_manifest:N { - \seq_set_eq:NN\l_tmpa_seq #1 - \bool_set_true:N\l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_if_empty:NTF \l_tmpa_seq { - \bool_set_false:N\l_tmpa_bool - }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool +\cs_new_protected:Nn \stex_in_archive:nn { + \cs_if_exist:NF \l__stex_mathhub_cs { + \cs_set:Npn \l__stex_mathhub_cs ##1 {} + } + \stex_pseudogroup:nn{ + \cs_set:Npn \l__stex_mathhub_cs ##1 {#2} + \tl_if_empty:nTF{#1}{ + \prop_if_exist:NTF \l_stex_current_archive_prop { + \exp_args:Ne \l__stex_mathhub_cs {\prop_item:Nn \l_stex_current_archive_prop { id } } }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/META-INF/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{META-INF} - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool - }{ - \file_if_exist:nTF{ - \stex_path_to_string:N\l_tmpa_seq/meta-inf/MANIFEST.MF - }{ - \seq_put_right:Nn\l_tmpa_seq{meta-inf} - \seq_put_right:Nn\l_tmpa_seq{MANIFEST.MF} - \bool_set_false:N\l_tmpa_bool - }{ - \seq_pop_right:NN\l_tmpa_seq\l_tmpa_tl - } - } + \l__stex_mathhub_cs {} } + }{ + \stex_set_current_archive:n{#1} + \l__stex_mathhub_cs {#1} } - } - \seq_set_eq:NN\l__stex_mathhub_manifest_file_seq\l_tmpa_seq -} -\ior_new:N \c__stex_mathhub_manifest_ior -\cs_new_protected:Nn \__stex_mathhub_parse_manifest:n { - \seq_set_eq:NN \l_tmpa_seq \l__stex_mathhub_manifest_file_seq - \ior_open:Nn \c__stex_mathhub_manifest_ior {\stex_path_to_string:N \l_tmpa_seq} - \ior_map_inline:Nn \c__stex_mathhub_manifest_ior { - \str_set:Nn \l_tmpa_str {##1} - \exp_args:NNoo \seq_set_split:Nnn - \l_tmpb_seq \c_colon_str \l_tmpa_str - \seq_pop_left:NNTF \l_tmpb_seq \l_tmpa_tl { - \exp_args:NNe \str_set:Nn \l_tmpb_tl { - \exp_args:NNo \seq_use:Nn \l_tmpb_seq \c_colon_str - } - \exp_args:No \str_case:nnTF \l_tmpa_tl { - {id} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { id } \l_tmpb_tl - } - {narration-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { narr } \l_tmpb_tl - } - {url-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { docurl } \l_tmpb_tl - } - {source-base} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { ns } \l_tmpb_tl - } - {ns} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { ns } \l_tmpb_tl - } - {dependencies} { - \prop_gput:cno { c_stex_mathhub_#1_manifest_prop } - { deps } \l_tmpb_tl - } - }{}{} - }{} - } - \ior_close:N \c__stex_mathhub_manifest_ior - \stex_persist:x { - \prop_set_from_keyval:cn{ c_stex_mathhub_#1_manifest_prop }{ - \exp_after:wN \prop_to_keyval:N \csname c_stex_mathhub_#1_manifest_prop\endcsname + }{ + \stex_pseudogroup_restore:N \l_stex_current_archive_prop + \cs_set:Npn \exp_not:N \l__stex_mathhub_cs ##1 { + \exp_args:No \exp_not:n {\l__stex_mathhub_cs {##1}} } } } -\cs_new_protected:Nn \stex_set_current_repository:n { - \stex_require_repository:n { #1 } - \prop_set_eq:Nc \l_stex_current_repository_prop { - c_stex_mathhub_#1_manifest_prop +\cs_new_protected:Nn \stex_require_archive:n { + \prop_if_exist:cF { c_stex_mathhub_#1_manifest_prop } { + \seq_if_empty:NTF \c_stex_mathhub_file { + \stex_fatal_error:n{warning/nomathhub} + }{ + \stex_debug:nn{mathhub}{Opening~archive:~#1} + \__stex_mathhub_do_manifest:n { #1 } + } } } -\cs_new_protected:Nn \stex_require_repository:n { - \prop_if_exist:cF { c_stex_mathhub_#1_manifest_prop } { - \stex_debug:nn{mathhub}{Opening~archive:~#1} - \__stex_mathhub_do_manifest:n { #1 } +\cs_generate_variant:Nn \stex_require_archive:n {o} +\cs_new_protected:Nn \__stex_mathhub_do_manifest:n { + \exp_args:Ne \__stex_mathhub_find_manifest:n {\stex_file_use:N \c_stex_mathhub_file / #1} + \str_if_empty:NT \l__stex_mathhub_manifest_str { + \stex_fatal_error:nxx{error/noarchive} + {#1}{\stex_file_use:N \c_stex_mathhub_file} } + \__stex_mathhub_parse_manifest:n {#1} } -\bool_if:NF \c_stex_persist_mode_bool { - \__stex_mathhub_find_manifest:N \c_stex_pwd_seq - \seq_if_empty:NTF \l__stex_mathhub_manifest_file_seq { - \stex_debug:nn{mathhub}{Not~currently~in~a~MathHub~repository} - } { - \__stex_mathhub_parse_manifest:n { main } - \prop_get:NnN \c_stex_mathhub_main_manifest_prop {id} - \l_tmpa_str - \prop_set_eq:cN { c_stex_mathhub_\l_tmpa_str _manifest_prop } - \c_stex_mathhub_main_manifest_prop - \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str } - \stex_debug:nn{mathhub}{Current~repository:~ - \prop_item:Nn \l_stex_current_repository_prop {id} - } - } -} -\cs_new_protected:Nn \stex_in_repository:nn { - \str_set:Nx \l_tmpa_str { #1 } - \cs_set:Npn \l_tmpa_cs ##1 { #2 } - \str_if_empty:NTF \l_tmpa_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \stex_debug:nn{mathhub}{do~in~current~repository:~\prop_item:Nn \l_stex_current_repository_prop { id }} - \exp_args:Ne \l_tmpa_cs{ - \prop_item:Nn \l_stex_current_repository_prop { id } - } - }{ - \l_tmpa_cs{} - } - }{ - \stex_debug:nn{mathhub}{in~repository:~\l_tmpa_str} - \stex_require_repository:n \l_tmpa_str - \str_set:Nx \l_tmpa_str { #1 } - \exp_args:Nne \use:nn { - \stex_set_current_repository:n \l_tmpa_str - \exp_args:Nx \l_tmpa_cs{\l_tmpa_str} + +\cs_new_protected:Nn \__stex_mathhub_find_manifest:n { + \str_clear:N \l__stex_mathhub_manifest_str + \seq_set_split:Nnn \l__stex_mathhub_seq / {#1} + \bool_set_true:N \l__stex_mathhub_bool + \bool_while_do:Nn \l__stex_mathhub_bool { + \tl_if_eq:NNTF \l__stex_mathhub_seq \c_stex_mathhub_file { + \bool_set_false:N \l__stex_mathhub_bool }{ - \stex_debug:nn{mathhub}{switching~back~to:~ - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_item:Nn \l_stex_current_repository_prop { id }:~ - \meaning\l_stex_current_repository_prop - }{ - no~repository - } - } - \prop_if_exist:NTF \l_stex_current_repository_prop { - \stex_set_current_repository:n { - \prop_item:Nn \l_stex_current_repository_prop { id } - } - }{ - \let\exp_not:N\l_stex_current_repository_prop\exp_not:N\undefined + \__stex_mathhub_check_manifest: + \bool_if:NT \l__stex_mathhub_bool { + \seq_pop_right:NN \l__stex_mathhub_seq \l__stex_mathhub_tl } } } } -\def \mhpath #1 #2 { - \exp_args:Ne \tl_if_empty:nTF{#1}{ - \c_stex_mathhub_str / - \prop_item:Nn \l_stex_current_repository_prop { id } - / source / #2 - }{ - \c_stex_mathhub_str / #1 / source / #2 +\cs_generate_variant:Nn \__stex_mathhub_find_manifest:n {x} + +\cs_new_protected:Nn \__stex_mathhub_check_manifest: { + \__stex_mathhub_check_manifest:n {MANIFEST.MF} + \bool_if:NT \l__stex_mathhub_bool { + \__stex_mathhub_check_manifest:n {META-INF/MANIFEST.MF} + \bool_if:NT \l__stex_mathhub_bool { + \__stex_mathhub_check_manifest:n {meta-inf/MANIFEST.MF} + } } } -\newif \ifinputref \inputreffalse -\cs_new_protected:Nn \__stex_mathhub_mhinput:nn { - \stex_in_repository:nn {#1} { - \ifinputref - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - \else - \inputreftrue - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - \inputreffalse - \fi +\cs_new_protected:Nn \__stex_mathhub_check_manifest:n { + \stex_debug:nn{mathhub}{Checking~\stex_file_use:N \l__stex_mathhub_seq / #1} + \file_if_exist:nT {\stex_file_use:N \l__stex_mathhub_seq / #1} { + \bool_set_false:N \l__stex_mathhub_bool + \str_set:Nx \l__stex_mathhub_manifest_str {\stex_file_use:N \l__stex_mathhub_seq / #1} } } -\NewDocumentCommand \mhinput { O{} m}{ - \__stex_mathhub_mhinput:nn{ #1 }{ #2 } -} - -\cs_new_protected:Nn \__stex_mathhub_inputref:nn { - \stex_in_repository:nn {#1} { - \stex_html_backend:TF { - \str_clear:N \l_tmpa_str - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } - \tl_if_empty:nTF{ ##1 }{ - \IfFileExists{#2}{ - \stex_annotate_invisible:nnn{inputref}{ - \l_tmpa_str / #2 - }{} - }{ - \input{#2} - } - }{ - \IfFileExists{ \c_stex_mathhub_str / ##1 / source / #2 }{ - \stex_annotate_invisible:nnn{inputref}{ - \l_tmpa_str / #2 - }{} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } - } +\ior_new:N \c__stex_mathhub_manifest_ior +\cs_new_protected:Nn \__stex_mathhub_parse_manifest:n { + \ior_open:Nn \c__stex_mathhub_manifest_ior \l__stex_mathhub_manifest_str + \prop_clear:N \l__stex_mathhub_prop + \ior_map_inline:Nn \c__stex_mathhub_manifest_ior { + \exp_args:NNNo \exp_args:NNNx + \seq_set_split:Nnn \l__stex_mathhub_seq \c_colon_str {\tl_to_str:n{##1}} + \seq_pop_left:NNT \l__stex_mathhub_seq \l__stex_mathhub_key { + \exp_args:NNo \str_set:Nn \l__stex_mathhub_key \l__stex_mathhub_key + \str_set:Nx \l__stex_mathhub_val {\seq_use:Nn \l__stex_mathhub_seq :} + \str_case:Nn \l__stex_mathhub_key { + {id} {\prop_put:Nno \l__stex_mathhub_prop { id } \l__stex_mathhub_val } + {narration-base} {\prop_put:Nno \l__stex_mathhub_prop { narr } \l__stex_mathhub_val } + {url-base} {\prop_put:Nno \l__stex_mathhub_prop { docurl } \l__stex_mathhub_val } + {source-base} {\prop_put:Nno \l__stex_mathhub_prop { ns } \l__stex_mathhub_val } + {ns} {\prop_put:Nno \l__stex_mathhub_prop { ns } \l__stex_mathhub_val } } - + } + } + \ior_close:N \c__stex_mathhub_manifest_ior + \prop_gset_eq:cN { c_stex_mathhub_#1_manifest_prop } \l__stex_mathhub_prop + \stex_debug:nn{mathhub}{Result:~\prop_to_keyval:N \l__stex_mathhub_prop} + \stex_persist:e { + \prop_gset_from_keyval:cn {c_stex_mathhub_#1_manifest_prop}{ + \prop_to_keyval:N \l__stex_mathhub_prop + } + } +} +\cs_new_protected:Nn \_stex_main_archive: { + \stex_if_file_starts_with:NNTF \c_stex_pwd_file \c_stex_mathhub_file { + \__stex_mathhub_find_manifest:x { \stex_file_use:N \c_stex_pwd_file } + \str_if_empty:NTF \l__stex_mathhub_manifest_str { + \stex_debug:nn{mathhub}{Not~currently~in~a~MathHub~archive} }{ - \begingroup - \inputreftrue - \tl_if_empty:nTF{ ##1 }{ - \input{#2} - }{ - \input{ \c_stex_mathhub_str / ##1 / source / #2 } + \__stex_mathhub_parse_manifest:n { main } + \prop_set_eq:NN \c_stex_main_archive_prop \c_stex_mathhub_main_manifest_prop + \cs_undefine:N \c_stex_mathhub_main_manifest_prop + \prop_get:NnN \c_stex_main_archive_prop {id} + \l__stex_mathhub_str + \prop_set_eq:cN { c_stex_mathhub_\l__stex_mathhub_str _manifest_prop } + \c_stex_main_archive_prop + \exp_args:No \stex_set_current_archive:n { \l__stex_mathhub_str } + \stex_debug:nn{mathhub}{Current~archive:~ + \prop_item:Nn \l_stex_current_archive_prop {id} + } + \bool_if:NT \c_stex_persist_write_mode_bool { + \tl_put_right:Nx \_stex_persist_read_now: { + \stex_persist:n { + \prop_gset_from_keyval:cn {c_stex_mathhub_\l__stex_mathhub_str _manifest_prop}{ + \prop_to_keyval:N \c_stex_main_archive_prop + } + \prop_gset_eq:Nc \exp_not:N \l_stex_current_archive_prop { + c_stex_mathhub_\l__stex_mathhub_str _manifest_prop + } + \prop_gset_eq:Nc \exp_not:N \c_stex_main_archive_prop { + c_stex_mathhub_\l__stex_mathhub_str _manifest_prop + } + } } - \endgroup + } } + }{ + \stex_debug:nn{mathhub}{Not~currently~in~the~MathHub~directory} } } -\NewDocumentCommand \inputref { O{} m}{ - \__stex_mathhub_inputref:nn{ #1 }{ #2 } + + \_stex_main_archive: +\tl_new:N \g__stex_doc_title_tl +\cs_new_protected:Npn \stexdoctitle #1 { + \tl_gset:Nn \g__stex_doc_title_tl { #1 } + \global\def\stexdoctitle##1{} } -\cs_new_protected:Nn \__stex_mathhub_mhbibresource:nn { - \stex_in_repository:nn {#1} { - \addbibresource{ \c_stex_mathhub_str / ##1 / #2 } +\cs_new_protected:Nn \__stex_doc_set_title:n { + \stex_if_smsmode:F{ + \global\def\stexdoctitle##1{} + \stex_debug:nn{title}{Setting~title~to:\tl_to_str:n{#1}} + \tl_gset:Nn \g__stex_doc_title_tl { #1 } + \__stex_doc_title_html: } } -\newcommand\addmhbibresource[2][]{ - \__stex_mathhub_mhbibresource:nn{ #1 }{ #2 } +\cs_new_protected:Nn \__stex_doc_title_html: { + \stex_if_do_html:T{\stex_if_html_backend:T{ + \stex_annotate_invisible:nn{shtml:doctitle={}}{ \hbox{\g__stex_doc_title_tl} } + }} } -\cs_new_protected:Npn \libinput #1 { - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libinput - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libinput + +\AtBeginDocument { + \tl_if_empty:NTF \g__stex_doc_title_tl { + \cs_set_eq:NN \stexdoctitle \__stex_doc_set_title:n + }{ + \stex_debug:nn{title}{Setting~title~to:\exp_args:No\tl_to_str:n\g__stex_doc_title_tl} + \global\def\stexdoctitle#1{} + \__stex_doc_title_html: } - \seq_clear:N \l__stex_mathhub_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / #1.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l__stex_mathhub_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str + \cs_set_eq:NN \__stex_doc_maketitle: \maketitle + \global\protected\def\maketitle{ + \tl_if_empty:NF \@title { + \exp_args:No \stexdoctitle \@title + } + \__stex_doc_maketitle: } +} +\int_new:N \l_stex_docheader_sect - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / #1.tex} - \IfFileExists{ \l_tmpa_str }{ - \seq_put_right:No \l__stex_mathhub_libinput_files_seq \l_tmpa_str - }{} +\tl_set:Nn \stex_current_section_level {document} - \seq_if_empty:NTF \l__stex_mathhub_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libinput}{#1.tex} +\cs_set_protected:Npn \currentsectionlevel { + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:currentsectionlevel={},shtml:capitalize=false}{} }{ - \seq_map_inline:Nn \l__stex_mathhub_libinput_files_seq { - \input{ ##1 } - } + \stex_current_section_level } + \tl_if_exist:NT\xspace\xspace } -\NewDocumentCommand \libusepackage {O{} m} { - \prop_if_exist:NF \l_stex_current_repository_prop { - \msg_error:nnn{stex}{error/notinarchive}\libusepackage - } - \prop_get:NnNF \l_stex_current_repository_prop {id} \l_tmpa_str { - \msg_error:nnn{stex}{error/notinarchive}\libusepackage - } - \seq_clear:N \l__stex_mathhub_libinput_files_seq - \seq_set_eq:NN \l_tmpa_seq \c_stex_mathhub_seq - \seq_set_split:NnV \l_tmpb_seq / \l_tmpa_str - \bool_while_do:nn { ! \seq_if_empty_p:N \l_tmpb_seq }{ - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / meta-inf / lib / #2} - \IfFileExists{ \l_tmpa_str.sty }{ - \seq_put_right:No \l__stex_mathhub_libinput_files_seq \l_tmpa_str - }{} - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str - \seq_put_right:No \l_tmpa_seq \l_tmpa_str +\cs_set_protected:Npn \Currentsectionlevel { + \stex_if_do_html:TF{ + \stex_annotate:nn{shtml:currentsectionlevel={},shtml:capitalize=true}{} + }{ + \exp_args:No \_stex_capitalize:n \stex_current_section_level } + \tl_if_exist:NT\xspace\xspace +} - \str_set:Nx \l_tmpa_str {\stex_path_to_string:N \l_tmpa_seq / lib / #2} - \IfFileExists{ \l_tmpa_str.sty }{ - \seq_put_right:No \l__stex_mathhub_libinput_files_seq \l_tmpa_str - }{} - - \seq_if_empty:NTF \l__stex_mathhub_libinput_files_seq { - \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libusepackage}{#2.sty} - }{ - \int_compare:nNnTF {\seq_count:N \l__stex_mathhub_libinput_files_seq} = 1 { - \seq_map_inline:Nn \l__stex_mathhub_libinput_files_seq { - \usepackage[#1]{ ##1 } - } +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_sfragment_do_level:nn { + \stexdoctitle{#2} + \par + \begin{stex_annotate_env}{shtml:section={\int_use:N \l_stex_docheader_sect}} + \noindent\stex_annotate:nn{shtml:sectiontitle={}}{ + \_stex_annotate_force_break:n{#2} + }\par + } + \cs_new_protected:Nn \_sfragment_end: { + \end{stex_annotate_env} + } +}{ + \cs_new_protected:Nn \_sfragment_do_level:nn { + \stexdoctitle{#2} + \tl_if_empty:NTF \l_stex_key_short_tl { + \use:c{#1} }{ - \msg_error:nnxx{stex}{error/twofiles}{\exp_not:N\libusepackage}{#2.sty} - } + \exp_args:Nnx \use:nn{\use:c{#1}}{[\exp_args:No \exp_not:n \l_stex_key_short_tl]} + }{#2} + \int_incr:N \l_stex_docheader_sect + \tl_set:Nn \stex_current_section_level{#1} } + \cs_new_protected:Nn \_sfragment_end: {} } -\AddToHook{begindocument}{ -\ltx@ifpackageloaded{graphicx}{ - \define@key{Gin}{mhrepos}{\def\Gin@mhrepos{#1}} - \providecommand\mhgraphics[2][]{% - \def\Gin@mhrepos{}\setkeys{Gin}{#1}% - \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}}} - \providecommand\cmhgraphics[2][]{\begin{center}\mhgraphics[#1]{#2}\end{center}} - }{} -\ltx@ifpackageloaded{listings}{ - \define@key{lst}{mhrepos}{\def\lst@mhrepos{#1}} - \newcommand\lstinputmhlisting[2][]{% - \def\lst@mhrepos{}\setkeys{lst}{#1}% - \lstinputlisting[#1]{\mhpath\lst@mhrepos{#2}}} - \newcommand\clstinputmhlisting[2][]{\begin{center}\lstinputmhlisting[#1]{#2}\end{center}} - }{} +\cs_new_protected:Npn \__stex_doc_do_section:n { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart {\_sfragment_do_level:nn{part}}{ + \int_incr:N \l_stex_docheader_sect + \__stex_doc_do_section:n + }} + {1}{\cs_if_exist:NTF \thechapter {\_sfragment_do_level:nn{chapter}}{ + \int_incr:N \l_stex_docheader_sect + \__stex_doc_do_section:n + }} + {2}{\_sfragment_do_level:nn{section}} + {3}{\_sfragment_do_level:nn{subsection}} + {4}{\_sfragment_do_level:nn{subsubsection}} + {5}{\_sfragment_do_level:nn{paragraph}} + }{\_sfragment_do_level:nn{subparagraph}} } +\stex_keys_define:nnnn{ sfragment }{ + \tl_clear:N \l_stex_key_short_tl +}{ + short .tl_set:N = \l_stex_key_short_tl +}{id} -%%%%%%%%%%%%% stex-references.dtx %%%%%%%%%%%%% - -\msg_new:nnn{stex}{error/extrefmissing}{ - Missing~in~or~cite~value~for~\detokenize{\extref}! -} -\msg_new:nnn{stex}{warning/smsmissing}{ - .sref~file~#1~doesn't~exist! -} -\msg_new:nnn{stex}{warning/smslabelmissing}{ - No~label~#2~in~.sref~file~#1! +\NewDocumentEnvironment{sfragment}{ O{} m}{ + \stex_keys_set:nn{sfragment}{#1} + \__stex_doc_do_section:n{#2} + \_stex_do_id: +}{ + \_sfragment_end: } -\iow_new:N \c__stex_refs_refs_iow -\AtBeginDocument{ - \iow_open:Nn \c__stex_refs_refs_iow {\jobname.sref} + +\NewDocumentEnvironment{blindfragment}{}{ + \__stex_doc_skip_section: +}{ + \stex_if_html_backend:T{ + \stex_annotate_invisible:n{~} + \end{stex_annotate_env} + } } -\AtEndDocument{ - \iow_close:N \c__stex_refs_refs_iow + +\cs_new_protected:Nn \__stex_doc_skip_section_i: { + \int_case:nn \l_stex_docheader_sect { + {0}{\cs_if_exist:NF \thepart { + \int_incr:N \l_stex_docheader_sect \__stex_doc_skip_section_i: + }} + {1}{\cs_if_exist:NF \thechapter { + \int_incr:N \l_stex_docheader_sect \__stex_doc_skip_section_i: + }} + } + \int_incr:N \l_stex_docheader_sect } -\str_new:N \l_stex_current_docns_str -\cs_new_protected:Nn \stex_get_document_uri: { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - \str_clear:N \l_tmpa_str - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } +\stex_if_html_backend:TF { + \cs_new_protected:Nn \__stex_doc_skip_section: { + \__stex_doc_skip_section_i: + \begin{stex_annotate_env}{shtml:skipsection={\int_use:N \l_stex_docheader_sect}} + \stex_annotate_invisible:n{~} } +}{ + \cs_set_eq:NN \__stex_doc_skip_section: \__stex_doc_skip_section_i: +} - \str_if_empty:NTF \l_tmpa_str { - \str_set:Nx \l_stex_current_docns_str { - file:/\stex_path_to_string:N \l_tmpa_seq - } +\cs_new_protected:Nn \__stex_doc_skip_fragment:n { + \stepcounter{#1} +} + +\cs_new_protected:Npn \skipfragment { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart {\__stex_doc_skip_fragment:n{part}}{ + \int_incr:N \l_stex_docheader_sect + \skipfragment + }} + {1}{\cs_if_exist:NTF \thechapter {\__stex_doc_skip_fragment:n{chapter}}{ + \int_incr:N \l_stex_docheader_sect + \skipfragment + }} + {2}{\__stex_doc_skip_fragment:n{section}} + {3}{\__stex_doc_skip_fragment:n{subsection}} + {4}{\__stex_doc_skip_fragment:n{subsubsection}} + {5}{\__stex_doc_skip_fragment:n{paragraph}} + }{\__stex_doc_skip_fragment:n{subparagraph}} +} +\cs_new_protected:Npn \setsectionlevel #1 { + \str_case:nnF{#1}{ + {part}{\int_set:Nn \l_stex_docheader_sect 0} + {chapter}{\int_set:Nn \l_stex_docheader_sect 1} + {section}{\int_set:Nn \l_stex_docheader_sect 2} + {subsection}{\int_set:Nn \l_stex_docheader_sect 3} + {subsubsection}{\int_set:Nn \l_stex_docheader_sect 4} + {paragraph}{\int_set:Nn \l_stex_docheader_sect 5} }{ - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } - } + \int_set:Nn \l_stex_docheader_sect 6 + } + \cs_if_eq:NNTF\@onlypreamble\@notprerr{ + \stex_annotate_invisible:nn{shtml:sectionlevel={\int_use:N\l_stex_docheader_sect}}{} + }{} +} - \seq_if_empty:NTF \l_tmpa_seq { - \str_gset_eq:NN \l_stex_current_docns_str \l_tmpa_str +\stex_if_html_backend:T{ + \cs_new_protected:Nn \__stex_doc_check_topsect: { + \int_case:nnF \l_stex_docheader_sect { + {0}{\cs_if_exist:NTF \thepart { + \stex_annotate_invisible:nn{shtml:sectionlevel=0}{} + }{ + \int_incr:N \l_stex_docheader_sect + \__stex_doc_check_topsect: + }} + {1}{\cs_if_exist:NTF \thechapter { + \stex_annotate_invisible:nn{shtml:sectionlevel=1}{} + }{ + \int_incr:N \l_stex_docheader_sect + \__stex_doc_check_topsect: + }} }{ - \str_gset:Nx \l_stex_current_docns_str { - \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq - } + \stex_annotate_invisible:nn{shtml:sectionlevel={\int_use:N\l_stex_docheader_sect}}{} } } - %\stex_get_document_url: + \AtBeginDocument{\__stex_doc_check_topsect:} } -\str_new:N \l_stex_current_docurl_str -\cs_new_protected:Nn \stex_get_document_url: { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - \str_clear:N \l_tmpa_str - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnNF \l_stex_current_repository_prop { docurl } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { narr } \l_tmpa_str { - \prop_get:NnNF \l_stex_current_repository_prop { ns } \l_tmpa_str {} - } +\AtBeginDocument{ + \cs_if_exist:NTF\frontmatter{ + \let\__stex_doc_orig_frontmatter\frontmatter + \let\frontmatter\relax + }{ + \tl_set:Nn\__stex_doc_orig_frontmatter{ + \clearpage + %\@mainmatterfalse + \pagenumbering{roman} } } - - \str_if_empty:NTF \l_tmpa_str { - \str_set:Nx \l_stex_current_docurl_str { - file:/\stex_path_to_string:N \l_tmpa_seq + \cs_if_exist:NTF\backmatter{ + \let\__stex_doc_orig_backmatter\backmatter + \let\backmatter\relax + }{ + \tl_set:Nn\__stex_doc_orig_backmatter{ + \clearpage + %\@mainmatterfalse + \pagenumbering{roman} } + } + \newenvironment{frontmatter}{ + \__stex_doc_orig_frontmatter }{ - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } + \cs_if_exist:NTF\mainmatter{ + \mainmatter + }{ + \clearpage + %\@mainmattertrue + \pagenumbering{arabic} } - - \seq_if_empty:NTF \l_tmpa_seq { - \str_set_eq:NN \l_stex_current_docurl_str \l_tmpa_str + } + \newenvironment{backmatter}{ + \__stex_doc_orig_backmatter + }{ + \cs_if_exist:NTF\mainmatter{ + \mainmatter }{ - \str_set:Nx \l_stex_current_docurl_str { - \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq - } + \clearpage + %\@mainmattertrue + \pagenumbering{arabic} } } } -\str_const:Nn \c__stex_refs_url_str{URL} -\str_const:Nn \c__stex_refs_ref_str{REF} -\str_new:N \l__stex_refs_curr_label_str -\int_new:N \l__stex_refs_unnamed_counter_int +\iow_new:N \c__stex_refs_iow +\AtBeginDocument{\iow_open:Nn \c__stex_refs_iow {\jobname.sref}} +\AtEndDocument{\iow_close:N \c__stex_refs_iow} \cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {} -\seq_new:N \g_stex_ref_files_seq - -\cs_new_protected:Nn \stex_ref_new_doc_target:n { - %\stex_get_document_uri: - \str_clear:N \l__stex_refs_curr_label_str - \str_set:Nx \l_tmpa_str { #1 } - \str_if_empty:NT \l_tmpa_str { - \int_gincr:N \l__stex_refs_unnamed_counter_int - \str_set:Nx \l_tmpa_str {REF\int_use:N \l__stex_refs_unnamed_counter_int} - } - \str_set:Nx \l__stex_refs_curr_label_str { - \l_stex_current_docns_str?\l_tmpa_str - } - \exp_args:Noo \STEXInternalAuxAddDocRef\l_stex_current_docns_str\l_tmpa_str +\cs_new_protected:Npn \STEXInternalSetSrefSymURL #1 #2 { + \str_gset:cn{g_stex_sref_sym_\tl_to_str:n{#1}_target}{#2} +} - %\seq_if_exist:cF{g__stex_refs_labels_\l_tmpa_str _seq}{ - % \seq_new:c {g__stex_refs_labels_\l_tmpa_str _seq} - %} - %\seq_if_in:coF{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str { - % \seq_gput_right:co{g__stex_refs_labels_\l_tmpa_str _seq}\l__stex_refs_curr_label_str - %} +\seq_new:N \g__stex_refs_files_seq +\int_new:N \l__stex_refs_unnamed_counter_int - \stex_if_smsmode:TF { - %\stex_get_document_url: - %\str_gset_eq:cN {sref_url_\l__stex_refs_curr_label_str _str}\l_stex_current_docurl_str - %\str_gset_eq:cN {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_url_str +\cs_new_protected:Nn \_stex_ref_new_id:n { + \str_if_empty:nTF {#1}{ + \int_gincr:N \l__stex_refs_unnamed_counter_int + \str_set:Nx \l__stex_refs_str {REF\int_use:N \l__stex_refs_unnamed_counter_int} }{ - \iow_now:Nx \c__stex_refs_refs_iow { - \STEXInternalSrefRestoreTarget - {\l_stex_current_docns_str} - {\l_tmpa_str} - {\@currentcounter} - {\@currentlabel} - {\tl_if_exist:NT\@currentlabelname{\exp_args:No\unexpanded\@currentlabelname}} - } - %\iow_now:Nx \c__stex_refs_refs_iow { - % {\l_stex_current_docns_str?\l_tmpa_str}~=~{{\use:c{\@currentcounter autorefname}~\@currentlabel}~(\@currentlabelname)~in~\exp_args:No\unexpanded\g__stex_refs_title_tl},} - \stex_debug:nn{sref}{New~label~\l__stex_refs_curr_label_str~at~\use:c{\use:c{@currentcounter}autorefname}} - \exp_args:Nx\label{sref_\l__stex_refs_curr_label_str} - \immediate\write\@auxout{\STEXInternalAuxAddDocRef{\l_stex_current_docns_str}{\l_tmpa_str}} - %\str_gset:cx {sref_\l__stex_refs_curr_label_str _type}\c__stex_refs_ref_str - } -} -\NewDocumentCommand \slabel {m} {\stex_ref_new_doc_target:n {#1}} -\cs_new_protected:Npn \STEXInternalAuxAddDocRef #1 #2 { - \exp_args:NNx \seq_if_in:NnTF \g_stex_ref_files_seq {\detokenize{#1}} { - \exp_args:Nnx \seq_if_in:cnF{g_stex_ref_ #1 _seq}{\detokenize{#2}}{ - \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} - } - }{ - \exp_args:NNx \seq_gput_right:Nn \g_stex_ref_files_seq {\detokenize{#1}} - %\seq_if_exist:cF{g_stex_ref_ #1 _seq}{ - \seq_new:c{g_stex_ref_ #1 _seq} % <- seq_new throws errors?? - %} - \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} + \str_set:Nn \l__stex_refs_str {#1} } - - %\str_set:Nn \l_tmpa_str {#1?#2} - %\str_gset_eq:cN{sref_#1?#2_type}\c__stex_refs_ref_str - %\seq_if_exist:cF{g__stex_refs_labels_#2_seq}{ - % \seq_new:c {g__stex_refs_labels_#2_seq} - %} - %\seq_if_in:coF{g__stex_refs_labels_#2_seq}\l_tmpa_str { - % \seq_gput_right:co{g__stex_refs_labels_#2_seq}\l_tmpa_str - %} -} -\AtEndDocument{ - \def\STEXInternalAuxAddDocRef#1 #2 {}{} + \str_set:Nx \l_stex_ref_url_str {\stex_uri_use:N \l_stex_current_doc_uri ? \l__stex_refs_str} } -\cs_new_protected:Nn \stex_ref_new_sym_target:n { +\cs_new_protected:Nn \stex_ref_new_doc_target:n { + \_stex_ref_new_id:n{#1} + %\stex_uri_add_module:NNo \l__stex_refs_uri \l_stex_current_doc_uri \l__stex_refs_str + %\stex_debug:nn{sref}{New~document~target:~\stex_uri_use:N \l__stex_refs_uri} + \__stex_refs_add_doc_ref:xo {\stex_uri_use:N \l_stex_current_doc_uri} \l__stex_refs_str + \stex_if_smsmode:F { + \iow_now:Nx \c__stex_refs_iow { + \STEXInternalSrefRestoreTarget + {\stex_uri_use:N \l_stex_current_doc_uri} + {\l__stex_refs_str} + {\@currentcounter} + {\@currentlabel} + { + \tl_if_exist:NT\@currentlabelname{ + \exp_args:No\exp_not:n\@currentlabelname + } + } + } + \exp_args:Nx \label {sref@\l_stex_ref_url_str} + \stex_if_do_html:T { + \pdfdest name "sref@\l_stex_ref_url_str" xyz\relax + } + } } +\NewDocumentCommand \sreflabel {m} {\stex_ref_new_doc_target:n {#1}} -\keys_define:nn { stex / sref / 1 } { - archive .str_set_x:N = \l__stex_refs_repo_str, - file .str_set_x:N = \l__stex_refs_file_str, +\cs_new_protected:Nn \__stex_refs_add_doc_ref:nn { + \seq_if_in:NnTF \g__stex_refs_files_seq {#1} { + \seq_if_in:cnF {g__stex_refs_#1_seq}{#2}{ + \seq_gput_left:cn{g__stex_refs_#1_seq}{#2} + } + }{ + \seq_gput_right:Nn \g__stex_refs_files_seq {#1} + \seq_new:c{g__stex_refs_#1_seq} + \seq_gput_left:cn{g__stex_refs_#1_seq}{#2} + } +} +\cs_generate_variant:Nn \__stex_refs_add_doc_ref:nn {xo,xx} +\stex_keys_define:nnnn{sref / 1}{}{ % TODO get rid of this fallback .code:n = {}, pre .code:n = {}, post .code:n = {} -} -\cs_new_protected:Nn \__stex_refs_args_i:n { - \str_clear:N \l__stex_refs_repo_str - \str_clear:N \l__stex_refs_file_str - \keys_set:nn { stex / sref / 1 } { #1 } -} -\keys_define:nn { stex / sref / 2 } { - in .str_set_x:N = \l__stex_refs_in_str, - archive .str_set_x:N = \l__stex_refs_repob_str, - title .tl_set:N = \l__stex_refs_title_tl -} -\cs_new_protected:Nn \__stex_refs_args_ii:n { - \str_clear:N \l__stex_refs_in_str - \tl_clear:N \l__stex_refs_title_tl - \str_clear:N \l__stex_refs_repob_str - \keys_set:nn { stex / sref / 2 } { #1 } -} -\NewDocumentCommand \sref { O{} m O{}}{ - \__stex_refs_args_i:n{#1} - \__stex_refs_args_ii:n{#3} - \str_clear:N \l__stex_refs_uri_str - \__stex_refs_find_uri:n{#2} - \__stex_refs_do_sref:n{#2} -} -\NewDocumentCommand \extref { O{} m m}{ - \__stex_refs_args_i:n{#1} - \__stex_refs_args_ii:n{#3} - \str_if_empty:NT \l__stex_refs_in_str { - \msg_error:nn{stex}{error/extrefmissing} +}{archive file} +\stex_keys_define:nnnn{sref / 2}{}{}{archive file, title} + +\str_new:N \l__stex_refs_default_archive_str +\str_new:N \l__stex_refs_default_file_str +\tl_new:N \l__stex_refs_default_title_tl + +\cs_set_protected:Nn \__stex_refs_set_keys_b:n { + \tl_if_empty:nTF{#1}{ + \str_set_eq:NN \l_stex_key_archive_str \l__stex_refs_default_archive_str + \str_set_eq:NN \l_stex_key_file_str \l__stex_refs_default_file_str + \tl_set_eq:NN \l_stex_key_title_tl \l__stex_refs_default_title_tl + }{ + \stex_keys_set:nn{ sref / 2 }{ #1 } } - \str_clear:N \l__stex_refs_uri_str - \__stex_refs_find_uri:n{#2} - \__stex_refs_do_sref_in:n{#2} +} + +\newcommand\srefsetin[3][]{ + \str_set:Nx \l__stex_refs_default_archive_str {#1} + \str_set:Nx \l__stex_refs_default_file_str {#2} + \tl_set:Nn \l__stex_refs_default_title_tl {#3} } \cs_new_protected:Nn \__stex_refs_find_uri:n { - \stex_debug:nn{sref}{File:~\l__stex_refs_file_str^^JRepo:\l__stex_refs_repo_str} - \str_if_empty:NTF \l__stex_refs_file_str { + \str_clear:N \l__stex_refs_uri_str + \stex_debug:nn{sref}{ + File:~\l_stex_key_file_str^^J + Repo:\l_stex_key_archive_str + } + \str_if_empty:NTF \l_stex_key_file_str { \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1} - \seq_if_exist:cT{g_stex_ref_\l_stex_current_docns_str _seq}{ - \seq_map_inline:cn{g_stex_ref_\l_stex_current_docns_str _seq}{ - \str_if_eq:nnT{#1}{##1}{ - \str_set_eq:NN \l__stex_refs_uri_str \l_stex_current_docns_str - \stex_debug:nn{sref}{Found.} - \seq_map_break: - } - } + \seq_if_exist:cT{g__stex_refs_\stex_uri_use:N \l_stex_current_doc_uri _seq}{ + \exp_args:Nnx \__stex_refs_find_uri_in_file:nnn{#1} + {\stex_uri_use:N \l_stex_current_doc_uri}\seq_map_break: } \str_if_empty:NT \l__stex_refs_uri_str { - \stex_debug:nn{sref}{Checking~other~files} - \seq_map_inline:Nn \g_stex_ref_files_seq { - \stex_debug:nn{sref}{##1...} - \seq_map_inline:cn{g_stex_ref_##1_seq}{ - \str_if_eq:nnT{#1}{####1}{ - \stex_debug:nn{sref}{Found~##1} - \str_set:Nn \l__stex_refs_uri_str {##1} - \seq_map_break:n{\seq_map_break:} - } - } + \seq_map_inline:Nn \g__stex_refs_files_seq { + \__stex_refs_find_uri_in_file:nnn{#1}{##1}{\seq_map_break:n{\seq_map_break:}} } } }{ - \str_if_empty:NTF \l__stex_refs_repo_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { ns } \l__stex_refs_uri_str - \str_set:Nx \l__stex_refs_uri_str {\l__stex_refs_uri_str / \l__stex_refs_file_str} - \stex_path_from_string:Nn \l_tmpb_seq \l__stex_refs_uri_str - \str_set:Nx \l__stex_refs_uri_str {\stex_path_to_string:N \l_tmpb_seq} + \str_if_empty:NTF \l_stex_key_archive_str { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \__stex_refs_find_uri_in_prop_file:N \l_stex_current_archive_prop }{ - \stex_path_from_string:Nn \l_tmpb_seq { - \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l__stex_refs_file_str - } - \str_set:Nx \l__stex_refs_uri_str {file:/\stex_path_to_string:N \l_tmpb_seq} + \stex_file_resolve:Nx \l__stex_refs_file + { \stex_file_use:N \g_stex_current_file / .. / \l_stex_key_file_str } + \str_set:Nx \l__stex_refs_uri_str { file:/ \stex_file_use:N \l__stex_refs_file } } }{ - \stex_require_repository:n \l__stex_refs_repo_str - \prop_get:cnN { c_stex_mathhub_\l__stex_refs_repo_str _manifest_prop } { ns } \l__stex_refs_uri_str - \str_set:Nx \l__stex_refs_uri_str {\l__stex_refs_uri_str / \l__stex_refs_file_str} - \stex_path_from_string:Nn \l_tmpb_seq \l__stex_refs_uri_str - \str_set:Nx \l__stex_refs_uri_str {\stex_path_to_string:N \l_tmpb_seq} + \stex_require_archive:o \l_stex_key_archive_str + \prop_set_eq:Nc \l__stex_refs_prop { c_stex_mathhub_\l_stex_key_archive_str _manifest_prop } + \__stex_refs_find_uri_in_prop_file:N \l__stex_refs_prop } } } -\cs_new_protected:Nn \__stex_refs_do_autoref:n{ +\cs_new_protected:Nn \__stex_refs_find_uri_in_prop_file:N { + \str_set:Nx \l__stex_refs_uri_str { + \stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn #1 {id} / + source / \l_stex_key_file_str .sref + } + \stex_file_resolve:No \l__stex_refs_file \l__stex_refs_uri_str + \stex_uri_from_repo_file:NNNn \l__stex_refs_uri #1 + \l__stex_refs_file {narr} + \str_set:Nx \l__stex_refs_uri_str {\stex_uri_use:N \l__stex_refs_uri} +} + +\cs_new_protected:Nn \__stex_refs_find_uri_in_file:nnn { + \stex_debug:nn{sref}{Checking~file~#2} + \seq_map_inline:cn{g__stex_refs_#2_seq}{ + \str_if_eq:nnT{#1}{##1}{ + \str_set:Nx \l__stex_refs_uri_str {\stex_uri_use:N \l_stex_current_doc_uri} + \stex_debug:nn{sref}{Found.} + #3 + } + } +} +\cs_new_protected:Nn \__stex_refs_do_autoref:n { \cs_if_exist:cTF{autoref}{ - \exp_args:Nx\autoref{sref_#1} + \exp_args:Nx\autoref{sref@#1} }{ - \exp_args:Nx\ref{sref_#1} + \exp_args:Nx\ref{sref@#1} } } -\cs_new_protected:Nn \__stex_refs_do_sref:n { +\cs_new_protected:Nn \__stex_refs_do_sref:nn { \str_if_empty:NTF \l__stex_refs_uri_str { - \str_if_empty:NTF \l__stex_refs_in_str { - \stex_debug:nn{sref}{autoref~on~#1} - \__stex_refs_do_autoref:n{#1} + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{autoref~on~\stex_uri_use:N \l_stex_current_doc_uri?#1} + \exp_args:Ne \__stex_refs_do_autoref:n{\stex_uri_use:N \l_stex_current_doc_uri ? #1} }{ \stex_debug:nn{sref}{srefin~on~#1} + \__stex_refs_set_keys_b:n{ #2 } \__stex_refs_do_sref_in:n{#1} } }{ - \exp_args:NNo \seq_if_in:NnTF \g_stex_ref_files_seq \l__stex_refs_uri_str { + \exp_args:NNo \seq_if_in:NnTF \g__stex_refs_files_seq \l__stex_refs_uri_str { + \stex_debug:nn{sref}{Using~ref~file~\l__stex_refs_uri_str} \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l__stex_refs_uri_str _seq}{\detokenize{#1}}{ - \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~#1} + \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~\l__stex_refs_uri_str?#1} \__stex_refs_do_autoref:n{\l__stex_refs_uri_str?#1} }{ - \str_if_empty:NTF \l__stex_refs_in_str { - \stex_debug:nn{sref}{in~empty;~autoref~on~#1} - \__stex_refs_do_autoref:n{#1} + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~\l__stex_refs_uri_str?#1} + \__stex_refs_do_autoref:n{\l__stex_refs_uri_str?#1} }{ - \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} + \stex_debug:nn{sref}{in~non-empty;~srefin~on~\l__stex_refs_uri_str?#1} + \__stex_refs_set_keys_b:n{ #2 } \__stex_refs_do_sref_in:n{#1} } } }{ - \str_if_empty:NTF \l__stex_refs_in_str { - \stex_debug:nn{sref}{in~empty;~autoref~on~#1} - \__stex_refs_do_autoref:n{#1} + \stex_debug:nn{sref}{No~ref~file~found~for~\l__stex_refs_uri_str} + \str_if_empty:NTF \l_stex_key_file_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~\l__stex_refs_uri_str?#1} + \__stex_refs_do_autoref:n{\l__stex_refs_uri_str?#1} }{ - \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} + \stex_debug:nn{sref}{in~non-empty;~srefin~on~\l__stex_refs_uri_str?#1} + \__stex_refs_set_keys_b:n{ #2 } \__stex_refs_do_sref_in:n{#1} } } } } +\cs_new_protected:Nn \__stex_refs_do_sref_in:n { + \stex_debug:nn{sref}{In: \l_stex_key_file_str^^JRepo:\l_stex_key_archive_str} + \stex_debug:nn{sref}{URI: \l__stex_refs_uri_str?#1} + \tl_if_exist:cTF{r@sref@\l__stex_refs_uri_str?#1}{ + \__stex_refs_do_autoref:n{\l__stex_refs_uri_str?#1} + }{ + %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>} + \group_begin:\catcode13=9\relax\catcode10=9\relax + \str_if_empty:NTF \l_stex_key_archive_str { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \str_set:Nx \l__stex_refs_file_str { + \stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn \l_stex_current_archive_prop { id } + / source / \l_stex_key_file_str .sref + } + }{ + \str_set:Nx \l__stex_refs_file_str { + \stex_file_use:N \g_stex_current_file / .. / \l_stex_key_file_str . sref + } + } + }{ + \str_set:Nx \l__stex_refs_file_str { + \stex_file_use:N \c_stex_mathhub_file / \l_stex_key_archive_str + / source / \l_stex_key_file_str . sref + } + } + \stex_file_resolve:No \l__stex_refs_file \l__stex_refs_file_str + \str_set:Nx \l__stex_refs_file_str {\stex_file_use:N \l__stex_refs_file } + \stex_debug:nn{sref}{File: \l__stex_refs_file_str } + \exp_args:NNNx \exp_args:No \str_if_eq:nnTF \l__stex_refs_file_str {\stex_file_use:N\c_stex_pwd_file / \jobname.sref}{ + \__stex_refs_do_autoref:n{ + \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1 + } + }{ + \exp_args:No \IfFileExists \l__stex_refs_file_str { + \tl_clear:N \l__stex_refs_return_tl + \str_set:Nn \l__stex_refs_id_str {#1} + \let\STEXInternalSrefRestoreTarget\__stex_refs_restore_target:nnnnn + \use:c{@ @ input}{\l__stex_refs_file_str} + \exp_args:No \tl_if_empty:nTF \l__stex_refs_return_tl { + \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l__stex_refs_file_str{#1} + \__stex_refs_do_autoref:n{ + \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1 + } + }{ + \l__stex_refs_return_tl + } + }{ + \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l__stex_refs_file_str + \__stex_refs_do_autoref:n{ + \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1 + } + } + } + \group_end: + } +} + +\cs_new_protected:Nn \__stex_refs_do_return:nnnn { + \tl_set:Nn \l__stex_refs_return_tl { + \stex_annotate:nn{shtml:sref={#4},shtml:srefin={\l__stex_refs_file_str}}{ + \use:c{#3autorefname}~#1\tl_if_empty:nF{#2}{~(#2)} + \tl_if_empty:NF\l_stex_key_title_tl{ + {}~in~\l_stex_key_title_tl + } + } + } +} + \cs_new_protected:Nn \__stex_refs_restore_target:nnnnn { \str_if_empty:NTF \l__stex_refs_uri_str { \exp_args:No \str_if_eq:nnT \l__stex_refs_id_str {#2}{ - \tl_set:Nn \l__stex_refs_return_tl { - \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ - \tl_if_empty:nTF\l__stex_refs_title_tl{ - ??? - }\l__stex_refs_title_tl - } + \__stex_refs_do_return:nnnn{#4}{#5}{#3}{#1?#2} } }{ \stex_debug:nn{sref}{\l__stex_refs_uri_str{}~ == ~ #1 ~ ?} @@ -1225,5180 +1732,5308 @@ \stex_debug:nn{sref}{\l__stex_refs_id_str~ == ~ #2 ~ ?} \exp_args:No \str_if_eq:nnT \l__stex_refs_id_str {#2}{ \stex_debug:nn{sref}{success!} - \tl_set:Nn \l__stex_refs_return_tl { - \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ - \tl_if_empty:nTF\l__stex_refs_title_tl{ - ??? - }\l__stex_refs_title_tl - } + \__stex_refs_do_return:nnnn{#4}{#5}{#3}{#1?#2} \endinput } } } } +\NewDocumentCommand \sref { O{} m O{}}{ + \stex_keys_set:nn { sref / 1 }{ #1 } + \__stex_refs_find_uri:n { #2 } + \__stex_refs_do_sref:nn{#2}{#3} +} +\NewDocumentCommand \extref { O{} m m}{ + \stex_keys_set:nn { sref / 1 }{ #1 } + \__stex_refs_find_uri:n { #2 } + \__stex_refs_set_keys_b:n{ #3 } + \str_if_empty:NT \l_stex_key_file_str { + \msg_error:nn{stex}{error/extrefmissing} + } + \__stex_refs_do_sref_in:n{#2} +} +\cs_new_protected:Nn \stex_ref_new_symbol:n { + \cs_if_exist:cF{r@sref@sym@\tl_to_str:n{#1}}{ + \__stex_refs_new_symbol:n{#1} + } +} -\cs_new_protected:Nn \__stex_refs_do_sref_in:n { - \stex_debug:nn{sref}{In: \l__stex_refs_in_str^^JRepo:\l__stex_refs_repo_str} - \stex_debug:nn{sref}{URI: \l__stex_refs_uri_str?#1} - %\msg_warning:nnn{stex}{warning/smsmissing}{<filename>} - \begingroup\catcode13=9\relax\catcode10=9\relax - \str_if_empty:NTF \l__stex_refs_repob_str { - \prop_if_exist:NTF \l_stex_current_repository_prop { - \str_set:Nx \l_tmpa_str { - \c_stex_mathhub_str / - \prop_item:Nn \l_stex_current_repository_prop { id } - / source / \l__stex_refs_in_str .sref - } - }{ - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l__stex_refs_in_str . sref - } - } - }{ - \str_set:Nx \l_tmpa_str { - \c_stex_mathhub_str / \l__stex_refs_repob_str - / source / \l__stex_refs_in_str . sref - } - } - \stex_path_from_string:Nn \l_tmpb_seq \l_tmpa_str - \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str - \stex_debug:nn{sref}{File: \l_tmpa_str} - \exp_args:No \IfFileExists \l_tmpa_str { - \tl_clear:N \l__stex_refs_return_tl - \str_set:Nn \l__stex_refs_id_str {#1} - \let\STEXInternalSrefRestoreTarget\__stex_refs_restore_target:nnnnn - \use:c{@ @ input}{\l_tmpa_str} - \exp_args:No \tl_if_empty:nTF \l__stex_refs_return_tl { - \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_tmpa_str{#1} - \__stex_refs_do_autoref:n{ - \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1 - } - }{ - \l__stex_refs_return_tl +\cs_new_protected:Nn \_stex_sref_do_aux:n { + #1 \iow_now:Nn \@auxout {#1} +} + +\cs_new_protected:Nn \__stex_refs_new_symbol:n { + \prop_if_exist:NTF \l_stex_current_archive_prop { + \prop_get:NnNTF \l_stex_current_archive_prop {docurl} \l__stex_refs_str { + \exp_args:Ne \_stex_sref_do_aux:n { + \STEXInternalSetSrefSymURL{#1}{\l__stex_refs_str / symbol? #1} } }{ - \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_tmpa_str - \__stex_refs_do_autoref:n{ - \str_if_empty:NF\l__stex_refs_uri_str{\l__stex_refs_uri_str?}#1 - } + \_stex_sref_do_aux:n { \STEXInternalSetSrefSymURL{#1}{} } } - \endgroup + }{ + \_stex_sref_do_aux:n { \STEXInternalSetSrefSymURL{#1}{} } + } } - % \__stex_refs_args:n { #1 } - % \str_if_empty:NTF \l__stex_refs_indocument_str { - % \str_set:Nx \l_tmpa_str { #2 } - % \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str - % \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 { - % \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{ - % \seq_get_left:cNF {g__stex_refs_labels_\l_tmpa_str _seq} \l_tmpa_str { - % \str_clear:N \l_tmpa_str - % } - % }{ - % \str_clear:N \l_tmpa_str - % } - % }{ - % \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - % \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - % \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} } - % \seq_if_exist:cTF{g__stex_refs_labels_\l_tmpa_str _seq}{ - % \str_set_eq:NN \l_tmpc_str \l_tmpa_str - % \str_clear:N \l_tmpa_str - % \seq_map_inline:cn {g__stex_refs_labels_\l_tmpc_str _seq} { - % \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{ - % \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } - % }{ - % \seq_map_break:n { - % \str_set:Nn \l_tmpa_str { ##1 } - % } - % } - % } - % }{ - % \str_clear:N \l_tmpa_str - % } - % } - % \str_if_empty:NTF \l_tmpa_str { - % \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl - % }{ - % \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c__stex_refs_ref_str { - % \tl_if_empty:NTF \l__stex_refs_linktext_tl { - % \cs_if_exist:cTF{autoref}{ - % \l__stex_refs_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l__stex_refs_post_tl - % }{ - % \l__stex_refs_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l__stex_refs_post_tl - % } - % }{ - % \ltx@ifpackageloaded{hyperref}{ - % \hyperref[sref_\l_tmpa_str]\l__stex_refs_linktext_tl - % }{ - % \l__stex_refs_linktext_tl - % } - % } - % }{ - % \ltx@ifpackageloaded{hyperref}{ - % \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl} - % }{ - % \tl_if_empty:NTF \l__stex_refs_linktext_tl \l__stex_refs_fallback_tl \l__stex_refs_linktext_tl - % } - % } - % } - % }{ - % TODO - % } -\NewDocumentCommand \srefsym { O{} m}{ - \stex_get_symbol:n { #2 } - \__stex_refs_sym_aux:nn{#1}{\l_stex_get_symbol_uri_str} -} - -\cs_new_protected:Nn \__stex_refs_sym_aux:nn { - -} -\cs_new_protected:Npn \srefsymuri #1 #2 { % TODO - #2%\__stex_refs_sym_aux:nn{linktext={#2}}{#1} -} - -%%%%%%%%%%%%% modules.dtx %%%%%%%%%%%%% - -\msg_new:nnn{stex}{error/unknownmodule}{ - No~module~#1~found -} -\msg_new:nnn{stex}{error/syntax}{ - Syntax~error:~#1 -} -\msg_new:nnn{stex}{error/siglanguage}{ - Module~#1~declares~signature~#2,~but~does~not~ - declare~its~language -} -\msg_new:nnn{stex}{warning/deprecated}{ - #1~is~deprecated;~please~use~#2~instead! -} - -\msg_new:nnn{stex}{error/conflictingmodules}{ - Conflicting~imports~for~module~#1 -} -\str_new:N \l_stex_current_module_str -\seq_new:N \l_stex_all_modules_seq -\prg_new_conditional:Nnn \stex_if_in_module: {p, T, F, TF} { - \str_if_empty:NTF \l_stex_current_module_str - \prg_return_false: \prg_return_true: -} -\prg_new_conditional:Nnn \stex_if_module_exists:n {p, T, F, TF} { - \prop_if_exist:cTF { c_stex_module_#1_prop } - \prg_return_true: \prg_return_false: +\cs_new_protected:Nn \stex_ref_new_sym_target:n { + \exp_args:Ne \label{\tl_to_str:n{sref@sym@ #1}} } -\cs_new_protected:Nn \stex_execute_in_module:n { \stex_if_in_module:T { - \stex_add_to_current_module:n { #1 } - \stex_do_up_to_module:n { #1 } -}} -\cs_generate_variant:Nn \stex_execute_in_module:n {x} -\cs_new_protected:Nn \stex_add_to_current_module:n { - \tl_gput_right:cn {c_stex_module_\l_stex_current_module_str _code} { #1 } +\cs_new_protected:Nn \stex_ref_new_sym_target:nn { + \str_if_eq:nnTF{#1}{#2}{ + \stex_ref_new_sym_target:n{#1} + }{ + \str_gset:cn{g_stex_sref_sym_ #1 _label}{#2} + } } -\cs_generate_variant:Nn \stex_add_to_current_module:n {x} -\cs_new_protected:Npn \STEXexport { - \ExplSyntaxOn - \__stex_modules_export:n +\NewDocumentCommand \srefsym { m m}{ + \stex_get_symbol:n { #1 } + \exp_args:Ne + \__stex_refs_sym_aux:nn{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} } -\cs_new_protected:Nn \__stex_modules_export:n { - \ignorespacesandpars#1\ExplSyntaxOff - \stex_add_to_current_module:n { \ignorespacesandpars#1} - \stex_smsmode_do: + +\cs_new_protected:Npn \__stex_refs_do_internal_link:nn #1 { + \cs_if_exist:NTF \hyperref { + \hyperref[{#1}] + }\use:n } -\let \stex_module_export_helper:n \use:n -\stex_deactivate_macro:Nn \STEXexport {module~environments} -\cs_new_protected:Nn \stex_add_constant_to_current_module:n { - \str_set:Nx \l_tmpa_str { #1 } - \seq_gput_right:co {c_stex_module_\l_stex_current_module_str _constants} { \l_tmpa_str } + +\cs_new_protected:Npn \__stex_refs_do_url_link:nn { + \cs_if_exist:NTF \href \href \use_ii:nn } -\cs_new_protected:Nn \stex_add_import_to_current_module:n { - \str_set:Nx \l_tmpa_str { #1 } - \exp_args:Nno - \seq_if_in:cnF{c_stex_module_\l_stex_current_module_str _imports}\l_tmpa_str{ - \seq_gput_right:co{c_stex_module_\l_stex_current_module_str _imports}\l_tmpa_str + +\cs_new_protected:Npn \__stex_refs_sym_aux:nn #1 { + \cs_if_exist:cTF{r@sref@sym@\tl_to_str:n{#1}}{ + \exp_args:Ne \__stex_refs_do_internal_link:nn{\tl_to_str:n{sref@sym@#1}} + }{ + \str_if_exist:cTF{g_stex_sref_sym_#1_label}{ + \exp_args:Ne \__stex_refs_sym_aux:nn{\use:c{g_stex_sref_sym_#1_label}} + }{ + \str_if_empty:cTF{g_stex_sref_sym_#1_target}{ + \exp_args:Ne \__stex_refs_do_internal_link:nn{\tl_to_str:n{sref@sym@#1}} + }{ + \exp_args:Ne \__stex_refs_do_url_link:nn{\use:c{g_stex_sref_sym_#1_target}} + } + } } } -\cs_new_protected:Nn \stex_collect_imports:n { - \seq_clear:N \l_stex_collect_imports_seq - \__stex_modules_collect_imports:n {#1} +\cs_new_protected:Npn \srefsymuri #1 { + \__stex_refs_sym_aux:nn{#1} } -\cs_new_protected:Nn \__stex_modules_collect_imports:n { - \seq_map_inline:cn {c_stex_module_#1_imports} { - \seq_if_in:NnF \l_stex_collect_imports_seq { ##1 } { - \__stex_modules_collect_imports:n { ##1 } +\cs_new_protected:Nn \stex_resolve_path_pair:Nnn { + \stex_debug:nn{resolving~path}{#3~in~[#2]} + \str_if_empty:nTF{#2}{ + \prop_if_exist:NTF \l_stex_current_archive_prop { + \str_set:Nx #1 {\stex_file_use:N \c_stex_mathhub_file / + \prop_item:Nn \l_stex_current_archive_prop { id } / source / + #3} + \stex_debug:nn{resolving~path}{In~current~archive~ + \prop_item:Nn \l_stex_current_archive_prop { id } + ;~result:~#1} + }{ + \str_set:Nx #1 {\stex_file_use:N \c_stex_pwd_file / .. / #3 } + \stex_debug:nn{resolving~path}{No~current~archive;~result:~#1} } - } - \seq_if_in:NnF \l_stex_collect_imports_seq { #1 } { - \seq_put_right:Nx \l_stex_collect_imports_seq { #1 } + }{ + \stex_require_archive:n { #2 } + \str_set:Nx #1 {\stex_file_use:N \c_stex_mathhub_file / + \prop_item:cn {c_stex_mathhub_#2_manifest_prop} { id } / source / + #3} + \stex_debug:nn{resolving~path}{result:~#1} } } -\int_new:N \l__stex_modules_group_depth_int -\cs_new_protected:Nn \stex_do_up_to_module:n { - \int_compare:nNnTF \l__stex_modules_group_depth_int = \currentgrouplevel { - #1 - }{ - #1 - \expandafter \tl_gset:Nn - \csname l__stex_modules_aftergroup_\l_stex_current_module_str _tl - \expandafter\expandafter\expandafter\endcsname - \expandafter\expandafter\expandafter { \csname - l__stex_modules_aftergroup_\l_stex_current_module_str _tl\endcsname #1 } - \aftergroup\__stex_modules_aftergroup_do: +\cs_generate_variant:Nn \stex_resolve_path_pair:Nnn {Nxx} +\newif \ifinputref \inputreffalse + +\cs_new_protected:Nn \__stex_inputs_mhinput:nn { + \stex_in_archive:nn {#1} { + \ifinputref + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / ##1 / source / #2 } + \else + \inputreftrue + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / ##1 / source / #2 } + \inputreffalse + \fi } } -\cs_generate_variant:Nn \stex_do_up_to_module:n {x} -\cs_new_protected:Nn \__stex_modules_aftergroup_do: { - \stex_debug:nn{aftergroup}{\cs_meaning:c{ - l__stex_modules_aftergroup_\l_stex_current_module_str _tl - }} - \int_compare:nNnTF \l__stex_modules_group_depth_int = \currentgrouplevel { - \use:c{l__stex_modules_aftergroup_\l_stex_current_module_str _tl} - \tl_gclear:c{l__stex_modules_aftergroup_\l_stex_current_module_str _tl} - }{ - \use:c{l__stex_modules_aftergroup_\l_stex_current_module_str _tl} - \aftergroup\__stex_modules_aftergroup_do: - } -} -\cs_new_protected:Nn \_stex_reset_up_to_module:n { - \expandafter\let\csname l__stex_modules_aftergroup_#1_tl\endcsname\undefined + +\NewDocumentCommand \mhinput { O{} m}{ + \exp_args:NNx\exp_args:Nnx\__stex_inputs_mhinput:nn{ \tl_to_str:n{#1} }{ \tl_to_str:n{#2} } } -\str_new:N \l_stex_module_ns_str -\str_new:N \l_stex_module_subpath_str -\cs_new_protected:Nn \__stex_modules_compute_namespace:nN { - \seq_set_eq:NN \l_tmpa_seq #2 - % split off file extension - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str % <- filename - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str % <- filename without suffixes - \seq_put_right:No \l_tmpa_seq \l_tmpb_str % <- file path including name without suffixes - - \bool_set_true:N \l_tmpa_bool - \bool_while_do:Nn \l_tmpa_bool { - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \exp_args:No \str_case:nnTF { \l_tmpb_str } { - {source} { \bool_set_false:N \l_tmpa_bool } - }{}{ - \seq_if_empty:NT \l_tmpa_seq { - \bool_set_false:N \l_tmpa_bool - } - } - } - - \stex_path_to_string:NN \l_tmpa_seq \l_stex_module_subpath_str - % \l_tmpa_seq <- sub-path relative to archive - \str_if_empty:NTF \l_stex_module_subpath_str { - \str_set:Nx \l_stex_module_ns_str {#1} - }{ - \str_set:Nx \l_stex_module_ns_str { - #1/\l_stex_module_subpath_str - } - } -} - -\cs_new_protected:Nn \stex_modules_current_namespace: { - \str_clear:N \l_stex_module_subpath_str - \prop_if_exist:NTF \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { ns } \l_tmpa_str - \__stex_modules_compute_namespace:nN \l_tmpa_str \g_stex_currentfile_seq - }{ - % split off file extension - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpb_str - \exp_args:NNno \seq_set_split:Nnn \l_tmpb_seq . \l_tmpb_str - \seq_get_left:NN \l_tmpb_seq \l_tmpb_str - \seq_put_right:No \l_tmpa_seq \l_tmpb_str - \str_set:Nx \l_stex_module_ns_str { - file:/\stex_path_to_string:N \l_tmpa_seq - } - } -} -\keys_define:nn { stex / module } { - title .tl_set:N = \smoduletitle , - type .str_set_x:N = \smoduletype , - id .str_set_x:N = \smoduleid , - deprecate .str_set_x:N = \l_stex_module_deprecate_str , - ns .str_set_x:N = \l_stex_module_ns_str , - lang .str_set_x:N = \l_stex_module_lang_str , - sig .str_set_x:N = \l_stex_module_sig_str , - creators .str_set_x:N = \l_stex_module_creators_str , - contributors .str_set_x:N = \l_stex_module_contributors_str , - meta .str_set_x:N = \l_stex_module_meta_str , - srccite .str_set_x:N = \l_stex_module_srccite_str -} - -\cs_new_protected:Nn \__stex_modules_args:n { - \str_clear:N \smoduletitle - \str_clear:N \smoduletype - \str_clear:N \smoduleid - \str_clear:N \l_stex_module_ns_str - \str_clear:N \l_stex_module_deprecate_str - \str_clear:N \l_stex_module_lang_str - \str_clear:N \l_stex_module_sig_str - \str_clear:N \l_stex_module_creators_str - \str_clear:N \l_stex_module_contributors_str - \str_clear:N \l_stex_module_meta_str - \str_clear:N \l_stex_module_srccite_str - \keys_set:nn { stex / module } { #1 } -} - - -\cs_new_protected:Nn \stex_module_setup:nn { - \int_set:Nn \l__stex_modules_group_depth_int {\currentgrouplevel} - \str_set:Nx \l_stex_module_name_str { #2 } - \__stex_modules_args:n { #1 } - \stex_if_in_module:TF { - % Nested module - \prop_get:cnN {c_stex_module_\l_stex_current_module_str _prop} - { ns } \l_stex_module_ns_str - \str_set:Nx \l_stex_module_name_str { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { name } / \l_stex_module_name_str - } - \str_if_empty:NT \l_stex_module_lang_str { - \str_set:Nx \l_stex_module_lang_str { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { lang } - } - } - }{ - % not nested: - \str_if_empty:NT \l_stex_module_ns_str { - \stex_modules_current_namespace: - \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq - / {\l_stex_module_ns_str} - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \str_if_eq:NNT \l_tmpa_str \l_stex_module_name_str { - \str_set:Nx \l_stex_module_ns_str { - \stex_path_to_string:N \l_tmpa_seq - } - } - } - } - \str_if_empty:NT \l_stex_module_lang_str { - \seq_get_right:NN \g_stex_currentfile_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpa_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str % .tex - \exp_args:No \str_if_eq:nnF \l_tmpa_str {tex} { - \exp_args:No \str_if_eq:nnF \l_tmpa_str {dtx} { - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq \l_tmpa_str - } +\cs_new_protected:Nn \__stex_inputs_inputref_html:nn { + \str_clear:N \l_tmpa_str + \prop_get:NnNF \l_stex_current_archive_prop { narr } \l_tmpa_str { + \prop_get:NnNF \l_stex_current_archive_prop { ns } \l_tmpa_str {} + } + \tl_if_empty:nTF{ #1 }{ + \IfFileExists{#2}{ + \ifvmode\noindent\fi\stex_annotate_invisible:nn{shtml:inputref={ + \l_tmpa_str / #2 + }}{} + }{ + \stex_input_with_hooks:n{#2} } - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_str % <filename> - \seq_if_empty:NF \l_tmpa_seq { %remaining element should be [<something>.]language - \seq_pop_right:NN \l_tmpa_seq \l_stex_module_lang_str - \stex_debug:nn{modules} {Language~\l_stex_module_lang_str~ - inferred~from~file~name} + }{ + \IfFileExists{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 }{ + \par\stex_annotate_invisible:nn{shtml:inputref={ + \l_tmpa_str / #2 + }}{~} + }{ + \input{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 } } } +} - \stex_if_smsmode:F { \str_if_empty:NF \l_stex_module_lang_str { - \exp_args:NNo \stex_set_language:Nn \l_tmpa_str \l_stex_module_lang_str - }} - \str_if_empty:NTF \l_stex_module_sig_str { - \exp_args:Nnx \prop_gset_from_keyval:cn { - c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _prop - } { - name = \l_stex_module_name_str , - ns = \l_stex_module_ns_str , - file = \exp_not:o { \g_stex_currentfile_seq } , - lang = \l_stex_module_lang_str , - sig = \l_stex_module_sig_str , - deprecate = \l_stex_module_deprecate_str , - meta = \l_stex_module_meta_str - } - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _imports} - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _constants} - \seq_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _copymodules} - \tl_clear:c {c_stex_module_\l_stex_module_ns_str?\l_stex_module_name_str _code} - \str_set:Nx\l_stex_current_module_str{\l_stex_module_ns_str?\l_stex_module_name_str} - \str_if_empty:NT \l_stex_module_meta_str { - \str_set:Nx \l_stex_module_meta_str { - \c_stex_metatheory_ns_str ? Metatheory - } - } - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \bool_set_true:N \l_stex_in_meta_bool - \exp_args:Nx \stex_add_to_current_module:n { - \bool_set_true:N \l_stex_in_meta_bool - \stex_activate_module:n {\l_stex_module_meta_str} - \bool_set_false:N \l_stex_in_meta_bool - } - \stex_activate_module:n {\l_stex_module_meta_str} - \bool_set_false:N \l_stex_in_meta_bool - } - }{ - \str_if_empty:NT \l_stex_module_lang_str { - \msg_error:nnxx{stex}{error/siglanguage}{ - \l_stex_module_ns_str?\l_stex_module_name_str - }{\l_stex_module_sig_str} - } - \stex_debug:nn{modules}{Signature~\l_stex_module_sig_str~for~\l_stex_module_ns_str?\l_stex_module_name_str} - \stex_if_module_exists:nTF{\l_stex_module_ns_str?\l_stex_module_name_str}{ - \stex_debug:nn{modules}{(already exists)} +\cs_new_protected:Nn \__stex_inputs_inputref_pdf:nn { + \begingroup + \inputreftrue + \tl_if_empty:nTF{ #1 }{ + \stex_input_with_hooks:n{#2} }{ - \stex_debug:nn{modules}{(needs loading)} - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpb_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpb_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str % <filename> - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \l_tmpa_seq / - \l_tmpa_str . \l_stex_module_sig_str .tex - } - \IfFileExists \l_tmpa_str { - \exp_args:No \stex_file_in_smsmode:nn { \l_tmpa_str } { - \str_clear:N \l_stex_current_module_str - \seq_clear:N \l_stex_all_modules_seq - \stex_debug:nn{modules}{Loading~signature} - } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{for~signature~\l_tmpa_str} - } + \stex_input_with_hooks:n{ \stex_file_use:N \c_stex_mathhub_file / #1 / source / #2 } } - \stex_if_smsmode:F { - \stex_activate_module:n { - \l_stex_module_ns_str ? \l_stex_module_name_str - } - } - \str_set:Nx\l_stex_current_module_str{\l_stex_module_ns_str?\l_stex_module_name_str} + \endgroup +} + +\cs_new_protected:Nn \__stex_inputs_inputref:nn { + \stex_in_archive:nn {#1} { + \stex_if_html_backend:TF + \__stex_inputs_inputref_html:nn + \__stex_inputs_inputref_pdf:nn + {##1}{#2} } - \str_if_empty:NF \l_stex_module_deprecate_str { - \msg_warning:nnxx{stex}{warning/deprecated}{ - Module~\l_stex_current_module_str - }{ - \l_stex_module_deprecate_str +} + +\NewDocumentCommand \inputref { O{} m}{ + \exp_args:NNx \exp_args:Nnx \__stex_inputs_inputref:nn{ \tl_to_str:n{#1} }{ \tl_to_str:n{#2} } +} +\cs_new_protected:Nn \__stex_inputs_bibresource:n { + \__stex_inputs_up_archive:nn{#1}{bib} + \seq_if_empty:NTF \l__stex_inputs_libinput_files_seq { + \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\addmhbibresource}{#1.bib} + }{ + \seq_map_inline:Nn \l__stex_inputs_libinput_files_seq { + \addbibresource{ ##1 } } } - \seq_put_right:Nx \l_stex_all_modules_seq { - \l_stex_module_ns_str ? \l_stex_module_name_str +} +\newcommand\addmhbibresource[2][]{ + \tl_if_empty:nTF{#1}{ + \__stex_inputs_bibresource:n{#2} + }{ + \stex_in_archive:nn{#1}{\__stex_inputs_bibresource:n{#2}} + } +} +\stex_if_html_backend:TF{ + \newcommand \IfInputref[2]{ + \stex_annotate:nn{shtml:ifinputref=true}{#1} + \stex_annotate:nn{shtml:ifinputref=false}{#2} + } +}{ + \newcommand \IfInputref[2]{ + \ifinputref #1 \else #2 \fi } - \tl_clear:c{l__stex_modules_aftergroup_\l_stex_module_ns_str ? \l_stex_module_name_str _tl} } -\cs_new_protected:Nn \__stex_modules_begin_module: { - \stex_reactivate_macro:N \STEXexport - \stex_reactivate_macro:N \importmodule - \stex_reactivate_macro:N \symdecl - \stex_reactivate_macro:N \notation - \stex_reactivate_macro:N \symdef +\cs_new_protected:Nn \__stex_inputs_up_archive:nn { + \prop_if_exist:NF \l_stex_current_archive_prop { + \msg_error:nnn{stex}{error/notinarchive}\libinput + } + \prop_get:NnNF \l_stex_current_archive_prop {id} \l__stex_inputs_id_str { + \msg_error:nnn{stex}{error/notinarchive}\libinput + } + \seq_clear:N \l__stex_inputs_libinput_files_seq + \seq_set_eq:NN \l__stex_inputs_path_seq \c_stex_mathhub_file + \seq_set_split:NnV \l__stex_inputs_id_seq / \l__stex_inputs_id_str - \stex_debug:nn{modules}{ - New~module:\\ - Namespace:~\l_stex_module_ns_str\\ - Name:~\l_stex_module_name_str\\ - Language:~\l_stex_module_lang_str\\ - Signature:~\l_stex_module_sig_str\\ - Metatheory:~\l_stex_module_meta_str\\ - File:~\stex_path_to_string:N \g_stex_currentfile_seq + \bool_while_do:nn { ! \seq_if_empty_p:N \l__stex_inputs_id_seq }{ + \str_set:Nx \l__stex_inputs_path_str {\stex_file_use:N \l__stex_inputs_path_seq / meta-inf / lib / #1.#2} + \IfFileExists{ \l__stex_inputs_path_str }{ + \seq_put_right:No \l__stex_inputs_libinput_files_seq \l__stex_inputs_path_str + }{} + \seq_pop_left:NN \l__stex_inputs_id_seq \l__stex_inputs_path_str + \seq_put_right:No \l__stex_inputs_path_seq \l__stex_inputs_path_str } - \stex_if_do_html:T{ - \begin{stex_annotate_env} {theory} { - \l_stex_module_ns_str ? \l_stex_module_name_str - } + \str_set:Nx \l__stex_inputs_path_str {\stex_file_use:N \l__stex_inputs_path_seq / lib / #1.#2} + \IfFileExists{ \l__stex_inputs_path_str }{ + \seq_put_right:No \l__stex_inputs_libinput_files_seq \l__stex_inputs_path_str + }{} +} - \stex_annotate_invisible:nnn{header}{} { - \stex_annotate:nnn{language}{ \l_stex_module_lang_str }{} - \stex_annotate:nnn{signature}{ \l_stex_module_sig_str }{} - \str_if_eq:VnF \l_stex_module_meta_str {NONE} { - \stex_annotate:nnn{metatheory}{ \l_stex_module_meta_str }{} - } - \str_if_empty:NF \smoduletype { - \stex_annotate:nnn{type}{\smoduletype}{} - } +\cs_new_protected:Nn \__stex_inputs_libinput:n { + \__stex_inputs_up_archive:nn{#1}{tex} + \seq_if_empty:NTF \l__stex_inputs_libinput_files_seq { + \msg_error:nnxx{stex}{error/nofile}{\exp_not:N\libinput}{#1.tex} + }{ + \seq_map_inline:Nn \l__stex_inputs_libinput_files_seq { + \input{ ##1 } } } - % TODO: Inherit metatheory for nested modules? } -\iffalse \end{stex_annotate_env} \fi %^^A make syntax highlighting work again -\cs_new_protected:Nn \__stex_modules_end_module: { - \stex_debug:nn{modules}{Closing~module~\prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} { name }} - \_stex_reset_up_to_module:n \l_stex_current_module_str - \stex_if_smsmode:T { - \stex_persist:x { - \prop_set_from_keyval:cn{c_stex_module_\l_stex_current_module_str _prop}{ - \exp_after:wN \prop_to_keyval:N \csname c_stex_module_\l_stex_current_module_str _prop\endcsname - } - \seq_set_from_clist:cn{c_stex_module_\l_stex_current_module_str _constants}{ - \seq_use:cn{c_stex_module_\l_stex_current_module_str _constants}, - } - \seq_set_from_clist:cn{c_stex_module_\l_stex_current_module_str _imports}{ - \seq_use:cn{c_stex_module_\l_stex_current_module_str _imports}, - } - \tl_set:cn {c_stex_module_\l_stex_current_module_str _code} - } - \exp_after:wN \let \exp_after:wN \l_tmpa_tl \csname c_stex_module_\l_stex_current_module_str _code\endcsname - \exp_after:wN \stex_persist:n \exp_after:wN { \exp_after:wN { \l_tmpa_tl } } + +\newcommand \libinput [2][] { + \tl_if_empty:nTF{#1}{ + \__stex_inputs_libinput:n{#2} + }{ + \stex_in_archive:nn{#1}{\__stex_inputs_libinput:n{#2}} } } -\iffalse \begin{stex_annotate_env} \fi %^^A make syntax highlighting work again -\NewDocumentEnvironment { smodule } { O{} m } { - \stex_module_setup:nn{#1}{#2} - %\par - \stex_if_smsmode:F{ - \tl_if_empty:NF \smoduletitle { - \exp_args:No \stex_document_title:n \smoduletitle - } - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \smoduletype { - \tl_if_exist:cT {__stex_modules_smodule_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_modules_smodule_##1_start:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_modules_smodule_start: - }{ - \l_tmpa_tl +\newcommand\libusepackage[2][]{ + \__stex_inputs_up_archive:nn{#2}{sty} + \int_compare:nNnTF {\seq_count:N \l__stex_inputs_libinput_files_seq} = 1 { + \str_set:Nx \l__stex_inputs_tmp_str {\seq_item:Nn \l__stex_inputs_libinput_files_seq 1} + \exp_args:Nne \use:n {\usepackage[#1]} { + \str_range:Nnn\l__stex_inputs_tmp_str 1 {-5} } + }{ + \stex_fatal_error:nnn{error/nofile}{\libusepackage}{#1.sty} } - \__stex_modules_begin_module: - \str_if_empty:NF \smoduleid { - \stex_ref_new_doc_target:n \smoduleid +} +\str_new:N \l__stex_inputs_gin_repo_str +\ltx@ifpackageloaded{graphicx}{\use:n}{\AtEndOfPackageFile{graphicx}}{ + \define@key{Gin}{archive}{ + \tl_set:Nx\Gin@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} } - \stex_smsmode_do: -} { - \__stex_modules_end_module: - \stex_if_smsmode:F { - \end{stex_annotate_env} - \clist_set:No \l_tmpa_clist \smoduletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_modules_smodule_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_modules_smodule_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_modules_smodule_end: - }{ - \l_tmpa_tl + \providecommand\mhgraphics[2][]{ + \tl_set:Nx\Gin@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / } + \setkeys{Gin}{#1} + \includegraphics[#1]{ \Gin@mhrepos #2 } } + \providecommand\cmhgraphics[2][]{\begin{center}\mhgraphics[#1]{#2}\end{center}} } -\cs_new_protected:Nn \__stex_modules_smodule_start: {} -\cs_new_protected:Nn \__stex_modules_smodule_end: {} -\newcommand\stexpatchmodule[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_modules_smodule_start: { #2 } - \tl_set:Nn \__stex_modules_smodule_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname __stex_modules_smodule_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_modules_smodule_#1_end:\endcsname{ #3 } - } -} -\NewDocumentCommand \STEXModule { m } { - \exp_args:NNx \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnx{stex}{error/unknownmodule}{#1} +\ltx@ifpackageloaded{listings}{\use:n}{\AtEndOfPackageFile{listings}}{ + \define@key{lst}{archive}{ + \def\lst@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \tl_set:Nn \l_tmpa_tl { - \stex_invoke_module:n { ##1 } - } - } + \newcommand\lstinputmhlisting[2][]{% + \def\lst@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / } - } - \l_tmpa_tl + \setkeys{lst}{#1}% + \lstinputlisting[#1]{\lst@mhrepos #2}} + \newcommand\clstinputmhlisting[2][]{\begin{center}\lstinputmhlisting[#1]{#2}\end{center}} } -\cs_new_protected:Nn \stex_invoke_module:n { - \stex_debug:nn{modules}{Invoking~module~#1} - \peek_charcode_remove:NTF ! { - \__stex_modules_invoke_uri:nN { #1 } - } { - \peek_charcode_remove:NTF ? { - \__stex_modules_invoke_symbol:nn { #1 } - } { - \msg_error:nnx{stex}{error/syntax}{ - ?~or~!~expected~after~ - \c_backslash_str STEXModule{#1} - } +\ltx@ifpackageloaded{tikzinput}{\use:n}{\AtEndOfPackageFile{tikzinput}}{ + \define@key{Gin}{archive}{ + \str_set:Nn \l__stex_inputs_gin_repo_str {#1} + \def\Gin@mhrepos{\stex_file_use:N \c_stex_mathhub_file / #1 / source /} + } + \newcommand\mhtikzinput[2][]{% + \str_clear:N \l__stex_inputs_gin_repo_str + \def\Gin@mhrepos{ + \stex_file_use:N \c_stex_mathhub_file / \prop_item:Nn \l_stex_current_archive_prop {id} / source / + } + \setkeys{Gin}{#1}% + \exp_args:No \stex_in_archive:nn \l__stex_inputs_gin_repo_str { + \tikzinput[#1]{\Gin@mhrepos #2} } } + \newcommand\cmhtikzinput[2][]{\begin{center}\mhtikzinput[#1]{#2}\end{center}} } - -\cs_new_protected:Nn \__stex_modules_invoke_uri:nN { - \str_set:Nn #2 { #1 } +\cs_new_protected:Nn \__stex_inputs_usetikzlibrary:nn { + \pgfkeys@spdef\pgf@temp{#1} + \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$} + \catcode`\@=11 + \catcode`\|=12 + \catcode`\$=3 + \pgfutil@InputIfFileExists{#2}{}{} + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname } -\cs_new_protected:Nn \__stex_modules_invoke_symbol:nn { - \stex_invoke_symbol:n{#1?#2} +\cs_new_protected:Npn \libusetikzlibrary #1 { + \cs_if_exist:NF \usetikzlibrary { + \msg_error:nnx{stex}{error/notikz}{\tl_to_str:n{\libusetikzlibrary}} + } + \__stex_inputs_up_archive:nn{tikzlibrary#1}{code.tex} + \int_compare:nNnTF {\seq_count:N \l__stex_inputs_libinput_files_seq} = 1 { + \exp_args:Nne \__stex_inputs_usetikzlibrary:nn{#1}{ \seq_item:Nn \l__stex_inputs_libinput_files_seq 1 } + }{ + \stex_fatal_error:nnn{error/nofile}{\libusetikzlibrary}{tikzlibrary#1.code.tex} + } } -\bool_new:N \l_stex_in_meta_bool -\bool_set_false:N \l_stex_in_meta_bool -\cs_new_protected:Nn \stex_activate_module:n { - \stex_debug:nn{modules}{Activating~module~#1} - \exp_args:NNx \seq_if_in:NnF \l_stex_all_modules_seq { #1 } { - \seq_put_right:Nx \l_stex_all_modules_seq { #1 } - \use:c{ c_stex_module_#1_code } - } -} -\NewDocumentEnvironment { mmtinterface } { O{} m m } { - \begin{smodule}[#1]{#3} - \str_set:Nx \l_stex_module_mmtfor_str {#2} - \MMTinclude{#2} - \stex_reactivate_macro:N \mmtdecl - \stex_reactivate_macro:N \mmtdef -}{ - \end{smodule} +\tl_new:N \g__stex_smsmode_allowed_tl +\tl_new:N \g__stex_smsmode_allowed_escape_tl +\seq_new:N \g__stex_smsmode_allowedenvs_seq +\cs_new_protected:Nn \stex_sms_allow:N { + \tl_gput_right:Nn \g__stex_smsmode_allowed_tl {#1} } -%%%%%%%%%%%%% inheritance.dtx %%%%%%%%%%%%% - -\tl_new:N \g_stex_smsmode_allowedmacros_tl -\tl_new:N \g_stex_smsmode_allowedmacros_escape_tl -\seq_new:N \g_stex_smsmode_allowedenvs_seq +\cs_new_protected:Nn \stex_sms_allow_escape:N { + \tl_gput_right:Nn \g__stex_smsmode_allowed_escape_tl {#1} +} -\tl_set:Nn \g_stex_smsmode_allowedmacros_tl { - \makeatletter - \makeatother - \ExplSyntaxOn - \ExplSyntaxOff - \rustexBREAK -} - -\tl_set:Nn \g_stex_smsmode_allowedmacros_escape_tl { - \symdef - \importmodule - \notation - \symdecl - \STEXexport - \inlineass - \inlinedef - \inlineex - \endinput - \setnotation - \copynotation - \assign - \renamedecl - \donotcopy - \instantiate - \textsymdecl -} - -\exp_args:NNx \seq_set_from_clist:Nn \g_stex_smsmode_allowedenvs_seq { - \tl_to_str:n { - smodule, - copymodule, - interpretmodule, - realization, - sdefinition, - sexample, - sassertion, - sparagraph, - mathstructure, - extstructure, - extstructure* - } +\cs_new_protected:Nn \stex_sms_allow_env:n { + \exp_args:NNx \seq_gput_right:Nn \g__stex_smsmode_allowedenvs_seq {\tl_to_str:n{#1}} } +\stex_sms_allow:N \makeatletter +\stex_sms_allow:N \makeatother +\stex_sms_allow:N \ExplSyntaxOn +\stex_sms_allow:N \ExplSyntaxOff +\stex_sms_allow:N \rustexBREAK \bool_new:N \g__stex_smsmode_bool \bool_set_false:N \g__stex_smsmode_bool \prg_new_conditional:Nnn \stex_if_smsmode: { p, T, F, TF } { \bool_if:NTF \g__stex_smsmode_bool \prg_return_true: \prg_return_false: } -\cs_new_protected:Nn \__stex_smsmode_in_smsmode:nn { \stex_suppress_html:n { +\tl_new:N \g__stex_smsmode_allowed_import_tl +\seq_new:N \g__stex_smsmode_allowed_import_env_seq +\cs_new_protected:Nn \stex_sms_allow_import:Nn { + \tl_gput_right:Nn \g__stex_smsmode_allowed_import_tl {#1} + \tl_gset:cn{\tl_to_str:n{#1}~-~smsmode} {#2} +} +\cs_new_protected:Nn \stex_sms_allow_import_env:nn { + \exp_args:NNx \seq_gput_right:Nn \g__stex_smsmode_allowed_import_env_seq {\tl_to_str:n{#1}} + \tl_gset:cn{\tl_to_str:n{#1}~-~env~-~smsmode} {#2} +} + +\tl_new:N \g_stex_sms_import_code +\cs_new_protected:Nn \__stex_smsmode_in_smsmode:n { \stex_suppress_html:n { \vbox_set:Nn \l_tmpa_box { - \bool_set_eq:cN { l__stex_smsmode_#1_bool } \g__stex_smsmode_bool - \bool_gset_true:N \g__stex_smsmode_bool - #2 - \bool_gset_eq:Nc \g__stex_smsmode_bool { l__stex_smsmode_#1_bool } + \bool_set_true:N \g__stex_smsmode_bool + \bool_set_false:N \_stex_html_do_output_bool + #1 } - \box_clear:N \l_tmpa_box + %\box_clear:N \l_tmpa_box } } + \quark_new:N \q__stex_smsmode_break -\NewDocumentCommand \__stex_smsmode_importmodule: { O{} m} { - \seq_gput_right:Nn \l__stex_smsmode_importmodules_seq {{#1}{#2}} +\cs_new_protected:Nn \__stex_smsmode_start_smsmode:n { + \everyeof{\q__stex_smsmode_break\exp_not:N} + \let\stex_smsmode_do:\__stex_smsmode_smsmode_do: + \exp_after:wN \exp_after:wN \exp_after:wN \stex_smsmode_do: -} - -\cs_new_protected:Nn \__stex_smsmode_module:nn { - \__stex_modules_args:n{#1} - \stex_if_in_module:F { - \str_if_empty:NF \l_stex_module_sig_str { - \stex_modules_current_namespace: - \str_set:Nx \l_stex_module_name_str { #2 } - \stex_if_module_exists:nF{\l_stex_module_ns_str?\l_stex_module_name_str}{ - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \seq_set_split:NnV \l_tmpb_seq . \l_tmpa_str - \seq_pop_right:NN \l_tmpb_seq \l_tmpa_str % .tex - \seq_pop_left:NN \l_tmpb_seq \l_tmpa_str % <filename> - \str_set:Nx \l_tmpa_str { - \stex_path_to_string:N \l_tmpa_seq / - \l_tmpa_str . \l_stex_module_sig_str .tex - } - \IfFileExists \l_tmpa_str { - \exp_args:NNx \seq_gput_right:Nn \l__stex_smsmode_sigmodules_seq \l_tmpa_str - }{ - \msg_error:nnx{stex}{error/unknownmodule}{for~signature~\l_tmpa_str} - } - } - } - } -} - -\prg_new_conditional:Nnn \__stex_smsmode_check_import_pair:nn {T,F,TF} { - %\stex_debug:nn{import-pair}{\detokenize{{#1}~{#2}}} - \tl_if_empty:nTF{#1}{ - \prop_if_exist:NTF \l_stex_current_repository_prop - { - %\stex_debug:nn{import-pair}{in repository \prop_item:Nn \l_stex_current_repository_prop {id}} - \prg_return_true: - } { - \seq_set_split:Nnn \l_tmpa_seq ? {#2} - \seq_get_left:NN \l_tmpa_seq \l_tmpa_tl - \tl_if_empty:NT \l_tmpa_tl { - \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl - } - %\stex_debug:nn{import-pair}{\seq_use:Nn \l_tmpa_seq,~of~length~\seq_count:N \l_tmpa_seq} - \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} > 1 - \prg_return_true: \prg_return_false: - } - }\prg_return_true: + \cs:w @ @ input\cs_end: "#1" \relax } \cs_new_protected:Nn \stex_file_in_smsmode:nn { - \stex_filestack_push:n{#1} \seq_gclear:N \l__stex_smsmode_importmodules_seq \seq_gclear:N \l__stex_smsmode_sigmodules_seq - % ----- new ----------------------------- - \__stex_smsmode_in_smsmode:nn{#1}{ - \let\importmodule\__stex_smsmode_importmodule: - \let\stex_module_setup:nn\__stex_smsmode_module:nn - \let\__stex_modules_begin_module:\relax - \let\__stex_modules_end_module:\relax - \seq_clear:N \g_stex_smsmode_allowedenvs_seq - \exp_args:NNx \seq_put_right:Nn \g_stex_smsmode_allowedenvs_seq {\tl_to_str:n{smodule}} - \tl_clear:N \g_stex_smsmode_allowedmacros_tl - \tl_clear:N \g_stex_smsmode_allowedmacros_escape_tl - \tl_put_right:Nn \g_stex_smsmode_allowedmacros_escape_tl {\importmodule} - \everyeof{\q__stex_smsmode_break\noexpand} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "#1"\relax - - \seq_map_inline:Nn \l__stex_smsmode_sigmodules_seq { - \stex_filestack_push:n{##1} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "##1"\relax - \stex_filestack_pop: - } - } - % ----- new ----------------------------- - \__stex_smsmode_in_smsmode:nn{#1} { + \tl_clear:N \g_stex_sms_import_code + \group_begin: + \let \l_stex_metatheory_uri \c_stex_default_metatheory + \cs_set:Npn \stex_check_term:n ##1 {} + \seq_clear:N \l_stex_all_modules_seq + \str_clear:N \l_stex_current_module_str #2 - % ----- new ----------------------------- - \begingroup - %\stex_debug:nn{smsmode}{Here:~\seq_use:Nn\l__stex_smsmode_importmodules_seq, } - \seq_map_inline:Nn \l__stex_smsmode_importmodules_seq { - \__stex_smsmode_check_import_pair:nnT ##1 { \begingroup - \stex_import_module_uri:nn ##1 - \stex_import_require_module:nnnn - \l_stex_import_ns_str - \l_stex_import_archive_str - \l_stex_import_path_str - \l_stex_import_name_str \endgroup + \stex_filestack_push:n{#1} + \__stex_smsmode_in_smsmode:n { + \let \__stex_smsmode_do_aux_curr:N \__stex_smsmode_do_aux_imports:N + \tl_map_inline:Nn \g__stex_smsmode_allowed_import_tl { + \use:c{\tl_to_str:n{##1}~-~smsmode} + } + \seq_map_inline:Nn \g__stex_smsmode_allowed_import_env_seq { + \use:c{\tl_to_str:n{##1}~-~env~-~smsmode} } + \__stex_smsmode_start_smsmode:n{#1} } - \endgroup - \stex_debug:nn{smsmode}{Actually~loading~file~#1} - % ----- new ----------------------------- - \everyeof{\q__stex_smsmode_break\noexpand} - \expandafter\expandafter\expandafter - \stex_smsmode_do: - \csname @ @ input\endcsname "#1"\relax - } - \stex_filestack_pop: + \__stex_smsmode_in_smsmode:n \g_stex_sms_import_code + \__stex_smsmode_in_smsmode:n { + \let \__stex_smsmode_do_aux_curr:N \__stex_smsmode_do_aux_normal:N + \__stex_smsmode_start_smsmode:n{#1} + } + \stex_filestack_pop: + \group_end: } -\cs_new_protected:Npn \stex_smsmode_do: { - \stex_if_smsmode:T { +\cs_generate_variant:Nn \stex_file_in_smsmode:nn {on} +\cs_new_protected:Nn \__stex_smsmode_smsmode_do: { + %\stex_if_smsmode:T { \__stex_smsmode_do:w - } + %} } +\let\stex_smsmode_do:\relax + +\cs_new:Nn \__stex_smsmode_check_cs:NNn { + \exp_after:wN\if\exp_after:wN\relax\exp_not:N#3 + \exp_after:wN#1\exp_after:wN#3\else + \exp_after:wN#2\fi +} + \cs_new_protected:Npn \__stex_smsmode_do:w #1 { \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #1 }}{ - \expandafter\if\expandafter\relax\noexpand#1 - \expandafter\__stex_smsmode_do_aux:N\expandafter#1 - \else\expandafter\__stex_smsmode_do:w\fi + \__stex_smsmode_check_cs:NNn \__stex_smsmode_do_aux:N \__stex_smsmode_do:w { #1 } }{ - \__stex_smsmode_do:w %#1 + \__stex_smsmode_do:w } } + \cs_new_protected:Nn \__stex_smsmode_do_aux:N { \cs_if_eq:NNF #1 \q__stex_smsmode_break { - \tl_if_in:NnTF \g_stex_smsmode_allowedmacros_tl {#1} { - #1\__stex_smsmode_do:w + \__stex_smsmode_do_aux_curr:N #1 + } +} + +\cs_new_protected:Nn \__stex_smsmode_do_aux_imports:N { + % \stex_debug:nn{sms}{Checking~\tl_to_str:n{#1}~in~import} + \tl_if_in:NnTF \g__stex_smsmode_allowed_import_tl {#1} { + \stex_debug:nn{sms}{Executing~\tl_to_str:n{#1}~in~import} + #1 + }{ + \cs_if_eq:NNTF \begin #1 { + \__stex_smsmode_check_begin:Nn \g__stex_smsmode_allowed_import_env_seq }{ - \tl_if_in:NnTF \g_stex_smsmode_allowedmacros_escape_tl {#1} { - #1 + \cs_if_eq:NNTF \end #1 { + \__stex_smsmode_check_end:Nn \g__stex_smsmode_allowed_import_env_seq + }{ + \__stex_smsmode_do:w + } + } + } +} + +\cs_new_protected:Nn \__stex_smsmode_do_aux_normal:N { + % \stex_debug:nn{sms}{Checking~\tl_to_str:n{#1}~in~sms~mode} + \tl_if_in:NnTF \g__stex_smsmode_allowed_tl {#1} { + \stex_debug:nn{sms}{Executing~\tl_to_str:n{#1}} + #1\__stex_smsmode_do:w + }{ + \tl_if_in:NnTF \g__stex_smsmode_allowed_escape_tl {#1} { + \stex_debug:nn{sms}{Executing~escaped~\tl_to_str:n{#1}} + #1 + }{ + \cs_if_eq:NNTF \begin #1 { + \__stex_smsmode_check_begin:Nn \g__stex_smsmode_allowedenvs_seq }{ - \cs_if_eq:NNTF \begin #1 { - \__stex_smsmode_check_begin:n + \cs_if_eq:NNTF \end #1 { + \__stex_smsmode_check_end:Nn \g__stex_smsmode_allowedenvs_seq }{ - \cs_if_eq:NNTF \end #1 { - \__stex_smsmode_check_end:n - }{ - \__stex_smsmode_do:w - } + \__stex_smsmode_do:w } } } } } -\cs_new_protected:Nn \__stex_smsmode_check_begin:n { - \seq_if_in:NxTF \g_stex_smsmode_allowedenvs_seq { \detokenize{#1} }{ - \begin{#1} +\cs_new_protected:Nn \__stex_smsmode_check_begin:Nn { + % \stex_debug:nn{sms}{Checking~environment~#2} + \seq_if_in:NxTF #1 { \tl_to_str:n{#2} }{ + \stex_debug:nn{sms}{Environment~#2} + \begin{#2} }{ \__stex_smsmode_do:w } } -\cs_new_protected:Nn \__stex_smsmode_check_end:n { - \seq_if_in:NxTF \g_stex_smsmode_allowedenvs_seq { \detokenize{#1} }{ - \end{#1}\__stex_smsmode_do:w +\cs_new_protected:Nn \__stex_smsmode_check_end:Nn { + \seq_if_in:NxTF #1 { \tl_to_str:n{#2} }{ + \stex_debug:nn{sms}{End~Environment~#2} + \end{#2}\__stex_smsmode_do:w }{ - \str_if_eq:nnTF{#1}{document}{\endinput}{\__stex_smsmode_do:w} + %\str_if_eq:nnTF{#2}{document} \endinput + \__stex_smsmode_do:w } } +\str_new:N \l_stex_current_module_str +\seq_new:N \l_stex_all_modules_seq +\tl_clear:N \g_stex_every_module_tl { +} +\cs_new_protected:Nn \stex_every_module:n { + \tl_gput_right:Nn \g_stex_every_module_tl { #1 } +} +\cs_new_protected:Npn \stex_module_setup:n { + \stex_if_in_module:TF \__stex_module_setup_setup_nested:n \__stex_module_setup_setup_top:n +} -\cs_new_protected:Nn \stex_import_module_uri:nn { - \str_set:Nx \l_stex_import_archive_str { #1 } - \str_set:Nn \l_stex_import_path_str { #2 } - - \exp_args:NNNo \seq_set_split:Nnn \l_tmpb_seq ? { \l_stex_import_path_str } - \seq_pop_right:NN \l_tmpb_seq \l_stex_import_name_str - \str_set:Nx \l_stex_import_path_str { \seq_use:Nn \l_tmpb_seq ? } +\cs_new_protected:Nn \__stex_module_setup_setup_top:n { + \__stex_module_setup_get_uri_str:n{#1} + \stex_debug:nn{module}{Module~URI:~\l__stex_module_setup_ns_str?#1} + \str_if_empty:NTF \l_stex_key_sig_str + \_stex_module_setup_top_nosig:n \__stex_module_setup_setup_top_sig:n {\l__stex_module_setup_ns_str?#1} + \stex_metagroup_new:o \l_stex_current_module_str + \g_stex_every_module_tl + \stex_execute_in_module:x { + \_stex_do_deprecation:n{#1} + } + \__stex_module_setup_load_meta: +} - \stex_modules_current_namespace: - \bool_lazy_all:nTF { - {\str_if_empty_p:N \l_stex_import_archive_str} - {\str_if_empty_p:N \l_stex_import_path_str} - {\stex_if_module_exists_p:n { \l_stex_module_ns_str ? \l_stex_import_name_str } } - }{ - \str_set_eq:NN \l_stex_import_path_str \l_stex_module_subpath_str - \str_set_eq:NN \l_stex_import_ns_str \l_stex_module_ns_str +\cs_new_protected:Nn \_stex_module_setup_top_nosig:n { + \stex_if_module_exists:nTF{#1}{ + \stex_debug:nn{modules}{(already exists)} }{ - \str_if_empty:NT \l_stex_import_archive_str { - \prop_if_exist:NT \l_stex_current_repository_prop { - \prop_get:NnN \l_stex_current_repository_prop { id } \l_stex_import_archive_str - } - } - \str_if_empty:NTF \l_stex_import_archive_str { - \str_if_empty:NF \l_stex_import_path_str { - \stex_path_from_string:Nn \l_tmpb_seq { - \l_stex_module_ns_str / .. / \l_stex_import_path_str - } - \str_set:Nx \l_stex_import_ns_str {\stex_path_to_string:N \l_tmpb_seq} - \str_replace_once:Nnn \l_stex_import_ns_str {file:/} {file://} - } - }{ - \stex_require_repository:n \l_stex_import_archive_str - \prop_get:cnN { c_stex_mathhub_\l_stex_import_archive_str _manifest_prop } { ns } - \l_stex_import_ns_str - \str_if_empty:NF \l_stex_import_path_str { - \str_set:Nx \l_stex_import_ns_str { - \l_stex_import_ns_str / \l_stex_import_path_str - } - } - } + \tl_gclear:c{c_stex_module_ #1 _code} + \prop_gclear:c{c_stex_module_ #1 _morphisms_prop } + \prop_gclear:c{c_stex_module_ #1 _symbols_prop } + \prop_gclear:c{c_stex_module_ #1 _notations_prop } } + \str_set:Nx \l_stex_current_module_str {#1} + \seq_put_right:No \l_stex_all_modules_seq \l_stex_current_module_str } -\str_new:N \l_stex_import_name_str -\str_new:N \l_stex_import_archive_str -\str_new:N \l_stex_import_path_str -\str_new:N \l_stex_import_ns_str -\cs_new_protected:Nn \stex_import_require_module:nnnn { - \exp_args:Nx \stex_if_module_exists:nF { #1 ? #4 } { - \stex_debug:nn{requiremodule}{Here:\\~~1:~#1\\~~2:~#2\\~~3:~#3\\~~4:~#4} +\cs_new_protected:Nn \__stex_module_setup_setup_top_sig:n { + \stex_if_module_exists:nTF{#1}{ + \stex_debug:nn{modules}{(already exists)} + }{ + \stex_debug:nn{modules}{(needs loading)} + \__stex_module_setup_load_sig: + } + %\stex_if_smsmode:F { % WHY? + \stex_activate_module:x { + #1 + } + %} + \str_set:Nx\l_stex_current_module_str{#1} +} - \exp_args:NNxx \seq_set_split:Nnn \l_tmpa_seq {\tl_to_str:n{/}} {#4} - \seq_get_left:NN \l_tmpa_seq \l_tmpc_str +\cs_new_protected:Nn \__stex_module_setup_load_sig: { + \stex_file_split_off_ext:NN \l__stex_module_setup_sigfile \g_stex_current_file + \stex_file_split_off_lang:NN \l__stex_module_setup_sigfile \l__stex_module_setup_sigfile + \exp_args:Ne \stex_file_in_smsmode:nn { + \stex_file_use:N \l__stex_module_setup_sigfile . \l_stex_key_sig_str . tex + }{} +} - %\stex_debug:nn{requiremodule}{Top~module:\l_tmpc_str} +\cs_new_protected:Nn \__stex_module_setup_setup_nested:n { + \exp_after:wN + \__stex_module_setup_split_module:n \l_stex_current_module_str \__stex_module_setup_end: {#1} + \stex_debug:nn{module}{Nested~Module~URI:~\l_stex_current_module_str} + \seq_put_right:No \l_stex_all_modules_seq \l_stex_current_module_str + \stex_metagroup_new:o \l_stex_current_module_str +} - % archive - \str_set:Nx \l_tmpa_str { #2 } - \str_if_empty:NTF \l_tmpa_str { - \seq_set_eq:NN \l_tmpa_seq \g_stex_currentfile_seq - \seq_put_right:Nn \l_tmpa_seq {..} - } { - \stex_path_from_string:Nn \l_tmpb_seq { \l_tmpa_str } - \seq_concat:NNN \l_tmpa_seq \c_stex_mathhub_seq \l_tmpb_seq - \seq_put_right:Nn \l_tmpa_seq { source } +\cs_new_protected:Nn \__stex_module_setup_get_uri_str:n { + \str_clear:N \l__stex_module_setup_ns_str + \stex_map_uri:Nnnnn \l_stex_current_ns_uri { + \str_set:Nx \l__stex_module_setup_ns_str{##1\c_colon_str/} + }{ + \seq_set_split:Nnn \l__stex_module_setup_seq / {##1} + \seq_pop_right:NN \l__stex_module_setup_seq \l__stex_module_setup_seg + \exp_args:No \str_if_eq:nnF \l__stex_module_setup_seg {#1} { + \seq_put_right:No \l__stex_module_setup_seq \l__stex_module_setup_seg } + \tl_put_right:Nx \l__stex_module_setup_ns_str {\seq_use:Nn \l__stex_module_setup_seq /} + }{}{} +} - % path - \str_set:Nx \l_tmpb_str { #3 } - \str_if_empty:NTF \l_tmpb_str { - \str_set:Nx \l_tmpa_str { \stex_path_to_string:N \l_tmpa_seq / \l_tmpc_str } +\cs_new_protected:Npn \__stex_module_setup_split_module:n #1?#2 \__stex_module_setup_end: #3 { + \_stex_module_setup_top_nosig:n { #1 ? #2 / #3} +} - \ltx@ifpackageloaded{babel} { - \exp_args:NNx \prop_get:NnNF \c_stex_language_abbrevs_prop - { \languagename } \l_tmpb_str { - \msg_error:nnx{stex}{error/unknownlanguage}{\languagename} - } - } { - \str_clear:N \l_tmpb_str - } +\bool_new:N \l_stex_in_meta_bool +\bool_set_false:N \l_stex_in_meta_bool - \stex_debug:nn{modules}{Checking~a1~\l_tmpa_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~a2~\l_tmpa_str.tex} - \IfFileExists{ \l_tmpa_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~a3~\l_tmpa_str.en.tex} - \IfFileExists{ \l_tmpa_str.en.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.en.tex } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{#1?#4} - } - } +\cs_new_protected:Nn \__stex_module_setup_load_meta: { + \tl_if_empty:NF \l_stex_metatheory_uri { + \stex_execute_in_module:x{ + \stex_pseudogroup_with:nn{\l_stex_in_meta_bool}{ + \stex_activate_module:n {\stex_uri_use:N \l_stex_metatheory_uri } } + } + } +} - } { - \seq_set_split:NnV \l_tmpb_seq / \l_tmpb_str - \seq_concat:NNN \l_tmpb_seq \l_tmpa_seq \l_tmpb_seq +\cs_new:Nn \stex_close_module: { + \bool_if:NT \c_stex_persist_write_mode_bool \__stex_modules_persist_module: + \stex_debug:nn{module}{ + Closing~module~\l_stex_current_module_str^^J + Code:~\expandafter\meaning\csname c_stex_module_\l_stex_current_module_str _code\endcsname^^J + Imports:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _morphisms_prop\cs_end:^^J + Declarations:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _symbols_prop\cs_end:^^J + Notations:\exp_after:wN \prop_to_keyval:N \cs:w c_stex_module_\l_stex_current_module_str _notations_prop\cs_end:^^J + } +} - \ltx@ifpackageloaded{babel} { - \exp_args:NNx \prop_get:NnNF \c_stex_language_abbrevs_prop - { \languagename } \l_tmpb_str { - \msg_error:nnx{stex}{error/unknownlanguage}{\languagename} - } - } { - \str_clear:N \l_tmpb_str - } +\cs_new_protected:Nn \__stex_modules_persist_module: { + \stex_persist:e { + \__stex_modules_restore_module:nnnn {\l_stex_current_module_str}{ + \exp_after:wN \prop_to_keyval:N \cs:w + c_stex_module_\l_stex_current_module_str _morphisms_prop + \cs_end: + }{ + \exp_after:wN \prop_to_keyval:N \cs:w + c_stex_module_\l_stex_current_module_str _symbols_prop + \cs_end: + }{ + \exp_after:wN \exp_after:wN \exp_after:wN \exp_not:n + \exp_after:wN \exp_after:wN \exp_after:wN + { \cs:w c_stex_module_\l_stex_current_module_str _code \cs_end: } + }{} + \prop_map_function:cN{c_stex_module_\l_stex_current_module_str _notations_prop} + \__stex_modules_persist_nots_i:nn + \exp_not:N \STEXRestoreNotsEnd {} + } +} - \stex_path_canonicalize:N \l_tmpb_seq - \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str +\cs_new_protected:Nn \__stex_modules_restore_module:nnnn { + \prop_gset_from_keyval:cn{c_stex_module_\tl_to_str:n{#1}_morphisms_prop}{#2} + \cs_set:Npn \__stex_modules_tl {#3} + \exp_args:Nno \prop_gset_from_keyval:cn{c_stex_module_\tl_to_str:n{#1}_symbols_prop}\__stex_modules_tl + \prop_map_inline:cn{c_stex_module_\tl_to_str:n{#1}_symbols_prop}{ + \stex_ref_new_symbol:n{#1?##1} + } + \cs_gset:cpn{c_stex_module_\tl_to_str:n{#1}_code}{#4} + \prop_gclear:c{c_stex_module_\tl_to_str:n{#1} _notations_prop} + \str_set:Nn \l__stex_modules_restore_mod_str {#1} + \group_begin: + \catcode`_=8\relax + \catcode`:=12\relax + \__stex_modules_restore_nots:n +} - \stex_debug:nn{modules}{Checking~b1~\l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str/\l_tmpc_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~b2~\l_tmpa_str/\l_tmpc_str.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str/\l_tmpc_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~b3~\l_tmpa_str/\l_tmpc_str.en.tex} - \IfFileExists{ \l_tmpa_str/\l_tmpc_str.en.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str/\l_tmpc_str.en.tex } - }{ - \stex_debug:nn{modules}{Checking~b4~\l_tmpa_str.\l_tmpb_str.tex} - \IfFileExists{ \l_tmpa_str.\l_tmpb_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.\l_tmpb_str.tex } - }{ - \stex_debug:nn{modules}{Checking~b4~\l_tmpa_str.tex} - \IfFileExists{ \l_tmpa_str.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.tex } - }{ - % try english as default - \stex_debug:nn{modules}{Checking~b5~\l_tmpa_str.en.tex} - \IfFileExists{ \l_tmpa_str.en.tex }{ - \str_gset:Nx \g__stex_importmodule_file_str { \l_tmpa_str.en.tex } - }{ - \msg_error:nnx{stex}{error/unknownmodule}{#1?#4} - } - } - } - } - } - } - } +\cs_new:Nn \__stex_modules_persist_nots_i:nn { + \exp_not:n{#2} +} - \str_if_eq:eeF{\g__stex_importmodule_file_str}{\seq_use:Nn \g_stex_currentfile_seq /}{ - \exp_args:No \stex_file_in_smsmode:nn { \g__stex_importmodule_file_str } { - \seq_clear:N \l_stex_all_modules_seq - \str_clear:N \l_stex_current_module_str - \str_set:Nx \l_tmpb_str { #2 } - \str_if_empty:NF \l_tmpb_str { - \stex_set_current_repository:n { #2 } - } - \stex_debug:nn{modules}{Loading~\g__stex_importmodule_file_str} - } +\quark_new:N \STEXRestoreNotsEnd - \stex_if_module_exists:nF { #1 ? #4 } { - \msg_error:nnx{stex}{error/unknownmodule}{ - #1?#4~(in~file~\g__stex_importmodule_file_str) - } - } - } +\cs_new_protected:Nn \__stex_modules_restore_nots:n { + \__stex_modules_restore_nots_i:n +} +\cs_new_protected:Nn \__stex_modules_restore_nots_i:n { + \tl_if_eq:nnTF{#1}{\STEXRestoreNotsEnd}{ + \group_end: + }{ + \__stex_modules_restore_nots_ii:nnnnn {#1} } - \stex_activate_module:n { #1 ? #4 } } -\NewDocumentCommand \importmodule { O{} m } { - \stex_import_module_uri:nn { #1 } { #2 } - \stex_debug:nn{modules}{Importing~module:~ - \l_stex_import_ns_str ? \l_stex_import_name_str - } - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn - {import} {\l_stex_import_ns_str ? \l_stex_import_name_str} {} - } - \stex_execute_in_module:x { - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - } - \exp_args:Nx \stex_add_import_to_current_module:n { - \l_stex_import_ns_str ? \l_stex_import_name_str + +\cs_new_protected:Nn \__stex_modules_restore_nots_ii:nnnnn { + \cs_set:Npn \l__stex_modules_tl {{#4}{#5}} + \exp_args:NNe\use:nn\prop_gput:cnn{ + {c_stex_module_\l__stex_modules_restore_mod_str _notations_prop} + {\tl_to_str:n{#1!#2}}{ + {\tl_to_str:n{#1}}{\tl_to_str:n{#2}}{#3} + \exp_args:No \exp_not:n \l__stex_modules_tl + } } - \stex_smsmode_do: - \ignorespacesandpars + \__stex_modules_restore_nots_i:n } -\stex_deactivate_macro:Nn \importmodule {module~environments} -\NewDocumentCommand \usemodule { O{} m } { - \stex_if_smsmode:F { +\tl_new:N \l_stex_metatheory_uri +\cs_new_protected:Nn \__stex_modules_set_metatheory:nn { + \group_begin: + \stex_debug:nn{metatheory}{Setting~metatheory~[#1]#2} \stex_import_module_uri:nn { #1 } { #2 } - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - \stex_annotate_invisible:nnn - {usemodule} {\l_stex_import_ns_str ? \l_stex_import_name_str} {} - } + \stex_debug:nn{metatheory}{Here:^^J + \l_stex_import_archive_str^^J + \l_stex_import_path_str^^J + \l_stex_import_name_str^^J + } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_debug:nn{metatheory}{Found:~\l_stex_import_ns_str} + \exp_args:Nne \use:nn { + \group_end: \stex_uri_resolve:Nn \l_stex_metatheory_uri + }{{\l_stex_import_ns_str}} +} + +\NewDocumentCommand \setmetatheory {O{} m}{ + \__stex_modules_set_metatheory:nn { #1 }{ #2 } \stex_smsmode_do: - \ignorespacesandpars } -\cs_new_protected:Nn \stex_csl_to_imports:Nn { - \tl_if_empty:nF{#2}{ - \clist_set:Nn \l_tmpa_clist {#2} - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_head_eq_charcode:nNTF {##1}[{ - #1 ##1 - }{ - #1{##1} +\stex_sms_allow_escape:N \setmetatheory +\stex_keys_define:nnnn{smodule}{ + \str_clear:N \l_stex_key_sig_str +}{ + meta .code:n = { + \str_if_empty:nTF {#1}{ + \tl_clear:N \l_stex_metatheory_uri + }{ + \stex_uri_resolve:Nx \l_stex_metatheory_uri { #1 } + } + }, + ns .code:n = { + \stex_uri_resolve:Nx \l_stex_current_ns_uri { #1 } + } , + lang .code:n = { + \stex_set_language:n { #1 } + } , + sig .str_set_x:N = \l_stex_key_sig_str , + creators .code:n = {} , % todo ? + contributors .code:n = {} , % todo ? + srccite .code:n = {} % todo ? +}{id, title, style, deprecate} +\stex_new_stylable_env:nnnnnnn {module} {O{} m}{ + \stex_keys_set:nn { smodule }{ #1 } + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \tl_if_empty:NF \thistitle { + \exp_args:No \stexdoctitle \thistitle + } + \exp_args:Nx \stex_module_setup:n { \tl_to_str:n{ #2 } } + + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:theory={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={\l_stex_key_sig_str} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} } } + \stex_annotate_invisible:n{} } -} -\cs_generate_variant:Nn \stex_csl_to_imports:Nn {No} - - -%%%%%%%%%%%%% symbols.dtx %%%%%%%%%%%%% + \stex_if_smsmode:F { + \str_set_eq:NN \thismoduleuri \l_stex_current_module_str + \tl_set:Nn \thismodulename {#2} + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_close_module: + \stex_if_smsmode:F \stex_style_apply: + \stex_if_do_html:T{ \end{stex_annotate_env} } +}{}{}{s} -\msg_new:nnn{stex}{error/wrongargs}{ - args~value~in~symbol~declaration~for~#1~ - needs~to~be~i,~a,~b~or~B,~but~#2~given +\stex_sms_allow_env:n{smodule} +\prg_new_conditional:Nnn \stex_if_in_module: {p, T, F, TF} { + \str_if_empty:NTF \l_stex_current_module_str + \prg_return_false: \prg_return_true: } -\msg_new:nnn{stex}{error/unknownsymbol}{ - No~symbol~#1~found! +\prg_new_conditional:Nnn \stex_if_module_exists:n {p, T, F, TF} { + \tl_if_exist:cTF { c_stex_module_#1_code } + \prg_return_true: \prg_return_false: } -\msg_new:nnn{stex}{error/seqlength}{ - Expected~#1~arguments;~got~#2! +\cs_new_protected:Nn \stex_do_up_to_module:n { + \exp_args:No \stex_metagroup_do_in:nn \l_stex_current_module_str {#1} } -\msg_new:nnn{stex}{error/unknownnotation}{ - Unknown~notation~#1~for~#2! +\cs_generate_variant:Nn \stex_do_up_to_module:n {x} +\cs_new_protected:Nn \stex_module_add_code:n { + \tl_gput_right:cn {c_stex_module_\l_stex_current_module_str _code} { #1 } } -\cs_new_protected:Nn \stex_all_symbols:n { - \def \__stex_symdecl_all_symbols_cs ##1 {#1} - \seq_map_inline:Nn \l_stex_all_modules_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \__stex_symdecl_all_symbols_cs{##1?####1} - } - } +\cs_generate_variant:Nn \stex_module_add_code:n {x} +\cs_new_protected:Nn \stex_execute_in_module:n { \stex_if_in_module:TF { + \stex_module_add_code:n { #1 } + \stex_do_up_to_module:n { #1 } +}{ #1 }} +\cs_generate_variant:Nn \stex_execute_in_module:n {x} +\NewDocumentCommand \STEXexport {} { + \ExplSyntaxOn + \__stex_modules_export:n } -\NewDocumentCommand \STEXsymbol { m } { - \stex_get_symbol:n { #1 } - \exp_args:No - \stex_invoke_symbol:n { \l_stex_get_symbol_uri_str } -} -\keys_define:nn { stex / symdecl } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - type .tl_set:N = \l_stex_symdecl_type_tl , - deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , - align .str_set:N = \l_stex_symdecl_align_str , % TODO(?) - gfc .str_set:N = \l_stex_symdecl_gfc_str , % TODO(?) - def .tl_set:N = \l_stex_symdecl_definiens_tl , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} -} - -\bool_new:N \l_stex_symdecl_make_macro_bool - -\cs_new_protected:Nn \__stex_symdecl_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_deprecate_str - \str_clear:N \l_stex_symdecl_reorder_str - \str_clear:N \l_stex_symdecl_assoctype_str - \bool_set_false:N \l_stex_symdecl_local_bool - \tl_clear:N \l_stex_symdecl_type_tl - \tl_clear:N \l_stex_symdecl_definiens_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - - \keys_set:nn { stex / symdecl } { #1 } -} - -\NewDocumentCommand \symdecl { s m O{}} { - \__stex_symdecl_args:n { #3 } - \IfBooleanTF #1 { - \bool_set_false:N \l_stex_symdecl_make_macro_bool - } { - \bool_set_true:N \l_stex_symdecl_make_macro_bool - } - \stex_symdecl_do:n { #2 } +\cs_new_protected:Nn \__stex_modules_export:n { + \stex_ignore_spaces_and_pars:#1\ExplSyntaxOff + \stex_module_add_code:n { \stex_ignore_spaces_and_pars:#1} \stex_smsmode_do: } - -\cs_new_protected:Nn \stex_symdecl_do:nn { - \__stex_symdecl_args:n{#1} - \bool_set_false:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n{#2} +\stex_deactivate_macro:Nn \STEXexport {module~environments} +\stex_sms_allow_escape:N \STEXexport +\stex_every_module:n {\stex_reactivate_macro:N \STEXexport} +\cs_new_protected:Nn \stex_module_add_morphism:nnnn { + \exp_args:Nne \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _morphisms_prop}{ + \tl_if_empty:nTF{#1}{[#2]}{#1} + }{{#1}{#2}{#3}{#4}} } - -\stex_deactivate_macro:Nn \symdecl {module~environments} -\cs_new_protected:Nn \stex_symdecl_do:n { - \stex_if_in_module:F { - % TODO throw error? some default namespace? +\cs_generate_variant:Nn \stex_module_add_morphism:nnnn {nonn,ooox} +\cs_new_protected:Nn \stex_module_add_symbol:nnnnnnnN { + \stex_debug:nn{declaration}{New~declaration:~\l_stex_current_module_str?#2^^J + Macro:#1^^JArity:#3~(#4)^^J + Def:~\tl_to_str:n{#5}^^J + Type:~\tl_to_str:n{#6}^^J + Returns:~\tl_to_str:n{#7} } - - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } + %\prop_gput:cnx{c_stex_module_\l_stex_current_module_str _symbols_prop} + %{#2}{\exp_not:n{{#1}{#2}{#3}{#4}{#5}{#6}}{#7}\exp_not:n{#8}} + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _symbols_prop} + {#2}{{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}} + \tl_if_empty:nF{#1}{ + \stex_execute_in_module:n { + \__stex_modules_activate_sym:n {#2} + } } +} - \prop_if_exist:cT { l_stex_symdecl_ - \l_stex_current_module_str ? - \l_stex_symdecl_name_str - _prop - }{ - % TODO throw error (beware of circular dependencies) +\cs_new_protected:Nn \__stex_modules_activate_sym:n { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _symbols_prop}{ + \str_if_eq:nnT{#1}{##1}{ + \__stex_modules_activate_i:nnnnnnnn ##2 + } } +} +\cs_new_protected:Nn \__stex_modules_activate_i:nnnnnnnn { + \stex_debug:nn{activating}{#1:\l_stex_current_module_str^^J + \tl_to_str:n{{#2}{#3}{#4}{#5}{#6}{#7}#8} + } + \cs_set:cpx{#1} { + \_stex_invoke_symbol:nnnnnnnN + {\l_stex_current_module_str} + \exp_not:n{{#2}{#3}{#4}{#5}{#6}{#7}{#8}} + } + \stex_debug:nn{activating}{done} + \prop_map_break: +} +\cs_new_protected:Nn \stex_module_add_notation:nnnnn { + \stex_debug:nn{notations}{Adding~notation:^^J + #1~\c_hash_str#2~#3^^J + to~\l_stex_current_module_str + } + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _notations_prop} + {#1!#2}{{#1}{#2}{#3}{#4}{#5}} + \stex_execute_in_module:n { + \__stex_modules_activate_not:nn{#1}{#2} + } +} +\cs_generate_variant:Nn \stex_module_add_notation:nnnnn {eoeoo} - \prop_clear:N \l_tmpa_prop - \prop_put:Nnx \l_tmpa_prop { module } { \l_stex_current_module_str } - \seq_clear:N \l_tmpa_seq - \prop_put:Nno \l_tmpa_prop { name } \l_stex_symdecl_name_str - \prop_put:Nno \l_tmpa_prop { type } \l_stex_symdecl_type_tl - - \str_if_empty:NT \l_stex_symdecl_deprecate_str { - \str_if_empty:NF \l_stex_module_deprecate_str { - \str_set_eq:NN \l_stex_symdecl_deprecate_str \l_stex_module_deprecate_str +\cs_new_protected:Nn \__stex_modules_activate_not:nn { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _notations_prop}{ + \str_if_eq:nnT{#1!#2}{##1}{ + \prop_map_break:n{\stex_set_notation_macro:nnnnn ##2 } } } - \prop_put:Nno \l_tmpa_prop { deprecate } \l_stex_symdecl_deprecate_str - - \exp_args:No \stex_add_constant_to_current_module:n { - \l_stex_symdecl_name_str +} +\cs_new_protected:Nn \stex_set_notation_macro:nnnnn { + \tl_set:cn {l_stex_notation_#1_#2_cs}{#4} + \cs_if_exist:cF{l_stex_notation_#1__cs}{ + \tl_set:cn {l_stex_notation_#1__cs}{#4} } - - % arity/args - \int_zero:N \l_tmpb_int - - \bool_set_true:N \l_tmpa_bool - \str_map_inline:Nn \l_stex_symdecl_args_str { - \token_case_meaning:NnF ##1 { - 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} - {\tl_to_str:n i} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n b} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n a} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - {\tl_to_str:n B} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - }{ - \msg_error:nnxx{stex}{error/wrongargs}{ - \l_stex_current_module_str ? - \l_stex_symdecl_name_str - }{##1} + \tl_if_empty:nF{#5}{ + \tl_set:cn{l_stex_notation_#1_op_#2_cs}{#5} + \cs_if_exist:cF{l_stex_notation_#1_op__cs}{ + \cs_set_eq:cc {l_stex_notation_#1_op__cs}{l_stex_notation_#1_op_#2_cs} } } - - \bool_if:NTF \l_tmpa_bool { - % possibly numeric - \str_if_empty:NTF \l_stex_symdecl_args_str { - \prop_put:Nnn \l_tmpa_prop { args } {} - \prop_put:Nnn \l_tmpa_prop { arity } { 0 } +} +\cs_generate_variant:Nn \stex_set_notation_macro:nnnnn {eoexo} +\cs_new_protected:Nn \stex_activate_module:n { + \seq_if_in:NnF \l_stex_all_modules_seq { #1 } { + \stex_debug:nn{modules}{Activating~module~#1^^J\expandafter\meaning\csname c_stex_module_#1_code\endcsname} + \seq_put_right:Nn \l_stex_all_modules_seq { #1 } + \stex_pseudogroup:nn{ + \str_set:Nn \l_stex_current_module_str {#1} + \use:c{ c_stex_module_#1_code } }{ - \int_set:Nn \l_tmpa_int { \l_stex_symdecl_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } { \int_use:N \l_tmpa_int } - \str_clear:N \l_tmpa_str - \int_step_inline:nn \l_tmpa_int { - \str_put_right:Nn \l_tmpa_str i + \stex_pseudogroup_restore:N \l_stex_current_module_str + } + } +} +\cs_generate_variant:Nn \stex_activate_module:n {o,x} +\cs_new_protected:Nn \stex_iterate_symbols:n { + \stex_pseudogroup_with:nn{\__stex_iterate_sym_cs:nnnnnnnnN\stex_iterate_break:\stex_iterate_break:n}{ + \cs_set:Npn \__stex_iterate_sym_cs:nnnnnnnnN + ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #1 } + \cs_set:Npn \stex_iterate_break: { + \prop_map_break:n{\seq_map_break:} + } + \cs_set:Npn \stex_iterate_break:n ##1 { + \prop_map_break:n{\seq_map_break:n{##1}} + } + \seq_map_inline:Nn \l_stex_all_modules_seq { + \prop_map_inline:cn{c_stex_module_##1_symbols_prop}{ + \__stex_iterate_sym_cs:nnnnnnnnN {##1} ####2 } - \prop_put:Nnx \l_tmpa_prop { args } { \l_tmpa_str } } - } { - \prop_put:Nnx \l_tmpa_prop { args } { \l_stex_symdecl_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } - { \str_count:N \l_stex_symdecl_args_str } } - \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int } - - \tl_if_empty:NTF \l_stex_symdecl_definiens_tl { - \prop_put:Nnx \l_tmpa_prop { defined }{ false } - }{ - \prop_put:Nnx \l_tmpa_prop { defined }{ true } +} +\cs_new_protected:Nn \stex_iterate_symbols:nn { + \seq_clear:N \l__stex_iterate_mods_seq + \stex_pseudogroup_with:nn{\__stex_iterate_sym_cs:nnnnnnnnN}{ + \cs_set:Npn \__stex_iterate_sym_cs:nnnnnnnnN + ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #2 } + \clist_map_function:nN {#1} \__stex_iterate_it_decl_i:n } +} - % argnames - - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { - \clist_if_empty:NTF \l_stex_symdecl_argnames_clist { - \clist_put_right:Nn \l_tmpa_clist {##1} - }{ - \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl - \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} +\cs_new_protected:Nn \__stex_iterate_it_decl_i:n { + \seq_if_in:NnF \l__stex_iterate_mods_seq {#1} { + \seq_put_left:Nn \l__stex_iterate_mods_seq {#1} + \prop_map_inline:cn{c_stex_module_#1_morphisms_prop}{ + \__stex_iterate_it_decl_check:nnnn ##2 + } + \prop_map_inline:cn{c_stex_module_#1_symbols_prop}{ + \__stex_iterate_sym_cs:nnnnnnnnN {#1} ##2 } } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} - - % semantic macro +} +\cs_new_protected:Nn \__stex_iterate_it_decl_check:nnnn { + \tl_if_empty:nT{#1}{ + \__stex_iterate_it_decl_i:n {#2} + } +} +\cs_new_protected:Nn \stex_iterate_notations:nn { + \seq_clear:N \l__stex_iterate_mods_seq + \stex_pseudogroup_with:nn{\__stex_iterate_not_cs:nnnnn}{ + \cs_set:Npn \__stex_iterate_not_cs:nnnnn + ##1 ##2 ##3 ##4 ##5 { #2 } + \clist_map_function:nN {#1} \__stex_iterate_it_not_i:n + } +} - \bool_if:NT \l_stex_symdecl_make_macro_bool { - \exp_args:Nx \stex_do_up_to_module:n { - \tl_set:cn { #1 } { \stex_invoke_symbol:n { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }} +\cs_new_protected:Nn \__stex_iterate_it_not_i:n { + \seq_if_in:NnF \l__stex_iterate_mods_seq {#1} { + \seq_put_left:Nn \l__stex_iterate_mods_seq {#1} + \prop_map_inline:cn{c_stex_module_#1_notations_prop}{ + \__stex_iterate_not_cs:nnnnn ##2 + } + \prop_map_inline:cn{c_stex_module_#1_morphisms_prop}{ + \__stex_iterate_it_not_check:nnnn ##2 } } - - \stex_debug:nn{symbols}{New~symbol:~ - \l_stex_current_module_str ? \l_stex_symdecl_name_str^^J - Type:~\exp_not:o { \l_stex_symdecl_type_tl }^^J - Args:~\prop_item:Nn \l_tmpa_prop { args }^^J - Definiens:~\exp_not:o {\l_stex_symdecl_definiens_tl} +} +\cs_new_protected:Nn \__stex_iterate_it_not_check:nnnn { + \tl_if_empty:nT{#1}{ + \__stex_iterate_it_not_i:n {#2} } - - % circular dependencies require this: - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {symdecl} { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } { - \tl_if_empty:NF \l_stex_symdecl_type_tl { - \stex_annotate_invisible:nnn{type}{}{$\l_stex_symdecl_type_tl$} - } - \stex_annotate_invisible:nnn{args}{\prop_item:Nn \l_tmpa_prop { args }}{} - \stex_annotate_invisible:nnn{macroname}{#1}{} - \tl_if_empty:NF \l_stex_symdecl_definiens_tl { - \stex_annotate_invisible:nnn{definiens}{} - {$\l_stex_symdecl_definiens_tl$} - } - \str_if_empty:NF \l_stex_symdecl_assoctype_str { - \stex_annotate_invisible:nnn{assoctype}{\l_stex_symdecl_assoctype_str}{} - } - \str_if_empty:NF \l_stex_symdecl_reorder_str { - \stex_annotate_invisible:nnn{reorderargs}{\l_stex_symdecl_reorder_str}{} +} +\cs_new_protected:Nn \stex_iterate_morphisms:nn { + \seq_clear:N \l__stex_iterate_mods_seq + \bool_set_true:N \l__stex_iterate_continue_bool + \cs_set:Npn \__stex_iterate_morphism_cs:nnnn ##1 ##2 ##3 ##4 ##5 { + #2 + \bool_if:NT \l__stex_iterate_continue_bool { + \str_if_eq:nnTF{##1}{[##2]}{ + \tl_put_right:Nn \l__stex_iterate_todo_tl { + \__stex_iterate_iterate_morphism:nn{##5}{##2} + } + }{ + \tl_put_right:Nn \l__stex_iterate_todo_tl { + \__stex_iterate_iterate_morphism:nn{##5 / ##1}{##2} + } } } } - \prop_if_exist:cF { - l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - _prop - } { - \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x { - \__stex_symdecl_restore_symbol:nnnnnnnn - {\l_stex_symdecl_name_str} - { \prop_item:Nn \l_tmpa_prop {args} } - { \prop_item:Nn \l_tmpa_prop {arity} } - { \prop_item:Nn \l_tmpa_prop {assocs} } - { \prop_item:Nn \l_tmpa_prop {defined} } - {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} } - {\l_stex_current_module_str} - { \prop_item:Nn \l_tmpa_prop {argnames} } - } - } -} -\cs_new_protected:Nn \__stex_symdecl_restore_symbol:nnnnnnnn { - \prop_clear:N \l_tmpa_prop - \prop_put:Nnn \l_tmpa_prop { module } { #7 } - \prop_put:Nnn \l_tmpa_prop { name } { #1} - \prop_put:Nnn \l_tmpa_prop { args } {#2} - \prop_put:Nnn \l_tmpa_prop { arity } { #3 } - \prop_put:Nnn \l_tmpa_prop { assocs } { #4 } - \prop_put:Nnn \l_tmpa_prop { defined } { #5 } - \prop_put:Nnn \l_tmpa_prop { argnames } { #8 } - \tl_if_empty:nF{#6}{ - \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}} + \cs_set:Npn \stex_iterate_break:n ##1 { + \bool_set_false:N \l__stex_iterate_continue_bool + \prop_map_break:n{##1} } - \prop_set_eq:cN{l_stex_symdecl_ \detokenize{#7 ? #1} _prop}\l_tmpa_prop - \seq_clear:c{l_stex_symdecl_ \detokenize{#7 ? #1} _notations} + \__stex_iterate_iterate_morphism:nn{}{#1} } -\keys_define:nn { stex / textsymdecl } { - name .str_set_x:N = \l__stex_symdecl_name_str , - type .tl_set:N = \l__stex_symdecl_type_tl +\cs_new_protected:Nn \__stex_iterate_iterate_morphism:nn { + \tl_clear:N \l__stex_iterate_todo_tl + \seq_if_in:NnF \l__stex_iterate_mods_seq {#1 #2}{ + \seq_put_right:Nn \l__stex_iterate_mods_seq {#1 #2} + \prop_map_inline:cn{c_stex_module_#2_morphisms_prop}{ + \__stex_iterate_morphism_cs:nnnn ##2 {#1} + % TODO + % ##1: name or [mpath] + % ##2 = {####1}{####2}{####3}{####4} + % ####1 = name + % ####2 = mpath + % ####3 = type + % ####4 = {origname}{newname}* + } + \bool_if:NT \l__stex_iterate_continue_bool \l__stex_iterate_todo_tl + } } - -\cs_new_protected:Nn \_stex_textsymdecl_args:n { - \str_clear:N \l__stex_symdecl_name_str - \tl_clear:N \l__stex_symdecl_type_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - \keys_set:nn { stex / textsymdecl } { #1 } +\cs_new_protected:Nn \stex_structural_feature_module:nn { + \stex_if_do_html:TF { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:feature-#2={ + \l_stex_current_module_str/#1} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + } + \stex_annotate_invisible:n{} + }\group_begin: + \stex_module_setup:n {#1-module} } -\NewDocumentCommand \textsymdecl {m O{} m} { - \_stex_textsymdecl_args:n { #2 } - \str_if_empty:NTF \l__stex_symdecl_name_str { - \__stex_symdecl_args:n{name=#1,#2} +\cs_new_protected:Nn \stex_structural_feature_module_end: { + \tl_gset_eq:NN \g_stex_last_feature_str \l_stex_current_module_str + \stex_close_module: + \stex_if_do_html:TF{ + \end{stex_annotate_env} + }\group_end: +} +\bool_new:N \l__stex_features_implicit_bool +\cs_new_protected:Nn \stex_structural_feature_morphism:nnnnn { + \str_clear:N \l_stex_current_domain_str + \tl_if_empty:nT{#3}{ + \_stex_get_mathstructure:n{#4} + \str_set_eq:NN \l_stex_current_domain_str \l_stex_get_structure_module_str + } + \str_if_empty:NT \l_stex_current_domain_str { + \stex_import_module_uri:nn { #3 }{ #4 } + \group_begin: + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \exp_args:Nnx \use:nn \group_end: { + \str_set:Nn \exp_not:N\l_stex_current_domain_str {\l_stex_import_ns_str} + } + } + \tl_if_empty:nTF{#1}{ + \bool_set_true:N \l__stex_features_implicit_bool + \str_set:Nx \l_tmpa_str {[\l_stex_current_domain_str]} }{ - \__stex_symdecl_args:n{#2} + \bool_set_false:N \l__stex_features_implicit_bool + \str_set:Nn \l_tmpa_str {#1} } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n{#1-sym} - \stex_execute_in_module:n{ - \cs_set_nopar:cpn{#1name}{ - \ifvmode\hbox_unpack:N\c_empty_box\fi - \ifmmode\hbox{#3}\else#3\fi\xspace - } - \cs_set_nopar:cpn{#1}{ - \ifmmode\csname#1-sym\expandafter\endcsname\else - \ifvmode\hbox_unpack:N\c_empty_box\fi - \symref{#1-sym}{#3}\expandafter\xspace - \fi + + \stex_if_do_html:TF { + \begin{stex_annotate_env} { + shtml:feature-#2={\l_stex_current_module_str?\l_tmpa_str}, + shtml:domain={\l_stex_current_domain_str} + #5 } + \stex_annotate_invisible:n{} + }\group_begin: + \str_set:Nn \l__stex_features_feature_str {#2} + \str_set_eq:NN \l_stex_feature_name_str \l_tmpa_str + \__stex_features_setup: + \__stex_features_reactivate: + %^^A\stex_activate_module:o \l_stex_current_domain_str + \exp_args:Ne \stex_metagroup_new:n {\l_stex_current_module_str / \l_stex_feature_name_str} +} + +\cs_new_protected:Nn \__stex_features_do_for_list: { + \seq_clear:N \l_stex_fors_seq + \clist_map_inline:Nn \l_stex_key_for_clist { + \exp_args:Ne\stex_get_in_morphism:n{\tl_to_str:n{##1}} + \seq_put_right:Nx \l_stex_fors_seq + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} } - \stex_execute_in_module:x{ - \__stex_notation_restore_notation:nnnnn - {\l_stex_current_module_str?\tl_if_empty:NTF\l__stex_symdecl_name_str{#1}\l__stex_symdecl_name_str} - {}{0} - {\exp_not:n{\STEXInternalTermMathOMSiiii{\STEXInternalCurrentSymbolStr}{}{\neginfprec}{ - \comp{\hbox{#3}}\STEXInternalSymbolAfterInvokationTL - }}} - {} +} + +\cs_new_protected:Nn \__stex_features_add_definiens:nn { + \__stex_features_set_definiens_macros: #1\__stex_features_break: + \_stex_assign_do:n{#2} + #2 +} +\cs_new_protected:Npn \__stex_features_set_definiens_macros: #1?#2?#3\__stex_features_break: { + \str_set:Nn \l_stex_get_symbol_mod_str {#1?#2} + \str_set:Nn \l_stex_get_symbol_name_str {#3} + \exp_args:Nne\use:nn{\__stex_features_set_definiens_macros_i:nnnnnnn}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#1?#2]/[#3]} } - \stex_smsmode_do: } -\str_new:N \l_stex_get_symbol_uri_str +\cs_new_protected:Nn \__stex_features_set_definiens_macros_i:nnnnnnn { + \tl_set:Nn \l_stex_get_symbol_def_tl{#4} +} -\cs_new_protected:Nn \stex_get_symbol:n { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \__stex_symdecl_get_symbol_from_cs: - }{ - % argument is a string - % is it a command name? - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N \l_tmpa_tl - } \stex_invoke_symbol:n { - \__stex_symdecl_get_symbol_from_cs: - }{ - \__stex_symdecl_get_symbol_from_string:n { #1 } - } - } { - \__stex_symdecl_get_symbol_from_string:n { #1 } +\cs_new_protected:Nn \stex_structural_feature_morphism_end: { + \str_gset_eq:NN \l_stex_feature_name_str \l_stex_feature_name_str + \str_gset_eq:NN \l_stex_current_domain_str \l_stex_current_domain_str + \seq_gset_eq:NN \l_stex_morphism_symbols_prop \l_stex_morphism_symbols_prop + \seq_gset_eq:NN \l_stex_morphism_renames_prop \l_stex_morphism_renames_prop + \seq_gset_eq:NN \l_stex_morphism_morphisms_seq \l_stex_morphism_morphisms_seq + \__stex_features_do_elaboration: + \stex_if_do_html:TF{ + \end{stex_annotate_env} + }\group_end: +} + +\cs_new_protected:Nn \__stex_features_setup: { + \prop_clear:N \l_stex_morphism_symbols_prop + \prop_clear:N \l_stex_morphism_renames_prop + \seq_clear:N \l_stex_morphism_morphisms_seq + \__stex_features_do_decls: + \exp_args:No \__stex_features_do_morphisms:n \l_stex_current_domain_str +} + +\cs_new_protected:Nn \__stex_features_rename_all: { + +} + +\cs_new:Npn \__stex_features_clean:nnw [#1] / #2 \_stex_end: { + [#1]/[#2] +} + +\cs_new_protected:Nn \__stex_features_do_decls: { + \exp_args:No \stex_iterate_symbols:nn \l_stex_current_domain_str { + \stex_str_if_starts_with:nnTF{##3}[{ + \exp_args:NNe \prop_put:Nnn \l_stex_morphism_symbols_prop { + \__stex_features_clean:nnw ##3 \_stex_end: } }{ - % argument is not a command name - \__stex_symdecl_get_symbol_from_string:n { #1 } - % \l_stex_all_symbols_seq - } - } - \str_if_eq:eeF { - \prop_item:cn { - l_stex_symdecl_\l_stex_get_symbol_uri_str _prop - }{ deprecate } - }{}{ - \msg_warning:nnxx{stex}{warning/deprecated}{ - Symbol~\l_stex_get_symbol_uri_str + \prop_put:Nnn \l_stex_morphism_symbols_prop + {[##1]/[##3]} }{ - \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{ deprecate } + {##2}{##4}{##5}{##6}{##7}{##8}##9 } } } -\cs_new_protected:Nn \__stex_symdecl_get_symbol_from_string:n { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownsymbol}{#1} +\cs_new_protected:Nn \stex_structural_feature_morphism_check_total: { + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \__stex_features_total_check: ##1 ##2 } - \str_set:Nn \l_tmpa_str { #1 } +} - %\int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } +\cs_new_protected:Npn \__stex_features_total_check: [#1]/[#2] #3 #4 #5 #6 #7 #8 #9 { + \tl_if_empty:nT{#6}{ + \msg_error:nnxx{stex}{error/needsdefiniens}{#1?#2}{total~morphism} + } +} - \str_if_in:NnTF \l_tmpa_str ? { - \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \str_set:Nx \l_tmpb_str {\seq_use:Nn \l_tmpa_seq ?} - }{ - \str_clear:N \l_tmpb_str +\cs_new:Npn \__stex_features_split_qm:w #1 ? #2 ? #3 { #3 } +\cs_new_protected:Nn \__stex_features_do_elaboration: { + \stex_debug:nn{morphisms}{ + Elaborating:^^J\prop_to_keyval:N \l_stex_morphism_symbols_prop + ^^J + Renamings:^^J + \prop_to_keyval:N \l_stex_morphism_renames_prop } - \str_if_empty:NTF \l_tmpb_str { - \seq_map_inline:Nn \l_stex_all_modules_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str { - \seq_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 } - } - }} - } - } - } - }{ - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpb_str } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_if_eq:eeT{ \l_tmpb_str }{ \str_range:nnn {##1}{-\l_tmpa_int}{-1}}{ - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \exp_args:Nno \str_if_eq:nnT{####1} \l_tmpa_str { - \seq_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { ##1 ? ####1 } - } - }} - } - } - } - } + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \__stex_features_elab_check: ##1 ##2 + } + \exp_args:No\stex_iterate_notations:nn\l_stex_current_domain_str{ + \prop_get:NnNTF \l_stex_morphism_renames_prop {##1}\l__stex_features_tmp { + \exp_args:Ne \stex_module_add_notation:nnnnn + {\l_stex_current_module_str ? \exp_after:wN \use_ii:nn \l__stex_features_tmp} + }{ + \exp_args:Ne \stex_module_add_notation:nnnnn + {\l_stex_current_module_str ? \l_stex_feature_name_str + / \__stex_features_split_qm:w ##1} + }{##2}{##3}{##4}{##5} } + \stex_module_add_morphism:ooox + \l_stex_feature_name_str + \l_stex_current_domain_str + \l__stex_features_feature_str + {\prop_map_function:NN \l_stex_morphism_renames_prop \__stex_features_rename:nn} +} - \l_tmpa_tl +\cs_new:Nn \__stex_features_rename:nn{ + {#1}{\use_ii:nn#2} } -\cs_new_protected:Nn \__stex_symdecl_get_symbol_from_cs: { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \tl_if_single:NTF \l_tmpa_tl { - \exp_args:No \tl_if_head_is_group:nTF \l_tmpa_tl { - \exp_after:wN \str_set:Nn \exp_after:wN - \l_stex_get_symbol_uri_str \l_tmpa_tl +\cs_new_protected:Npn \__stex_features_elab_check: [#1]/[#2] #3 { + \prop_get:NnNTF \l_stex_morphism_renames_prop {#1?#2} \l__stex_features_tmp { + \stex_debug:nn{morphisms}{Generating~\l__stex_features_tmp} + \exp_after:wN \stex_module_add_symbol:nnnnnnnN \l__stex_features_tmp + }{ + \bool_if:NTF \l__stex_features_implicit_bool { + \stex_debug:nn{morphisms}{Generating~#3:~\l_stex_feature_name_str / #2} + \exp_args:Nno \stex_module_add_symbol:nnnnnnnN {#3}{\l_stex_feature_name_str / #2} }{ - % TODO - % tail is not a single group + \stex_debug:nn{morphisms}{Generating~\l_stex_feature_name_str / #2} + \exp_args:Nno \stex_module_add_symbol:nnnnnnnN {}{\l_stex_feature_name_str / #2} } - }{ - % TODO - % tail is not a single group } } -\keys_define:nn { stex / notation } { - variant .tl_set_x:N = \l__stex_notation_variant_str , - prec .str_set_x:N = \l__stex_notation_prec_str , - op .tl_set:N = \l__stex_notation_op_tl , - primary .bool_set:N = \l__stex_notation_primary_bool , - primary .default:n = {true} , - hints .str_set_x:N = \l__stex_notation_hints_str, - unknown .code:n = \str_set:Nx - \l__stex_notation_variant_str \l_keys_key_str + +\cs_new_protected:Nn \__stex_features_do_morphisms:n { + \prop_map_inline:cn {c_stex_module_#1_morphisms_prop}{ + \__stex_features_do_morph:nnnn ##2 + } } -\cs_new_protected:Nn \_stex_notation_args:n { - \str_clear:N \l__stex_notation_variant_str - \str_clear:N \l__stex_notation_prec_str - \str_clear:N \l__stex_notation_hints_str - \tl_clear:N \l__stex_notation_op_tl - \bool_set_false:N \l__stex_notation_primary_bool +\cs_new_protected:Nn \__stex_features_do_morph:nnnn { + \tl_if_empty:nF{#3}{ + \seq_put_right:Nn \l_stex_morphism_morphisms_seq {{#1}{#2}{#3}} + } + \__stex_features_do_morphisms:n{#2} +} - \keys_set:nn { stex / notation } { #1 } +\cs_new_protected:Npn \__stex_features_reactivate: { + \stex_deactivate_macro:Nn \symdecl {module~environments} + \stex_deactivate_macro:Nn \textsymdecl {module~environments} + \stex_deactivate_macro:Nn \symdef {module~environments} + \stex_deactivate_macro:Nn \notation {module~environments} + \stex_deactivate_macro:Nn \importmodule {module~environments} + \stex_deactivate_macro:Nn \requiremodule {module~environments} + \stex_deactivate_macro:Nn \smodule {outside~of~morphisms} + \stex_reactivate_macro:N \assign + \stex_reactivate_macro:N \assignMorphism + \stex_reactivate_macro:N \renamedecl + \cs_set_eq:NN \_stex_do_for_list: \__stex_features_do_for_list: + \cs_set_eq:NN \_stex_add_definiens:nn \__stex_features_add_definiens:nn } -\NewDocumentCommand \notation { s m O{}} { - \_stex_notation_args:n { #3 } - \tl_clear:N \l_stex_symdecl_definiens_tl - \stex_get_symbol:n { #2 } - \tl_set:Nn \l_stex_notation_after_do_tl { - \__stex_notation_final: - \IfBooleanTF#1{ - \stex_setnotation:n {\l_stex_get_symbol_uri_str} - }{} - \stex_smsmode_do:\ignorespacesandpars +\cs_new_protected:Nn \stex_get_in_morphism:n { + \str_clear:N \l_stex_get_symbol_name_str + \prop_map_inline:Nn \l_stex_morphism_symbols_prop { + \exp_args:Nx\__stex_features_get_check:nnnn{\tl_to_str:n{#1}}##1##2 } - \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l__stex_notation_variant_str } - { \l__stex_notation_prec_str} -} -\stex_deactivate_macro:Nn \notation {module~environments} -\seq_new:N \l__stex_notation_precedences_seq -\tl_new:N \l__stex_notation_opprec_tl -\int_new:N \l__stex_notation_currarg_int -\tl_new:N \STEXInternalSymbolAfterInvokationTL - -\cs_new_protected:Nn \stex_notation_do:nnnnn { - \let\STEXInternalCurrentSymbolStr\relax - \seq_clear:N \l__stex_notation_precedences_seq - \tl_clear:N \l__stex_notation_opprec_tl - \str_set:Nx \l__stex_notation_args_str { #1 } - \str_set:Nx \l__stex_notation_arity_str { #2 } - \str_set:Nx \l__stex_notation_suffix_str { #3 } - \str_set:Nx \l__stex_notation_prec_str { #4 } - - % precedences - \str_if_empty:NTF \l__stex_notation_prec_str { - \int_compare:nNnTF \l__stex_notation_arity_str = 0 { - \tl_set:No \l__stex_notation_opprec_tl { \neginfprec } - }{ - \tl_set:Nn \l__stex_notation_opprec_tl { 0 } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \prop_map_inline:Nn \l_stex_morphism_renames_prop { + \__stex_features_renamed_check:nnnnn{#1}##1=##2 } - } { - \str_if_eq:onTF \l__stex_notation_prec_str {nobrackets}{ - \tl_set:No \l__stex_notation_opprec_tl { \neginfprec } - \int_step_inline:nn { \l__stex_notation_arity_str } { - \exp_args:NNo - \seq_put_right:Nn \l__stex_notation_precedences_seq { \infprec } - } - }{ - \seq_set_split:NnV \l_tmpa_seq ; \l__stex_notation_prec_str - \seq_pop_left:NNTF \l_tmpa_seq \l_tmpa_str { - \tl_set:No \l__stex_notation_opprec_tl { \l_tmpa_str } - \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_str { - \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn - \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str } - \seq_map_inline:Nn \l_tmpa_seq { - \seq_put_right:Nn \l__stex_notation_precedences_seq { ##1 } - } - } - }{ - \int_compare:nNnTF \l__stex_notation_arity_str = 0 { - \tl_set:No \l__stex_notation_opprec_tl { \infprec } - }{ - \tl_set:No \l__stex_notation_opprec_tl { 0 } - } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnxx{stex}{error/unknownsymbolin}{#1}{ + morphism~\l_stex_feature_name_str } } } +} - \seq_set_eq:NN \l_tmpa_seq \l__stex_notation_precedences_seq - \int_step_inline:nn { \l__stex_notation_arity_str } { - \seq_pop_left:NNF \l_tmpa_seq \l_tmpb_str { - \exp_args:NNo - \seq_put_right:No \l__stex_notation_precedences_seq { - \l__stex_notation_opprec_tl +\cs_new_protected:Npn \__stex_features_renamed_check:nnnnn #1#2?#3?#4=#5#6 { + \str_if_eq:nnTF{#1}{#5}{ + \exp_args:Nnx \use:nn{\__stex_features_check_break:nnnnnnnnn{#2?#3}{#4}}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#2?#3]/[#4]} + } + }{ + \str_if_eq:nnT{#1}{#6}{ + \exp_args:Nnx \use:nn{\__stex_features_check_break:nnnnnnnnn{#2?#3}{#4}}{ + \prop_item:Nn \l_stex_morphism_symbols_prop {[#2?#3]/[#4]} } } } - \tl_clear:N \l_stex_notation_dummyargs_tl +} - \int_compare:nNnTF \l__stex_notation_arity_str = 0 { - \exp_args:NNe - \cs_set:Npn \l_stex_notation_macrocode_cs { - \STEXInternalTermMathOMSiiii { \STEXInternalCurrentSymbolStr } - { \l__stex_notation_suffix_str } - { \l__stex_notation_opprec_tl } - { \exp_not:n { #5 } } - } - \l_stex_notation_after_do_tl +\cs_new_protected:Npn \__stex_features_get_check:nnnn #1[#2]/[#3]#4 { + \str_if_eq:nnTF{#1}{#3}{ + \__stex_features_check_break:nnnnnnnnn{#2}{#3}{#4} }{ - \str_if_in:NnTF \l__stex_notation_args_str b { - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l__stex_notation_arity_str } { { - \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr } - { \l__stex_notation_suffix_str } - { \l__stex_notation_opprec_tl } - { \exp_not:n { #5 } } - }} + \str_if_eq:nnTF{#1}{#4}{ + \__stex_features_check_break:nnnnnnnnn{#2}{#3}{#4} }{ - \str_if_in:NnTF \l__stex_notation_args_str B { - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l__stex_notation_arity_str } { { - \STEXInternalTermMathOMBiiii { \STEXInternalCurrentSymbolStr } - { \l__stex_notation_suffix_str } - { \l__stex_notation_opprec_tl } - { \exp_not:n { #5 } } - } } - }{ - \exp_args:Nne \use:nn - { - \cs_generate_from_arg_count:NNnn \l_stex_notation_macrocode_cs - \cs_set:Npn \l__stex_notation_arity_str } { { - \STEXInternalTermMathOMAiiii { \STEXInternalCurrentSymbolStr } - { \l__stex_notation_suffix_str } - { \l__stex_notation_opprec_tl } - { \exp_not:n { #5 } } - } } - } + \use_none:nnnnnn } + } +} - \str_set_eq:NN \l__stex_notation_remaining_args_str \l__stex_notation_args_str - \int_zero:N \l__stex_notation_currarg_int - \seq_set_eq:NN \l__stex_notation_remaining_precs_seq \l__stex_notation_precedences_seq - \__stex_notation_arguments: +\cs_new_protected:Nn \__stex_features_check_break:nnnnnnnnn { + \prop_map_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str{#1} + \str_set:Nn \l_stex_get_symbol_name_str{#2} + \str_set:Nn \l_stex_get_symbol_macro_str{#3} + \int_set:Nn \l_stex_get_symbol_arity_int {#4} + \tl_set:Nn \l_stex_get_symbol_args_tl {#5} + \tl_set:Nn \l_stex_get_symbol_def_tl {#6} + \tl_set:Nn \l_stex_get_symbol_type_tl {#7} + \tl_set:Nn \l_stex_get_symbol_return_tl {#8} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#9} } } -\cs_new_protected:Nn \__stex_notation_arguments: { - \int_incr:N \l__stex_notation_currarg_int - \str_if_empty:NTF \l__stex_notation_remaining_args_str { - \l_stex_notation_after_do_tl - }{ - \str_set:Nx \l_tmpa_str { \str_head:N \l__stex_notation_remaining_args_str } - \str_set:Nx \l__stex_notation_remaining_args_str { \str_tail:N \l__stex_notation_remaining_args_str } - \str_if_eq:VnTF \l_tmpa_str a { - \__stex_notation_argument_assoc:nn{a} +\stex_new_stylable_cmd:nnnn {usemodule} { O{} m } { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:usemodule=\l_stex_import_ns_str} {}} + } + \stex_if_smsmode:F{ + \group_begin: + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } +}{} +\cs_new_protected:Nn \stex_import_module_uri:nn { + \stex_debug:nn{importmodule}{URI:~>#1<~>#2<} + \exp_args:NNnx \seq_set_split:Nnn \__stex_importmodule_seq ? { \tl_to_str:n{ #2 } } + \seq_pop_right:NN \__stex_importmodule_seq \l_stex_import_name_str + \str_set:Nx \l_stex_import_path_str { \seq_use:Nn \__stex_importmodule_seq ? } + \tl_if_empty:nTF { #1 } { + \stex_debug:nn{importmodule}{No~archive} + \prop_if_exist:NTF \l_stex_current_archive_prop { + \stex_debug:nn{importmodule}{Picking~current~archive} + \str_set:Nx \l_stex_import_archive_str { + \prop_item:Nn \l_stex_current_archive_prop { id } + } }{ - \str_if_eq:VnTF \l_tmpa_str B { - \__stex_notation_argument_assoc:nn{B} + \str_clear:N \l_stex_import_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \str_if_empty:NTF \l_stex_import_path_str { + \stex_debug:nn{importmodule}{Empty~Path} + \stex_file_split_off_ext:NN \l__stex_importmodule_path_seq \g_stex_current_file + \stex_file_split_off_lang:NN \l__stex_importmodule_path_seq \l__stex_importmodule_path_seq + \str_set:Nx \l_stex_import_path_str { + \stex_file_use:N \l__stex_importmodule_path_seq + } }{ - \seq_pop_left:NN \l__stex_notation_remaining_precs_seq \l_tmpb_str - \tl_put_right:Nx \l_stex_notation_dummyargs_tl { - { \STEXInternalTermMathArgiii - { \l_tmpa_str\int_use:N \l__stex_notation_currarg_int } - { \l_tmpb_str } - { ####\int_use:N \l__stex_notation_currarg_int } - } + \stex_debug:nn{importmodule}{Resolving~path~\l_stex_import_path_str~relative~to~\stex_file_use:N \g_stex_current_file} + \stex_file_resolve:Nx \l__stex_importmodule_seq { \stex_file_use:N \g_stex_current_file / .. / \l_stex_import_path_str} + \str_set:Nx \l_stex_import_path_str { + \stex_file_use:N \l__stex_importmodule_seq } - \__stex_notation_arguments: + \stex_debug:nn{importmodule}{...yields~\l_stex_import_path_str} } } + } { + \stex_debug:nn{importmodule}{Archive~#1} + \str_set:Nx \l_stex_import_archive_str { #1 } + \stex_require_archive:o \l_stex_import_archive_str + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ \l_stex_import_archive_str _manifest_prop}{ ns } } } } -\cs_new_protected:Nn \__stex_notation_argument_assoc:nn { +\cs_new_protected:Npn \stex_import_require_module:nnn #1 { + \tl_if_empty:nTF { #1 } { + \str_clear:N \l__stex_importmodule_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \__stex_importmodule_get_module:nnn {} + }{ + \stex_require_archive:n { #1 } + \str_set:Nx \l__stex_importmodule_archive_str {#1} + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ #1 _manifest_prop}{ ns } } + \str_set:Nx \l__stex_importmodule_str { \stex_file_use:N \c_stex_mathhub_file / #1 / source } + \exp_args:No \__stex_importmodule_get_module:nnn \l__stex_importmodule_str + } +} +\cs_generate_variant:Nn \stex_import_require_module:nnn {ooo} - \cs_generate_from_arg_count:NNnn \l_tmpa_cs \cs_set:Npn - {\l__stex_notation_arity_str}{ - #2 +\cs_new_protected:Npn \stex_import_require_module_safe:nnn #1 { + \tl_if_empty:nTF { #1 } { + \str_clear:N \l__stex_importmodule_archive_str + \str_set:Nn \l_stex_import_uri_str {file:} + \__stex_importmodule_get_module_safe:nnn {} + }{ + \stex_require_archive:n { #1 } + \str_set:Nx \l__stex_importmodule_archive_str {#1} + \str_set:Nx \l_stex_import_uri_str { \prop_item:cn{ c_stex_mathhub_ #1 _manifest_prop}{ ns } } + \str_set:Nx \l__stex_importmodule_str { \stex_file_use:N \c_stex_mathhub_file / #1 / source } + \exp_args:No \__stex_importmodule_get_module_safe:nnn \l__stex_importmodule_str } - \int_zero:N \l_tmpa_int - \tl_clear:N \l_tmpa_tl - \str_map_inline:Nn \l__stex_notation_args_str { - \int_incr:N \l_tmpa_int - \tl_put_right:Nx \l_tmpa_tl { - \str_if_eq:nnTF {##1}{a}{ {} }{ - \str_if_eq:nnTF {##1}{B}{ {} }{ - {\_stex_term_arg:nn{##1\int_use:N \l_tmpa_int}{################ \int_use:N \l_tmpa_int}} - } - } - } +} + +\cs_new_protected:Nn \__stex_importmodule_get_module_uri:nnn { + \tl_if_empty:nF {#2}{ + \str_set:Nx \l_stex_import_uri_str {\l_stex_import_uri_str / #2} } - \exp_after:wN\exp_after:wN\exp_after:wN \def - \exp_after:wN\exp_after:wN\exp_after:wN \l_tmpa_cs - \exp_after:wN\exp_after:wN\exp_after:wN ## - \exp_after:wN\exp_after:wN\exp_after:wN 1 - \exp_after:wN\exp_after:wN\exp_after:wN ## - \exp_after:wN\exp_after:wN\exp_after:wN 2 - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN { - \exp_after:wN \l_tmpa_cs \l_tmpa_tl + \stex_debug:nn{importmodule}{~>#1<^^J>#2<^^J>#3<^^J>\l_stex_import_uri_str<^^J + Current~file:\stex_file_use:N \g_stex_current_file^^J + Current~namespace:\stex_uri_use:N \l_stex_current_ns_uri + } + \stex_if_module_exists:nTF {\l_stex_import_uri_str?#3} { + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + }{ + \stex_if_module_exists:nTF{\stex_uri_use:N \l_stex_current_ns_uri ? #3}{ + \str_set:Nx \l_stex_import_ns_str {\stex_uri_use:N \l_stex_current_ns_uri ? #3} + }{ + \__stex_importmodule_get_from_file:nnn{#1}{#2}{#3} + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} } } - - \seq_pop_left:NN \l__stex_notation_remaining_precs_seq \l_tmpa_str - \tl_put_right:Nx \l_stex_notation_dummyargs_tl { { - \STEXInternalTermMathAssocArgiiiii - { \int_use:N \l__stex_notation_currarg_int } - { \l_tmpa_str } - { ####\int_use:N \l__stex_notation_currarg_int } - { \l_tmpa_cs {####1} {####2} } - {#1} - } } - \__stex_notation_arguments: } -\cs_new_protected:Nn \__stex_notation_restore_notation:nnnnn { - \cs_generate_from_arg_count:cNnn{stex_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs} - \cs_set_nopar:Npn {#3}{#4} - \tl_if_empty:nF {#5}{ - \tl_set:cn{stex_op_notation_\detokenize{#1} \c_hash_str \detokenize{#2}_cs}{ \comp{ #5 } } +\cs_new_protected:Nn \__stex_importmodule_get_module_uri_safe:nnn { + \tl_if_empty:nF {#2}{ + \str_set:Nx \l_stex_import_uri_str {\l_stex_import_uri_str / #2} + } + \stex_debug:nn{importmodule}{~>#1<^^J>#2<^^J>#3<^^J>\l_stex_import_uri_str<^^J + Current~file:\stex_file_use:N \g_stex_current_file^^J + Current~namespace:\stex_uri_use:N \l_stex_current_ns_uri } - \seq_if_exist:cT { l_stex_symdecl_\detokenize{#1} _notations }{ - \seq_put_right:cx { l_stex_symdecl_\detokenize{#1} _notations } { \detokenize{#2} } + \stex_if_module_exists:nTF {\l_stex_import_uri_str?#3} { + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + }{ + \stex_if_module_exists:nTF{\stex_uri_use:N \l_stex_current_ns_uri ? #3}{ + \str_set:Nx \l_stex_import_ns_str {\stex_uri_use:N \l_stex_current_ns_uri ? #3} + }{ + \__stex_importmodule_get_from_file_safe:nnn{#1}{#2}{#3} + \str_set:Nx \l_stex_import_ns_str {\l_stex_import_uri_str?#3} + } } } -\cs_new_protected:Nn \__stex_notation_final: { - - \stex_execute_in_module:x { - \__stex_notation_restore_notation:nnnnn - {\l_stex_get_symbol_uri_str} - {\l__stex_notation_suffix_str} - {\l__stex_notation_arity_str} - { - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL} - } - {\exp_args:No \exp_not:n \l__stex_notation_op_tl } - } +\cs_new_protected:Nn \__stex_importmodule_get_module:nnn { + \stex_debug:nn{importmodule}{Requiring~>[#1]#2?#3<} + \__stex_importmodule_get_module_uri:nnn{#1}{#2}{#3} + \stex_activate_module:o \l_stex_import_ns_str +} - \stex_debug:nn{symbols}{ - Notation~\l__stex_notation_suffix_str - ~for~\l_stex_get_symbol_uri_str^^J - Operator~precedence:~\l__stex_notation_opprec_tl^^J - Argument~precedences:~ - \seq_use:Nn \l__stex_notation_precedences_seq {,~}^^J - Notation: \cs_meaning:c { - stex_notation_ \l_stex_get_symbol_uri_str \c_hash_str - \l__stex_notation_suffix_str - _cs - } - } - % HTML annotations - \stex_if_do_html:T { - \stex_annotate_invisible:nnn { notation } - { \l_stex_get_symbol_uri_str } { - \stex_annotate_invisible:nnn { notationfragment } - { \l__stex_notation_suffix_str }{} - \stex_annotate_invisible:nnn { precedence } - { \l__stex_notation_prec_str }{} +\cs_new_protected:Nn \__stex_importmodule_get_module_safe:nnn { + \stex_debug:nn{importmodule}{Requiring~>[#1]#2?#3<} + \__stex_importmodule_get_module_uri_safe:nnn{#1}{#2}{#3} +} - \int_zero:N \l_tmpa_int - \str_set_eq:NN \l__stex_notation_remaining_args_str \l__stex_notation_args_str - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \l__stex_notation_arity_str }{ - \int_incr:N \l_tmpa_int - \str_set:Nx \l_tmpb_str { \str_head:N \l__stex_notation_remaining_args_str } - \str_set:Nx \l__stex_notation_remaining_args_str { \str_tail:N \l__stex_notation_remaining_args_str } - \str_if_eq:VnTF \l_tmpb_str a { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \str_if_eq:VnTF \l_tmpb_str B { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{} - } } +\cs_new_protected:Nn \__stex_importmodule_get_from_file:nnn { + \stex_file_resolve:Nx \l__stex_importmodule_seq { \tl_if_empty:nF{ #1 }{ #1 / } #2 } + \str_set:Nx \l__stex_importmodule_str {\stex_file_use:N \l__stex_importmodule_seq} + \stex_debug:nn{imports}{Looking~for~\l_stex_import_uri_str?#3...} + \__stex_importmodule_check_file:nn{ /#3.tex }{ + \__stex_importmodule_check_file:nn{/#3.\l_stex_current_language_str .tex}{ + \__stex_importmodule_check_file:nn{/#3.en.tex}{ + \__stex_importmodule_check_file:nn{.tex}{ + \__stex_importmodule_check_file:nn{.\l_stex_current_language_str .tex}{ + \__stex_importmodule_check_file:nn{.en.tex}{ + \msg_error:nnx{stex}{error/unknownmodule}{\l_stex_import_uri_str?#3} + } } } } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {\l_stex_get_symbol_uri_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_notation_ \STEXInternalCurrentSymbolStr - \c_hash_str \l__stex_notation_suffix_str _cs - } } { \l_tmpa_tl } $ - } - \tl_if_empty:NF \l__stex_notation_op_tl { - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $\l__stex_notation_op_tl$ + } + } + \stex_if_smsmode:TF{ + \exp_args:NNo \exp_args:Nnx \str_if_eq:nnTF{\l__stex_importmodule_str}{\stex_file_use:N \g_stex_current_file}{ + \stex_debug:nn{imports}{Skipping~current~file} + }{ + \__stex_importmodule_load_file:n{#3} + } + }{ + \__stex_importmodule_load_file:n{#3} + } +} +\cs_new_protected:Nn \__stex_importmodule_get_from_file_safe:nnn { + \stex_file_resolve:Nx \l__stex_importmodule_seq { \tl_if_empty:nF{ #1 }{ #1 / } #2 } + \str_set:Nx \l__stex_importmodule_str {\stex_file_use:N \l__stex_importmodule_seq} + \stex_debug:nn{imports}{Looking~for~\l_stex_import_uri_str?#3...} + \__stex_importmodule_check_file:nn{ /#3.tex }{ + \__stex_importmodule_check_file:nn{/#3.\l_stex_current_language_str .tex}{ + \__stex_importmodule_check_file:nn{/#3.en.tex}{ + \__stex_importmodule_check_file:nn{.tex}{ + \__stex_importmodule_check_file:nn{.\l_stex_current_language_str .tex}{ + \__stex_importmodule_check_file:nn{.en.tex}{ + } + } } } } } + \stex_if_smsmode:TF{ + \exp_args:NNo \exp_args:Nnx \str_if_eq:nnTF{\l__stex_importmodule_str}{\stex_file_use:N \g_stex_current_file}{ + \stex_debug:nn{imports}{Skipping~current~file} + }{ + \IfFileExists{ \l__stex_importmodule_str }{ + \__stex_importmodule_load_file:n{#3} + }{} + } + }{ + \IfFileExists{ \l__stex_importmodule_str }{ + \__stex_importmodule_load_file:n{#3} + }{} + } } -\keys_define:nn { stex / setnotation } { - variant .tl_set_x:N = \l__stex_notation_variant_str , - unknown .code:n = \str_set:Nx - \l__stex_notation_variant_str \l_keys_key_str + +\cs_new_protected:Nn \__stex_importmodule_load_file:n { + \stex_file_in_smsmode:on \l__stex_importmodule_str { + \str_if_empty:NF \l__stex_importmodule_archive_str { + \stex_set_current_archive:n \l__stex_importmodule_archive_str + } + \stex_debug:nn{modules}{Loading~\l__stex_importmodule_str} + } + \stex_if_module_exists:nF {\l_stex_import_uri_str?#1} { + \msg_error:nnx{stex}{error/unknownmodule}{\l_stex_import_uri_str?#1} + } } -\cs_new_protected:Nn \_stex_setnotation_args:n { - % \str_clear:N \l__stex_notation_lang_str - \str_clear:N \l__stex_notation_variant_str - \keys_set:nn { stex / setnotation } { #1 } +\cs_new_protected:Npn \__stex_importmodule_check_file:nn #1 { + \stex_debug:nn{imports}{Checking~ \l__stex_importmodule_str #1} + \IfFileExists{ \l__stex_importmodule_str #1 }{ + \stex_debug:nn{imports}{Success} + \str_set:Nx \l__stex_importmodule_str { \l__stex_importmodule_str #1 } + } } +\stex_new_stylable_cmd:nnnn{importmodule} { O{} m } { + \__stex_importmodule_import_module:nn {#1}{#2} + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \importmodule {module~environments} -\cs_new_protected:Nn \__stex_notation_setnotation:nn { - \seq_if_exist:cT{l_stex_symdecl_#1_notations}{ - \seq_remove_all:cn { l_stex_symdecl_#1 _notations }{ #2 } - \seq_put_left:cn { l_stex_symdecl_#1 _notations }{ #2 } +\cs_new_protected:Nn \__stex_importmodule_import_module:nn { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_execute_in_module:x{ + \stex_activate_module:n{\l_stex_import_ns_str} + } + \stex_module_add_morphism:nonn + {}{\l_stex_import_ns_str}{import}{} + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import=\l_stex_import_ns_str} {} + } + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nn \thisarchive {#1} + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: } } -\cs_new_protected:Nn \stex_setnotation:n { - \exp_args:Nnx \seq_if_in:cnTF { l_stex_symdecl_#1 _notations } - { \l__stex_notation_variant_str }{ - \stex_execute_in_module:x{ \__stex_notation_setnotation:nn {#1}{\l__stex_notation_variant_str} } - \stex_debug:nn {notations}{ - Setting~default~notation~ - {\l__stex_notation_variant_str }~for~ - #1 \\ - \expandafter\meaning\csname - l_stex_symdecl_#1 _notations\endcsname - } - }{ - \msg_error:nnxx{stex}{unknownnotation}{\l__stex_notation_variant_str}{#1} - } +\cs_new_protected:Nn \__stex_importmodule_import_module_presms:nn { + \stex_import_module_uri:nn { #1 }{ #2 } + \tl_gput_right:Nx \g_stex_sms_import_code { + \stex_import_require_module_safe:nnn + {\l_stex_import_archive_str} + {\l_stex_import_path_str} + {\l_stex_import_name_str} + } } -\NewDocumentCommand \setnotation {m m} { - \stex_get_symbol:n { #1 } - \_stex_setnotation_args:n { #2 } - \stex_setnotation:n{\l_stex_get_symbol_uri_str} - \stex_smsmode_do:\ignorespacesandpars +\stex_sms_allow_escape:N \importmodule +\stex_every_module:n {\stex_reactivate_macro:N \importmodule} +\stex_sms_allow_import:Nn \importmodule { + \stex_reactivate_macro:N \importmodule + \let \__stex_importmodule_import_module:nn \__stex_importmodule_import_module_presms:nn } -\cs_new_protected:Nn \stex_copy_notations:nn { - \stex_debug:nn {notations}{ - Copying~notations~from~#2~to~#1\\ - \seq_use:cn{l_stex_symdecl_#2_notations}{,~} +\stex_new_stylable_cmd:nnnn{requiremodule} { O{} m } { + \stex_import_module_uri:nn { #1 }{ #2 } + \stex_import_require_module:ooo + \l_stex_import_archive_str + \l_stex_import_path_str + \l_stex_import_name_str + \stex_do_up_to_module:x{ + \stex_activate_module:n{\l_stex_import_ns_str} } - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } } { - \tl_put_right:Nn \l_tmpa_tl { {######## ##1} } + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import=\l_stex_import_ns_str} {} } - \seq_map_inline:cn {l_stex_symdecl_#2_notations}{\begingroup - \stex_debug:nn{Here}{Here:~##1} - \cs_set_eq:Nc \l_tmpa_cs { stex_notation_ #2 \c_hash_str ##1 _cs } - \edef \l_tmpa_tl { - \exp_after:wN\exp_after:wN\exp_after:wN \exp_not:n - \exp_after:wN\exp_after:wN\exp_after:wN { - \exp_after:wN \l_tmpa_cs \l_tmpa_tl - } - } - - \exp_after:wN \def \exp_after:wN \l_tmpa_tl - \exp_after:wN ####\exp_after:wN 1 \exp_after:wN ####\exp_after:wN 2 - \exp_after:wN { \l_tmpa_tl } + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nn \thisarchive {#1} + \tl_set_eq:NN \thismoduleuri \l_stex_import_ns_str + \tl_set_eq:NN \thismodulename \l_stex_import_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \requiremodule {module~environments} +\stex_new_stylable_cmd:nnnn {assign} { m m }{ + \stex_get_in_morphism:n{#1} + \_stex_assign_do:n{#2} + \stex_smsmode_do: +}{} +\stex_sms_allow_escape:N\assign - \edef \l_tmpa_tl { - \exp_after:wN \exp_not:n \exp_after:wN { - \l_tmpa_tl {######## 1}{######## 2} +\cs_new_protected:Nn \_stex_assign_do:n{ + \stex_debug:nn{assign}{Assigning~\l_stex_get_symbol_name_str~to~\tl_to_str:n{#1}} + \tl_if_empty:NF \l_stex_get_symbol_def_tl { + %\msg_error:nnxx{stex}{error/symbolalreadydefined}{\l_stex_get_symbol_name_str}{ + % morphism~\l_stex_feature_name_str + %} + } + \stex_check_term:n{#1} + \stex_debug:nn{HERE!}{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str^^J + \tl_to_str:n{#1} + } + \stex_if_do_html:T{ + \stex_annotate_invisible:nn{shtml:assign={\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}}{ + \_stex_annotate_force_break:n{ + \mode_if_math:T\hbox{$\stex_annotate:nn{shtml:definiens={}}{#1}$} } } - - \stex_debug:nn{Here}{Here:~\expandafter\detokenize\expandafter{\l_tmpa_tl}} - - \stex_execute_in_module:x { - \__stex_notation_restore_notation:nnnnn - {#1}{##1} - { \prop_item:cn {l_stex_symdecl_#2_prop}{ arity } } - { \exp_after:wN\exp_not:n\exp_after:wN{\l_tmpa_tl} } - { - \cs_if_exist:cT{stex_op_notation_ #2\c_hash_str ##1 _cs}{ - \exp_args:NNo\exp_args:No\exp_not:n{\csname stex_op_notation_ #2\c_hash_str ##1 _cs\endcsname} - } - } - }\endgroup + } + \exp_args:Ne \stex_metagroup_do_in:nx{ + \l_stex_current_module_str / \l_stex_feature_name_str + }{ + \prop_put:Nnn \exp_not:N \l_stex_morphism_symbols_prop + {[\l_stex_get_symbol_mod_str]/[\l_stex_get_symbol_name_str]} + { + {\l_stex_get_symbol_macro_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_not:n{#1}} + {\exp_args:No\exp_not:n\l_stex_get_symbol_type_tl} + {\exp_args:No\exp_not:n\l_stex_get_symbol_return_tl} + {\l_stex_get_symbol_invoke_cs} + } } } -\NewDocumentCommand \copynotation {m m} { - \stex_get_symbol:n { #1 } - \str_set_eq:NN \l_tmpa_str \l_stex_get_symbol_uri_str - \stex_get_symbol:n { #2 } - \exp_args:Noo - \stex_copy_notations:nn \l_tmpa_str \l_stex_get_symbol_uri_str - \stex_smsmode_do:\ignorespacesandpars -} - -\keys_define:nn { stex / symdef } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - type .tl_set:N = \l_stex_symdecl_type_tl , - def .tl_set:N = \l_stex_symdecl_definiens_tl , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - op .tl_set:N = \l__stex_notation_op_tl , - % lang .str_set_x:N = \l__stex_notation_lang_str , - variant .str_set_x:N = \l__stex_notation_variant_str , - prec .str_set_x:N = \l__stex_notation_prec_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, - unknown .code:n = \str_set:Nx - \l__stex_notation_variant_str \l_keys_key_str -} - -\cs_new_protected:Nn \__stex_notation_symdef_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_assoctype_str - \str_clear:N \l_stex_symdecl_reorder_str - \bool_set_false:N \l_stex_symdecl_local_bool - \tl_clear:N \l_stex_symdecl_type_tl - \tl_clear:N \l_stex_symdecl_definiens_tl - \clist_clear:N \l_stex_symdecl_argnames_clist - % \str_clear:N \l__stex_notation_lang_str - \str_clear:N \l__stex_notation_variant_str - \str_clear:N \l__stex_notation_prec_str - \tl_clear:N \l__stex_notation_op_tl - - \keys_set:nn { stex / symdef } { #1 } -} - -\NewDocumentCommand \symdef { m O{} } { - \__stex_notation_symdef_args:n { #2 } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \stex_symdecl_do:n { #1 } - \tl_set:Nn \l_stex_notation_after_do_tl { - \__stex_notation_final: - \stex_smsmode_do:\ignorespacesandpars - } - \str_set:Nx \l_stex_get_symbol_uri_str { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } - \exp_args:Nx \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l__stex_notation_variant_str } - { \l__stex_notation_prec_str} -} -\stex_deactivate_macro:Nn \symdef {module~environments} +\stex_new_stylable_cmd:nnnn {renamedecl} { m O{} m }{ + \stex_get_in_morphism:n{#1} + \_stex_renamedecl_do:nn{#2}{#3} + \stex_smsmode_do: +}{} +\stex_sms_allow_escape:N\renamedecl -\keys_define:nn { stex / mmtdef } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - op .tl_set:N = \l__stex_notation_op_tl , - % lang .str_set_x:N = \l__stex_notation_lang_str , - variant .str_set_x:N = \l__stex_notation_variant_str , - prec .str_set_x:N = \l__stex_notation_prec_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, - unknown .code:n = \str_set:Nx - \l__stex_notation_variant_str \l_keys_key_str -} -\cs_new_protected:Nn \_stex_mmtdef_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_assoctype_str - \str_clear:N \l_stex_symdecl_reorder_str - \bool_set_false:N \l_stex_symdecl_local_bool - \clist_clear:N \l_stex_symdecl_argnames_clist - % \str_clear:N \l__stex_notation_lang_str - \str_clear:N \l__stex_notation_variant_str - \str_clear:N \l__stex_notation_prec_str - \tl_clear:N \l__stex_notation_op_tl - - \keys_set:nn { stex / mmtdef } { #1 } -} - -\NewDocumentCommand \mmtdef {m O{} }{ - \_stex_mmtdef_args:n{ #2 } - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } - } - %\tl_set:Nx \l_stex_symdecl_definiens_tl { - % \stex_annotate:nnn{ OMID }{ - % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - % }{} - %} - \stex_symdecl_do:n { #1 } - \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ - \stex_annotate:nnn{ OMID }{ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }{}, - \stex_annotate:nnn{ OMID }{ - \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str +\cs_new_protected:Nn \_stex_renamedecl_do:nn { + \stex_debug:nn{renamedecl}{Renaming~\l_stex_get_symbol_name_str~to~[#1]{#2}} + \stex_if_do_html:T{ + \exp_args:Ne \stex_annotate_invisible:nn{ + shtml:rename={\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}, + shtml:macroname={#2} + \str_if_empty:nF{#1}{ ,shtml:to={#1} } }{} } - \tl_set:Nn \l_stex_notation_after_do_tl { - \__stex_notation_final: - \stex_smsmode_do:\ignorespacesandpars - } - \str_set:Nx \l_stex_get_symbol_uri_str { - \l_stex_current_module_str ? \l_stex_symdecl_name_str - } - \exp_args:Nx \stex_notation_do:nnnnn - { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } - { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } - { \l__stex_notation_variant_str } - { \l__stex_notation_prec_str} -} - -\keys_define:nn { stex / vardef } { - name .str_set_x:N = \l__stex_variables_name_str , - args .str_set_x:N = \l__stex_variables_args_str , - type .tl_set:N = \l__stex_variables_type_tl , - def .tl_set:N = \l__stex_variables_def_tl , - op .tl_set:N = \l__stex_variables_op_tl , - prec .str_set_x:N = \l__stex_variables_prec_str , - reorder .str_set_x:N = \l__stex_variables_reorder_str , - argnames .clist_set:N = \l__stex_variables_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l__stex_variables_assoctype_str {\l_keys_choice_tl}}, - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l__stex_variables_bind_str {\l_keys_choice_tl}} -} - -\cs_new_protected:Nn \__stex_variables_args:n { - \str_clear:N \l__stex_variables_name_str - \str_clear:N \l__stex_variables_args_str - \str_clear:N \l__stex_variables_prec_str - \str_clear:N \l__stex_variables_assoctype_str - \str_clear:N \l__stex_variables_reorder_str - \str_clear:N \l__stex_variables_bind_str - \tl_clear:N \l__stex_variables_type_tl - \tl_clear:N \l__stex_variables_def_tl - \tl_clear:N \l__stex_variables_op_tl - \clist_clear:N \l__stex_variables_argnames_clist - - \keys_set:nn { stex / vardef } { #1 } -} - -\NewDocumentCommand \__stex_variables_do_simple:nnn { m O{}} { - \__stex_variables_args:n {#2} - \str_if_empty:NT \l__stex_variables_name_str { - \str_set:Nx \l__stex_variables_name_str { #1 } - } - \prop_clear:N \l_tmpa_prop - \prop_put:Nno \l_tmpa_prop { name } \l__stex_variables_name_str - - \int_zero:N \l_tmpb_int - \bool_set_true:N \l_tmpa_bool - \str_map_inline:Nn \l__stex_variables_args_str { - \token_case_meaning:NnF ##1 { - 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {} 8 {} 9 {} - {\tl_to_str:n i} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n b} { \bool_set_false:N \l_tmpa_bool } - {\tl_to_str:n a} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } - {\tl_to_str:n B} { - \bool_set_false:N \l_tmpa_bool - \int_incr:N \l_tmpb_int - } + \exp_args:Ne \stex_metagroup_do_in:nx{ + \l_stex_current_module_str / \l_stex_feature_name_str + }{ + \prop_put:Nnn \exp_not:N \l_stex_morphism_renames_prop + {\l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str}{{#2}{ + \tl_if_empty:nTF{#1}{\l_stex_feature_name_str/\l_stex_get_symbol_name_str}{#1} + }} + } +} + +\stex_new_stylable_cmd:nnnn {assignMorphism} { m m }{ + \str_clear:N \l__stex_morphisms_morphism_dom_str + \stex_iterate_morphisms:nn\l_stex_current_domain_str{ + \stex_debug:nn{assignMorphism}{ + Checking:~#1~vs:^^J##1^^J##2^^J##3^^J##4 + } + \str_if_eq:nnTF{#1}{##1}{ + \__stex_morphisms_do_morph_assign:nnn{##1}{##2}{##4} }{ - \msg_error:nnxx{stex}{error/wrongargs}{ - variable~\l__stex_variables_name_str - }{##1} + \stex_str_if_ends_with:nnT{##2}{#1}{ + \__stex_morphisms_do_morph_assign:nnn{##1}{##2}{##4} + } } } - \bool_if:NTF \l_tmpa_bool { - % possibly numeric - \str_if_empty:NTF \l__stex_variables_args_str { - \prop_put:Nnn \l_tmpa_prop { args } {} - \prop_put:Nnn \l_tmpa_prop { arity } { 0 } + \str_if_empty:NT \l__stex_morphisms_morphism_dom_str { + \msg_error:nnn{stex}{error/nomorphism}{#1} + } + \bool_set_false:N \l_tmpa_bool + \stex_iterate_morphisms:nn \l_stex_current_module_str { + \stex_debug:nn{assignMorphism}{ + Checking:~#2~vs:^^J##1^^J##2^^J##3^^J##4 + } + \str_if_eq:nnTF{#2}{##1}{ + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_break:n{ + \stex_annotate_invisible:nn{ + shtml:assignMorphismFrom={\l__stex_morphisms_morphism_dom_str} + ahtml:assignMorphismTo={\l_stex_current_module_str?##1} + }{} + \bool_set_true:N \l_tmpa_bool + } }{ - \int_set:Nn \l_tmpa_int { \l__stex_variables_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } { \int_use:N \l_tmpa_int } - \str_clear:N \l_tmpa_str - \int_step_inline:nn \l_tmpa_int { - \str_put_right:Nn \l_tmpa_str i + \stex_str_if_ends_with:nnT{##2}{#2}{ + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_break:n{ + \stex_annotate_invisible:nn{ + shtml:assignMorphismFrom={\l__stex_morphisms_morphism_dom_str}, + shtml:assignMorphismTo={\l_stex_current_module_str?##1} + }{} + \bool_set_true:N \l_tmpa_bool + } } - \str_set_eq:NN \l__stex_variables_args_str \l_tmpa_str - \prop_put:Nnx \l_tmpa_prop { args } { \l__stex_variables_args_str } } - } { - \prop_put:Nnx \l_tmpa_prop { args } { \l__stex_variables_args_str } - \prop_put:Nnx \l_tmpa_prop { arity } - { \str_count:N \l__stex_variables_args_str } } - \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int } - \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l__stex_variables_name_str } } - - % argnames - - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { - \clist_if_empty:NTF \l__stex_variables_argnames_clist { - \clist_put_right:Nn \l_tmpa_clist {##1} - }{ - \clist_pop:NN \l__stex_variables_argnames_clist \l_tmpa_tl - \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} + \bool_if:NF \l_tmpa_bool { + \msg_error:nnn{stex}{error/nomorphism}{#2} + } +}{} +\cs_new_protected:Nn \__stex_morphisms_do_morph_assign:nnn { + \stex_iterate_break:n{ + \str_set:Nx \l__stex_morphisms_morphism_dom_str { \l_stex_current_domain_str ? #1 } + \stex_debug:nn{assignMorphism}{match!} + \stex_iterate_symbols:nn{#2}{ + \stex_debug:nn{assignMorphism}{removing~##1?##3} + % TODO: non-trivial assignments + \prop_remove:Nn \l_stex_morphism_symbols_prop { + [##1]/[##3] + } } } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} +} - \prop_set_eq:cN { l_stex_symdecl_var://\l__stex_variables_name_str _prop} \l_tmpa_prop +\stex_deactivate_macro:Nn \assign {morphism~environments} +\stex_deactivate_macro:Nn \renamedecl {morphism~environments} +\stex_deactivate_macro:Nn \assignMorphism {morphism~environments} +\stex_new_stylable_env:nnnnnnn {copymodule}{m O{} m}{ - \tl_if_empty:NF \l__stex_variables_op_tl { - \cs_set:cpx { - stex_var_op_notation_ \l__stex_variables_name_str _cs - } { \exp_not:N\comp{ \exp_args:No \exp_not:n { \l__stex_variables_op_tl } } } - } + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=false} - \tl_set:Nn \l_stex_notation_after_do_tl { - \exp_args:Nne \use:nn { - \cs_generate_from_arg_count:cNnn { stex_var_notation_\l__stex_variables_name_str _cs } - \cs_set:Npn { \prop_item:Nn \l_tmpa_prop { arity } } - } {{ - \exp_after:wN \exp_after:wN \exp_after:wN - \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN - { \exp_after:wN \l_stex_notation_macrocode_cs \l_stex_notation_dummyargs_tl \STEXInternalSymbolAfterInvokationTL} - }} - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {vardecl}{\l__stex_variables_name_str}{ - \stex_annotate_invisible:nnn { precedence } - { \l__stex_variables_prec_str }{} - \tl_if_empty:NF \l__stex_variables_type_tl {\stex_annotate_invisible:nnn{type}{}{$\l__stex_variables_type_tl$}} - \stex_annotate_invisible:nnn{args}{ \l__stex_variables_args_str }{} - \stex_annotate_invisible:nnn{macroname}{#1}{} - \tl_if_empty:NF \l__stex_variables_def_tl { - \stex_annotate_invisible:nnn{definiens}{} - {$\l__stex_variables_def_tl$} - } - \str_if_empty:NF \l__stex_variables_assoctype_str { - \stex_annotate_invisible:nnn{assoctype}{\l__stex_variables_assoctype_str}{} - } - \str_if_empty:NF \l__stex_variables_reorder_str { - \stex_annotate_invisible:nnn{reorderargs}{\l__stex_variables_reorder_str}{} - } - \int_zero:N \l_tmpa_int - \str_set_eq:NN \l__stex_variables_remaining_args_str \l__stex_variables_args_str - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn { \prop_item:Nn \l_tmpa_prop { arity } }{ - \int_incr:N \l_tmpa_int - \str_set:Nx \l_tmpb_str { \str_head:N \l__stex_variables_remaining_args_str } - \str_set:Nx \l__stex_variables_remaining_args_str { \str_tail:N \l__stex_variables_remaining_args_str } - \str_if_eq:VnTF \l_tmpb_str a { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \str_if_eq:VnTF \l_tmpb_str B { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int a}{} , - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int b}{} - } } - }{ - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{\int_use:N \l_tmpa_int}{} - } } - } - } - } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {var://\l__stex_variables_name_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_var_notation_\l__stex_variables_name_str _cs - } } { \l_tmpa_tl } $ - } - \tl_if_empty:NF \l__stex_variables_op_tl { - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $\l__stex_variables_op_tl$ - } - } - } - \str_if_empty:NF \l__stex_variables_bind_str { - \stex_annotate_invisible:nnn {bindtype}{\l__stex_variables_bind_str,\l__stex_variables_name_str}{} - } - }\ignorespacesandpars + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: } - - \stex_notation_do:nnnnn { \l__stex_variables_args_str } { \prop_item:Nn \l_tmpa_prop { arity } } {}{ \l__stex_variables_prec_str} + \stex_smsmode_do: +}{ + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \copymodule {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \copymodule } +\stex_sms_allow_env:n{copymodule} -\cs_new:Nn \_stex_reset:N { - \tl_if_exist:NTF #1 { - \def \exp_not:N #1 { \exp_args:No \exp_not:n #1 } - }{ - \let \exp_not:N #1 \exp_not:N \undefined +\stex_new_stylable_env:nnnnnnn {interpretmodule}{m O{} m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=true} + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: } + \stex_smsmode_do: +}{ + \stex_structural_feature_morphism_check_total: + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \interpretmodule {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \interpretmodule } +\stex_sms_allow_env:n{interpretmodule} +\stex_new_stylable_env:nnnnnnn {realization}{O{} m}{ -\NewDocumentCommand \__stex_variables_do_complex:nn { m m }{ - \clist_set:Nx \l__stex_variables_names { \tl_to_str:n {#1} } - \exp_args:Nnx \use:nn { - % TODO - \stex_annotate_invisible:nnn {vardecl}{\clist_use:Nn\l__stex_variables_names,}{ - #2 - } + \stex_structural_feature_morphism:nnnnn{}{morphism}{#1}{#2}{,shtml:total=true} + %\stex_execute_in_module:x{ + % \stex_activate_module:n{\l_stex_current_domain_str} + %} + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #2 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: + } + \stex_smsmode_do: +}{ + \stex_structural_feature_morphism_check_total: + \stex_if_smsmode:F { + \stex_style_apply: + } + \stex_structural_feature_morphism_end: +}{}{}{} +\stex_deactivate_macro:Nn \realization {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \realization +} +\stex_sms_allow_env:n{realization} +\cs_new_protected:Nn \__stex_morphisms_parse_assign:n { + \str_clear:N \l__stex_morphisms_name_str + \str_clear:N \l__stex_morphisms_newname_str + \tl_clear:N \l__stex_morphisms_ass_tl + \exp_args:NNe \seq_set_split:Nnn \l__stex_morphisms_seq {\tl_to_str:n{@}} {#1} + \int_compare:nNnTF {\seq_count:N \l__stex_morphisms_seq} = 1 { + \seq_pop_left:NN \l__stex_morphisms_seq \l__stex_morphisms_next_tl }{ - \_stex_reset:N \varnot - \_stex_reset:N \vartype - \_stex_reset:N \vardefi + \seq_pop_left:NN \l__stex_morphisms_seq \l__stex_morphisms_name_str + \exp_args:NNo \str_set:Nn \l__stex_morphisms_name_str \l__stex_morphisms_name_str + \tl_set:Nx \l__stex_morphisms_next_tl {\seq_use:Nn \l__stex_morphisms_seq @} + } + \exp_args:NNNo \seq_set_split:Nnn \l__stex_morphisms_seq = \l__stex_morphisms_next_tl + \str_if_empty:NTF \l__stex_morphisms_name_str { + \seq_pop_left:NN \l__stex_morphisms_seq \l__stex_morphisms_name_str + \exp_args:NNo \str_set:Nn \l__stex_morphisms_name_str \l__stex_morphisms_name_str + \tl_set:Nx \l__stex_morphisms_ass_tl {\seq_use:Nn \l__stex_morphisms_seq =} + }{ + \seq_pop_left:NN \l__stex_morphisms_seq \l__stex_morphisms_newname_str + \exp_args:NNo \str_set:Nn \l__stex_morphisms_newname_str \l__stex_morphisms_newname_str + \tl_set:Nx \l__stex_morphisms_ass_tl {\seq_use:Nn \l__stex_morphisms_seq =} } + \__stex_morphisms_do_parsed_assign: } -\NewDocumentCommand \vardef { s } { - \IfBooleanTF#1 { - \__stex_variables_do_complex:nn - }{ - \__stex_variables_do_simple:nnn +\cs_new_protected:Nn \__stex_morphisms_do_parsed_assign: { + \exp_args:No \stex_get_in_morphism:n \l__stex_morphisms_name_str + \str_if_empty:NF \l__stex_morphisms_newname_str { + \exp_after:wN \__stex_morphisms_do_parsed_newname: \l__stex_morphisms_newname_str \__stex_morphisms_end: + } + \tl_if_empty:NF \l__stex_morphisms_ass_tl { + \exp_args:No \_stex_assign_do:n \l__stex_morphisms_ass_tl } } -\NewDocumentCommand \svar { O{} m }{ - \tl_if_empty:nTF {#1}{ - \str_set:Nn \l_tmpa_str { #2 } - }{ - \str_set:Nn \l_tmpa_str { #1 } - } - \_stex_term_omv:nn { - var://\l_tmpa_str +\cs_new_protected:Nn \__stex_morphisms_do_parsed_newname: { + \peek_charcode:NTF [ { + \__stex_morphisms_do_parsed_newname:w }{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nx \STEXInternalCurrentSymbolStr { var://\l_tmpa_str } - \comp{ #2 } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } + \__stex_morphisms_do_parsed_newname:w [] } } -\keys_define:nn { stex / varseq } { - name .str_set_x:N = \l__stex_variables_name_str , - args .int_set:N = \l__stex_variables_args_int , - type .tl_set:N = \l__stex_variables_type_tl , - mid .tl_set:N = \l__stex_variables_mid_tl , - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l__stex_variables_bind_str {\l_keys_choice_tl}} +\cs_new_protected:Npn \__stex_morphisms_do_parsed_newname:w [#1] #2 \__stex_morphisms_end: { + \_stex_renamedecl_do:nn{#1}{#2} } -\cs_new_protected:Nn \__stex_variables_seq_args:n { - \str_clear:N \l__stex_variables_name_str - \int_set:Nn \l__stex_variables_args_int 1 - \tl_clear:N \l__stex_variables_type_tl - \str_clear:N \l__stex_variables_bind_str +\stex_new_stylable_cmd:nnnn{copymod}{m O{} m m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=false} - \keys_set:nn { stex / varseq } { #1 } -} + \clist_map_function:nN{#4}\__stex_morphisms_parse_assign:n -\NewDocumentCommand \varseq {m O{} m m m}{ - \__stex_variables_seq_args:n { #2 } - \str_if_empty:NT \l__stex_variables_name_str { - \str_set:Nx \l__stex_variables_name_str { #1 } + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: } - \prop_clear:N \l_tmpa_prop - \prop_put:Nnx \l_tmpa_prop { arity }{\int_use:N \l__stex_variables_args_int} + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \copymod {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \copymod +} +\stex_sms_allow_escape:N\copymod - \seq_set_from_clist:Nn \l_tmpa_seq {#3} - \int_compare:nNnF {\seq_count:N \l_tmpa_seq} = \l__stex_variables_args_int { - \msg_error:nnxx{stex}{error/seqlength} - {\int_use:N \l__stex_variables_args_int} - {\seq_count:N \l_tmpa_seq} - } - \seq_set_from_clist:Nn \l_tmpb_seq {#4} - \int_compare:nNnF {\seq_count:N \l_tmpb_seq} = \l__stex_variables_args_int { - \msg_error:nnxx{stex}{error/seqlength} - {\int_use:N \l__stex_variables_args_int} - {\seq_count:N \l_tmpb_seq} +\stex_new_stylable_cmd:nnnn{interpretmod}{m O{} m m}{ + \stex_structural_feature_morphism:nnnnn{#1}{morphism}{#2}{#3}{,shtml:total=true} + + \clist_map_function:nN{#4}\__stex_morphisms_parse_assign:n + + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: } - \prop_put:Nnn \l_tmpa_prop {starts} {#3} - \prop_put:Nnn \l_tmpa_prop {ends} {#4} + \stex_structural_feature_morphism_check_total: + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \interpretmod {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \iterpretmod +} +\stex_sms_allow_escape:N\interpretmod - \cs_generate_from_arg_count:cNnn {stex_varseq_\l__stex_variables_name_str _cs} - \cs_set:Npn {\int_use:N \l__stex_variables_args_int} { #5 } +\stex_new_stylable_cmd:nnnn{realize}{O{} m m}{ + \stex_structural_feature_morphism:nnnnn{}{morphism}{#1}{#2}{,shtml:total=true} - % argnames + \clist_map_function:nN{#3}\__stex_morphisms_parse_assign:n - \clist_clear:N \l_tmpa_clist - \int_step_inline:nn {\l__stex_variables_args_int} { - \clist_put_right:Nn \l_tmpa_clist {##1} + \stex_if_smsmode:F { + \tl_set:Nn \thiscopyname { #1 } + \tl_set_eq:NN \thismoduleuri \l_stex_current_domain_str + \stex_style_apply: } - \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} - - \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l__stex_variables_name_str _cs}} - \int_step_inline:nn \l__stex_variables_args_int { - \tl_put_right:Nx \l_tmpa_tl { {\seq_item:Nn \l_tmpa_seq {##1}} } + \stex_structural_feature_morphism_check_total: + \stex_structural_feature_morphism_end: + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \realize {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \realize +} +\stex_sms_allow_escape:N\realize +\stex_if_html_backend:TF { + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_false: + } +}{ + \stex_get_env:Nn\__stex_symdecl_env_str{STEX_CHECKTERMS} + \str_if_empty:NF\__stex_symdecl_env_str{ + \exp_args:No \str_if_eq:nnF \__stex_symdecl_env_str{false}{ + \bool_set_true:N \c_stex_check_terms_bool + } } - \tl_set:Nx \l_tmpa_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpa_tl}} - \tl_put_right:Nn \l_tmpa_tl {,\ellipses,} - \tl_if_empty:NF \l__stex_variables_mid_tl { - \tl_put_right:No \l_tmpa_tl \l__stex_variables_mid_tl - \tl_put_right:Nn \l_tmpa_tl {,\ellipses,} + \bool_if:NTF \c_stex_check_terms_bool { + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_true: + } + }{ + \prg_new_conditional:Nnn \stex_if_check_terms: {p, T, F, TF} { + \prg_return_false: + } } - \exp_args:NNo \tl_set:No \l_tmpb_tl {\use:c{stex_varseq_\l__stex_variables_name_str _cs}} - \int_step_inline:nn \l__stex_variables_args_int { - \tl_put_right:Nx \l_tmpb_tl { {\seq_item:Nn \l_tmpb_seq {##1}} } +} +\stex_if_check_terms:TF{ + \cs_new_protected:Nn \stex_check_term:n { + \hbox_set:Nn \l_tmpa_box { + \group_begin: + $#1$ + \group_end: + } } - \tl_set:Nx \l_tmpb_tl {\exp_args:NNo \exp_args:No \exp_not:n{\l_tmpb_tl}} - \tl_put_right:No \l_tmpa_tl \l_tmpb_tl +}{ + \cs_new_protected:Nn \stex_check_term:n {} +} +\stex_keys_define:nnnn{symargs}{ + \str_clear:N \l_stex_key_args_str + \str_clear:N \l_stex_key_role_str + \str_clear:N \l_stex_key_reorder_str + \str_clear:N \l_stex_key_assoc_str +}{ + args .str_set:N = \l_stex_key_args_str , + reorder .str_set:N = \l_stex_key_reorder_str , + assoc .choices:nn = {bin,binl,binr,pre,conj,pwconj} + {\str_set:Nx \l_stex_key_assoc_str \l_keys_choice_tl}, + role .str_set:N = \l_stex_key_role_str +}{} - \prop_put:Nno \l_tmpa_prop { notation }\l_tmpa_tl +\stex_keys_define:nnnn{decl}{ + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_args_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl + \tl_clear:N \l_stex_key_return_tl + \clist_clear:N \l_stex_key_argtypes_clist +}{ + name .str_set:N = \l_stex_key_name_str , - \tl_set:cx {#1} {\stex_invoke_sequence:n {\l__stex_variables_name_str}} + return .tl_set:N = \l_stex_key_return_tl , + argtypes .clist_set:N = \l_stex_key_argtypes_clist , - \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l__stex_variables_name_str _cs}} + type .tl_set:N = \l_stex_key_type_tl , + def .tl_set:N = \l_stex_key_def_tl , - \int_step_inline:nn \l__stex_variables_args_int { - \tl_set:Nx \l_tmpa_tl {\exp_args:No \exp_not:n \l_tmpa_tl { - \STEXInternalTermMathArgiii{i##1}{0}{\exp_not:n{####}##1} - }} + align .code:n = {}, + gfc .code:n = {} +}{style,deprecate,symargs} +\str_new:N \l_stex_macroname_str +\stex_new_stylable_cmd:nnnn {symdecl} { s m O{}} { + \stex_keys_set:nn{decl}{#3} + \IfBooleanTF #1 { + \str_clear:N \l_stex_macroname_str + }{ + \str_set:Nx \l_stex_macroname_str { #2 } } + \stex_symdecl_top:n{#2} - \tl_set:Nx \l_tmpa_tl { - \STEXInternalTermMathOMAiiii { varseq://\l__stex_variables_name_str}{}{0}{ - \exp_args:NNo \exp_args:No \exp_not:n {\l_tmpa_tl} - } + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_set_eq:NN \thistype \l_stex_key_type_tl + \tl_set_eq:NN \thisdefiniens \l_stex_key_def_tl + \tl_set_eq:NN \thisargs \l_stex_key_args_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: } + \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \symdecl {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \symdecl} +\stex_sms_allow_escape:N \symdecl +%% \begin{macro}{\stex_symdecl_top:n} +\cs_new_protected:Nn \stex_symdecl_top:n { + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \__stex_symdecl_add_decl: + \stex_if_do_html:T { + \_stex_symdecl_html: + } +} - \tl_set:No \l_tmpa_tl { \exp_after:wN { \l_tmpa_tl \STEXInternalSymbolAfterInvokationTL} } - - \exp_args:Nno \use:nn { - \cs_generate_from_arg_count:cNnn {stex_varseq_\l__stex_variables_name_str _cs} - \cs_set:Npn {\int_use:N \l__stex_variables_args_int}}{\l_tmpa_tl} - - \stex_debug:nn{sequences}{New~Sequence:~ - \expandafter\meaning\csname stex_varseq_\l__stex_variables_name_str _cs\endcsname\\~\\ - \prop_to_keyval:N \l_tmpa_prop +\cs_new_protected:Nn \__stex_symdecl_add_decl: { + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\tl_if_empty:NF \l_stex_key_def_tl{DEFED} }%{\exp_args:No \exp_not:n \l_stex_key_def_tl} + {}%{\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: } - \prop_set_eq:cN {l_stex_symdecl_varseq://\l__stex_variables_name_str _prop}\l_tmpa_prop + \exp_args:Ne \stex_ref_new_symbol:n + {\l_stex_current_module_str?\l_stex_key_name_str} +} - \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l__stex_variables_name_str}{ - \tl_if_empty:NF \l__stex_variables_type_tl { - \stex_annotate:nnn {type}{}{$\l__stex_variables_type_tl$} - } - \stex_annotate:nnn {args}{\int_use:N \l__stex_variables_args_int}{} - \str_if_empty:NF \l__stex_variables_bind_str { - \stex_annotate:nnn {bindtype}{\l__stex_variables_bind_str}{} - } - \stex_annotate:nnn{startindex}{}{$#3$} - \stex_annotate:nnn{endindex}{}{$#4$} +\cs_new:Nn \_stex_return_args:nn { + {\svar{ARGUMENT_#1}\_stex_eat_exclamation_point:} +} - \tl_clear:N \l_tmpa_tl - \int_step_inline:nn \l__stex_variables_args_int { - \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl { - \stex_annotate:nnn{argmarker}{##1}{} - } } +\cs_new_protected:Nn \_stex_symdecl_html: { + \exp_args:Ne \stex_annotate_invisible:nn { + shtml:symdecl = {\l_stex_current_module_str ? \l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} } - \stex_annotate_invisible:nnn { notationcomp }{}{ - \str_set:Nx \STEXInternalCurrentSymbolStr {varseq://\l__stex_variables_name_str } - $ \exp_args:Nno \use:nn { \use:c { - stex_varseq_\l__stex_variables_name_str _cs - } } { \l_tmpa_tl } $ + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} } - \stex_annotate_invisible:nnn { notationopcomp }{}{ - $ \prop_item:Nn \l_tmpa_prop { notation } $ + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} } - - }} - - \ignorespacesandpars + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + }{\hbox\bgroup\_stex_annotate_force_break:n{ + \bool_set_true:N \stex_in_invisible_html_bool + \tl_if_empty:NF \l_stex_key_type_tl { + $\stex_annotate:nn{shtml:type={}}{\l_stex_key_type_tl}$ + } + \tl_if_empty:NF \l_stex_key_def_tl { + $\stex_annotate:nn{shtml:definiens={}}{\l_stex_key_def_tl}$ + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l__stex_symdecl_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l__stex_symdecl_args_tl {\_stex_map_args:N \_stex_return_args:nn} + $\stex_annotate:nn{shtml:returntype={}}{ + \exp_after:wN \l__stex_symdecl_cs \l__stex_symdecl_args_tl! + }$ + } + \clist_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{\_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + $\stex_annotate:nn{shtml:type={}}{##1}$ + } + }} + } + }\egroup} } - -\keys_define:nn { stex / mmtdecl } { - name .str_set_x:N = \l_stex_symdecl_name_str , - args .str_set_x:N = \l_stex_symdecl_args_str , - deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , - reorder .str_set_x:N = \l_stex_symdecl_reorder_str , - argnames .clist_set:N = \l_stex_symdecl_argnames_clist , - assoc .choices:nn = - {bin,binl,binr,pre,conj,pwconj} - {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} +\cs_new_protected:Nn \stex_symdecl_do: { + \_stex_do_deprecation:n \l_stex_key_name_str + \__stex_symdecl_parse_arity: + \__stex_symdecl_do_args: } -\cs_new_protected:Nn \_stex_mmtdecl_args:n { - \str_clear:N \l_stex_symdecl_name_str - \str_clear:N \l_stex_symdecl_args_str - \str_clear:N \l_stex_symdecl_deprecate_str - \str_clear:N \l_stex_symdecl_reorder_str - \str_clear:N \l_stex_symdecl_assoctype_str - \bool_set_false:N \l_stex_symdecl_local_bool - \clist_clear:N \l_stex_symdecl_argnames_clist +\int_new:N \l_stex_assoc_args_count - \keys_set:nn { stex / symdecl } { #1 } +\cs_new_protected:Nn \__stex_symdecl_parse_arity: { + \int_zero:N \l_stex_get_symbol_arity_int + \int_zero:N \l_stex_assoc_args_count + \str_map_inline:Nn \l_stex_key_args_str { + \str_case:nnF ##1 { + 0 { \str_map_break: } + 1 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {1} + \str_set:Nn \l_stex_key_args_str {i} + } } + 2 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {2} + \str_set:Nn \l_stex_key_args_str {ii} + } } + 3 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {3} + \str_set:Nn \l_stex_key_args_str {iii} + } } + 4 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {4} + \str_set:Nn \l_stex_key_args_str {iiii} + } } + 5 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {5} + \str_set:Nn \l_stex_key_args_str {iiiii} + } } + 6 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {6} + \str_set:Nn \l_stex_key_args_str {iiiiii} + } } + 7 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {7} + \str_set:Nn \l_stex_key_args_str {iiiiiii} + } } + 8 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {8} + \str_set:Nn \l_stex_key_args_str {iiiiiiii} + } } + 9 { \str_map_break:n{ + \int_set:Nn \l_stex_get_symbol_arity_int {9} + \str_set:Nn \l_stex_key_args_str {iiiiiiiii} + } } + i {\int_incr:N \l_stex_get_symbol_arity_int} + b {\int_incr:N \l_stex_get_symbol_arity_int} + a {\int_incr:N \l_stex_get_symbol_arity_int \int_incr:N \l_stex_assoc_args_count} + B {\int_incr:N \l_stex_get_symbol_arity_int \int_incr:N \l_stex_assoc_args_count} + }{ + \msg_error:nnxx{stex}{error/wrongargs}{ + \l_stex_current_module_str ? \l_stex_key_name_str + }{##1} + } + } } -\NewDocumentCommand \mmtdecl { s m O{}} { - \_stex_mmtdecl_args:n{#3} - \IfBooleanTF #1 { - \bool_set_false:N \l_stex_symdecl_make_macro_bool - } { - \bool_set_true:N \l_stex_symdecl_make_macro_bool +\cs_new_protected:Nn \__stex_symdecl_do_args: { + \tl_clear:N \l_stex_get_symbol_args_tl + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \tl_put_right:Nn \l_stex_get_symbol_args_tl {##1} + \tl_put_right:Nx \l_stex_get_symbol_args_tl { + \str_item:Nn \l_stex_key_args_str {##1} + } } - \str_if_empty:NT \l_stex_symdecl_name_str { - \str_set:Nx \l_stex_symdecl_name_str { #1 } +} +\cs_new_protected:Nn \_stex_symdecl_check_terms: { + \stex_check_term:n{ + \stex_debug:nn{check_terms}{Checking~type...} + \group_begin:\l_stex_key_type_tl\group_end: + \stex_debug:nn{check_terms}{Checking~definiens...} + \group_begin:\l_stex_key_def_tl\group_end: + \stex_debug:nn{check_terms}{Checking~return...} + \group_begin:\l_stex_key_return_tl!\group_end: + \stex_debug:nn{check_terms}{Checking~argument~types...} + \group_begin:\l_stex_key_argtypes_clist\group_end: } - %\tl_set:Nx \l_stex_symdecl_definiens_tl { - % \stex_annotate:nnn{ OMID }{ - % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - % }{} +} + +\stex_keys_define:nnnn{textsymdecl}{ + \str_clear:N \l_stex_key_name_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl +}{ + name .str_set:N = \l_stex_key_name_str , + type .tl_set:N = \l_stex_key_type_tl , + def .tl_set:N = \l_stex_key_def_tl +}{style,deprecate} + +\stex_new_stylable_cmd:nnnn {textsymdecl} {m O{} m} { + \stex_keys_set:nn{symdef}{} + \stex_keys_set:nn{textsymdecl}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nn \l_stex_key_name_str {#1} + }%{ + % \str_set:Nx \l_stex_key_name_str {\l_stex_key_name_str-sym} %} - \stex_symdecl_do:n{#2} - \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ - \stex_annotate:nnn{ OMID }{ - \l_stex_current_module_str ? \l_stex_symdecl_name_str - }{}, - \stex_annotate:nnn{ OMID }{ - \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str - }{} + \str_set:Nn \l_stex_key_role_str {textsymdecl} + + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {0}{} + {\tl_if_empty:NF \l_stex_key_def_tl{DEFED} } + {}% type + {\use:c{#1name_nospace}}% return + \stex_invoke_text_symbol: + } + \exp_args:Ne \stex_ref_new_symbol:n + {\l_stex_current_module_str?\l_stex_key_name_str} + \stex_if_do_html:T { + \_stex_symdecl_html: + } + + \int_set:Nn \l_stex_get_symbol_arity_int 0 + \tl_clear:N \l_stex_key_op_tl + \str_clear:N \l_stex_key_intent_str + \str_clear:N \l_stex_key_prec_str + \str_set_eq:NN \l_stex_get_symbol_mod_str \l_stex_current_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{\hbox{#3}} + \_stex_notation_add: + \stex_if_do_html:T { + \def\comp{\_comp} + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_execute_in_module:x{ + \__stex_symdecl_set_textsymdecl_macro:nnn{#1}{\l_stex_current_module_str?\l_stex_key_name_str} + \exp_not:n{{#3}} + } + + \stex_if_smsmode:F{ + \group_begin: + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_clear:N \thisstyle + \stex_style_apply: + \group_end: } \stex_smsmode_do: +}{} +\stex_deactivate_macro:Nn \textsymdecl {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \textsymdecl} +\stex_sms_allow_escape:N \textsymdecl + +\cs_new_protected:Nn \__stex_symdecl_set_textsymdecl_macro:nnn { + \cs_set_protected:cpn{#1name_nospace}{#3} + \cs_set_protected:cpn{#1name}{ + \mode_if_vertical:T{\hbox_unpack:N\c_empty_box} + \mode_if_math:T\hbox{\let\xspace\relax #3} + \mode_if_math:F{\cs_if_exist:NT\xspace\xspace} + } } -\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments} -\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments} +\cs_new_protected:Nn \stex_invoke_text_symbol: { + \mode_if_vertical:T{\hbox_unpack:N\c_empty_box} + \_stex_term_oms_or_omv:nnn{}{}{\maincomp{\let\xspace\relax\l_stex_current_return_tl}} + \group_end:\mode_if_math:F{\cs_if_exist:NT\xspace\xspace} +} +\cs_new_protected:Nn \stex_get_symbol:n { + \_stex_get_symbol:n{ #1 } + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnn{stex}{error/unknownsymbol}{#1} + } +} +\cs_new_protected:Nn \_stex_get_symbol:n { + \str_clear:N \l_stex_get_symbol_mod_str + \str_clear:N \l_stex_get_symbol_name_str + \cs_if_exist:cTF { #1 }{ + \cs_set_eq:Nc \l__stex_symdecl_cs { #1 } + % command name + \exp_args:Ne \tl_if_empty:nTF { \cs_argument_spec:N \l__stex_symdecl_cs }{ + % ...that takes no arguments + \exp_args:Ne \cs_if_eq:NNTF {\tl_head:N \l__stex_symdecl_cs} + \_stex_invoke_symbol:nnnnnnnN + \__stex_symdecl_get_symbol_from_cs: + {\__stex_symdecl_get_symbol_from_string:n { #1 }} + }{ + \__stex_symdecl_get_symbol_from_string:n { #1 } + } + }{ + \__stex_symdecl_get_symbol_from_string:n { #1 } + } +} +\int_new:N \l_stex_get_symbol_arity_int +\cs_new_protected:Nn \__stex_symdecl_get_symbol_from_cs: { + \stex_debug:nn{symbols}{Getting~from~cs...} + \stex_pseudogroup_with:nn{\_stex_invoke_symbol:nnnnnnnN}{ + \cs_set:Npn \_stex_invoke_symbol:nnnnnnnN ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 { + \str_set:Nn \l_stex_get_symbol_mod_str {##1} + \str_set:Nn \l_stex_get_symbol_name_str {##2} + \int_set:Nn \l_stex_get_symbol_arity_int {##3} + \tl_set:Nn \l_stex_get_symbol_args_tl {##4} + \tl_set:Nn \l_stex_get_symbol_def_tl {##5} + \tl_set:Nn \l_stex_get_symbol_type_tl {##6} + \tl_set:Nn \l_stex_get_symbol_return_tl {##7} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {##8} + } + \l__stex_symdecl_cs + } +} -%%%%%%%%%%%%% terms.dtx %%%%%%%%%%%%% +\cs_new_protected:Nn \__stex_symdecl_get_symbol_from_string:n { + \stex_debug:nn{symbols}{Getting~from~string~#1...} + \seq_set_split:Nnn \l__stex_symdecl_seq ? {#1} + \seq_pop_right:NN \l__stex_symdecl_seq \l__stex_symdecl_name + \seq_if_empty:NTF \l__stex_symdecl_seq { + \exp_args:No \__stex_symdecl_get_from_one_string:n {#1} + }{ + \exp_args:NNe \exp_args:Nno \__stex_symdecl_get_symbol_from_modules:nn { + \seq_use:Nn \l__stex_symdecl_seq ? + } \l__stex_symdecl_name + } +} -\msg_new:nnn{stex}{error/nonotation}{ - Symbol~#1~invoked,~but~has~no~notation#2! +\cs_new_protected:Nn \__stex_symdecl_sym_from_str_i:nnnn { + \bool_lazy_any:nTF{ + {\str_if_eq_p:nn{#2}{#3}} + {\str_if_eq_p:nn{#2}{#4}} + {\stex_str_if_ends_with_p:nn{#4}{/#2}} + }{ + \__stex_symdecl_sym_i_finish:nnnnnnnN{#1}{#4} + }{ + \__stex_symdecl_sym_i_gobble:nnnnnn + } } -\msg_new:nnn{stex}{error/notationarg}{ - Error~in~parsing~notation~#1 +\cs_new_protected:Nn \__stex_symdecl_sym_i_gobble:nnnnnn {} + +\cs_new_protected:Nn \__stex_symdecl_sym_i_finish:nnnnnnnN { + \prop_map_break:n{\seq_map_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str {#1} + \str_set:Nn \l_stex_get_symbol_name_str {#2} + \int_set:Nn \l_stex_get_symbol_arity_int {#3} + \tl_set:Nn \l_stex_get_symbol_args_tl {#4} + \tl_set:Nn \l_stex_get_symbol_def_tl {#5} + \tl_set:Nn \l_stex_get_symbol_type_tl {#6} + \tl_set:Nn \l_stex_get_symbol_return_tl {#7} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#8} + }} } -\msg_new:nnn{stex}{error/noop}{ - Symbol~#1~has~no~operator~notation~for~notation~#2 + +\cs_new_protected:Nn \__stex_symdecl_get_symbol_from_modules:nn { + \stex_debug:nn{symbols}{Getting~#2~in~#1...} + \seq_map_inline:Nn \l_stex_all_modules_seq { + \stex_str_if_ends_with:nnT{##1}{#1}{ + \prop_map_inline:cn{c_stex_module_##1_symbols_prop}{ + \__stex_symdecl_sym_from_str_i:nnnn{##1}{#2} ####2 + } + } + } } -\msg_new:nnn{stex}{error/notallowed}{ - Symbol~invokation~#1~not~allowed~in~notation~component~of~#2 + +\cs_new_protected:Nn \__stex_symdecl_get_from_one_string:n { + \stex_debug:nn{symbols}{Getting~#1~anywhere...} + \stex_iterate_symbols:n{ + %\stex_debug:nn{symbols}{>#1==##2~|~#1==##3<...} + \bool_lazy_any:nT{ + {\str_if_eq_p:nn{#1}{##2}} + {\str_if_eq_p:nn{#1}{##3}} + {\stex_str_if_ends_with_p:nn{##3}{/#1}} + }{ + \stex_iterate_break:n{ + \str_set:Nn \l_stex_get_symbol_mod_str {##1} + \str_set:Nn \l_stex_get_symbol_name_str {##3} + \int_set:Nn \l_stex_get_symbol_arity_int {##4} + \tl_set:Nn \l_stex_get_symbol_args_tl {##5} + \tl_set:Nn \l_stex_get_symbol_def_tl {##6} + \tl_set:Nn \l_stex_get_symbol_type_tl {##7} + \tl_set:Nn \l_stex_get_symbol_return_tl {##8} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {##9} + } + } + } } -\msg_new:nnn{stex}{error/doubleargument}{ - Argument~#1~of~symbol~#2~already~assigned +\cs_new:Nn \_stex_map_args:N { + \tl_if_empty:NF \l_stex_get_symbol_args_tl { + \exp_after:wN \__stex_notations_map_args_i:w \exp_after:wN + #1 \l_stex_get_symbol_args_tl \__stex_notations_args_end: + } } -\msg_new:nnn{stex}{error/overarity}{ - Argument~#1~invalid~for~symbol~#2~with~arity~#3 +\cs_new:Npn \__stex_notations_map_args_i:w #1 #2 #3 #4 \__stex_notations_args_end: { + #1 #2 #3 + \tl_if_empty:nF{#4}{ + \__stex_notations_map_args_i:w #1 #4 \__stex_notations_args_end: + } } +\cs_new:Nn \_stex_map_notation_args:N { + \tl_if_empty:NF \l_stex_notation_args_tl { + \exp_after:wN \__stex_notations_map_args_ii:w \exp_after:wN + #1 \l_stex_get_symbol_args_tl \__stex_notations_args_end: + } +} +\cs_new:Npn \__stex_notations_map_args_ii:w #1 #2 #3 #4 #5 #6 \__stex_notations_args_end: { + #1 #2 #3 #4 #5 + \tl_if_empty:nF{#6}{ + \__stex_notations_map_args_ii:w #1 #6 \__stex_notations_args_end: + } +} +\stex_keys_define:nnnn{notation}{ + \str_clear:N \l_stex_key_variant_str + \str_clear:N \l_stex_key_prec_str + \str_clear:N \l_stex_key_op_tl + \str_clear:N \l_stex_key_intent_str + \clist_clear:N \l_stex_key_intent_args_clist +}{ + variant .str_set_x:N = \l_stex_key_variant_str , + prec .str_set_x:N = \l_stex_key_prec_str , + op .tl_set:N = \l_stex_key_op_tl , + intent .str_set:N = \l_stex_key_intent_str , + argnames .clist_set:N = \l_stex_key_intent_args_clist , + unknown .code:n = { + \str_set_eq:NN \l_stex_key_variant_str \l_keys_key_str + } +}{style} +\stex_new_stylable_cmd:nnnn {notation} { s m O{} m} { + \stex_keys_set:nn{notation}{#3} + \stex_get_symbol:n{#2} + \stex_notation_parse:n{#4} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_notation_add: + \stex_if_do_html:T { + \def\comp{\_comp} + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \IfBooleanTF#1{ + \_stex_notation_set_default:n{ + \l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str + } + }{} + \stex_if_smsmode:F{ + \group_begin: + \__stex_notations_styledefs: + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} -\bool_new:N \l_stex_allow_semantic_bool -\bool_set_true:N \l_stex_allow_semantic_bool +\cs_new_protected:Nn \__stex_notations_styledefs: { + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \str_set:Nn \thisdeclname \l_stex_get_symbol_name_str + \tl_set:Nx \thisdecluri {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \def\thisnotation{ + $ + \tl_set_eq:NN \l_stex_current_symbol_str\thisdecluri + \exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs}{ + \_stex_notation_make_args: + }$ + } +} -\cs_new_protected:Nn \stex_invoke_symbol:n { - \ifvmode\indent\fi - \bool_if:NTF \l_stex_allow_semantic_bool { - \str_if_eq:eeF { - \prop_item:cn { - l_stex_symdecl_#1_prop - }{ deprecate } - }{}{ - \msg_warning:nnxx{stex}{warning/deprecated}{ - Symbol~#1 - }{ - \prop_item:cn {l_stex_symdecl_#1_prop}{ deprecate } - } +\stex_deactivate_macro:Nn \notation {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \notation} +\stex_sms_allow_escape:N \notation +\cs_new_protected:Nn \stex_notation_parse:n { + \tl_if_empty:NF \l_stex_key_op_tl { + \tl_set:Nx \l_stex_key_op_tl { \exp_not:N\maincomp { + \exp_args:No \exp_not:n \l_stex_key_op_tl + } } + } + \seq_clear:N \l__stex_notations_precs_seq + \tl_clear:N \l_stex_notation_args_tl + \int_compare:nNnTF \l_stex_get_symbol_arity_int = 0 { + \__stex_notations_const_precs: + \tl_if_empty:NT \l_stex_key_op_tl { + \tl_set:Nn \l_stex_key_op_tl { \maincomp{#1} } } - \if_mode_math: - \exp_after:wN \__stex_terms_invoke_math:n - \else: - \exp_after:wN \__stex_terms_invoke_text:n - \fi: { #1 } }{ - \msg_error:nnxx{stex}{error/notallowed}{#1}{\STEXInternalCurrentSymbolStr} + \__stex_notations_fun_precs: + \str_set:Nn \l__stex_notations_missing_str {#1} + \tl_clear:N \l__stex_notations_missing_tl + \_stex_map_args:N \__stex_notations_add_missing_args:nn + \tl_if_empty:NT \l_stex_key_op_tl { + \hbox_set:Nn \l_tmpa_box { + \str_set:Nn \l_stex_current_symbol_str {} + \cs_set:Npn \l_tmpa_cs ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 ##9 { #1 } + \cs_set:Npn \maincomp ##1 { + \tl_gset:Nn \l_stex_key_op_tl { \maincomp{##1} } + ##1 + } + \cs_set:Npn \argsep ##1 ##2 {##1 ##2} + \cs_set:Npn \argmap ##1 ##2 ##3 {##1 ##3} + \cs_set:Npn \argarraymap ##1 ##2 ##3 ##4 { + ##1 ##2 + } + \stex_suppress_html:n{$\l_tmpa_cs abcdefghj$} + } + } + } + \exp_args:NNe + \tl_set:Nn \l_stex_notation_macrocode_cs { + \STEXInternalNotation + { \l_stex_key_variant_str } + { \l__stex_notations_opprec_tl } + { \l_stex_key_intent_str } + { \l_stex_notation_args_tl } + { + \int_compare:nNnTF \l_stex_get_symbol_arity_int = 0 + { \exp_not:n { \maincomp{ #1 } } } + { \exp_not:n { #1 } \l__stex_notations_missing_tl } + } } + \stex_debug:nn{notation}{Notation:~\meaning\l_stex_notation_macrocode_cs} } -\cs_new_protected:Nn \__stex_terms_invoke_text:n { - \peek_charcode_remove:NTF ! { - \__stex_terms_invoke_op_custom:nn {#1} +\cs_new_protected:Nn \__stex_notations_const_precs: { + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:No \l__stex_notations_opprec_tl { \neginfprec } }{ - \__stex_terms_invoke_custom:nn {#1} + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \tl_set:No \l__stex_notations_opprec_tl { \neginfprec } + }{ + \tl_set_eq:NN \l__stex_notations_opprec_tl \l_stex_key_prec_str + } } } -\cs_new_protected:Nn \__stex_terms_invoke_math:n { - \peek_charcode_remove:NTF ! { - % operator - \peek_charcode_remove:NTF * { - % custom op - \__stex_terms_invoke_op_custom:nn {#1} +\cs_new_protected:Nn \__stex_notations_fun_precs: { + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:No \l__stex_notations_opprec_tl { \neginfprec } + }{ + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \tl_set:No \l__stex_notations_opprec_tl { \neginfprec } }{ - % op notation - \peek_charcode:NTF [ { - \__stex_terms_invoke_op_notation:nw {#1} - }{ - \__stex_terms_invoke_op_notation:nw {#1}[] + \tl_set_eq:NN \l__stex_notations_opprec_tl \l_stex_key_prec_str + } + } + \str_if_empty:NTF \l_stex_key_prec_str { + \tl_set:Nn \l__stex_notations_opprec_tl { 0 } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \seq_put_right:Nn \l__stex_notations_precs_seq {0} + } + }{ + \str_if_eq:onTF \l_stex_key_prec_str {nobrackets}{ + \stex_debug:nn{notation}{No~brackets} + \tl_set:No \l__stex_notations_opprec_tl { \neginfprec } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \exp_args:NNo \seq_put_right:Nn \l__stex_notations_precs_seq \infprec } + }\__stex_notations_parse_precs: + } + \__stex_notations_do_argnames: +} + +\cs_new_protected:Nn \__stex_notations_parse_precs: { + \stex_debug:nn{notation}{parsing~precedence~\l_stex_key_prec_str} + \seq_set_split:NnV \l__stex_notations_seq ; \l_stex_key_prec_str + \seq_pop_left:NNTF \l__stex_notations_seq \l__stex_notations_str { + \tl_set_eq:NN \l__stex_notations_opprec_tl \l__stex_notations_str + \seq_pop_left:NNT \l__stex_notations_seq \l__stex_notations_str { + \exp_args:NNo \seq_set_split:NnV \l__stex_notations_seq + {\tl_to_str:n{x}} \l__stex_notations_str } }{ - \peek_charcode_remove:NTF * { - \__stex_terms_invoke_custom:nn {#1} - % custom + \tl_set:No \l__stex_notations_opprec_tl { 0 } + } + \int_step_inline:nn \l_stex_get_symbol_arity_int { + \seq_pop_left:NNTF \l__stex_notations_seq \l__stex_notations_str { + \seq_put_right:No \l__stex_notations_precs_seq \l__stex_notations_str }{ - % normal - \peek_charcode:NTF [ { - \__stex_terms_invoke_notation:nw {#1} - }{ - \__stex_terms_invoke_notation:nw {#1}[] - } + \seq_put_right:No \l__stex_notations_precs_seq \l__stex_notations_opprec_tl } } } -\cs_new_protected:Nn \__stex_terms_invoke_op_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \stex_mathml_intent:nn{#1}{ - \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{ - \comp{ #2 } +\cs_new_protected:Nn \__stex_notations_do_argnames: { + \tl_clear:N \l_stex_notation_args_tl + \_stex_map_args:N \__stex_notations_do_argname:nn +} + +\cs_new_protected:Nn \__stex_notations_do_argname:nn { + \clist_if_empty:NTF \l_stex_key_intent_args_clist { + \tl_put_right:Nx \l_stex_notation_args_tl { + #1#2{\seq_item:Nn \l__stex_notations_precs_seq #1}{ + \str_if_empty:NF \l_stex_key_intent_str {#1} } } }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool + \tl_put_right:Nx \l_stex_notation_args_tl { + #1#2{\seq_item:Nn \l__stex_notations_precs_seq #1} + {\c_dollar_str\clist_item:Nn \l_stex_key_intent_args_clist 1} + } + \clist_pop:NN \l_stex_key_intent_args_clist \l_tmpa_tl } } -\keys_define:nn { stex / terms } { - variant .tl_set_x:N = \l_stex_notation_variant_str , - unknown .code:n = \str_set:Nx - \l_stex_notation_variant_str \l_keys_key_str +\cs_new:Nn \__stex_notations_add_missing_args:nn { + \exp_args:NNe \str_if_in:NnF \l__stex_notations_missing_str {\c_hash_str\c_hash_str#1}{ + \tl_put_right:Nn \l__stex_notations_missing_tl{\STEXinvisible{## #1}} + } +} +\cs_new_protected:Nn \_stex_notation_check: { + \stex_check_term:n{ + \str_set:Nn \l_stex_current_symbol_str {test} + \cs_set:Npn \comp ##1 {##1} + \stex_debug:nn{check_terms}{Checking~notation...} + \exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + } + } } -\cs_new_protected:Nn \__stex_terms_args:n { - % \str_clear:N \l_stex_notation_lang_str - \str_clear:N \l_stex_notation_variant_str - - \keys_set:nn { stex / terms } { #1 } +\cs_new_protected:Nn \_stex_notation_add: { + \stex_module_add_notation:eoeoo{ + \l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str + }\l_stex_key_variant_str + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_notation_macrocode_cs + \l_stex_key_op_tl } -\cs_new_protected:Nn \stex_find_notation:nn { - \__stex_terms_args:n { #2 } - \seq_if_empty:cTF { - l_stex_symdecl_ #1 _notations - } { - \msg_error:nnxx{stex}{error/nonotation}{#1}{s} - } { - \str_if_empty:NTF \l_stex_notation_variant_str { - \seq_get_left:cN {l_stex_symdecl_#1_notations}\l_stex_notation_variant_str - }{ - \seq_if_in:cxTF {l_stex_symdecl_#1_notations}{ - \l_stex_notation_variant_str - }{ - % \str_set:Nx \l_stex_notation_variant_str { \l_stex_notation_variant_str \c_hash_str \l_stex_notation_lang_str } - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str +\cs_new_protected:Nn \_stex_notation_do_html:n { + \hbox{\stex_annotate_invisible:nn { + shtml:notation={#1}, + shtml:notationfragment={\l_stex_key_variant_str}, + shtml:precedence={\l__stex_notations_opprec_tl}, + shtml:argprecs={\seq_use:Nn \l__stex_notations_precs_seq ,} + }{ + \cs_set_protected:Npn \argsep ##1 ##2 { + \stex_annotate:nn{shtml:argsep={}}{ + ##1 ##2 + } + } + \cs_set_protected:Npn \argmap ##1 ##2 ##3 { + \cs_set:Npn \__stex_notations_map_cs: ####1 { ##2 } + \stex_annotate:nn{shtml:argmap={}}{ + \__stex_notations_map_cs:{##1} ##3 + } + } + \cs_set_protected:Npn \maincomp { + \_do_comp:nNn {maincomp}\compemph@uri + } + $ + \str_set:Nx \l_stex_current_symbol_str {#1} + \stex_annotate:nn{shtml:notationcomp={}}{ + \exp_args:Nne \use:nn { + \l_stex_notation_macrocode_cs {} + }{ + \_stex_map_args:N \__stex_notations_make_arg_html:nn } } + $ + \tl_if_empty:NF \l_stex_key_op_tl { + $ + \str_set:Nx \l_stex_current_symbol_str {#1} + \stex_annotate:nn{shtml:notationopcomp={}}{ + \_stex_term_oms:nnn{\l_stex_key_variant_str}{}{\l_stex_key_op_tl} + } + $ } - } + }} } -\cs_new_protected:Npn \__stex_terms_invoke_op_notation:nw #1 [#2] { - \exp_args:Nnx \use:nn { - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \stex_find_notation:nn { #1 }{ #2 } - \bool_set_false:N \l_stex_allow_semantic_bool - \cs_if_exist:cTF { - stex_op_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs +\cs_new:Nn \__stex_notations_make_arg_html:nn { + { + \stex_annotate:nn{shtml:argnum=#1}{x} + } +} + +\cs_new:Nn \_stex_notation_make_args: { + \_stex_map_notation_args:N \__stex_notations_make_arg:nnnn +} + +\cs_new:Nn \__stex_notations_make_arg:nnnn { + \str_case:nnF #2 { + a {{ + a\c_math_subscript_token{#1,1}, + a\c_math_subscript_token{#1,2} + }} + B {{ + B\c_math_subscript_token{#1,1}, + B\c_math_subscript_token{#1,2} + }} + }{ + \_stex_term_arg:nnnnn{#1}{#2}{#3}{#4} + {{#2}\c_math_subscript_token{#1}} + } +} +\cs_new_protected:Npn \setnotation #1 #2 { + \stex_get_symbol:n{#1} + \cs_if_exist:cTF{l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _#2_cs + }{ + \tl_set_eq:Nc \l_stex_notation_macrocode_cs {l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _#2_cs + } + \cs_if_exist:cTF{l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _op_#2_cs }{ - \_stex_term_oms:nnn { #1 }{ - #1 \c_hash_str \l_stex_notation_variant_str - }{ - \use:c{stex_op_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} + \tl_set_eq:Nc \l_stex_key_op_tl {l_stex_notation_ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + _op_#2_cs } }{ - \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_#1_prop}{arity}} = 0{ - \cs_if_exist:cTF { - stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs - }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str - } - } - }{ - \msg_error:nnxx{stex}{error/noop}{#1}{\l_stex_notation_variant_str} - } + \tl_clear:N \l_stex_key_op_tl + } + \_stex_notation_set_default:n{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str } }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool + \msg_error:nnxx{stex}{unknownnotation}{#2}{ + \l_stex_get_symbol_mod_str?\l_stex_get_symbol_name_str + } } } -\cs_new_protected:Npn \__stex_terms_invoke_notation:nw #1 [#2] { - \stex_find_notation:nn { #1 }{ #2 } - \cs_if_exist:cTF { - stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs +\cs_new_protected:Nn \_stex_notation_set_default:n{ + \stex_module_add_notation:eoeoo{#1}{} + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_notation_macrocode_cs + \l_stex_key_op_tl +} +\stex_new_stylable_cmd:nnnn {varnotation} { s m O{} m} { + \stex_keys_set:nn{notation}{#3} + \stex_get_var:n{#2} + \str_set_eq:NN \l_stex_key_name_str \l_stex_get_symbol_name_str + \stex_notation_parse:n{#4} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_vardecl_notation_macro: + \IfBooleanTF#1{ + \_stex_notation_set_default:n{\l_stex_get_symbol_name_str} + }{} + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_get_symbol_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + }$ + } + \stex_style_apply: + \group_end: +}{} +\stex_keys_define:nnnn{symdef}{}{}{decl,notation} + +\cs_new_protected:Nn \_stex_symdef_styledefs: { + \tl_set:Nx \thisdecluri {\l_stex_current_module_str ? \l_stex_key_name_str} + \tl_set_eq:NN \thisdeclname \l_stex_key_name_str + \tl_set_eq:NN \thistype \l_stex_key_type_tl + \tl_set_eq:NN \thisdefiniens \l_stex_key_def_tl + \tl_set_eq:NN \thisargs \l_stex_key_args_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisdecluri + \def\comp{\_comp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs}{ + \_stex_notation_make_args: + }$ + } +} + +\stex_new_stylable_cmd:nnnn {symdef} { m O{} m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \stex_symdecl_top:n{#1} + \stex_debug:nn{symdef}{Doing~\l_stex_current_module_str ? \l_stex_key_name_str} + \str_set_eq:NN \l_stex_get_symbol_mod_str \l_stex_current_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{#3} + \stex_debug:nn{Here!}{\meaning\l_stex_notation_args_tl} + \_stex_notation_check: + \_stex_notation_add: + \stex_if_do_html:T{ + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_if_smsmode:F{ + \group_begin: + \_stex_symdef_styledefs: + \stex_style_apply: + \group_end: + } + \stex_smsmode_do: +}{} + +\stex_deactivate_macro:Nn \symdef {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \symdef} +\stex_sms_allow_escape:N \symdef +\cs_new_protected:Nn \stex_do_default_notation: { + \stex_do_default_notation_op: + \tl_if_empty:NTF \l_stex_current_args_tl { + \tl_clear:N \l__stex_notations_args_tl }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool + \__stex_notations_make_name: + \tl_set_eq:NN \l_stex_get_symbol_args_tl \l_stex_current_args_tl + \tl_set:Nx \l__stex_notations_args_tl { + \_stex_map_args:N \__stex_notations_augment_arg:nn } - \def\comp{\_comp} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_notation_ #1 \c_hash_str \l_stex_notation_variant_str _cs} - }{ - \msg_error:nnxx{stex}{error/nonotation}{#1}{ - ~\l_stex_notation_variant_str + \tl_put_right:Nn \l_stex_default_notation {\comp(} + \seq_clear:N \l_tmpa_seq + \int_step_inline:nn \l_stex_current_arity_str { + \seq_put_right:Nn \l_tmpa_seq {#### ##1} + } + \tl_put_right:Nx \l_stex_default_notation { + \seq_use:Nn \l_tmpa_seq {\mathpunct{\comp{,}}} } + \tl_put_right:Nn \l_stex_default_notation {\comp)} } + \tl_set:Nx \l_stex_default_notation {\STEXInternalNotation{}{0}{}{\l__stex_notations_args_tl}{ + \exp_args:No \exp_not:n \l_stex_default_notation + }} } -\prop_new:N \l__stex_terms_custom_args_prop -\clist_new:N \l_stex_argnames_seq -\seq_new:N \l__stex_terms_tmp_seq +\cs_new:Nn \__stex_notations_augment_arg:nn { + #1#2{0}{} +} -\cs_new_protected:Nn\__stex_terms_custom_comp:n{\bool_set_false:N \l_stex_allow_semantic_bool\_comp{#1}\bool_set_true:N \l_stex_allow_semantic_bool} +\cs_new_protected:Nn \__stex_notations_make_name: { + \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq ? \l_stex_current_symbol_str + \seq_pop_right:NN \l_tmpa_seq \l__stex_notations_name_str + \exp_args:NNNo \seq_set_split:Nnn \l_tmpa_seq / \l__stex_notations_name_str + \seq_pop_right:NN \l_tmpa_seq \l__stex_notations_name_str +} -\cs_new_protected:Nn \__stex_terms_invoke_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\__stex_terms_custom_comp:n} - \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } - \prop_clear:N \l__stex_terms_custom_args_prop - \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1} - \prop_get:cnN { - l_stex_symdecl_#1 _prop - }{ args } \l_tmpa_str - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str - \tl_set:Nn \arg { \__stex_terms_arg: } - \str_if_empty:NTF \l_tmpa_str { - \stex_mathml_intent:nn{#1}{ - \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2} - } - }{ - \seq_clear:N \l__stex_terms_tmp_seq - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l__stex_terms_tmp_tl + - } - \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl - } - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l__stex_terms_tmp_seq , - ) - }{ - \str_if_in:NnTF \l_tmpa_str b { - \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - }{ - \str_if_in:NnTF \l_tmpa_str B { - \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - }{ - \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} - } - } - } - } - % TODO check that all arguments exist +\cs_new_protected:Nn \stex_do_default_notation_op: { + \__stex_notations_make_name: + \tl_set:Nx \l_stex_default_notation {\exp_not:N \maincomp{ \exp_not:N \mathrm {\l__stex_notations_name_str} }} +} + +\cs_new_protected:Npn \STEXInternalNotation #1 #2 #3 #4 #5 #6 { + \__stex_notations_process_notation:nnnnnn{#1}{#2}{#3}{#4}{#5}{ + \l__stex_notations_code_tl + #6 + } +} + +\cs_new_protected:Npn \__stex_notations_process_notation:nnnnnn #1 #2 #3 #4 { + \tl_if_empty:nTF{#4}{ + \__stex_notations_simple:nnnnn{#1}{#2}{#3} }{ - \_stex_reset:N \l_stex_argnames_seq - \_stex_reset:N \STEXInternalCurrentSymbolStr - \_stex_reset:N \arg - \_stex_reset:N \comp - \_stex_reset:N \l__stex_terms_custom_args_prop - %\bool_set_true:N \l_stex_allow_semantic_bool + \__stex_notations_complex:nnnnnn{#1}{#2}{#3}{#4} } } -\NewDocumentCommand \__stex_terms_arg: { s O{} m}{ - \tl_if_empty:nTF {#2}{ - \int_set:Nn \l_tmpa_int {\prop_item:Nn \l__stex_terms_custom_args_prop {currnum}} - \bool_set_true:N \l_tmpa_bool - \bool_do_while:Nn \l_tmpa_bool { - \exp_args:NNx \prop_if_in:NnTF \l__stex_terms_custom_args_prop {\int_use:N \l_tmpa_int} { - \int_incr:N \l_tmpa_int - }{ - \bool_set_false:N \l_tmpa_bool +\cs_new_protected:Nn \__stex_notations_simple:nnnnn { + \stex_debug:nn{Notation~code}{\tl_to_str:n{#4}} + \tl_set:Nn \l__stex_notations_code_tl { + \cs_set:Npn \l__stex_notations_cs { + \_stex_maybe_brackets:nn{#2}{ + \_stex_term_oms_or_omv:nnn{#1}{#3}{#4} } } - }{ - \int_set:Nn \l_tmpa_int { #2 } + \l__stex_notations_cs } - \str_set:Nx \l_tmpa_str {\prop_item:Nn \l__stex_terms_custom_args_prop {args} } - \int_compare:nNnT \l_tmpa_int > {\str_count:N \l_tmpa_str} { - \msg_error:nnxxx{stex}{error/overarity} - {\int_use:N \l_tmpa_int} - {\STEXInternalCurrentSymbolStr} - {\str_count:N \l_tmpa_str} + \stex_debug:nn{Here:Notation}{\meaning \l__stex_notations_code_tl } + #5 +} + +\cs_new_protected:Nn \__stex_notations_complex:nnnnnn { + \stex_debug:nn{Notation~code}{\tl_to_str:n{#5}} + \int_zero:N \l_tmpa_int + \tl_set:Nn \l__stex_notations_pre_tl {\cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_oma:nnn} + \tl_set:Nn \l__stex_notations_code_tl { + \cs_generate_from_arg_count:NNnn \l__stex_notations_cs \cs_set:Npn \l_tmpa_int + { + \_stex_maybe_brackets:nn{#2}{ + \_stex_term_oma_or_omb:nnn{#1}{#3}{ + \bool_set_false:N \l_stex_brackets_dones_bool + #5 + } + } + } + \l__stex_notations_cs } - \str_set:Nx \l_tmpa_str {\str_item:Nn \l_tmpa_str \l_tmpa_int} - \exp_args:NNx \prop_if_in:NnT \l__stex_terms_custom_args_prop {\int_use:N \l_tmpa_int} { - \bool_lazy_any:nF { - {\str_if_eq_p:Vn \l_tmpa_str {a}} - {\str_if_eq_p:Vn \l_tmpa_str {B}} - }{ - \msg_error:nnxx{stex}{error/doubleargument} - {\int_use:N \l_tmpa_int} - {\STEXInternalCurrentSymbolStr} + \tl_set:Nn \l__stex_notations_after_tl{ + \exp_args:NNo + \tl_put_left:Nn \l__stex_notations_code_tl \l__stex_notations_pre_tl + \tl_put_left:Nx \l__stex_notations_code_tl { + \int_set:Nn \l_tmpa_int {\int_use:N \l_tmpa_int} } + \stex_debug:nn{Here:Notation}{\meaning \l__stex_notations_code_tl } + #6 } - \exp_args:NNx \prop_put:Nnn \l__stex_terms_custom_args_prop {\int_use:N \l_tmpa_int} {\ignorespaces#3} - \bool_if:NTF \l_stex_allow_semantic_bool \use_i:nn { - \bool_set_true:N \l_stex_allow_semantic_bool - \use:nn + \__stex_notations_parse_notation_args:nnnnw #4 \__stex_notations_args_end: +} + +\cs_new_protected:Npn \__stex_notations_parse_notation_args:nnnnw #1 #2 #3 #4 #5 \__stex_notations_args_end: { + \tl_if_empty:nTF{#5}{ + \__stex_notations_add_last:nnnnn{#1}{#2}{#3}{#4} + }{ + \__stex_notations_add_next:nnnnnn{#1}{#2}{#3}{#4}{#5} } - { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ - \IfBooleanTF#1{ - \stex_annotate_invisible:n { %TODO - \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} - } - }{ %TODO - \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} - } - }} - {\bool_set_false:N \l_stex_allow_semantic_bool} } -\cs_new_protected:Nn \_stex_term_arg:nn { - \bool_set_true:N \l_stex_allow_semantic_bool - \stex_annotate:nnn{ arg }{ #1 }{ #2 } - \bool_set_false:N \l_stex_allow_semantic_bool +\cs_new_protected:Nn \__stex_notations_add_next:nnnnnn { + \__stex_notations_add:nnnnn{#1}{#2}{#3}{#4}{#6} + \__stex_notations_parse_notation_args:nnnnw #5 \__stex_notations_args_end: } -\cs_new_protected:Npn \STEXInternalTermMathArgiii #1#2#3 { - \exp_args:Nnx \use:nn - { \int_set:Nn \l__stex_terms_downprec { #2 } - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ - \_stex_term_arg:nn { #1 }{ #3 } +\cs_new_protected:Nn \__stex_notations_add_last:nnnnn { + \__stex_notations_add:nnnnn{#1}{#2}{#3}{#4}{#5} + \l__stex_notations_after_tl +} + +\cs_new_protected:Nn \__stex_notations_add:nnnnn { + \int_incr:N \l_tmpa_int + \str_case:nn{#2}{ + i { + \tl_put_right:Nn \l__stex_notations_code_tl { + {\_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{#5}} } } - { \int_set:Nn \exp_not:N \l__stex_terms_downprec { \int_use:N \l__stex_terms_downprec } } -} -\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiiii #1#2#3#4#5 { - \cs_set:Npn \l_tmpa_cs ##1 ##2 { #4 } - \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#5#1}{#2}} - \tl_if_empty:nTF { #3 }{ - \STEXInternalTermMathArgiii{#5#1}{#2}{} - }{ - \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #3 }}{ - \expandafter\if\expandafter\relax\noexpand#3 - \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_maybe_sequence:Nnn#3{#1}{#5}} - \else - \tl_set:Nn \l_tmpa_tl {\__stex_terms_math_assoc_arg_simple:nnn{#1}{#3}{#5}} - \fi - \l_tmpa_tl - }{ - \__stex_terms_math_assoc_arg_simple:nnn{#1}{#3}{#5} - } - } -} - -\cs_new_protected:Nn \__stex_terms_math_assoc_arg_maybe_sequence:Nnn { - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N #1 } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N #1 - } \stex_invoke_sequence:n { - \tl_set:Nx \l_tmpa_tl {\tl_tail:N #1} - \str_set:Nx \l_tmpa_str {\exp_after:wN \use:n \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\prop_item:cn {l_stex_symdecl_varseq://\l_tmpa_str _prop}{notation}} - \exp_args:NNo \seq_set_from_clist:Nn \l_tmpa_seq \l_tmpa_tl - \tl_set:Nx \l_tmpa_tl {{\exp_not:N \exp_not:n{ - \exp_not:n{\exp_args:Nnx \use:nn} { - \exp_not:n { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr - } {varseq://\l_tmpa_str} - \exp_not:n{ ##1 } - }{ - \exp_not:n { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - } - } - }}} - \exp_args:Nno \use:n {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl - \seq_reverse:N \l_tmpa_seq - \seq_pop:NN \l_tmpa_seq \l_tmpa_tl - \seq_map_inline:Nn \l_tmpa_seq { - \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl { - \exp_args:Nno - \l_tmpa_cs { ##1 } \l_tmpa_tl - } + b { + \tl_set:Nn \l__stex_notations_pre_tl { + \cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_omb:nnn } - \tl_set:Nx \l_tmpa_tl { - \_stex_term_omv:nn {varseq://\l_tmpa_str}{ - \exp_args:No \exp_not:n \l_tmpa_tl - } + \tl_put_right:Nn \l__stex_notations_code_tl { + {\_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + a { + \tl_put_right:Nn \l__stex_notations_code_tl { + {\_stex_term_arg_aB:nnnnn{#1}{#2}{#3}{#4}{#5}} + } + } + B { + \tl_set:Nn \l__stex_notations_pre_tl { + \cs_set_eq:NN \_stex_term_oma_or_omb:nnn \_stex_term_omb:nnn + } + \tl_put_right:Nn \l__stex_notations_code_tl { + {\_stex_term_arg_aB:nnnnn{#1}{#2}{#3}{#4}{#5}} } - \exp_args:No\l_tmpb_tl\l_tmpa_tl - }{ - \__stex_terms_math_assoc_arg_simple:nnn{#2} { #1 }{#3} } - } { - \__stex_terms_math_assoc_arg_simple:nnn{#2} { #1 }{#3} } - +} +\cs_new_protected:Nn \__stex_notations_check_aB_arg:Nn { + \exp_args:Ne \cs_if_eq:NNF {\tl_head:n{#2}} + \_stex_term_arg_aB:nnnnn { + \msg_error:nnx{stex}{error/assocarg}{\tl_to_str:n{#1}} + } } -\cs_new_protected:Nn \__stex_terms_math_assoc_arg_simple:nnn { - \clist_set:Nn \l_tmpa_clist{ #2 } - \int_compare:nNnTF { \clist_count:N \l_tmpa_clist } < 2 { - \tl_set:Nn \l_tmpa_tl { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{ #2 } } +\cs_new_protected:Npn \argsep #1 #2 { + \__stex_notations_check_aB_arg:Nn\argsep{#1} + \stex_pseudogroup_with:nn{\_stex_term_do_aB_clist:}{ + \tl_set:Nn \_stex_term_do_aB_clist: { + \seq_use:Nn \l_stex_aB_args_seq {#2} } + #1 + } +} +\cs_new_protected:Npn \argmap #1 #2 #3 { + \__stex_notations_check_aB_arg:Nn\argmap{#1} + \stex_pseudogroup_with:nn{ + \_stex_term_do_aB_clist: + \__stex_notations_map_cs: }{ - \clist_reverse:N \l_tmpa_clist - \clist_pop:NN \l_tmpa_clist \l_tmpa_tl - \tl_set:Nx \l_tmpa_tl { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{ - \exp_args:No \exp_not:n \l_tmpa_tl - } - }} - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl { - \exp_args:Nno - \l_tmpa_cs { - \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ - \_stex_term_arg:nn{A#3#1}{##1} + \cs_set:Npn \__stex_notations_map_cs: ##1 { #2 } + \tl_set:Nn \_stex_term_do_aB_clist: { + \seq_clear:N \l_tmpa_seq + \seq_map_inline:Nn \l_stex_aB_args_seq { + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l_tmpa_seq \ellipses + }{ + \seq_put_right:Nx \l_tmpa_seq { + \exp_after:wN \exp_not:n \exp_after:wN { \__stex_notations_map_cs: {##1} } } - } \l_tmpa_tl + } } + \seq_set_eq:NN \l_stex_aB_args_seq \l_tmpa_seq + \seq_use:Nn \l_stex_aB_args_seq {#3} } + #1 } - \exp_args:No\l_tmpb_tl\l_tmpa_tl } -\tl_const:Nx \infprec {\int_use:N \c_max_int} -\tl_const:Nx \neginfprec {-\int_use:N \c_max_int} -\int_new:N \l__stex_terms_downprec -\int_set_eq:NN \l__stex_terms_downprec \infprec -\tl_set:Nn \l__stex_terms_left_bracket_str ( -\tl_set:Nn \l__stex_terms_right_bracket_str ) -\cs_new_protected:Nn \__stex_terms_maybe_brackets:nn { - \bool_if:NTF \l__stex_terms_brackets_done_bool { - \bool_set_false:N \l__stex_terms_brackets_done_bool - #2 - } { - \int_compare:nNnTF { #1 } > \l__stex_terms_downprec { - \bool_if:NTF \l_stex_inparray_bool { #2 }{ - \stex_debug:nn{dobrackets}{\number#1 > \number\l__stex_terms_downprec; \detokenize{#2}} - \dobrackets { #2 } +\int_new:N \l__stex_notations_clist_count_int +\cs_new_protected:Npn \argarraymap #1 #2 #3 #4 { + \__stex_notations_check_aB_arg:Nn\argarraymap{#1} + \stex_pseudogroup_with:nn{ + \_stex_term_do_aB_clist: + \__stex_notations_map_cs: + }{ + \cs_set:Npn \__stex_notations_map_cs: ##1 { #3 } + \int_set:Nn \l__stex_notations_clist_count_int {\exp_args:No\clist_count:n{\tl_to_str:n{#4}}} + \tl_set:Nn \_stex_term_do_aB_clist: { + \tl_clear:N \l_tmpa_tl + \int_zero:N \l_tmpa_int + \seq_map_inline:Nn \l_stex_aB_args_seq { + \int_incr:N \l_tmpa_int + \int_compare:nNnT \l_tmpa_int > \l__stex_notations_clist_count_int { + \int_set:Nn \l_tmpa_int 1 + } + \tl_put_right:Nx \l_tmpa_tl { + \exp_after:wN \exp_not:n \exp_after:wN { \__stex_notations_map_cs: {##1} } + \clist_item:nn{#4}\l_tmpa_int + } } - }{ #2 } + \seq_set_eq:NN \l_stex_aB_args_seq \l_tmpa_seq + \begin{array}{#2} + \l_tmpa_tl + \end{array} + } + #1 } } -\bool_new:N \l__stex_terms_brackets_done_bool -\cs_new_protected:Npn \dobrackets #1 { - %\ThisStyle{\if D\m@switch - % \exp_args:Nnx \use:nn - % { \exp_after:wN \left\l__stex_terms_left_bracket_str #1 } - % { \exp_not:N\right\l__stex_terms_right_bracket_str } - % \else - \exp_args:Nnx \use:nn - { - \bool_set_true:N \l__stex_terms_brackets_done_bool - \int_set:Nn \l__stex_terms_downprec \infprec - \l__stex_terms_left_bracket_str - #1 + +\tl_new:N \l_stex_variables_prop +\bool_new:N \l__stex_vars_bind_bool +\cs_new_protected:Nn \_stex_variable:nnnnnnnN {} +\stex_keys_define:nnnn{vardef}{ + \bool_set_false:N \l__stex_vars_bind_bool +}{ + bind .bool_set:N = \l__stex_vars_bind_bool +}{symdef} + +\stex_new_stylable_cmd:nnnn {vardef} { m O{} m} { + \stex_keys_set:nn{vardef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + + \stex_symdecl_do: + \_stex_symdecl_check_terms: + \__stex_vars_add: + \__stex_vars_macro: + \stex_if_do_html:T \__stex_vars_html: + + \int_set:Nn \l_stex_get_symbol_arity_int {\l_stex_get_symbol_arity_int} + \stex_debug:nn{vardef}{Doing~\l_stex_key_name_str} + \tl_set_eq:NN \l_stex_get_symbol_return_tl \l_stex_key_return_tl + \stex_notation_parse:n{#3} + \stex_if_check_terms:T{ \_stex_notation_check: } + \_stex_vardecl_notation_macro: + \stex_if_do_html:T { + \def\comp{\_varcomp} + \_stex_notation_do_html:n \l_stex_key_name_str + } + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_key_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \_stex_notation_make_args: + }$ + } + \stex_style_apply: + \group_end:\ignorespaces +}{} + +\cs_new_protected:Nn \__stex_vars_add: { + \exp_args:NNNo \exp_args:NNnx + \prop_put:Nnn \l_stex_variables_prop \l_stex_key_name_str { + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: + } +} + +\cs_new_protected:Nn \__stex_vars_macro: { + \tl_set:cx{\l_stex_macroname_str}{ + \_stex_invoke_variable:nnnnnnN + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l_stex_key_type_tl} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_symbol: + } +} + +\cs_new_protected:Nn \__stex_vars_html: { + \stex_if_do_html:T { + \hbox\bgroup\exp_args:Ne \stex_annotate_invisible:nn { + shtml:vardef = {\l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} } - { - \bool_set_false:N \l__stex_terms_brackets_done_bool - \l__stex_terms_right_bracket_str - \int_set:Nn \l__stex_terms_downprec { \int_use:N \l__stex_terms_downprec } + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} } - %\fi} + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} + } + \bool_if:NT \l__stex_vars_bind_bool {, + shtml:bind={} + } + }{ + \_stex_annotate_force_break:n{ + \bool_set_true:N \stex_in_invisible_html_bool + \tl_if_empty:NF \l_stex_key_type_tl { + \stex_annotate:nn{shtml:type={}}{$\l_stex_key_type_tl$} + } + \tl_if_empty:NF \l_stex_key_def_tl { + \stex_annotate:nn{shtml:definiens={}}{$\l_stex_key_def_tl$} + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l__stex_vars_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l__stex_vars_args_tl {\_stex_map_args:N \_stex_return_args:nn} + $\stex_annotate:nn{shtml:returntype={}}{ + \exp_after:wN \l__stex_vars_cs \l__stex_vars_args_tl!}$ + } + \tl_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{ + \_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + $\stex_annotate:nn{shtml:type={}}{##1}$ + } + } + } + } + } + }\egroup + } } -\cs_new_protected:Npn \withbrackets #1 #2 #3 { - \exp_args:Nnx \use:nn - { - \tl_set:Nx \l__stex_terms_left_bracket_str { #1 } - \tl_set:Nx \l__stex_terms_right_bracket_str { #2 } - #3 +\cs_new_protected:Nn \_stex_vardecl_notation_macro: { + \tl_set_eq:cN {l_stex_notation_ + \l_stex_key_name_str _ + \l_stex_key_variant_str _cs + }\l_stex_notation_macrocode_cs + \cs_if_exist:cF {l_stex_notation_\l_stex_key_name_str __cs}{ + \tl_set_eq:cN{l_stex_notation_\l_stex_key_name_str __cs} + \l_stex_notation_macrocode_cs } - { - \tl_set:Nn \exp_not:N \l__stex_terms_left_bracket_str - {\l__stex_terms_left_bracket_str} - \tl_set:Nn \exp_not:N \l__stex_terms_right_bracket_str - {\l__stex_terms_right_bracket_str} + \tl_if_empty:NF \l_stex_key_op_tl { + \tl_set_eq:cN {l_stex_notation_\l_stex_key_name_str _op_ + \l_stex_key_variant_str _cs}\l_stex_key_op_tl + \cs_if_exist:cF {l_stex_notation_\l_stex_key_name_str _op__cs}{ + \cs_set_eq:cN{l_stex_notation_\l_stex_key_name_str _op__cs} + \l_stex_key_op_tl + } } } -\cs_new_protected:Npn \STEXinvisible #1 { - \stex_annotate_invisible:n { #1 } +\cs_new_protected:Nn \__stex_vars_set_vars:nnnnnnN { + \stex_debug:nn{symbols}{Variable~#1~found} + \cs_set:Npn \_stex_variable:nnnnnnnN ##1 ##2 ##3 ##4 ##5 ##6 ##7 ##8 {} + \str_clear:N \l_stex_get_symbol_mod_str + \str_set:Nn \l_stex_get_symbol_name_str {#1} + \int_set:Nn \l_stex_get_symbol_arity_int {#2} + \tl_set:Nn \l_stex_get_symbol_args_tl {#3} + \tl_set:Nn \l_stex_get_symbol_def_tl {#4} + \tl_set:Nn \l_stex_get_symbol_type_tl {#5} + \tl_set:Nn \l_stex_get_symbol_return_tl {#6} + \tl_set:Nn \l_stex_get_symbol_invoke_cs {#7} } -\cs_new_protected:Nn \_stex_term_oms:nnn { - \stex_annotate:nnn{ OMID }{ #2 }{ - #3 + +\cs_new_protected:Nn \__stex_vars_get_var:n { + \prop_map_inline:Nn \l_stex_variables_prop { + \__stex_vars_check_var:nnnnnnnnN {#1} ##2 } } -\cs_new_protected:Npn \STEXInternalTermMathOMSiiii #1#2#3#4 { - \__stex_terms_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{#1} { - \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 } +\cs_new_protected:Nn \__stex_vars_check_var:nnnnnnnnN { + \str_if_eq:nnTF{#1}{#2}{ + \prop_map_break:n{\__stex_vars_set_vars:nnnnnnN {#3}{#4}{#5}{#6}{#7}{#8}#9} + }{ + \str_if_eq:nnT{#1}{#3}{ + \prop_map_break:n{\__stex_vars_set_vars:nnnnnnN {#3}{#4}{#5}{#6}{#7}{#8}#9} } } } -\cs_new_protected:Nn \_stex_term_omv:nn { - \stex_annotate:nnn{ OMV }{ #1 }{ - #2 + +\cs_new_protected:Nn \stex_get_var:n { + \str_clear:N \l_stex_get_symbol_name_str + \__stex_vars_get_var:n{#1} + \str_if_empty:NT \l_stex_get_symbol_name_str { + \msg_error:nnn{stex}{error/unknownsymbol}{#1} } } -\cs_new_protected:Nn \_stex_term_oma:nnn { - \stex_annotate:nnn{ OMA }{ #2 }{ - #3 + +\cs_new_protected:Nn \stex_get_symbol_or_var:n { + \str_clear:N \l_stex_get_symbol_name_str + \__stex_vars_get_var:n{#1} + \str_if_empty:NT \l_stex_get_symbol_name_str { + \stex_debug:nn{symbols}{No~variable~#1~found} + \stex_get_symbol:n{#1} } } - -\cs_new_protected:Npn \STEXInternalTermMathOMAiiii #1#2#3#4 { - \exp_args:Nnx \use:nn { - \seq_clear:N \l__stex_terms_tmp_seq - \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l__stex_terms_tmp_tl + - } - \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl +\NewDocumentCommand \svar {O{} m}{ + \group_begin: + \tl_if_empty:nTF{#1}{ + \str_set:Nn \l_stex_current_symbol_str {#2} + }{ + \str_set:Nn \l_stex_current_symbol_str {#1} } - } - \__stex_terms_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l__stex_terms_tmp_seq , - ) + \bool_if:NTF \l_stex_allow_semantic_bool{ + \tl_clear:N \l_stex_current_term_tl + \_stex_term_omv:nnn{}{}{\_varcomp{#2}} }{ - \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 } + \msg_error:nnxx{stex}{error/notallowed}{Variable}{\l_stex_current_symbol_str} } - } - }{ - \_stex_reset:N \l_stex_argnames_seq - } -} -\cs_new_protected:Nn \_stex_term_ombind:nnn { - \stex_annotate:nnn{ OMBIND }{ #2 }{ - #3 - } + \group_end: } - -\cs_new_protected:Npn \STEXInternalTermMathOMBiiii #1#2#3#4 { - \exp_args:Nnx \use:nn { - \seq_clear:N \l__stex_terms_tmp_seq - \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ - \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { - \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} - } - \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ - \tl_set:Nx \l__stex_terms_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} - \bool_lazy_or:nnT{ - \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} - }{ - \tl_put_right:Nn \l__stex_terms_tmp_tl + - } - \seq_put_right:No \l__stex_terms_tmp_seq \l__stex_terms_tmp_tl - } +\stex_new_stylable_cmd:nnnn {varseq}{m O{} m m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } } - \__stex_terms_maybe_brackets:nn { #3 }{ - \stex_mathml_intent:nn{ - #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( - \seq_use:Nn \l__stex_terms_tmp_seq , - ) - }{ - \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 } - } + \str_if_empty:NT \l_stex_key_args_str { + \str_set:Nn \l_stex_key_args_str {1} } + \stex_symdecl_do: + + \tl_set_eq:NN \l_stex_get_symbol_return_tl \l_stex_key_return_tl + \clist_set:Nn \l__stex_seqs_range_clist {#3} + \tl_if_empty:NTF \l_stex_key_op_tl { + \stex_notation_parse:n{#4} + \tl_clear:N \l_stex_key_op_tl }{ - \_stex_reset:N \l_stex_argnames_seq + \stex_notation_parse:n{#4} + } + \stex_if_do_html:T \__stex_seqs_html: + \stex_if_check_terms:T \__stex_seqs_check_terms: + \__stex_seqs_add: + \__stex_seqs_macro: + \stex_if_check_terms:T \_stex_notation_check: + \_stex_vardecl_notation_macro: + \group_begin: + \tl_set_eq:NN \thisvarname \l_stex_key_name_str + \tl_clear:N \thisstyle + \str_set_eq:NN\thisnotationvariant\l_stex_key_variant_str + \def\thisnotation{ + $\let\l_stex_current_symbol_str\thisvarname + \def\comp{\_varcomp}\exp_args:Nne \use:nn{\l_stex_notation_macrocode_cs{}}{ + \__stex_seqs_make_args: + }$ + } + \stex_style_apply: + \group_end:\ignorespaces +}{} + +\cs_new_protected:Nn \__stex_seqs_add: { + \exp_args:NNNo \exp_args:NNnx + \prop_put:Nnn \l_stex_variables_prop \l_stex_key_name_str { + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l__stex_seqs_range_clist} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_sequence: } } -\cs_new:Nn \stex_capitalize:n { \uppercase{#1} } -\keys_define:nn { stex / symname } { - pre .tl_set_x:N = \l__stex_terms_pre_tl , - post .tl_set_x:N = \l__stex_terms_post_tl , - root .tl_set_x:N = \l__stex_terms_root_tl +\cs_new_protected:Nn \__stex_seqs_macro: { + \tl_set:cx{\l_stex_macroname_str}{ + \_stex_invoke_variable:nnnnnnN + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {\exp_args:No \exp_not:n \l_stex_key_def_tl} + {\exp_args:No \exp_not:n \l__stex_seqs_range_clist} + {\exp_args:No \exp_not:n \l_stex_key_return_tl} + \stex_invoke_sequence: + } } -\cs_new_protected:Nn \stex_symname_args:n { - \tl_clear:N \l__stex_terms_post_tl - \tl_clear:N \l__stex_terms_pre_tl - \tl_clear:N \l__stex_terms_root_str - \keys_set:nn { stex / symname } { #1 } -} +\cs_new_protected:Nn \__stex_seqs_make_args: { \TODO } +\cs_new_protected:Nn \__stex_seqs_check_terms: { \TODO } -\NewDocumentCommand \symref { m m }{ - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \STEXsymbol{#1}!{ #2 } - \let\compemph@uri\compemph_uri_prev: +\cs_new_protected:Nn \__stex_seqs_html: { + \exp_args:Ne \stex_annotate_invisible:nn { + shtml:varseq = {\l_stex_key_name_str}, + shtml:args = {\l_stex_key_args_str} + \str_if_empty:NF \l_stex_macroname_str {, + shtml:macroname={\l_stex_macroname_str} + } + \str_if_empty:NF \l_stex_key_assoc_str {, + shtml:assoctype={\l_stex_key_assoc_str} + } + \str_if_empty:NF \l_stex_key_role_str {, + shtml:role={\l_stex_key_role_str} + } + \str_if_empty:NF \l_stex_key_reorder_str {, + shtml:reorderargs={\l_stex_key_reorder_str} + } + }{\hbox\bgroup + \_stex_annotate_force_break:n{ + \tl_if_empty:NF \l_stex_key_type_tl { + \stex_annotate:nn{shtml:type={}}{$\l_stex_key_type_tl$} + } + \tl_if_empty:NF \l_stex_key_def_tl { + \stex_annotate:nn{shtml:definiens={}}{$\l_stex_key_def_tl$} + } + \tl_if_empty:NF \l_stex_key_return_tl{ + \exp_args:Nno \use:n{ + \cs_generate_from_arg_count:NNnn \l__stex_seqs_cs + \cs_set:Npn \l_stex_get_symbol_arity_int} \l_stex_key_return_tl + \tl_set:Nx \l__stex_seqs_args_tl {\_stex_map_args:N \_stex_return_args:nn} + \stex_annotate:nn{shtml:returntype={}}{ + $\exp_after:wN \l__stex_seqs_cs \l__stex_seqs_args_tl!$} + } + \tl_if_empty:NF \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:argtypes={}}{ + \_stex_annotate_force_break:n{ + \clist_map_inline:Nn \l_stex_key_argtypes_clist { + \stex_annotate:nn{shtml:type={}}{$##1$} + } + } + } + } + } + \egroup} } - -\NewDocumentCommand \synonym { O{} m m}{ - \stex_symname_args:n { #1 } - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - % TODO - \STEXsymbol{#2}!{\l__stex_terms_pre_tl #3 \l__stex_terms_post_tl} - \let\compemph@uri\compemph_uri_prev: +\cs_new_protected:Nn \stex_invoke_sequence: { + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ \__stex_seqs_do_op:w { \__stex_seqs_do_op:w [] } + }\__stex_seqs_do_first: } -\NewDocumentCommand \symname { O{} m }{ - \stex_symname_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } +\cs_new_protected:Npn \__stex_seqs_do_op:w [#1] { + \cs_if_exist:cTF {l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}{ + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\use:c{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}} + } + \group_end: + }{ + \__stex_seqs_get_index_notation:n{#1} + \peek_charcode:NTF [ \__stex_seqs_doop_range:w { \__stex_seqs_doop_range:w[] } } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \exp_args:NNx \use:nn - \stex_invoke_symbol:n { { \l_stex_get_symbol_uri_str }!\ifmmode*\fi{ - \l__stex_terms_pre_tl \l_tmpa_str \l__stex_terms_post_tl - } } - \let\compemph@uri\compemph_uri_prev: } -\NewDocumentCommand \Symname { O{} m }{ - \stex_symname_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - \let\compemph_uri_prev:\compemph@uri - \let\compemph@uri\symrefemph@uri - \exp_args:NNx \use:nn - \stex_invoke_symbol:n { { \l_stex_get_symbol_uri_str }!\ifmmode*\fi{ - \exp_after:wN \stex_capitalize:n \l_tmpa_str - \l__stex_terms_post_tl - } } - \let\compemph@uri\compemph_uri_prev: -} -\cs_new_protected:Npn \_comp #1 { - \str_if_empty:NF \STEXInternalCurrentSymbolStr { - \stex_html_backend:TF { - \stex_annotate:nnn { comp }{ \STEXInternalCurrentSymbolStr }{ #1 } +\cs_new_protected:Npn \__stex_seqs_doop_range:w [#1] { + \bool_set_true:N \l_stex_allow_semantic_bool + \clist_clear:N \l__stex_seqs_clist + \clist_map_function:NN \l_stex_current_type_tl \__stex_seqs_doop_arg:n + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={} }{ - \exp_args:Nnx \compemph@uri { #1 } { \STEXInternalCurrentSymbolStr } + \l__stex_seqs_clist } - } + \group_end: } -\cs_new_protected:Npn \_varcomp #1 { - \str_if_empty:NF \STEXInternalCurrentSymbolStr { - \stex_html_backend:TF { - \stex_annotate:nnn { varcomp }{ \STEXInternalCurrentSymbolStr }{ #1 } - }{ - \exp_args:Nnx \varemph@uri { #1 } { \STEXInternalCurrentSymbolStr } +\cs_new_protected:Nn \__stex_seqs_doop_arg:n { + \tl_if_eq:nnTF{#1}{\ellipses}{ + \clist_put_right:Nn \l__stex_seqs_clist { + \ellipses + } + }{ + \clist_put_right:Nn \l__stex_seqs_clist { + \exp_args:No \str_if_eq:nnTF \l_stex_current_arity_str {1}{ + \group_begin: + \l__stex_seqs_cs \group_end: {#1} + + }{ + \group_begin: + \l__stex_seqs_cs \group_end: #1 + } } } } -\def\comp{\_comp} - -\cs_new_protected:Npn \compemph@uri #1 #2 { - \compemph{ #1 } +\cs_new_protected:Nn \__stex_seqs_get_index_notation:n { + \cs_if_exist:cTF {l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \cs_set_eq:Nc \l__stex_seqs_cs {l_stex_notation_\l_stex_current_symbol_str _#1_cs} + }{ + \stex_do_default_notation: + \cs_set_eq:NN \l__stex_seqs_cs \l_stex_default_notation + } } -\cs_new_protected:Npn \compemph #1 { - #1 -} +\cs_new:Nn \__stex_seqs_do_first_arg:n {{\exp_not:n{## #1}}} -\cs_new_protected:Npn \defemph@uri #1 #2 { - \defemph{#1} +\cs_new_protected:Nn \__stex_seqs_do_first: { + \exp_args:Nnx \use:nn{ + \cs_generate_from_arg_count:NNnn \l__stex_seqs_cs \cs_set:Npn + \l_stex_current_arity_str} {{ + \tl_set:Nn \exp_not:N \l__stex_seqs_first_args_tl { + \int_step_function:nN \l_stex_current_arity_str \__stex_seqs_do_first_arg:n + } + \exp_not:N \__stex_seqs_do_first_next: + }} + \l__stex_seqs_cs } -\cs_new_protected:Npn \defemph #1 { - \textbf{#1} +\cs_new_protected:Nn \__stex_seqs_do_first_next: { + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ \__stex_seqs_do_one:w {\__stex_seqs_do_one:w []} + }{ + \peek_charcode:NTF [ \__stex_seqs_do_all:w {\__stex_seqs_do_all:w []} + } } -\cs_new_protected:Npn \symrefemph@uri #1 #2 { - \symrefemph{#1} +\cs_new_protected:Npn \__stex_seqs_do_one:w [#1] { + \__stex_seqs_get_index_notation:n{#1} + \stex_debug:nn{HERE~seq~one}{\meaning\l__stex_seqs_cs^^J\meaning\l__stex_seqs_first_args_tl} + \exp_args:Nno\use:nn{\l__stex_seqs_cs\group_end:}\l__stex_seqs_first_args_tl } -\cs_new_protected:Npn \symrefemph #1 { - \emph{#1} +\cs_new_protected:Npn \__stex_seqs_do_all:w [#1] { + \stex_debug:nn{HERE~seq~all}{\meaning\l__stex_seqs_first_args_tl} + \exp_args:Nno\use:nn{\_stex_invoke_notation:w [#1]}\l__stex_seqs_first_args_tl } - -\cs_new_protected:Npn \varemph@uri #1 #2 { - \varemph{#1} +\cs_new_protected:Npn \seqmap #1 #2 { + \symuse{Metatheory?sequence~expression}{\seqmap{#1}{#2}}%\l_tmpa_tl {#2} } - -\cs_new_protected:Npn \varemph #1 { - #1 +\bool_new:N \l_stex_allow_semantic_bool +\bool_set_true:N \l_stex_allow_semantic_bool +\tl_new:N \l_stex_current_term_tl +\tl_set:Nn \l_stex_every_symbol_tl { + \bool_set_false:N \l_stex_allow_semantic_bool } -\NewDocumentCommand \ellipses {} { \ldots } -\bool_new:N \l_stex_inparray_bool -\bool_set_false:N \l_stex_inparray_bool -\NewDocumentCommand \parray { m m } { - \begingroup - \bool_set_true:N \l_stex_inparray_bool - \begin{array}{#1} - #2 - \end{array} - \endgroup +\tl_new:N \l__stex_expr_reset_tl +\cs_new_protected:Nn \_stex_next_symbol:n { + \tl_set:Nx \l_stex_every_symbol_tl { + \tl_gset:Nn \exp_not:N \l__stex_expr_reset_tl { + \tl_set:Nn \exp_not:N \l_stex_every_symbol_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \tl_gset:Nn \exp_not:N \l__stex_expr_reset_tl { + \exp_args:No \exp_not:n \l__stex_expr_reset_tl + } + } + \tl_set:Nn \exp_not:N \l_stex_every_symbol_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \exp_not:n{ \aftergroup \l__stex_expr_reset_tl } + \exp_not:N \l_stex_every_symbol_tl + \exp_not:n{ #1 } + } } - -\NewDocumentCommand \prmatrix { m } { - \begingroup - \bool_set_true:N \l_stex_inparray_bool - \begin{matrix} - #1 - \end{matrix} - \endgroup +\cs_generate_variant:Nn \_stex_next_symbol:n {e} +\cs_new_protected:Npn \STEXinvisible #1 { + \stex_annotate_invisible:n { #1 } } - -\def \maybephline { - \bool_if:NT \l_stex_inparray_bool {\hline} +\cs_new_protected:Nn \_stex_invoke_symbol:nnnnnnnN { + \bool_if:NTF \l_stex_allow_semantic_bool{ + \stex_if_html_backend:T{\ifvmode\indent\fi} + \__stex_expr_setup:nnnnnn{\_comp}{#1?#2}{#3}{#4}{#7}{#6} + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn + \tl_put_right:Nn \l_stex_current_redo_tl{ + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn + } + #8 + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1?#2}{\l_stex_current_symbol_str} + } +} +\cs_generate_variant:Nn \_stex_invoke_symbol:nnnnnnnN {ooxooooN} + +\cs_new_protected:Nn \__stex_expr_setup:nnnnnn { + \group_begin: + \tl_clear:N \l_stex_return_notation_tl + \tl_set:Nn \l_stex_current_redo_tl { + \let \this \stex_current_this: + \def\comp{#1} + \def\maincomp{\comp} + \str_set:Nn \l_stex_current_symbol_str {#2} + \str_set:Nn \l_stex_current_arity_str{ #3 } + \tl_set:Nn \l_stex_current_args_tl{ #4 } + \tl_set:Nn \l_stex_current_return_tl{ #5 } + \tl_set:Nn \l_stex_current_type_tl{ #6 } + \tl_clear:N \l_stex_current_term_tl + } + \tl_put_right:Nx \l_stex_current_redo_tl { + \exp_args:No \exp_not:n \l_stex_every_symbol_tl + } + \l_stex_current_redo_tl +} +\cs_new_protected:Nn \_stex_invoke_variable:nnnnnnN { + \bool_if:NTF \l_stex_allow_semantic_bool{ + \stex_if_html_backend:T{\ifvmode\indent\fi} + \__stex_expr_setup:nnnnnn{\_varcomp}{#1}{#2}{#3}{#6}{#5} + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_omv:nnn + \tl_put_right:Nn \l_stex_current_redo_tl { + \cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_omv:nnn + } + #7 + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} + } } - -\def \parrayline #1 #2 { - #1 #2 \bool_if:NT \l_stex_inparray_bool {\\} +\cs_new_protected:Npn \symuse #1 { + \stex_get_symbol:n{#1} + \exp_args:Nno \use:n {\_stex_invoke_symbol:ooxooooN + \l_stex_get_symbol_mod_str + \l_stex_get_symbol_name_str + {\int_use:N \l_stex_get_symbol_arity_int} + \l_stex_get_symbol_args_tl + \l_stex_get_symbol_def_tl + \l_stex_get_symbol_type_tl + \l_stex_get_symbol_return_tl} + \l_stex_get_symbol_invoke_cs } - -\def \pmrow #1 { \parrayline{}{ #1 } } - -\def \parraylineh #1 #2 { - #1 #2 \bool_if:NT \l_stex_inparray_bool {\\\hline} +\cs_new_protected:Nn \stex_invoke_symbol: { + \stex_debug:nn{expressions}{Invoking~\l_stex_current_symbol_str} + \mode_if_math:TF \__stex_expr_invoke_math: \__stex_expr_invoke_text: } -\def \parraycell #1 { - #1 \bool_if:NT \l_stex_inparray_bool {&} -} -\cs_new_protected:Nn \stex_invoke_variable:n { - \if_mode_math: - \exp_after:wN \__stex_variables_invoke_math:n - \else: - \exp_after:wN \__stex_variables_invoke_text:n - \fi: {#1} +\cs_new_protected:Nn \__stex_expr_invoke_text: { + \stex_debug:nn{expressions}{text~mode} + \peek_charcode_remove:NTF ! \__stex_expr_invoke_op_custom:n \__stex_expr_invoke_custom:n } -\cs_new_protected:Nn \__stex_variables_invoke_text:n { +\cs_new_protected:Nn \__stex_expr_invoke_math: { + \stex_debug:nn{expressions}{math~mode} \peek_charcode_remove:NTF ! { - \__stex_variables_invoke_op_custom:nn {#1} + % operator + \peek_charcode_remove:NTF * \__stex_expr_invoke_op_custom:n { + % op notation + \peek_charcode:NTF [ \__stex_expr_invoke_op_notation:w { + \__stex_expr_invoke_op_notation:w [] + } + } }{ - \__stex_variables_invoke_custom:nn {#1} + \peek_charcode_remove:NTF * \__stex_expr_invoke_custom:n { + % normal + \peek_charcode:NTF [ \_stex_invoke_notation:w { + \_stex_invoke_notation:w [] + } + } } } - -\cs_new_protected:Nn \__stex_variables_invoke_math:n { - \peek_charcode_remove:NTF ! { - \peek_charcode_remove:NTF ! { - \peek_charcode:NTF [ { - % TODO throw error - }{ - \__stex_variables_invoke_op_custom:nn - } +\cs_new_protected:Npn \_stex_invoke_notation:w [#1] { + \stex_debug:nn{expressions}{using~notation~#1~for~\l_stex_current_symbol_str} + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \tl_if_empty:NTF \l_stex_current_return_tl { + \stex_debug:nn{expressions}{return~empty} + \use:c{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{\group_end:\_stex_eat_exclamation_point:} }{ - \__stex_variables_invoke_op:n { #1 } + \stex_debug:nn{expressions}{return?} + \exp_after:wN\exp_after:wN\exp_after:wN + \__stex_expr_invoke_return_maybe:n + \exp_after:wN\exp_after:wN\exp_after:wN + {\cs:w l_stex_notation_\l_stex_current_symbol_str _#1_cs \cs_end: {}} } }{ - \peek_charcode_remove:NTF * { - \__stex_variables_invoke_custom:nn { #1 } + \stex_do_default_notation: + \tl_if_empty:NTF \l_stex_current_return_tl { + \l_stex_default_notation{\group_end:\_stex_eat_exclamation_point:} }{ - \__stex_variables_invoke_math_ii:n { #1 } + \exp_after:wN + \__stex_expr_invoke_return_maybe:n + \exp_after:wN + {\l_stex_default_notation {}} } } } -\cs_new_protected:Nn \__stex_variables_invoke_op_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \_stex_term_omv:nn {var://#1}{ - \comp{ #2 } +\cs_new_protected:Npn \__stex_expr_invoke_op_notation:w [#1] { + \stex_debug:nn{expressions}{op~notation~for~\l_stex_current_symbol_str} + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}{ + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\use:c{l_stex_notation_\l_stex_current_symbol_str _op_#1_cs}} } + \group_end: }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool + \int_compare:nNnTF \l_stex_current_arity_str = 0 { + \tl_clear:N \l_stex_current_return_tl + \_stex_invoke_notation:w [#1] + }{ + \stex_do_default_notation_op: + \_stex_maybe_brackets:nn{\neginfprec}{ + \_stex_term_oms_or_omv:nnn{#1}{} + {\l_stex_default_notation} + } + \group_end: + } } } +\cs_new_protected:Nn \__stex_expr_invoke_return_maybe:n { + \tl_clear:N \l__stex_expr_return_args_tl + \tl_set:Nn \l__stex_expr_return_this_tl {#1} + \exp_args:Nnx \use:n { + \cs_generate_from_arg_count:NNnn \__stex_expr_ret_cs + \cs_set:Npn \l_stex_current_arity_str } { + \int_step_function:nN \l_stex_current_arity_str \__stex_expr_return_arg:n + \__stex_expr_invoke_return_next: + } + \__stex_expr_ret_cs +} -\cs_new_protected:Nn \__stex_variables_invoke_op:n { - \cs_if_exist:cTF { - stex_var_op_notation_ #1 _cs - }{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \_stex_term_omv:nn { var://#1 }{ - \use:c{stex_var_op_notation_ #1 _cs } +\cs_new:Nn \__stex_expr_return_arg:n { + \tl_put_right:Nn \exp_not:N \l__stex_expr_return_args_tl {{#### #1}} +} + +\cs_new_protected:Nn \__stex_expr_invoke_return_next: { + \peek_charcode_remove:NTF ! { + \exp_after:wN \l__stex_expr_return_this_tl \l__stex_expr_return_args_tl \group_end: + }\__stex_expr_invoke_return: +} + +\cs_new_protected:Nn \__stex_expr_invoke_return: { + \tl_set:Nx \l__stex_expr_return_this_tl { + \__stex_expr_return_notation:n { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:n \exp_after:wN \exp_after:wN \exp_after:wN { + \exp_after:wN \l__stex_expr_return_this_tl \l__stex_expr_return_args_tl } - }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr } + } + \stex_debug:nn{return}{Notation:~\meaning\l__stex_expr_return_this_tl} + \tl_put_left:Nx \l__stex_expr_return_this_tl { + \group_begin:\exp_args:No \exp_not:n \l_stex_current_redo_tl + } + \exp_args:Nnx \use:n { + \cs_generate_from_arg_count:NNnn \__stex_expr_ret_cs + \cs_set:Npn \l_stex_current_arity_str } { + \exp_args:No \exp_not:n \l_stex_current_return_tl + } + \stex_debug:nn{return}{ + \meaning\__stex_expr_ret_cs^^J + \meaning\l__stex_expr_return_this_tl^^J + \exp_args:No \exp_not:n \l__stex_expr_return_args_tl^^J + } + \exp_args:Nnx \use:nn { + \exp_after:wN \group_end: \__stex_expr_ret_cs }{ - \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_var://#1_prop}{arity}} = 0{ - \__stex_variables_invoke_math_ii:n {#1} - }{ - \msg_error:nnxx{stex}{error/noop}{variable~#1}{} + \exp_args:No \exp_not:n \l__stex_expr_return_args_tl + { + \exp_args:No \exp_not:n \l__stex_expr_return_this_tl + \group_end: } } } -\cs_new_protected:Npn \__stex_variables_invoke_math_ii:n #1 { - \cs_if_exist:cTF { - stex_var_notation_#1_cs +\cs_new_protected:Nn \__stex_expr_return_notation:n { + \tl_if_empty:NTF \l_stex_return_notation_tl { #1 }{ + \l_stex_return_notation_tl + } +} + +\cs_new_protected:Nn \__stex_expr_invoke_op_custom:n { + \stex_debug:nn{expressions}{custom~op} + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_oms_or_omv:nnn{}{}{\maincomp{#1}} + \group_end: +} + +\int_new:N \l__stex_expr_arg_counter_int +\cs_new_protected:Nn \__stex_expr_invoke_custom:n { + \stex_debug:nn{custom}{custom~notation~for~\l_stex_current_symbol_str} + \stex_pseudogroup:nn{ + \bool_set_true:N \l_stex_allow_semantic_bool + \prop_gclear:N \l__stex_expr_customs_prop + \seq_gclear:N \l__stex_expr_customs_seq + \int_gzero:N \l__stex_expr_arg_counter_int + \tl_if_empty:NF \l_stex_current_args_tl { + \exp_after:wN \__stex_expr_add_prop_arg:nnw \l_stex_current_args_tl \_stex_args_end: + \cs_set_eq:NN \arg \__stex_expr_arg:n + } + \tl_set_eq:NN \l_stex_get_symbol_args_tl \l_stex_current_args_tl + \cs_set_eq:NN \__stex_expr_do_ab_next:nnn \_stex_term_oma:nnn + \_stex_map_args:N \__stex_expr_check_b:nn + \__stex_expr_do_ab_next:nnn{}{}{#1} }{ - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool + \prop_if_exist:NT \l__stex_expr_customs_prop { + \prop_gset_from_keyval:Nn \exp_not:N \l__stex_expr_customs_prop { + \prop_to_keyval:N \l__stex_expr_customs_prop + } + } + \int_gset:Nn \l__stex_expr_arg_counter_int { \int_use:N \l__stex_expr_arg_counter_int} + \seq_if_exist:NT \l__stex_expr_customs_seq { + \seq_gset_split:Nnn \exp_not:N \l__stex_expr_customs_seq , { + \seq_use:Nn \l__stex_expr_customs_seq , + } + } + } + % TODO check that all arguments are present + \group_end: +} + +\cs_new_protected:Npn \__stex_expr_add_prop_arg:nnw #1 #2 #3\_stex_args_end: { + \prop_gput:Nnn \l__stex_expr_customs_prop {#1} {} + \seq_gput_right:Nn \l__stex_expr_customs_seq {#2} + \tl_if_empty:nF{#3}{\__stex_expr_add_prop_arg:nnw #3 \_stex_args_end:} +} + +\cs_new:Nn \__stex_expr_check_b:nn { + \str_case:nn #2 { + b {\cs_set_eq:NN \__stex_expr_do_ab_next:nnn \_stex_term_omb:nnn} + B {\cs_set_eq:NN \__stex_expr_do_ab_next:nnn \_stex_term_omb:nnn} + } +} + +\NewDocumentCommand \__stex_expr_arg:n {s O{} m} { + \IfBooleanTF #1 { + \stex_annotate_invisible:n{ + \__stex_expr_arg_inner:nn{#2}{#3} } - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \bool_set_false:N \l_stex_allow_semantic_bool - \use:c{stex_var_notation_#1_cs} }{ - \msg_error:nnxx{stex}{error/nonotation}{variable~#1}{s} + \__stex_expr_arg_inner:nn{#2}{#3} } } -\cs_new_protected:Nn \__stex_variables_invoke_custom:nn { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr { var://#1 } - \prop_clear:N \l__stex_terms_custom_args_prop - \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1} - \prop_get:cnN { - l_stex_symdecl_var://#1 _prop - }{ args } \l_tmpa_str - \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str - \tl_set:Nn \arg { \__stex_terms_arg: } - \str_if_empty:NTF \l_tmpa_str { - \_stex_term_omv:nn {var://#1}{\ignorespaces#2} +\cs_new_protected:Nn \__stex_expr_arg_inner:nn { + \tl_if_empty:nTF{#1}{ + \int_gincr:N \l__stex_expr_arg_counter_int + \exp_args:Ne \__stex_expr_check:nTF{ \int_use:N \l__stex_expr_arg_counter_int }{ + \__stex_expr_arg_do:oon \l_tmpa_tl \l_tmpb_tl }{ - \str_if_in:NnTF \l_tmpa_str b { - \_stex_term_ombind:nnn {var://#1}{}{\ignorespaces#2} - }{ - \str_if_in:NnTF \l_tmpa_str B { - \_stex_term_ombind:nnn {var://#1}{}{\ignorespaces#2} - }{ - \_stex_term_oma:nnn {var://#1}{}{\ignorespaces#2} + \__stex_expr_arg_inner:nn{} + }{ #2 } + }{ + \__stex_expr_check:nTF {#1}{ + \__stex_expr_arg_do:oon \l_tmpa_tl \l_tmpb_tl { #2 } + }{ + \exp_args:No \str_case:nnTF \l_tmpb_tl { + {a}{ + \exp_args:NNnx \prop_gput:Nnn \l__stex_expr_customs_prop {#1}{ + \l_tmpa_tl X + } + \tl_set:Nx \l_tmpa_tl { #1 \int_eval:n {\tl_count:N \l_tmpa_tl + 1} } + } + {B}{ + \exp_args:NNnx \prop_gput:Nnn \l__stex_expr_customs_prop {#1}{ + \l_tmpa_tl X + } + \tl_set:Nx \l_tmpa_tl { #1 \int_eval:n {\tl_count:N \l_tmpa_tl + 1} } } + }{ + \__stex_expr_arg_do:oon \l_tmpa_tl \l_tmpb_tl { #2 } + }{ + \msg_error:nnxx{stex}{error/invalidarg}{#1}{\l_stex_current_symbol_str} } } - % TODO check that all arguments exist - }{ - \_stex_reset:N \STEXInternalCurrentSymbolStr - \_stex_reset:N \arg - \_stex_reset:N \comp - \_stex_reset:N \l__stex_terms_custom_args_prop - %\bool_set_true:N \l_stex_allow_semantic_bool } } -\cs_new_protected:Nn \stex_invoke_sequence:n { - \peek_charcode_remove:NTF ! { - \_stex_term_omv:nn {varseq://#1}{ - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1} - \prop_item:cn{l_stex_symdecl_varseq://#1_prop}{notation} +\prg_new_conditional:Nnn \__stex_expr_check:n {TF} { + \exp_args:NNe \prop_get:NnNTF \l__stex_expr_customs_prop {#1} \l_tmpa_tl { + \tl_set:Nx \l_tmpb_tl {\seq_item:Nn \l__stex_expr_customs_seq {#1} } + \tl_if_empty:NTF \l_tmpa_tl { + \exp_args:NNe \prop_gput:Nnn \l__stex_expr_customs_prop + { #1 }{X} + \exp_args:No \str_case:nnF \l_tmpb_tl { + {a}{ + \tl_set:Nx \l_tmpa_tl{ #1 1 } + } + {B}{ + \tl_set:Nx \l_tmpa_tl{ #1 1 } + } }{ - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalCurrentSymbolStr + \tl_set:Nx \l_tmpa_tl{ #1 } } + \prg_return_true: + }{ + \prg_return_false: } }{ - \bool_set_false:N \l_stex_allow_semantic_bool - \def\comp{\_varcomp} - \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1} - \tl_set:Nx \STEXInternalSymbolAfterInvokationTL { - \_stex_reset:N \comp - \_stex_reset:N \STEXInternalSymbolAfterInvokationTL - \_stex_reset:N \STEXInternalCurrentSymbolStr - \bool_set_true:N \l_stex_allow_semantic_bool - } - \use:c { stex_varseq_#1_cs } + \msg_error:nnxx{stex}{error/invalidarg}{#1}{\l_stex_current_symbol_str} + \prg_return_false: } } +\cs_new_protected:Nn \__stex_expr_arg_do:nnn { + \stex_debug:nn{custom}{Doing~argument~#1~of~mode~#2:~\tl_to_str:n{#3}} + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_arg:nnn {#2}{#1}{#3} + \group_end: +} +\cs_generate_variant:Nn \__stex_expr_arg_do:nnn {oon} +\cs_new_protected:Nn \_stex_term_arg:nnnnn { + \group_begin: + \str_clear:N \l_stex_current_symbol_str + \tl_clear:N \l_stex_current_term_tl + \int_set:Nn \l_stex_notation_downprec { #3 } + \bool_set_true:N \l_stex_allow_semantic_bool + \_stex_term_arg:nnn {#2}{#1}{ + \tl_if_empty:nTF{#4}{ + #5 + }{ + \stex_annotate:nn{mml:arg={#4}}{#5} + } + } + \group_end: +} - -%%%%%%%%%%%%% features.dtx %%%%%%%%%%%%% - -\msg_new:nnn{stex}{error/copymodule/notallowed}{ - Symbol~#1~can~not~be~assigned~in~copymodule~#2 +\cs_new_protected:Nn \_stex_term_arg:nnn { + \stex_annotate:nn{ shtml:arg={#2}, shtml:argmode={#1}}{ + \_stex_annotate_force_break:n{ #3 } + } } -\msg_new:nnn{stex}{error/interpretmodule/nodefiniens}{ - Symbol~#1~not~assigned~in~interpretmodule~#2 +\tl_set:Nn \__stex_expr_do_aB_clist: { + \seq_use:Nn \l_stex_aB_args_seq { + \mathpunct{\comp{,}} + } } +\tl_set_eq:NN \_stex_term_do_aB_clist: \__stex_expr_do_aB_clist: -\msg_new:nnn{stex}{error/unknownstructure}{ - No~structure~#1~found! +\int_new:N \l__stex_expr_count_int +\cs_new_protected:Nn \_stex_term_arg_aB:nnnnn { + \tl_if_empty:nTF{#5}{ + \_stex_term_arg:nnnnn{#1}{#2}{#3}{#4}{} + }{ + \seq_clear:N \l_stex_aB_args_seq + \int_zero:N \l__stex_expr_count_int + \clist_map_inline:nn{#5}{ + \__stex_expr_aB_arg:nnnnn{##1}{#1}{#2}{#3}{#4} + } + \_stex_term_do_aB_clist: + } } -\msg_new:nnn{stex}{error/unknownfield}{ - No~field~#1~in~instance~#2~found!\\#3 +\cs_new_protected:Npn \__stex_expr_aB_arg:nnnnn #1 { + \int_incr:N \l__stex_expr_count_int + \__stex_expr_is_varseq:nTF{#1}{ + \exp_after:wN \exp_after:wN \exp_after:wN + \__stex_expr_assoc_seq:nnnnnnn + \exp_after:wN + \__stex_expr_gobble:nnnnnnnn #1 \__stex_expr_end: + }{ + \__stex_expr_is_seqmap:nTF{#1}{ + \exp_args:NNe \use:nn \__stex_expr_do_seqmap:nnnnnn {\tl_tail:n{#1}} + }{ + \__stex_expr_aB_simple_arg:nnnnn{#1} + } + } } -\msg_new:nnn{stex}{error/keyval}{ - Invalid~key=value~pair:#1 -} -\msg_new:nnn{stex}{error/instantiate/missing}{ - Assignments~missing~in~instantiate:~#1 -} -\msg_new:nnn{stex}{error/incompatible}{ - Incompatible~signature:~#1~(#2)~and~#3~(#4) +\cs_new:Npn \__stex_expr_gobble:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 #9 \__stex_expr_end: { + {#2} #3 {#6} } -\cs_new_protected:Nn \stex_get_symbol_in_seq:nn { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \__stex_copymodule_get_symbol_from_cs: - }{ - % argument is a string - % is it a command name? - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { - \tl_head:N \l_tmpa_tl - } \stex_invoke_symbol:n { - \__stex_copymodule_get_symbol_from_cs:n{ #2 } - }{ - \__stex_copymodule_get_symbol_from_string:nn { #1 }{ #2 } - } - } { - \__stex_copymodule_get_symbol_from_string:nn { #1 }{ #2 } +\cs_new_protected:Nn \__stex_expr_aB_simple_arg:nnnnn{ + \seq_put_right:Nx \l_stex_aB_args_seq { + \_stex_term_arg:nnnnn{#2\int_use:N\l__stex_expr_count_int}{#3}{#4}{#5}{ + \exp_not:n{ + \tl_set_eq:NN \_stex_term_do_aB_clist: \__stex_expr_do_aB_clist: + #1 } - }{ - % argument is not a command name - \__stex_copymodule_get_symbol_from_string:nn { #1 }{ #2 } - % \l_stex_all_symbols_seq } } } -\cs_new_protected:Nn \__stex_copymodule_get_symbol_from_string:nn { - \str_set:Nn \l_tmpa_str { #1 } - \bool_set_false:N \l_tmpa_bool - \bool_if:NF \l_tmpa_bool { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownsymbol}{#1} - } - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \seq_map_inline:Nn #2 { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_symbol_uri_str { - ##1 +\cs_new_protected:Nn \_stex_is_sequentialized:n { + \group_begin: #1 \group_end: +} +\prg_new_conditional:Nnn \__stex_expr_is_varseq:n {TF} { + \int_compare:nNnTF {\tl_count:n{#1}} = 1 { + \exp_args:Ne \cs_if_eq:NNTF {\exp_args:No \tl_head:n{#1}} + \_stex_invoke_variable:nnnnnnN { + \exp_args:Ne \cs_if_eq:NNTF {\exp_args:No\tl_item:nn{#1}{8}} + \stex_invoke_sequence: + \prg_return_true:\prg_return_false: + }\prg_return_false: + }\prg_return_false: +} + +\prg_new_conditional:Nnn \__stex_expr_is_seqmap:n {TF} { + \int_compare:nNnTF {\tl_count:n{#1}} = 3 { + \exp_args:Ne \tl_if_eq:nnTF {\tl_head:n{#1}} {\seqmap} + \prg_return_true:\prg_return_false: + }\prg_return_false: +} +\cs_new_protected:Nn \__stex_expr_assoc_seq:nnnnnnn { + \group_begin: + \seq_clear:N \l_stex_aB_args_seq + \__stex_expr_assoc_make_seq:nnn{#1}{#3}{#2} + \exp_args:NNe \use:nn \group_end: { + \seq_put_right:Nn \exp_not:N \l_stex_aB_args_seq { + \_stex_is_sequentialized:n{ + \_stex_term_arg:nnnnn{#4\int_use:N\l__stex_expr_count_int}{#5}{#6}{#7}{ + \bool_set_true:N \l_stex_allow_semantic_bool + \str_set:Nn \exp_not:N \l_stex_current_symbol_str + {\l_stex_current_symbol_str} + \tl_if_empty:NF \l_stex_current_term_tl { + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \exp_args:No \exp_not:n \l_stex_current_term_tl + } + } + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={#1}, + shtml:notationid={} + }{ + \_stex_annotate_force_break:n{ + \_stex_term_do_aB_clist: } } } } } - \l_tmpa_tl } } -\cs_new_protected:Nn \__stex_copymodule_get_symbol_from_cs:n { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \tl_if_single:NTF \l_tmpa_tl { - \exp_args:No \tl_if_head_is_group:nTF \l_tmpa_tl { - \exp_after:wN \str_set:Nn \exp_after:wN - \l_stex_get_symbol_uri_str \l_tmpa_tl - \__stex_copymodule_get_symbol_check:n { #1 } +\cs_new_protected:Nn \__stex_expr_assoc_make_seq:nnn { + \cs_if_exist:cTF{l_stex_notation_#1__cs}{ + \cs_set_eq:Nc \l__stex_expr_cs {l_stex_notation_#1__cs} + }{ + \stex_do_default_notation: + \cs_set_eq:NN \l__stex_expr_cs \l_stex_default_notation + } + \clist_map_inline:nn{#2}{ + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l_stex_aB_args_seq { ##1 } }{ - % TODO - % tail is not a single group + \int_compare:nNnTF {#3} = 1 { + \tl_set:Nn \l__stex_expr_iarg_tl { {##1} } + }{ + \tl_set:Nn \l__stex_expr_iarg_tl { ##1 } + } + \seq_put_right:Nx \l_stex_aB_args_seq { + \group_begin: + \exp_not:n { + \tl_set_eq:NN \_stex_term_do_aB_clist: \__stex_expr_do_aB_clist: + \def\comp{\_varcomp} + \str_set:Nn \l_stex_current_symbol_str{#1} + } + \exp_after:wN \exp_after:wN \exp_after:wN \exp_not:n + \exp_after:wN \exp_after:wN \exp_after:wN { + \exp_after:wN \l__stex_expr_cs \exp_after:wN \group_end: \l__stex_expr_iarg_tl + } + } } - }{ - % TODO - % tail is not a single group } } - -\cs_new_protected:Nn \__stex_copymodule_get_symbol_check:n { - \exp_args:NNx \seq_if_in:NnF #1 \l_stex_get_symbol_uri_str { - \msg_error:nnxx{stex}{error/copymodule/notallowed}{\l_stex_get_symbol_uri_str}{ - :~\seq_use:Nn #1 {,~} +\cs_new_protected:Nn \__stex_expr_do_seqmap:nnnnnn { + \group_begin: + \cs_set:Npn \l_tmpa_cs ##1 {#1} + \seq_clear:N \l_stex_aB_args_seq + \clist_map_inline:nn{#2}{ + \__stex_expr_is_varseq:nTF{##1}{ + \exp_after:wN + \__stex_expr_varseq_in_map:nnnnnnnn ##1 + }{ + \seq_put_right:Nn \l_stex_aB_args_seq {##1} + } + } + \seq_clear:N \l__stex_expr_old_seq + \seq_map_inline:Nn \l_stex_aB_args_seq { + \tl_if_eq:nnTF{##1}{\ellipses}{ + \seq_put_right:Nn \l__stex_expr_old_seq {##1} + } + % TODO \_stex_is_sequentialized:n + { + \exp_args:NNo \seq_put_right:Nn \l__stex_expr_old_seq { + \l_tmpa_cs {##1} + } + } + } + \seq_set_eq:NN \l_stex_aB_args_seq \l__stex_expr_old_seq + \exp_args:NNe \use:nn \group_end: { + \seq_put_right:Nn \exp_not:N \l_stex_aB_args_seq { + \_stex_is_sequentialized:n{ + \_stex_term_arg:nnnnn{#4\int_use:N\l__stex_expr_count_int}{#4}{#5}{#6}{ + \bool_set_true:N \l_stex_allow_semantic_bool + \str_set:Nn \exp_not:N \l_stex_current_symbol_str + {\l_stex_current_symbol_str} + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \symuse{Metatheory?sequence~map} + {\exp_args:No \exp_not:n \l_tmpa_tl} + {\_stex_term_do_aB_clist:} + } + \__stex_expr_do_headterm:nn{}{ + \_stex_term_do_aB_clist: + } + } + } } } } -\cs_new_protected:Nn \stex_copymodule_start:nnnn { - % import module - \stex_import_module_uri:nn { #1 } { #2 } - \str_set:Nx \l_stex_current_copymodule_name_str {#3} - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - - \stex_collect_imports:n {\l_stex_import_ns_str ?\l_stex_import_name_str } - \seq_set_eq:NN \l__stex_copymodule_copymodule_modules_seq \l_stex_collect_imports_seq +\cs_new_protected:Nn \__stex_expr_varseq_in_map:nnnnnnnn { + \__stex_expr_assoc_make_seq:nnn{#2}{#6}{#3} +} +\cs_new_protected:Nn \_stex_eat_exclamation_point: { + \peek_charcode_remove:NT ! { + \_stex_eat_exclamation_point: + } +} - % fields - \seq_clear:N \l__stex_copymodule_copymodule_fields_seq - \seq_map_inline:Nn \l__stex_copymodule_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \exp_args:NNx \seq_put_right:Nn \l__stex_copymodule_copymodule_fields_seq { - ##1 ? ####1 +\bool_new:N \stex_in_invisible_html_bool +\bool_set_false:N \stex_in_invisible_html_bool +\stex_if_html_backend:TF { + % 1: variant 2: intent 3: code + \cs_new_protected:Nn \_stex_term_oms:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMID, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1}, + }{ + \_stex_annotate_force_break:n{#3} } + }{ + \__stex_expr_do_headterm:nn{#1}{#3} } } - - % setup prop - \seq_clear:N \l_tmpa_seq - \exp_args:NNx \prop_set_from_keyval:Nn \l_stex_current_copymodule_prop { - name = \l_stex_current_copymodule_name_str , - module = \l_stex_current_module_str , - from = \l_stex_import_ns_str ?\l_stex_import_name_str , - includes = \l_tmpa_seq %, - % fields = \l_tmpa_seq - } - \stex_debug:nn{copymodule}{#4~for~module~{\l_stex_import_ns_str ?\l_stex_import_name_str} - as~\l_stex_current_module_str?\l_stex_current_copymodule_name_str} - \stex_debug:nn{copymodule}{modules:\seq_use:Nn \l__stex_copymodule_copymodule_modules_seq {,~}} - \stex_debug:nn{copymodule}{fields:\seq_use:Nn \l__stex_copymodule_copymodule_fields_seq {,~}} - - \stex_if_do_html:T { - \begin{stex_annotate_env} {#4} { - \l_stex_current_module_str?\l_stex_current_copymodule_name_str + \cs_new_protected:Nn \_stex_term_omv:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMV, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} + } + }{ + \__stex_expr_do_headterm:nn{#1}{#3} } - \stex_annotate_invisible:nnn{domain}{\l_stex_import_ns_str ?\l_stex_import_name_str}{} } -} - -\cs_new_protected:Nn \stex_copymodule_end:n { - % apply to every field - \def \l_tmpa_cs ##1 ##2 {#1} - - \tl_clear:N \__stex_copymodule_module_tl - \tl_clear:N \__stex_copymodule_exec_tl - - %\prop_get:NnN \l_stex_current_copymodule_prop {fields} \l_tmpa_seq - \seq_clear:N \__stex_copymodule_fields_seq - - \seq_map_inline:Nn \l__stex_copymodule_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - - \tl_clear:N \__stex_copymodule_curr_symbol_tl % <- wrap in current symbol html - \l_tmpa_cs{##1}{####1} - - \str_if_exist:cTF {l__stex_copymodule_copymodule_##1?####1_name_str} { - \str_set_eq:Nc \__stex_copymodule_curr_name_str {l__stex_copymodule_copymodule_##1?####1_name_str} - \stex_if_do_html:T { - \tl_put_right:Nx \__stex_copymodule_curr_symbol_tl { - \stex_annotate_invisible:nnn{alias}{\use:c{l__stex_copymodule_copymodule_##1?####1_name_str}}{} - } - } - }{ - \str_set:Nx \__stex_copymodule_curr_name_str { \l_stex_current_copymodule_name_str / ####1 } + \cs_new_protected:Nn \__stex_expr_do_headterm:nn { + \bool_if:NTF \stex_in_invisible_html_bool { + {\bool_set_true:N \l_stex_allow_semantic_bool + \ensuremath{\l_stex_current_term_tl} } - - \prop_set_eq:Nc \l_tmpa_prop {l_stex_symdecl_ ##1?####1 _prop} - \prop_put:Nnx \l_tmpa_prop { name } \__stex_copymodule_curr_name_str - \prop_put:Nnx \l_tmpa_prop { module } \l_stex_current_module_str - - \tl_if_exist:cT {l__stex_copymodule_copymodule_##1?####1_def_tl}{ - \stex_if_do_html:T { - \tl_put_right:Nx \__stex_copymodule_curr_symbol_tl { - $\stex_annotate_invisible:nnn{definiens}{}{\exp_after:wN \exp_not:N\csname l__stex_copymodule_copymodule_##1?####1_def_tl\endcsname}$ + }{ + \stex_annotate:nn{ + shtml:term=complex, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{ + {\bool_set_true:N \l_stex_allow_semantic_bool + \ensuremath{\l_stex_current_term_tl} + } } } - \prop_put:Nnn \l_tmpa_prop { defined } { true } + #2 } - - \stex_add_constant_to_current_module:n \__stex_copymodule_curr_name_str - \tl_put_right:Nx \__stex_copymodule_module_tl { - \seq_clear:c {l_stex_symdecl_ \l_stex_current_module_str ? \__stex_copymodule_curr_name_str _notations} - \prop_set_from_keyval:cn { - l_stex_symdecl_\l_stex_current_module_str ? \__stex_copymodule_curr_name_str _prop - }{ - \prop_to_keyval:N \l_tmpa_prop - } + } + } +}{ + \cs_new_protected:Nn \_stex_term_oms:nnn {#3} + \cs_new_protected:Nn \_stex_term_omv:nnn {#3} + \cs_new_protected:Nn \__stex_expr_do_headterm:nn { #2 } +} +\cs_set_eq:NN \_stex_term_oms_or_omv:nnn \_stex_term_oms:nnn +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_term_oma:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMA, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} } - - \str_if_exist:cT {l__stex_copymodule_copymodule_##1?####1_macroname_str} { - \stex_if_do_html:T { - \tl_put_right:Nx \__stex_copymodule_curr_symbol_tl { - \stex_annotate_invisible:nnn{macroname}{\use:c{l__stex_copymodule_copymodule_##1?####1_macroname_str}}{} - } - } - \tl_put_right:Nx \__stex_copymodule_module_tl { - \tl_set:cx {\use:c{l__stex_copymodule_copymodule_##1?####1_macroname_str}}{ - \stex_invoke_symbol:n { - \l_stex_current_module_str ? \__stex_copymodule_curr_name_str - } - } + }{ + \stex_annotate:nn{ + shtml:term=OMA, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{{ + \bool_set_true:N \l_stex_allow_semantic_bool + \l_stex_current_term_tl + }} + #3 } } - - \seq_put_right:Nx \__stex_copymodule_fields_seq {\l_stex_current_module_str ? \__stex_copymodule_curr_name_str } - - \tl_put_right:Nx \__stex_copymodule_exec_tl { - \stex_copy_notations:nn {\l_stex_current_module_str ? \__stex_copymodule_curr_name_str} { ##1 ? ####1 } + } + } +}{ + \cs_new_protected:Nn \_stex_term_oma:nnn {#3} +} +\stex_if_html_backend:TF { + \cs_new_protected:Nn \_stex_term_omb:nnn { + \tl_if_empty:NTF \l_stex_current_term_tl { + \stex_annotate:nn{ + shtml:term=OMBIND, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{#3} } - - \tl_put_right:Nx \__stex_copymodule_exec_tl { - \stex_if_do_html:TF{ - \stex_annotate_invisible:nnn{assignment} {##1?####1} { \exp_after:wN \exp_not:n \exp_after:wN {\__stex_copymodule_curr_symbol_tl} } - }{ - \exp_after:wN \exp_not:n \exp_after:wN {\__stex_copymodule_curr_symbol_tl} + }{ + \stex_annotate:nn{ + shtml:term=OMBIND, + shtml:head={\l_stex_current_symbol_str}, + shtml:notationid={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate_invisible:nn{shtml:headterm={}}{{ + \bool_set_true:N \l_stex_allow_semantic_bool + \l_stex_current_term_tl + }} + #3 } } } } - - \prop_put:Nno \l_stex_current_copymodule_prop {fields} \__stex_copymodule_fields_seq - \tl_put_left:Nx \__stex_copymodule_module_tl { - \prop_set_from_keyval:cn { - l_stex_copymodule_ \l_stex_current_module_str?\l_stex_current_copymodule_name_str _prop +}{ + \cs_new_protected:Nn \_stex_term_omb:nnn { #3 } +} +\tl_const:Nx \infprec {\int_use:N \c_max_int} +\tl_const:Nx \neginfprec {-\int_use:N \c_max_int} +\int_new:N \l_stex_notation_downprec +\int_set:Nn \l_stex_notation_downprec \infprec +\tl_set:Nn \l__stex_expr_left_bracket_str ( +\tl_set:Nn \l__stex_expr_right_bracket_str ) +\bool_new:N \l_stex_brackets_dones_bool + +\cs_new_protected:Nn \_stex_maybe_brackets:nn { + \bool_if:NTF \l_stex_brackets_dones_bool { + \bool_set_false:N \l_stex_brackets_dones_bool + #2 + } { + \stex_debug:nn{brackets}{#1>\int_eval:n \l_stex_notation_downprec?} + \int_compare:nNnTF { #1 } > \l_stex_notation_downprec { + %\bool_if:NTF \l_stex_inparray_bool { #2 }{ + \dobrackets { + #2 + } + %} }{ - \prop_to_keyval:N \l_stex_current_copymodule_prop + #2 } } +} - \seq_gput_right:cx{c_stex_module_\l_stex_current_module_str _copymodules}{ - \l_stex_current_module_str?\l_stex_current_copymodule_name_str +\cs_new_protected:Npn \dobrackets #1 { + %\ThisStyle{\if D\m@switch + % \exp_args:Nnx \use:nn + % { \exp_after:wN \left\l__stex_expr_left_bracket_str #1 } + % { \exp_not:N\right\l__stex_expr_right_bracket_str } + % \else + \group_begin: + %\stex_pseudogroup_with:nn{\l_stex_brackets_dones_bool\l_stex_notation_downprec}{ + \bool_set_true:N \l_stex_brackets_dones_bool + %\int_set:Nn \l_stex_notation_downprec \infprec + \mathopen{\cs_if_exist:NT\l_stex_current_symbol_str\comp + \l__stex_expr_left_bracket_str + } + #1 + \group_end:%} + \mathclose{\cs_if_exist:NT\l_stex_current_symbol_str\comp + \l__stex_expr_right_bracket_str } - - \exp_args:No \stex_execute_in_module:n \__stex_copymodule_module_tl - \stex_debug:nn{copymodule}{result:\meaning \__stex_copymodule_module_tl} - \stex_debug:nn{copymodule}{output:\meaning \__stex_copymodule_exec_tl} - - \__stex_copymodule_exec_tl - \stex_if_do_html:T { - \end{stex_annotate_env} + %\fi} +} +\cs_new_protected:Npn \withbrackets #1 #2 #3 { + \stex_pseudogroup_with:nn{\l__stex_expr_left_bracket_str\l__stex_expr_right_bracket_str}{ + \tl_set:Nn \l__stex_expr_left_bracket_str { #1 } + \tl_set:Nn \l__stex_expr_right_bracket_str { #2 } + #3 } } - -\NewDocumentEnvironment {copymodule} { O{} m m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #3 }{ copymodule } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \assign - \stex_reactivate_macro:N \renamedecl - \stex_reactivate_macro:N \donotcopy - \stex_smsmode_do: -}{ - \stex_copymodule_end:n {} +\cs_new_protected:Npn \dowithbrackets #1 #2 #3 { + \withbrackets{#1}{#2}{\dobrackets{#3}} } +\def\maincomp{\comp} -\NewDocumentEnvironment {interpretmodule} { O{} m m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #3 }{ interpretmodule } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \assign - \stex_reactivate_macro:N \renamedecl - \stex_reactivate_macro:N \donotcopy - \stex_smsmode_do: +\stex_keys_define:nnnn{symname}{ + \tl_clear:N \l_stex_key_pre_tl + \tl_clear:N \l_stex_key_post_tl + %\tl_clear:N \l_stex_key_proot_tl }{ - \stex_copymodule_end:n { - \tl_if_exist:cF { - l__stex_copymodule_copymodule_##1?##2_def_tl - }{ - \str_if_eq:eeF { - \prop_item:cn{ - l_stex_symdecl_ ##1 ? ##2 _prop }{ defined } - }{ true }{ - \msg_error:nnxx{stex}{error/interpretmodule/nodefiniens}{ - ##1?##2 - }{\l_stex_current_copymodule_name_str} - } - } + pre .tl_set:N = \l_stex_key_pre_tl , + post .tl_set:N = \l_stex_key_post_tl , + root .code:n = {}%.tl_set:N = \l_stex_key_root_tl +}{} + +\NewDocumentCommand \symref { O{} m m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \__stex_expr_do_ref:nNn{#3}\symrefemph@uri\_stex_term_oms:nnn +} +\let\sr\symref + +\NewDocumentCommand \symname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \__stex_expr_do_ref:nNn{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\symrefemph@uri\_stex_term_oms:nnn +} +\let\sn\symname +\protected\def\sns{\symname[post=s]} + +\NewDocumentCommand \Symname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_symbol:n{#2} + \__stex_expr_do_ref:nNn{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\symrefemph@uri\_stex_term_oms:nnn +} +\cs_new_protected:Nn \_stex_capitalize:n { + \uppercase{#1} +} +\let\Sn\Symname +\protected\def\Sns{\Symname[post=s]} + +\cs_new:Npn \_stex_split_slash: #1/#2/#3\_stex_args_end: { + \tl_if_empty:nTF{#3}{ + #2 + }{ + \_stex_split_slash: #2 / #3 \_stex_args_end: + } +} + +\NewDocumentCommand \varref { O{} m m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \__stex_expr_do_ref:nNn{#3}\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn } } -\iffalse \begin{stex_annotate_env} \fi -\NewDocumentEnvironment {realization} { O{} m}{ - \stex_copymodule_start:nnnn { #1 }{ #2 }{ #2 }{ realize } - \stex_deactivate_macro:Nn \symdecl {module~environments} - \stex_deactivate_macro:Nn \symdef {module~environments} - \stex_deactivate_macro:Nn \notation {module~environments} - \stex_reactivate_macro:N \donotcopy - \stex_reactivate_macro:N \assign - \stex_smsmode_do: -}{ - \stex_import_module_uri:nn { #1 } { #2 } - \tl_clear:N \__stex_copymodule_exec_tl - \tl_set:Nx \__stex_copymodule_module_tl { - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } - } - \exp_args:Nx \stex_add_import_to_current_module:n{ - \l_stex_import_ns_str ? \l_stex_import_name_str - } - - \seq_map_inline:Nn \l__stex_copymodule_copymodule_modules_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \str_set:Nx \__stex_copymodule_curr_name_str { \l_stex_current_copymodule_name_str / ####1 } - \tl_if_exist:cT {l__stex_copymodule_copymodule_##1?####1_def_tl}{ - \stex_if_do_html:T { - \tl_put_right:Nx \__stex_copymodule_exec_tl { - \stex_annotate_invisible:nnn{assignment} {##1?####1} { - $\stex_annotate_invisible:nnn{definiens}{}{\exp_after:wN \exp_not:N\csname l__stex_copymodule_copymodule_##1?####1_def_tl\endcsname}$ - } - } - } - \tl_put_right:Nx \__stex_copymodule_module_tl { - \prop_put:cnn {l_stex_symdecl_##1?####1_prop}{ defined }{ true } - } - } - }} - - \exp_args:No \stex_execute_in_module:n \__stex_copymodule_module_tl +\NewDocumentCommand \varname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \__stex_expr_do_ref:nNn{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn + } +} - \__stex_copymodule_exec_tl - \stex_if_do_html:T {\end{stex_annotate_env}} +\NewDocumentCommand \Varname { O{} m} { + \group_begin: + \stex_keys_set:nn{symname}{#1} + \stex_get_var:n{#2} + \__stex_expr_do_ref:nNn{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + }\varemph@uri{ + \str_set_eq:NN \l_stex_current_symbol_str\l_stex_get_symbol_name_str + \def\comp{\_varcomp} + \_stex_term_omv:nnn + } } -\NewDocumentCommand \donotcopy { m }{ - \str_clear:N \l_stex_import_name_str - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } - \seq_map_inline:Nn \l_stex_all_modules_seq { - \str_set:Nn \l_tmpb_str { ##1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n { - \stex_if_do_html:T { - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn{donotcopy}{##1}{ - \stex_annotate:nnn{domain}{##1}{} - } - } - } - \str_set_eq:NN \l_stex_import_name_str \l_tmpb_str - } - } - \seq_map_inline:cn {c_stex_module_##1_copymodules}{ - \str_set:Nn \l_tmpb_str { ####1 } - \str_if_eq:eeT { \l_tmpa_str } { - \str_range:Nnn \l_tmpb_str { -\l_tmpa_int } { -1 } - } { - \seq_map_break:n {\seq_map_break:n { - \stex_if_do_html:T { - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn{donotcopy}{####1}{ - \stex_annotate:nnn{domain}{ - \prop_item:cn {l_stex_copymodule_ ####1 _prop}{module} - }{} - } - } - } - \str_set:Nx \l_stex_import_name_str { - \prop_item:cn {l_stex_copymodule_ ####1 _prop}{module} - } - }} +\cs_new_protected:Nn \__stex_expr_do_ref:nNn { + \stex_if_html_backend:T{\ifvmode\indent\fi} + \bool_if:NTF \l_stex_allow_semantic_bool{ + \str_set:Nx\l_stex_current_symbol_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \str_if_in:NnT \l_stex_get_symbol_name_str / { + \str_set:Nx \l_stex_get_symbol_name_str { + \exp_after:wN \_stex_split_slash: \l_stex_get_symbol_name_str + /\_stex_args_end: } } - } - \str_if_empty:NTF \l_stex_import_name_str { - % TODO throw error + \tl_clear:N \l_stex_current_term_tl + \def\comp{\_comp} + \let\compemph@uri#2 + #3{}{}{\comp{#1}} }{ - \stex_collect_imports:n {\l_stex_import_name_str } - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_remove_all:Nn \l__stex_copymodule_copymodule_modules_seq { ##1 } - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_remove_all:Nn \l__stex_copymodule_copymodule_fields_seq { ##1 ? ####1 } - \bool_lazy_any:nT { - { \cs_if_exist_p:c {l__stex_copymodule_copymodule_##1?####1_name_str}} - { \cs_if_exist_p:c {l__stex_copymodule_copymodule_##1?####1_macroname_str}} - { \cs_if_exist_p:c {l__stex_copymodule_copymodule_##1?####1_def_tl}} - }{ - % TODO throw error - } + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} + } + \group_end: +} +\cs_new_protected:Nn \_do_comp:nNn { + \stex_pseudogroup_with:nn{\comp}{ + \def\comp##1{##1} + \str_if_empty:NTF \l_stex_current_symbol_str { + #3 + }{ + \stex_if_html_backend:TF { + \stex_annotate:nn { shtml:#1 = \l_stex_current_symbol_str}{ #3 } + }{ + \exp_args:Nno #2 { #3 } \l_stex_current_symbol_str } } - \prop_get:NnN \l_stex_current_copymodule_prop { includes } \l_tmpa_seq - \seq_put_right:Nx \l_tmpa_seq {\l_stex_import_name_str } - \prop_put:Nno \l_stex_current_copymodule_prop {includes} \l_tmpa_seq } - \stex_smsmode_do: } -\NewDocumentCommand \assign { m m }{ - \stex_get_symbol_in_seq:nn {#1} \l__stex_copymodule_copymodule_fields_seq - \stex_debug:nn{assign}{defining~{\l_stex_get_symbol_uri_str}~as~\detokenize{#2}} - \tl_set:cn {l__stex_copymodule_copymodule_\l_stex_get_symbol_uri_str _def_tl}{#2} - \stex_smsmode_do: +\cs_new_protected:Npn \_comp { + \_do_comp:nNn {comp}\compemph@uri } -\keys_define:nn { stex / renamedecl } { - name .str_set_x:N = \l_stex_renamedecl_name_str +\cs_new_protected:Npn \_varcomp { + \_do_comp:nNn {varcomp}\varemph@uri } -\cs_new_protected:Nn \__stex_copymodule_renamedecl_args:n { - \str_clear:N \l_stex_renamedecl_name_str - \keys_set:nn { stex / renamedecl } { #1 } + +\cs_new_protected:Npn \_defcomp { + \_do_comp:nNn {definiendum}\defemph@uri } -\NewDocumentCommand \renamedecl { O{} m m}{ - \__stex_copymodule_renamedecl_args:n { #1 } - \stex_get_symbol_in_seq:nn {#2} \l__stex_copymodule_copymodule_fields_seq - \stex_debug:nn{renamedecl}{renaming~{\l_stex_get_symbol_uri_str}~to~#3} - \str_set:cx {l__stex_copymodule_copymodule_\l_stex_get_symbol_uri_str _macroname_str}{#3} - \str_if_empty:NTF \l_stex_renamedecl_name_str { - \tl_set:cx { #3 }{ \stex_invoke_symbol:n { - \l_stex_get_symbol_uri_str - } } - } { - \str_set:cx {l__stex_copymodule_copymodule_\l_stex_get_symbol_uri_str _name_str}{\l_stex_renamedecl_name_str} - \stex_debug:nn{renamedecl}{@~\l_stex_current_module_str ? \l_stex_renamedecl_name_str} - \prop_set_eq:cc {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop} - \seq_set_eq:cc {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _notations - }{l_stex_symdecl_ \l_stex_get_symbol_uri_str _notations} - \prop_put:cnx {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{ name }{ \l_stex_renamedecl_name_str } - \prop_put:cnx {l_stex_symdecl_ - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - _prop - }{ module }{ \l_stex_current_module_str } - \exp_args:NNx \seq_put_left:Nn \l__stex_copymodule_copymodule_fields_seq { - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - } - \tl_set:cx { #3 }{ \stex_invoke_symbol:n { - \l_stex_current_module_str ? \l_stex_renamedecl_name_str - } } - } - \stex_smsmode_do: +\cs_set_protected:Npn \comp {} + +\cs_new_protected:Npn \compemph@uri #1 #2 { + \compemph{ #1 } } -\stex_deactivate_macro:Nn \assign {copymodules} -\stex_deactivate_macro:Nn \renamedecl {copymodules} -\stex_deactivate_macro:Nn \donotcopy {copymodules} +\cs_new_protected:Npn \compemph #1 { + #1 +} +\cs_new_protected:Npn \defemph@uri #1 #2 { + \defemph{#1} +} -\NewDocumentEnvironment{structural_feature_module}{ m m m }{ - \stex_if_in_module:F { - \msg_set:nnn{stex}{error/nomodule}{ - Structural~Feature~has~to~occur~in~a~module:\\ - Feature~#2~of~type~#1\\ - In~File:~\stex_path_to_string:N \g_stex_currentfile_seq - } - \msg_error:nn{stex}{error/nomodule} - } +\cs_new_protected:Npn \defemph #1 { + \ifmmode\else\expandafter\textbf\fi{#1} +} - \str_set_eq:NN \l_stex_feature_parent_str \l_stex_current_module_str +\cs_new_protected:Npn \symrefemph@uri #1 #2 { + \symrefemph{#1} +} + +\cs_new_protected:Npn \symrefemph #1 { + \emph{#1} +} - \stex_module_setup:nn{meta=NONE}{#2 - #1} +\cs_new_protected:Npn \varemph@uri #1 #2 { + \varemph{#1} +} - \stex_if_do_html:T { - \begin{stex_annotate_env}{ feature:#1 }{\l_stex_feature_parent_str ? #2 - #1} - \stex_annotate_invisible:nnn{header}{}{ #3 } +\cs_new_protected:Npn \varemph #1 { + #1 +} +\cs_new_protected:Npn \stex_current_this: { + { \bool_set_true:N \l_stex_allow_semantic_bool + \tl_if_empty:NTF \l_stex_current_this_tl {{}}{ + \str_set:Nx \l_stex_current_symbol_str { + \l_stex_current_module_str ? \l__stex_structures_name_str + } + \maincomp{\l_stex_current_this_tl} + } } +} +\let \this \stex_current_this: +\stex_new_stylable_env:nnnnnnn {mathstructure}{m O{}}{ + \__stex_structures_begin:nn{#1}{#2} + \stex_smsmode_do: +}{ + \stex_structural_feature_module_end: + \__stex_structures_do_externals: +}{}{}{} + +\stex_keys_define:nnnn{mathstructure}{ + \tl_clear:N \l_stex_current_this_tl + \str_clear:N \l__stex_structures_name_str }{ - \str_gset_eq:NN \l_stex_last_feature_str \l_stex_current_module_str - \prop_gput:cnn {c_stex_module_ \l_stex_current_module_str _prop}{feature}{#1} - \stex_debug:nn{features}{ - Feature: \l_stex_last_feature_str + this .tl_set:N = \l_stex_current_this_tl , + unknown .code:n = { + \str_set_eq:NN \l__stex_structures_name_str \l_keys_key_str } - \stex_if_do_html:T { - \end{stex_annotate_env} +}{} + +\cs_new_protected:Nn \__stex_structures_begin:nn { + \stex_keys_set:nn {mathstructure}{#2} + \str_if_empty:NT \l__stex_structures_name_str { + \str_set:Nn \l__stex_structures_name_str {#1} + } + \def\comp{\_comp} + + \exp_args:Nne \use:nn { \stex_module_add_symbol:nnnnnnnN } + { {#1}{\l__stex_structures_name_str}{0}{}{defed}{ + \l_stex_current_module_str / \l__stex_structures_name_str-module + }} + {}\stex_invoke_structure: + \str_set:Nx \l_stex_macroname_str {#1} + \stex_execute_in_module:x{ + \seq_clear:c{l_stex_structure_macros_\l_stex_current_module_str / \l__stex_structures_name_str-module_seq} + \seq_put_right:cn{l_stex_structure_macros_\l_stex_current_module_str / \l__stex_structures_name_str-module_seq}{#1} } + \exp_args:No \stex_structural_feature_module:nn + {\l__stex_structures_name_str}{structure} } -\cs_new_protected:Nn \stex_add_structure_to_current_module:nn { - \prop_if_exist:cF {c_stex_module_\l_stex_current_module_str _structures}{ - \prop_new:c {c_stex_module_\l_stex_current_module_str _structures} + +\stex_sms_allow_env:n{mathstructure} +\stex_deactivate_macro:Nn \mathstructure {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \mathstructure} + +\cs_new_protected:Nn \__stex_structures_do_externals: { + \tl_set:Nn \l__stex_structures_replace_this_tl {####1} + \exp_args:No \stex_iterate_symbols:nn{\g_stex_last_feature_str}{ + \__stex_structures_external_decl:nnnn{##5}{##4}{##3}{##8} } - \prop_gput:cxx{c_stex_module_\l_stex_current_module_str _structures} - {#1}{#2} } -\keys_define:nn { stex / features / structure } { - name .str_set_x:N = \l__stex_structures_name_str , +\cs_new_protected:Nn \__stex_structures_external_decl:nnnn { + %\stex_debug:nn{structure}{ + % Generating~external~declaration~\l__stex_structures_name_str/#3~in~ + % \l_stex_current_module_str^^J + % \tl_to_str:n{#1}^^J\tl_to_str:n{#2}^^J\tl_to_str:n{#4} + %} + %\tl_set:Nn \l_stex_get_symbol_args_tl {#1} + %\exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN} { + % {}{\l__stex_structures_name_str/#3}{\int_eval:n{#2 + 1}} + % {1i\tl_if_empty:nF{#1}{\_stex_map_args:N \__stex_structures_shift_argls:nn}} + % {defed}{typed} + %}{#4}\stex_invoke_outer_field: } -\cs_new_protected:Nn \__stex_structures_structure_args:n { - \str_clear:N \l__stex_structures_name_str - \keys_set:nn { stex / features / structure } { #1 } +\cs_new:Nn \__stex_structures_shift_argls:nn { + \int_eval:n{#1+1}#2 } -\NewDocumentEnvironment{mathstructure}{m O{}}{ - \begin{mathstructure_inner}{#1}[#2] - \stex_smsmode_do: - \ignorespacesandpars - }{\end{mathstructure_inner}} -\NewDocumentEnvironment{mathstructure_inner}{m O{}}{ - \__stex_structures_structure_args:n { #2 } - \str_if_empty:NT \l__stex_structures_name_str { - \str_set:Nx \l__stex_structures_name_str { #1 } - } - \stex_suppress_html:n { - \bool_set_true:N \l_stex_symdecl_make_macro_bool - \exp_args:Nx \stex_symdecl_do:nn { - name = \l__stex_structures_name_str , - def = {\STEXsymbol{module-type}{ - \STEXInternalTermMathOMSiiii { - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { ns } ? - \prop_item:cn {c_stex_module_\l_stex_current_module_str _prop} - { name } / \l__stex_structures_name_str - structure - }{}{0}{} - }} - }{ #1 } +\cs_new_protected:Nn \stex_get_mathstructure:n { + \_stex_get_mathstructure:n{#1} + \str_if_empty:NT \l_stex_get_structure_module_str { + \msg_error:nnn{stex}{error/unknownstructure}{#1} } - \exp_args:Nnnx - \begin{structural_feature_module}{ structure } - { \l__stex_structures_name_str }{} -}{ - \end{structural_feature_module} - \_stex_reset_up_to_module:n \l_stex_last_feature_str - \exp_args:No \stex_collect_imports:n \l_stex_last_feature_str - \seq_clear:N \l_tmpa_seq - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn{c_stex_module_##1_constants}{ - \seq_put_right:Nn \l_tmpa_seq { ##1 ? ####1 } +} +\cs_new_protected:Nn \_stex_get_mathstructure:n { + \str_clear:N \l_stex_get_structure_module_str + \_stex_get_symbol:n{#1} + \str_if_empty:NF \l_stex_get_symbol_name_str { + \exp_args:No \tl_if_eq:NNT \l_stex_get_symbol_invoke_cs \stex_invoke_structure: { + \str_set_eq:NN \l_stex_get_structure_module_str \l_stex_get_symbol_type_tl } } - \exp_args:Nnno - \prop_gput:cnn {c_stex_module_ \l_stex_last_feature_str _prop}{fields}\l_tmpa_seq - \stex_debug:nn{structure}{Fields:~\seq_use:Nn \l_tmpa_seq ,} - \stex_add_structure_to_current_module:nn - \l__stex_structures_name_str - \l_stex_last_feature_str - - \stex_execute_in_module:x { - \tl_set:cn { #1 }{ - \exp_not:N \stex_invoke_structure:nn {\l_stex_current_module_str }{ \l__stex_structures_name_str} +} +\stex_new_stylable_env:nnnnnnn {extstructure}{m O{} m}{ + \seq_clear:N \l__stex_structures_imports_seq + \clist_map_inline:nn{#3}{ + \stex_get_mathstructure:n{##1} + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{####1}}{ + \seq_put_right:Nn \l__stex_structures_imports_seq{####1} + } + } + \stex_execute_in_module:x{ + \seq_put_right:cn{l_stex_structure_macros_\l_stex_get_structure_module_str _seq}{#1} } } -} + \__stex_structures_begin:nn{#1}{#2} + \seq_map_inline:Nn\l__stex_structures_imports_seq{ + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:import={##1}} {}} + } + \stex_module_add_morphism:nonn + {}{##1}{import}{} + \stex_execute_in_module:x{ + \stex_activate_module:n{##1} + } + } + \stex_smsmode_do: +}{ + \stex_structural_feature_module_end: + \__stex_structures_do_externals: +}{}{}{} -\cs_new:Nn \stex_invoke_structure:nn { - \stex_invoke_symbol:n { #1?#2 } +\stex_sms_allow_env:n{extstructure} +\stex_deactivate_macro:Nn \extstructure {module~environments} +\stex_every_module:n { + \stex_reactivate_macro:N \extstructure } -\cs_new_protected:Nn \stex_get_structure:n { - \tl_if_head_eq_catcode:nNTF { #1 } \relax { - \tl_set:Nn \l_tmpa_tl { #1 } - \__stex_structures_get_from_cs: - }{ - \cs_if_exist:cTF { #1 }{ - \cs_set_eq:Nc \l_tmpa_cs { #1 } - \str_set:Nx \l_tmpa_str {\cs_argument_spec:N \l_tmpa_cs } - \str_if_empty:NTF \l_tmpa_str { - \cs_if_eq:NNTF { \tl_head:N \l_tmpa_cs} \stex_invoke_structure:nn { - \__stex_structures_get_from_cs: - }{ - \__stex_structures_get_from_string:n { #1 } - } - }{ - \__stex_structures_get_from_string:n { #1 } - } - }{ - \__stex_structures_get_from_string:n { #1 } - } +\cs_new:Nn \__stex_structures_extend_structure_i:NnnnnnnnN { + \exp_not:n{#1{#2}{#3}{#4}{#5}{defed}}{\l__stex_structures_extmod_str,#7}\exp_not:n{{#8}#9} +} +\cs_new_protected:Nn \__stex_structures_extend_structure:nn { + \stex_debug:nn{ext}{Extending~#1~by~#2} + \str_set:Nn \l__stex_structures_extmod_str{#2} + \tl_set:cx{#1}{ + \exp_after:wN \exp_after:wN \exp_after:wN + \__stex_structures_extend_structure_i:NnnnnnnnN \cs:w #1 \cs_end: } } -\cs_new_protected:Nn \__stex_structures_get_from_cs: { - \exp_args:NNx \tl_set:Nn \l_tmpa_tl - { \tl_tail:N \l_tmpa_tl } - \str_set:Nx \l_tmpa_str { - \exp_after:wN \use_i:nn \l_tmpa_tl - } - \str_set:Nx \l_tmpb_str { - \exp_after:wN \use_ii:nn \l_tmpa_tl +\stex_new_stylable_env:nnnnnnn {extstructure*}{m}{ + \__stex_structures_new_extstruct_name: + \seq_clear:N \l__stex_structures_imports_seq + \stex_get_mathstructure:n{#1} + + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{##1}}{ + \seq_put_right:Nn \l__stex_structures_imports_seq{##1} + } } - \str_set:Nx \l_stex_get_structure_str { - \l_tmpa_str ? \l_tmpb_str + + \stex_execute_in_module:x{ + \seq_map_inline:cn{l_stex_structure_macros_\l_stex_get_structure_module_str _seq}{ + \exp_not:N \tl_if_exist:cT{####1}{ + \__stex_structures_extend_structure:nn{####1}{\l_stex_current_module_str/\l__stex_structures_exstruct_name_str -module} + } + } } - \str_set:Nx \l_stex_get_structure_module_str { - \exp_args:Nno \prop_item:cn {c_stex_module_\l_tmpa_str _structures}{\l_tmpb_str} + + \exp_args:No \__stex_structures_begin:nn\l__stex_structures_exstruct_name_str{} + + \seq_map_inline:Nn \l__stex_structures_imports_seq { + \stex_if_do_html:T { + \stex_annotate_invisible:nn + {shtml:import= {##1}} {} + } + \stex_module_add_morphism:nonn + {}{##1}{import}{} + \stex_execute_in_module:x{ + \stex_activate_module:n{##1} + } } -} -\cs_new_protected:Nn \__stex_structures_get_from_string:n { - \tl_set:Nn \l_tmpa_tl { - \msg_error:nnn{stex}{error/unknownstructure}{#1} + \stex_smsmode_do: +}{ + \prop_map_inline:cn{ + c_stex_module_ \l_stex_current_module_str _symbols_prop + }{ + \__stex_structures_check_def:nnnnnnnn ##2 } - \str_set:Nn \l_tmpa_str { #1 } - \int_set:Nn \l_tmpa_int { \str_count:N \l_tmpa_str } + \stex_structural_feature_module_end: + \__stex_structures_do_externals: +}{}{}{} - \seq_map_inline:Nn \l_stex_all_modules_seq { - \prop_if_exist:cT {c_stex_module_##1_structures} { - \prop_map_inline:cn {c_stex_module_##1_structures} { - \exp_args:No \str_if_eq:nnT \l_tmpa_str {####1}{ - %\str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{ - \prop_map_break:n{\seq_map_break:n{ - \tl_set:Nn \l_tmpa_tl { - \str_set:Nn \l_stex_get_structure_str {##1?####1} - \str_set:Nn \l_stex_get_structure_module_str {####2} - } - }} - } - } - } +\stex_sms_allow_env:n{extstructure*} +\exp_after:wN \stex_deactivate_macro:Nn + \cs:w extstructure*\cs_end: {module~environments} +\stex_every_module:n { + \exp_after:wN \stex_reactivate_macro:N \cs:w extstructure*\cs_end: +} + +\cs_new_protected:Nn \__stex_structures_check_def:nnnnnnnn { + \tl_if_empty:nT{#5}{ + \msg_error:nnnn{stex}{error/needsdefiniens}{#2}{extstructure*} } - \l_tmpa_tl } -\NewDocumentEnvironment{usestructure}{m}{ - \stex_get_structure:n {#1} - \exp_args:Nnx \stex_debug:nn{features}{using~structure:~\l_stex_get_structure_module_str} - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str -}{} +\stex_every_module:n{ \str_set:Nn \l__stex_structures_extname_count 0} -\keys_define:nn { stex / instantiate } { - name .str_set_x:N = \l__stex_structures_name_str +\cs_new_protected:Nn \__stex_structures_new_extstruct_name: { + \stex_do_up_to_module:n { + \str_set:Nx \l__stex_structures_extname_count {\int_eval:n{\l__stex_structures_extname_count+1}} + } + \str_set:Nx \l__stex_structures_exstruct_name_str {EXTSTRUCT_\l__stex_structures_extname_count} } -\cs_new_protected:Nn \__stex_structures_instantiate_args:n { - \str_clear:N \l__stex_structures_name_str - \keys_set:nn { stex / instantiate } { #1 } + +\cs_new_protected:Nn \stex_invoke_structure: { + \tl_set:Nn \l__stex_structures_set_comp_tl {\__stex_structures_set_thiscomp:} + \__stex_structures_invoke_top:n {} } -\NewDocumentEnvironment{extstructure}{m m O{}}{ - \begin{mathstructure_inner}{#1}[#3] - \seq_set_split:Nnn\__stex_structures_extstructure_imports_seq,{#2} - \seq_map_inline:Nn\__stex_structures_extstructure_imports_seq { - \stex_get_structure:n {##1} - \exp_args:Nnx \stex_debug:nn{features}{importing~structure:~\l_stex_get_structure_module_str{}~into~\l_stex_current_module_str} - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \stex_if_smsmode:F { - \stex_annotate_invisible:nnn - {import} {\l_stex_get_structure_module_str} {} - } - \exp_args:Nx \stex_add_import_to_current_module:n { - \l_stex_get_structure_module_str - } - \exp_args:Nx \stex_add_to_current_module:n { - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str +\cs_new_protected:Nn \__stex_structures_invoke_top:n { + \stex_debug:nn{structure}{ + invoking~structure~{\l_stex_current_type_tl}<\tl_to_str:n{#1}> + } + \peek_charcode:NTF [ { + \__stex_structures_merge:nw{#1} + }{ + \__stex_structures_invokation_type:n {#1} + \tl_set:Nn \l__stex_structures_this_tl {} + \peek_charcode_remove:NTF ! { + \peek_charcode:NTF [ { + \__stex_structures_maybe_notation:w + }{ + \__stex_structures_maybe_notation:w [] } + }{ + \__stex_structures_invoke_this:n } - \stex_smsmode_do: - \ignorespacesandpars -}{ - \end{mathstructure_inner} -} - -\NewDocumentEnvironment{extstructure*}{m m O{}}{ - % TODO - \begin{extstructure}{#1}{#2}[#3] -}{ - \end{extstructure} + } } -\NewDocumentCommand \instantiate {m O{} m m O{}}{ - \begingroup - \stex_get_structure:n {#3} - \__stex_structures_instantiate_args:n { #2 } - \str_if_empty:NT \l__stex_structures_name_str { - \str_set:Nn \l__stex_structures_name_str { #1 } - } - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \seq_clear:N \l__stex_structures_fields_seq - \exp_args:Nx \stex_collect_imports:n \l_stex_get_structure_module_str - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_put_right:Nx \l__stex_structures_fields_seq { ##1 ? ####1 } - } - } - - \tl_if_empty:nF{#5}{ - \seq_set_split:Nnn \l_tmpa_seq , {#5} - \prop_clear:N \l_tmpa_prop - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq = { ##1 } - \int_compare:nNnF { \seq_count:N \l_tmpb_seq } = 2 { - \msg_error:nnn{stex}{error/keyval}{##1} - } - \exp_args:Nx \stex_get_symbol_in_seq:nn {\seq_item:Nn \l_tmpb_seq 1} \l__stex_structures_fields_seq - \str_set_eq:NN \l__stex_structures_dom_str \l_stex_get_symbol_uri_str - \exp_args:NNx \seq_remove_all:Nn \l__stex_structures_fields_seq \l_stex_get_symbol_uri_str - \exp_args:Nx \stex_get_symbol:n {\seq_item:Nn \l_tmpb_seq 2} - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l__stex_structures_dom_str} - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}} +\cs_new_protected:Npn \__stex_structures_merge:nw #1 [ #2 ] { + \exp_args:Ne \stex_str_if_starts_with:nnTF {\tl_to_str:n{#2}}{comp=}{ + \__stex_structures_set_customcomp: #2 \__stex_structures_end: + \__stex_structures_invoke_top:n{#1} + }{ + \exp_args:Ne \stex_str_if_starts_with:nnTF {\tl_to_str:n{#2}}{this=}{ + \__stex_structures_set_thisnotation: #2 \__stex_structures_end: + \__stex_structures_invoke_top:n{#1} + }{ + \tl_if_empty:nTF{#1}{ + \__stex_structures_invoke_top:n{#2} + }{ + \tl_if_empty:nTF{#2}{ + \__stex_structures_invoke_top:n{#1} + }{ + \__stex_structures_invoke_top:n{#1,#2} } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} \l_stex_get_symbol_uri_str } } + } +} - \seq_map_inline:Nn \l__stex_structures_fields_seq { - \str_set:Nx \l_tmpa_str {field:\l__stex_structures_name_str . \prop_item:cn {l_stex_symdecl_##1_prop}{name} } - \stex_debug:nn{instantiate}{Field~\l_tmpa_str :~##1} +\cs_new_protected:Npn \__stex_structures_set_thisnotation: this= #1 \__stex_structures_end: { + \tl_set:Nn \l_stex_return_notation_tl { \comp{#1} } + \tl_set:Nn \l__stex_structures_set_comp_tl {} +} - \stex_add_constant_to_current_module:n {\l_tmpa_str} - \stex_execute_in_module:x { - \prop_set_from_keyval:cn { l_stex_symdecl_ \l_stex_current_module_str?\l_tmpa_str _prop}{ - name = \l_tmpa_str , - args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , - arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , - argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} +\cs_new_protected:Npn \__stex_structures_set_customcomp: comp= #1 \__stex_structures_end: { + \tl_set:Nn \l__stex_structures_set_comp_tl { + \__stex_structures_set_custom_comp:n{#1} + } + \tl_set:Nn \l_stex_return_notation_tl { \comp{} } +} +\cs_new_protected:Nn \__stex_structures_invokation_type:n { + \__stex_structures_do_assign_list:n{#1} + \clist_if_empty:NTF \l__stex_structures_fields_clist { + \int_compare:nNnTF {\clist_count:N \l_stex_current_type_tl} + = 1 { + \tl_set:Nx \l__stex_structures_current_type_tl { + \exp_args:No \exp_not:n \l_stex_current_redo_tl + \_stex_term_oms_or_omv:nnn{}{}{} } - \seq_clear:c {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations} - } + }{ + \exp_args:No \__stex_structures_make_type:n \l_stex_current_type_tl + } + }{ + \int_compare:nNnTF {\clist_count:N \l_stex_current_type_tl} + = 1 { + \__stex_structures_make_type:n {} + }{ + \exp_args:No \__stex_structures_make_type:n \l_stex_current_type_tl + } + } +} - \seq_if_empty:cF{l_stex_symdecl_##1_notations}{ - \stex_find_notation:nn{##1}{} - \stex_execute_in_module:x { - \seq_put_right:cn {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations}{\l_stex_notation_variant_str} - } +\cs_new_protected:Nn \__stex_structures_do_assign_list:n { + \clist_clear:N \l__stex_structures_fields_clist + \tl_if_empty:nF {#1} { + \keyval_parse:NNn\TODO\__stex_structures_do_assign:nn{#1} + } +} - \stex_copy_control_sequence_ii:ccN - {stex_notation_\l_stex_current_module_str?\l_tmpa_str\c_hash_str \l_stex_notation_variant_str _cs} - {stex_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \l_tmpa_tl - \exp_args:No \stex_execute_in_module:n \l_tmpa_tl - - \cs_if_exist:cT{stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs}{ - \tl_set_eq:Nc \l_tmpa_cs {stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_execute_in_module:x { - \tl_set:cn - {stex_op_notation_\l_stex_current_module_str?\l_tmpa_str\c_hash_str \l_stex_notation_variant_str _cs} - { \exp_args:No \exp_not:n \l_tmpa_cs} +\cs_new_protected:Nn \__stex_structures_do_assign:nn { + \clist_put_right:Nn \l__stex_structures_fields_clist {{#1}{#2}} +} + +\cs_new_protected:Nn \__stex_structures_make_type:n { + \tl_if_empty:nTF{#1}{ + \seq_clear:N \l_tmpa_seq + }{ + \seq_set_split:Nnn \l_tmpa_seq ,{#1} + \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl + \seq_reverse:N \l_tmpa_seq + } + \tl_set:Nx \l__stex_structures_current_type_tl { + \symuse{Metatheory?module~type~merge}{ + { + \exp_args:No \exp_not:n \l_stex_current_redo_tl + \_stex_term_oms_or_omv:nnn{}{}{} + } + \seq_map_function:NN \l_tmpa_seq \__stex_structures_make_mod:n + \clist_if_empty:NF \l__stex_structures_fields_clist { + ,\symuse{Metatheory?anonymous~record}{ + \exp_args:Ne \tl_tail:n{ + \clist_map_function:NN \l__stex_structures_fields_clist \__stex_structures_make_oml:n } } - } - - \prop_put:Nxx \l_tmpa_prop {\prop_item:cn {l_stex_symdecl_##1_prop}{name}}{\l_stex_current_module_str?\l_tmpa_str} } + } +} - \stex_execute_in_module:x { - \prop_set_from_keyval:cn {l_stex_instance_\l_stex_current_module_str?\l__stex_structures_name_str _prop}{ - domain = \l_stex_get_structure_module_str , - \prop_to_keyval:N \l_tmpa_prop - } - \tl_set:cn{ #1 }{\stex_invoke_instance:n{ \l_stex_current_module_str?\l__stex_structures_name_str} } - } - \stex_debug:nn{instantiate}{ - Instance~\l_stex_current_module_str?\l__stex_structures_name_str \\ - \prop_to_keyval:N \l_tmpa_prop - } - \exp_args:Nxx \stex_symdecl_do:nn { - type={\STEXsymbol{module-type}{ - \STEXInternalTermMathOMSiiii { - \l_stex_get_structure_module_str - }{}{0}{} - }} - }{\l__stex_structures_name_str} - \str_set:Nx \l_stex_get_symbol_uri_str {\l_stex_current_module_str?\l__stex_structures_name_str} - \tl_set:Nn \l_stex_notation_after_do_tl {\__stex_notation_final:} - \stex_notation_do:nnnnn{}{0}{}{}{\comp{#4}} - % } - %\exp_args:Nx \notation{\l__stex_structures_name_str}{\comp{#5}} - \endgroup - \stex_smsmode_do:\ignorespacesandpars -} - -\cs_new_protected:Nn \stex_symbol_or_var:n { - \cs_if_exist:cTF{#1}{ - \cs_set_eq:Nc \l_tmpa_tl { #1 } - \str_set:Nx \l_tmpa_str { \cs_argument_spec:N \l_tmpa_tl } - \str_if_empty:NTF \l_tmpa_str { - \exp_args:Nx \cs_if_eq:NNTF { \tl_head:N \l_tmpa_tl } - \stex_invoke_variable:n { - \bool_set_true:N \l_stex_symbol_or_var_bool - \bool_set_false:N \l_stex_instance_or_symbol_bool - \tl_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\exp_after:wN \use:n \l_tmpa_tl} - \str_set:Nx \l_stex_get_symbol_uri_str { - \exp_after:wN \use:n \l_tmpa_tl - } - }{ % TODO \stex_invoke_varinstance:n - \exp_args:Nx \cs_if_eq:NNTF { \tl_head:N \l_tmpa_tl } \stex_invoke_varinstance:n { - \bool_set_true:N \l_stex_symbol_or_var_bool - \bool_set_true:N \l_stex_instance_or_symbol_bool - \tl_set:Nx \l_tmpa_tl {\tl_tail:N \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\exp_after:wN \use:n \l_tmpa_tl} - \str_set:Nx \l_stex_get_symbol_uri_str { - \exp_after:wN \use:n \l_tmpa_tl - } - }{ - \bool_set_false:N \l_stex_symbol_or_var_bool - \stex_get_symbol:n{#1} - } - } - }{ - \__stex_structures_symbolorvar_from_string:n{ #1 } +\cs_new:Nn \__stex_structures_make_mod:n { + ,\symuse{Metatheory?module~type}{ + \stex_annotate:nn{shtml:term=OMMOD,shtml:head={#1}}{} + } +} + +\cs_new:Nn \__stex_structures_make_oml:n { + \__stex_structures_make_oml:nn #1 +} +\cs_new:Nn \__stex_structures_make_oml:nn { + ,\stex_annotate:nn{ + shtml:term=OML, + shtml:head={#1} + }{ + \_stex_annotate_force_break:n{ + \stex_annotate:nn{shtml:definiens={}}{\exp_not:n{#2!}} } + } +} +\cs_new:Nn \__stex_structures_current_type: { + %\exp_args:No \exp_not:n \l_stex_current_redo_tl + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \exp_args:No\exp_not:n\l__stex_structures_current_type_tl + } + \_stex_term_oms_or_omv:nnn{}{}{} +} +\cs_new_protected:Npn \__stex_structures_maybe_notation:w [ #1 ] { + \tl_set_eq:NN \l_stex_current_term_tl \l__stex_structures_current_type_tl + \cs_if_exist:cTF{l_stex_notation_\l_stex_current_symbol_str _#1_cs}{ + \use:c{l_stex_notation_\l_stex_current_symbol_str _#1_cs}\group_end: }{ - \__stex_structures_symbolorvar_from_string:n{ #1 } + \__stex_structures_make_prop: + \__stex_structures_make_prop_assign: + \__stex_structures_present_i:w [#1] } } -\cs_new_protected:Nn \__stex_structures_symbolorvar_from_string:n { - \prop_if_exist:cTF {l_stex_symdecl_var://#1 _prop}{ - \bool_set_true:N \l_stex_symbol_or_var_bool - \str_set:Nn \l_stex_get_symbol_uri_str { #1 } +\cs_new_protected:Nn \__stex_structures_present: { + \peek_charcode:NTF [ { + \__stex_structures_present_i:w }{ - \bool_set_false:N \l_stex_symbol_or_var_bool - \stex_get_symbol:n{#1} + \__stex_structures_present:nn{}{} } } -\keys_define:nn { stex / varinstantiate } { - name .str_set_x:N = \l__stex_structures_name_str, - bind .choices:nn = - {forall,exists} - {\str_set:Nx \l__stex_structures_bind_str {\l_keys_choice_tl}} - +\cs_new_protected:Npn \__stex_structures_present_i:w [#1] { + \int_compare:nNnTF{\clist_count:n{#1}} = 1 { + \__stex_structures_present:nn{}{#1} + }{ + \peek_charcode:NTF [ { + \__stex_structures_present_ii:nw{#1} + }{ + \__stex_structures_present:nn{#1}{} + } + } } -\cs_new_protected:Nn \__stex_structures_varinstantiate_args:n { - \str_clear:N \l__stex_structures_name_str - \str_clear:N \l__stex_structures_bind_str - \keys_set:nn { stex / varinstantiate } { #1 } + +\cs_new_protected:Npn \__stex_structures_present_ii:nw #1 [#2] { + \__stex_structures_present:nn{#1}{#2} } -\NewDocumentCommand \varinstantiate {m O{} m m O{}}{ - \begingroup - \stex_get_structure:n {#3} - \__stex_structures_varinstantiate_args:n { #2 } - \str_if_empty:NT \l__stex_structures_name_str { - \str_set:Nn \l__stex_structures_name_str { #1 } - } - \stex_if_do_html:TF{ - \stex_annotate:nnn{varinstance}{\l__stex_structures_name_str} - }{\use:n} - { - \stex_if_do_html:T{ - \stex_annotate_invisible:nnn{domain}{\l_stex_get_structure_module_str}{} - } - \seq_clear:N \l__stex_structures_fields_seq - \exp_args:Nx \stex_collect_imports:n \l_stex_get_structure_module_str - \seq_map_inline:Nn \l_stex_collect_imports_seq { - \seq_map_inline:cn {c_stex_module_##1_constants}{ - \seq_put_right:Nx \l__stex_structures_fields_seq { ##1 ? ####1 } - } +\cs_new_protected:Nn \__stex_structures_present:nn { + \clist_clear:N \l__stex_structures_clist + \tl_if_empty:nTF{#1}{ + \cs_set:Npn \l__stex_structures_cs ##1 ##2 ##3 { + \tl_if_empty:nF{##2}{ + \__stex_structures_present_entry:nn {##1}{##3} } - \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str - \prop_clear:N \l_tmpa_prop - \tl_if_empty:nF {#5} { - \seq_set_split:Nnn \l_tmpa_seq , {#5} - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq = { ##1 } - \int_compare:nNnF { \seq_count:N \l_tmpb_seq } = 2 { - \msg_error:nnn{stex}{error/keyval}{##1} - } - \exp_args:Nx \stex_get_symbol_in_seq:nn {\seq_item:Nn \l_tmpb_seq 1} \l__stex_structures_fields_seq - \str_set_eq:NN \l__stex_structures_dom_str \l_stex_get_symbol_uri_str - \exp_args:NNx \seq_remove_all:Nn \l__stex_structures_fields_seq \l_stex_get_symbol_uri_str - \exp_args:Nx \stex_symbol_or_var:n {\seq_item:Nn \l_tmpb_seq 2} - \stex_if_do_html:T{ - \stex_annotate:nnn{assign}{\l__stex_structures_dom_str, - \bool_if:NTF\l_stex_symbol_or_var_bool{var://}{}\l_stex_get_symbol_uri_str}{} - } - \bool_if:NTF \l_stex_symbol_or_var_bool { - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l__stex_structures_dom_str} - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}} - } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_variable:n {\l_stex_get_symbol_uri_str}} - }{ - \exp_args:Nxx \str_if_eq:nnF - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}}{ - \msg_error:nnxxxx{stex}{error/incompatible} - {\l__stex_structures_dom_str} - {\prop_item:cn{l_stex_symdecl_\l__stex_structures_dom_str _prop}{args}} - {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_symdecl_\l_stex_get_symbol_uri_str _prop}{args}} - } - \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_symbol:n {\l_stex_get_symbol_uri_str}} - } - } + } + }{ + \cs_set:Npn \l__stex_structures_cs ##1 ##2 ##3 { + \exp_args:Ne \clist_if_in:nnT{\tl_to_str:n{#1}}{##1}{ + \__stex_structures_present_entry:nn {##1}{##3} } - \tl_gclear:N \g__stex_structures_aftergroup_tl - \seq_map_inline:Nn \l__stex_structures_fields_seq { - \str_set:Nx \l_tmpa_str {\l__stex_structures_name_str . \prop_item:cn {l_stex_symdecl_##1_prop}{name} } - \stex_debug:nn{varinstantiate}{Field~\l_tmpa_str :~##1} - \seq_if_empty:cF{l_stex_symdecl_##1_notations}{ - \stex_find_notation:nn{##1}{} - \cs_gset_eq:cc{g__stex_structures_tmpa_\l_tmpa_str _cs} - {stex_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_debug:nn{varinstantiate}{Notation:~\cs_meaning:c{g__stex_structures_tmpa_\l_tmpa_str _cs}} - \cs_if_exist:cT{stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs}{ - \cs_gset_eq:cc {g__stex_structures_tmpa_op_\l_tmpa_str _cs} - {stex_op_notation_##1\c_hash_str \l_stex_notation_variant_str _cs} - \stex_debug:nn{varinstantiate}{Operator~Notation:~\cs_meaning:c{g__stex_structures_tmpa_op_\l_tmpa_str _cs}} - } - } + } + } + \prop_map_inline:Nn \l__stex_structures_prop { + \l__stex_structures_cs {##1} ##2 + } + \_stex_term_oms_or_omv:nnn{}{}{ + \exp_args:Nno \use:n{ + \bool_set_true:N \l_stex_allow_semantic_bool + \symuse{Metatheory?mathematical~structure}[#2] + }{\l__stex_structures_clist} + }\group_end: +} - \exp_args:NNx \tl_gput_right:Nn \g__stex_structures_aftergroup_tl { - \prop_set_from_keyval:cn { l_stex_symdecl_ var://\l_tmpa_str _prop}{ - name = \l_tmpa_str , - args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , - arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , - argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} , - } - \cs_set_eq:cc {stex_var_notation_\l_tmpa_str _cs} - {g__stex_structures_tmpa_\l_tmpa_str _cs} - \cs_set_eq:cc {stex_var_op_notation_\l_tmpa_str _cs} - {g__stex_structures_tmpa_op_\l_tmpa_str _cs} +\cs_new_protected:Nn \__stex_structures_present_entry:nn { + \seq_if_in:NnTF \l__stex_structures_assigned_seq {#1}{ + \clist_put_right:Nn \l__stex_structures_clist {#2!} + }{ + \exp_args:NNe \clist_put_right:Nn \l__stex_structures_clist { + \_stex_next_symbol:n { + \exp_args:No \exp_not:n \l__stex_structures_set_comp_tl + \tl_set:Nn \exp_not:N \l__stex_structures_this_tl { + \exp_args:No \exp_not:n \l__stex_structures_this_tl } - \prop_put:Nxx \l_tmpa_prop {\prop_item:cn {l_stex_symdecl_##1_prop}{name}}{\stex_invoke_variable:n {\l_tmpa_str}} - } - \exp_args:NNx \tl_gput_right:Nn \g__stex_structures_aftergroup_tl { - \prop_set_from_keyval:cn {l_stex_varinstance_\l__stex_structures_name_str _prop }{ - domain = \l_stex_get_structure_module_str , - \prop_to_keyval:N \l_tmpa_prop + \exp_not:n { + \tl_set_eq:NN \this \l__stex_structures_this_tl } - \tl_set:cn { #1 }{\stex_invoke_varinstance:n {\l__stex_structures_name_str}} - \tl_set:cn {l_stex_varinstance_\l__stex_structures_name_str _op_tl}{ - \exp_args:Nnx \exp_not:N \use:nn { - \str_set:Nn \exp_not:N \STEXInternalCurrentSymbolStr {var://\l__stex_structures_name_str} - \_stex_term_omv:nn {var://\l__stex_structures_name_str}{ - \exp_not:n{ - \_varcomp{#4} - } - } - }{ - \exp_not:n{\_stex_reset:N \STEXInternalCurrentSymbolStr} - } + \tl_set:Nn \exp_not:N \l_stex_return_notation_tl { + \exp_args:No \exp_not:n \l_stex_return_notation_tl } } + \exp_not:n{#2!} } - \stex_debug:nn{varinstantiate}{\expandafter\detokenize\expandafter{\g__stex_structures_aftergroup_tl}} - \aftergroup\g__stex_structures_aftergroup_tl - \endgroup - \stex_smsmode_do:\ignorespacesandpars + } } -\cs_new_protected:Nn \stex_invoke_instance:n { - \peek_charcode_remove:NTF ! { - \stex_invoke_symbol:n{#1} - }{ - \_stex_invoke_instance:nn {#1} +\cs_new_protected:Npn \_thiscomp #1 #2 { + {\tl_set:cn{this}{{}}#1{#2}\c_math_subscript_token{ + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \l__stex_structures_this_tl + \group_end: + } + } +} + +\cs_new_protected:Nn \__stex_structures_set_thiscomp: { + \exp_args:Ne \tl_if_eq:NNF {\tl_head:N \maincomp} \_thiscomp { + \edef\maincomp {\_thiscomp{\comp}} } } -\cs_new_protected:Nn \stex_invoke_varinstance:n { +\cs_new_protected:Nn \__stex_structures_set_custom_comp:n { + \exp_args:Ne \tl_if_eq:NNF {\tl_head:N \maincomp} \_customthiscomp { + \cs_set_protected:Npx \_customthiscomp ##1 { + \group_begin: + \bool_set_true:N \l_stex_allow_semantic_bool + \exp_not:n{ + \cs_set:Npn \l__stex_structures_comp_cs ##1 { + #1 + } + \def\maincomp + }{\comp} + \exp_not:N\l__stex_structures_comp_cs{\comp{##1}} + \group_end: + } + \def\maincomp {\_customthiscomp} + } +} + + +\cs_new_protected:Nn \__stex_structures_invoke_this:n { \peek_charcode_remove:NTF ! { - \exp_args:Nnx \use:nn { - \def\comp{\_varcomp} - \use:c{l_stex_varinstance_#1_op_tl} + \exp_args:Nne\use:nn{ + \group_end:\symuse{Metatheory?of~type}[invisible]{#1} }{ - \_stex_reset:N \comp + {\__stex_structures_current_type:} } }{ - \_stex_invoke_varinstance:nn {#1} + \__stex_structures_invoke_maybe_field:nn{#1} } } -\cs_new_protected:Nn \_stex_invoke_instance:nn { - \prop_if_in:cnTF {l_stex_instance_ #1 _prop}{#2}{ - \exp_args:Nx \stex_invoke_symbol:n {\prop_item:cn{l_stex_instance_ #1 _prop}{#2}} +\cs_new_protected:Nn \__stex_structures_invoke_maybe_field:nn { + \__stex_structures_make_prop: + \__stex_structures_set_this:n{#1} + \tl_if_empty:nTF{#2}{ + \__stex_structures_make_prop_assign: + \__stex_structures_present: }{ - \prop_set_eq:Nc \l_tmpa_prop{l_stex_instance_ #1 _prop} - \msg_error:nnxxx{stex}{error/unknownfield}{#2}{#1}{ - \prop_to_keyval:N \l_tmpa_prop - } + \__stex_structures_invoke_field:n{#2} } } -\cs_new_protected:Nn \_stex_invoke_varinstance:nn { - \prop_if_in:cnTF {l_stex_varinstance_ #1 _prop}{#2}{ - \prop_get:cnN{l_stex_varinstance_ #1 _prop}{#2}\l_tmpa_tl - \l_tmpa_tl +\cs_new_protected:Nn \__stex_structures_set_this:n { + \tl_if_empty:nTF{#1}{ + %\tl_put_right:Nn \l_stex_current_redo_tl { + % \tl_clear:N \l__stex_structures_this_tl + %} }{ - \msg_error:nnnnn{stex}{error/unknownfield}{#2}{#1}{} + \tl_set:Nx \l__stex_structures_this_tl {{ + \bool_set_true:N \l_stex_allow_semantic_bool + \tl_set:Nn \exp_not:N \this { + \exp_args:No \exp_not:n \this + } + \exp_not:n{#1} + }} + \tl_set_eq:NN \this \l__stex_structures_this_tl + % \l_stex_return_notation_tl } } -\cs_new_protected:Nn \stex_invoke_structure:nnn { - \tl_if_empty:nTF{ #3 }{ - \prop_set_eq:Nc \l__stex_structures_structure_prop { - c_stex_feature_ #2 _prop - } - \tl_clear:N \l_tmpa_tl - \prop_get:NnN \l__stex_structures_structure_prop { fields } \l_tmpa_seq - \seq_map_inline:Nn \l_tmpa_seq { - \seq_set_split:Nnn \l_tmpb_seq ? { ##1 } - \seq_get_right:NN \l_tmpb_seq \l_tmpa_str - \cs_if_exist:cT { - stex_notation_ #1/\l_tmpa_str \c_hash_str\c_hash_str _cs - }{ - \tl_if_empty:NF \l_tmpa_tl { - \tl_put_right:Nn \l_tmpa_tl {,} + +\cs_new_protected:Nn \__stex_structures_get_field_name:n { + \str_set:Nx \l__stex_structures_field_name_str { + \exp_args:Nne \use:n {\exp_after:wN \use_i:nn \use:n} + {\prop_item:Nn \l__stex_structures_prop {#1}} + } + \str_if_empty:NT \l__stex_structures_field_name_str { + \str_set:Nn \l__stex_structures_field_name_str {#1} + } +} + +\cs_new_protected:Nn \__stex_structures_invoke_field:n { + \prop_if_in:NnTF \l__stex_structures_prop {#1}{ + \__stex_structures_get_field_name:n{#1} + \tl_clear:N \l__stex_structures_more_nextsymbol_tl + %\exp_args:NNe \seq_if_in:NnF \l__stex_structures_assigned_seq {\tl_to_str:n{#1}}{ + \tl_set:Nx \l__stex_structures_more_nextsymbol_tl { + \tl_set:Nn \exp_not:N \l__stex_structures_this_tl { + \exp_args:No \exp_not:n \l__stex_structures_this_tl } - \tl_put_right:Nx \l_tmpa_tl { - \stex_invoke_symbol:n {#1/\l_tmpa_str}! + \exp_not:n { + \tl_set_eq:NN \this \l__stex_structures_this_tl + } + \tl_set:Nn \exp_not:N \l_stex_return_notation_tl { + \exp_args:No \exp_not:n \l_stex_return_notation_tl } + \exp_args:No \exp_not:n \l__stex_structures_set_comp_tl + } + %} + \exp_args:NNx \use:nn \group_end: { + \_stex_next_symbol:n { + \exp_args:No \exp_not:n \l__stex_structures_redo_tl + \tl_set:Nn \exp_not:N \l_stex_current_term_tl { + \symuse{Metatheory?record~field}{ + \symuse{Metatheory?of~type}{ + \exp_args:No \exp_not:n \l__stex_structures_this_tl + }{ \__stex_structures_current_type: } + }{ + \stex_annotate:nn{shtml:term=OML,shtml:head={\l__stex_structures_field_name_str}}{} + } + } + \exp_args:No \exp_not:n \l__stex_structures_more_nextsymbol_tl } + \exp_not:N \use_ii:nn + \prop_item:Nn \l__stex_structures_prop {#1} } - \exp_args:No \mathstruct \l_tmpa_tl }{ - \stex_invoke_symbol:n{#1/#3} + \msg_error:nnn{stex}{error/unknownfield}{#1} } } -%%%%%%%%%%%%% features.dtx %%%%%%%%%%%%% - - -\def\titleemph#1{\textbf{#1}} -\keys_define:nn {stex / definiendum }{ - pre .tl_set:N = \l__stex_statements_definiendum_pre_tl, - post .tl_set:N = \l__stex_statements_definiendum_post_tl, - root .str_set_x:N = \l__stex_statements_definiendum_root_str, - gfa .str_set_x:N = \l__stex_statements_definiendum_gfa_str -} -\cs_new_protected:Nn \__stex_statements_definiendum_args:n { - \str_clear:N \l__stex_statements_definiendum_root_str - \tl_clear:N \l__stex_statements_definiendum_post_tl - \str_clear:N \l__stex_statements_definiendum_gfa_str - \keys_set:nn { stex / definiendum }{ #1 } +\cs_new_protected:Nn \__stex_structures_make_prop: { + \prop_clear:N \l__stex_structures_prop + \seq_clear:N \l__stex_structures_seq + \seq_clear:N \l__stex_structures_assigned_seq + \tl_clear:N \l__stex_structures_redo_tl + \__stex_structures_prop_do_decls: + \__stex_structures_prop_do_notations: } -\NewDocumentCommand \definiendum { O{} m m} { - \__stex_statements_definiendum_args:n { #1 } - \stex_get_symbol:n { #2 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \str_if_empty:NTF \l__stex_statements_definiendum_root_str { - \tl_if_empty:NTF \l__stex_statements_definiendum_post_tl { - \tl_set:Nn \l_tmpa_tl { #3 } - } { - \str_set:Nx \l__stex_statements_definiendum_root_str { #3 } - \tl_set:Nn \l_tmpa_tl { - \l__stex_statements_definiendum_pre_tl\l__stex_statements_definiendum_root_str\l__stex_statements_definiendum_post_tl - } - } - } { - \tl_set:Nn \l_tmpa_tl { #3 } - } - % TODO root - \stex_html_backend:TF { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { \l_tmpa_tl } - } { - \exp_args:Nnx \defemph@uri { \l_tmpa_tl } { \l_stex_get_symbol_uri_str } +\cs_new_protected:Nn \__stex_structures_make_prop_assign: { + \clist_if_empty:NF \l__stex_structures_fields_clist { + \clist_map_inline:Nn \l__stex_structures_fields_clist { + \__stex_structures_make_prop_assign:nn ##1 + } } } -\stex_deactivate_macro:Nn \definiendum {definition~environments} -\NewDocumentCommand \definame { O{} m } { - \__stex_statements_definiendum_args:n { #1 } - % TODO: root - \stex_get_symbol:n { #2 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \str_replace_all:Nnn \l_tmpa_str {-} {~} - \stex_html_backend:TF { - \stex_if_do_html:T { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { - \l_tmpa_str\l__stex_statements_definiendum_post_tl - } - } - } { - \exp_args:Nnx \defemph@uri { - \l_tmpa_str\l__stex_statements_definiendum_post_tl - } { \l_stex_get_symbol_uri_str } +\cs_new_protected:Nn \__stex_structures_make_prop_assign:nn { + \prop_if_in:NnTF \l__stex_structures_prop {#1}{ + \exp_args:NNe \seq_put_right:Nn \l__stex_structures_assigned_seq {\tl_to_str:n{#1}} + \exp_args:Nne \use:nn {\__stex_structures_make_prop_assign_replace:nnnn {#1}{#2}} + {\prop_item:Nn \l__stex_structures_prop {#1}} + }{ + \msg_error:nnn{stex}{error/unknownfieldass}{#1} } } -\stex_deactivate_macro:Nn \definame {definition~environments} - -\NewDocumentCommand \Definame { O{} m } { - \__stex_statements_definiendum_args:n { #1 } - \stex_get_symbol:n { #2 } - \str_set:Nx \l_tmpa_str { - \prop_item:cn { l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop } { name } - } - \exp_args:NNno \str_replace_all:Nnn \l_tmpa_str {-} {~} - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str - \stex_html_backend:TF { - \stex_if_do_html:T { - \stex_annotate:nnn { definiendum } { \l_stex_get_symbol_uri_str } { - \exp_after:wN \stex_capitalize:n \l_tmpa_str\l__stex_statements_definiendum_post_tl - } +\cs_new_protected:Nn \__stex_structures_make_prop_assign_replace:nnnn { + \prop_put:Nnn \l__stex_structures_prop {#1}{{#3}{#2}} + \tl_if_empty:nF{#3}{ + \tl_set:cn{#1}{ #2 } + \tl_put_right:Nn \l__stex_structures_redo_tl { + \tl_set:cn{#1}{ #2 } } - } { - \exp_args:Nnx \defemph@uri { - \exp_after:wN \stex_capitalize:n \l_tmpa_str\l__stex_statements_definiendum_post_tl - } { \l_stex_get_symbol_uri_str } } } -\stex_deactivate_macro:Nn \Definame {definition~environments} -\NewDocumentCommand \premise { m }{ - \noindent\stex_annotate:nnn{ premise }{}{\ignorespaces #1 } -} -\NewDocumentCommand \conclusion { m }{ - \noindent\stex_annotate:nnn{ conclusion }{}{\ignorespaces #1 } -} -\NewDocumentCommand \definiens { O{} m }{ - \str_clear:N \l_stex_get_symbol_uri_str - \tl_if_empty:nF {#1} { - \stex_get_symbol:n { #1 } - } - \str_if_empty:NT \l_stex_get_symbol_uri_str { - \int_compare:nNnTF {\clist_count:N \l__stex_statements_sdefinition_for_clist} = 1 { - \str_set:Nx \l_stex_get_symbol_uri_str {\clist_item:Nn \l__stex_statements_sdefinition_for_clist 1} +\cs_new_protected:Nn \__stex_structures_prop_do_decls: { + \exp_args:No \stex_iterate_symbols:nn \l_stex_current_type_tl { + \tl_if_empty:nTF{##2}{ + \__stex_structures_do_decl_nomacro:nnnnnnnnn{##3} }{ - % TODO throw error + \__stex_structures_do_decl:nnnnnnnnn{##2} } + {##1}{##3}{##4}{##5}{##6}{##7}{##8}{##9} } - \str_if_eq:eeT {\prop_item:cn {l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{module}} - {\l_stex_current_module_str}{ - \str_if_eq:eeF {\prop_item:cn {l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}} - {true}{ - \prop_put:cnn{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}{true} - \exp_args:Nx \stex_add_to_current_module:n { - \prop_put:cnn{l_stex_symdecl_ \l_stex_get_symbol_uri_str _prop}{defined}{true} - } - } - } - \stex_annotate:nnn{ definiens }{\l_stex_get_symbol_uri_str}{ #2 } } -\NewDocumentCommand \varbindforall {m}{ - \stex_symbol_or_var:n {#1} - \bool_if:NTF\l_stex_symbol_or_var_bool{ - \stex_if_do_html:T { - \stex_annotate_invisible:nnn {bindtype}{forall,\l_stex_get_symbol_uri_str}{} +\cs_new_protected:Nn \__stex_structures_do_decl_nomacro:nnnnnnnnn { + \prop_if_in:NnF \l__stex_structures_prop {#1} { + \seq_put_left:Nx \l__stex_structures_seq {\tl_to_str:n{#2?#3}} + \prop_put:Nnn \l__stex_structures_prop {#1}{ + {}{ + \_stex_invoke_symbol:nnnnnnnN + {#2} + {#3} + {#4}{#5}{#6}{#7}{#8}#9 + } } - }{ - % todo throw error } } -\stex_deactivate_macro:Nn \premise {definition,~example~or~assertion~environments} -\stex_deactivate_macro:Nn \conclusion {example~or~assertion~environments} -\stex_deactivate_macro:Nn \definiens {definition~environments} -\stex_deactivate_macro:Nn \varbindforall {definition~or~assertion~environments} - - -\keys_define:nn {stex / sdefinition }{ - type .str_set_x:N = \sdefinitiontype, - id .str_set_x:N = \sdefinitionid, - name .str_set_x:N = \sdefinitionname, - for .clist_set:N = \l__stex_statements_sdefinition_for_clist , - title .tl_set:N = \sdefinitiontitle -} -\cs_new_protected:Nn \__stex_statements_sdefinition_args:n { - \str_clear:N \sdefinitiontype - \str_clear:N \sdefinitionid - \str_clear:N \sdefinitionname - \clist_clear:N \l__stex_statements_sdefinition_for_clist - \tl_clear:N \sdefinitiontitle - \keys_set:nn { stex / sdefinition }{ #1 } +\cs_new_protected:Nn \__stex_structures_do_decl:nnnnnnnnn { + \prop_if_in:NnF \l__stex_structures_prop {#1} { + \seq_put_left:Nx \l__stex_structures_seq {\tl_to_str:n{#2?#3}} + \prop_put:Nnn \l__stex_structures_prop {#1}{ + {#3}{ + \_stex_invoke_symbol:nnnnnnnN + {#2} + {#3} + {#4}{#5}{#6}{#7}{#8}#9 + } + } + } + %\tl_set:cn{#1}{ + % \_stex_invoke_symbol:nnnnnnnN + % {#2}{#3}{#4}{#5}{#6}{#7}{#8}#9 + %} + %\tl_put_right:Nn \l__stex_structures_redo_tl { + % \tl_set:cn{#1}{ + % \_stex_invoke_symbol:nnnnnnnN + % {#2}{#3}{#4}{#5}{#6}{#7}{#8}#9 + % } + %} } -\NewDocumentEnvironment{sdefinition}{O{}}{ - \__stex_statements_sdefinition_args:n{ #1 } - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - \stex_reactivate_macro:N \varbindforall - \stex_if_smsmode:F{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sdefinition_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str +\cs_new_protected:Nn \__stex_structures_prop_do_notations: { + \exp_args:No \stex_iterate_notations:nn\l_stex_current_type_tl{ + \exp_args:NNe \seq_if_in:NnT \l__stex_structures_seq {\tl_to_str:n{##1}}{ + \tl_put_right:Nn \l__stex_structures_redo_tl { + \cs_if_exist:cF{l_stex_notation_##1 _##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _##2_cs}{##4} + } + \cs_if_exist:cF{l_stex_notation_##1 __cs}{ + \tl_set:cn{l_stex_notation_##1 __cs}{##4} } } - } - \clist_set_from_seq:NN \l__stex_statements_sdefinition_for_clist \l_tmpb_seq - \exp_args:Nnnx - \begin{stex_annotate_env}{definition}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sdefinitiontype { - \stex_annotate_invisible:nnn{typestrings}{\sdefinitiontype}{} - } - \str_if_empty:NF \sdefinitionname { - \stex_annotate_invisible:nnn{statementname}{\sdefinitionname}{} - } - \clist_set:No \l_tmpa_clist \sdefinitiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sdefinition_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sdefinition_##1_start:}} + \cs_if_exist:cF{l_stex_notation_##1 _##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _##2_cs}{##4} + } + \cs_if_exist:cF{l_stex_notation_##1 __cs}{ + \tl_set:cn{l_stex_notation_##1 __cs}{##4} + } + \tl_if_empty:nF{##5}{ + \tl_put_right:Nn \l__stex_structures_redo_tl { + \cs_if_exist:cF{l_stex_notation_##1 _op_##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _op_##2_cs}{##5} + } + \cs_if_exist:cF{l_stex_notation_##1 _op__cs}{ + \tl_set:cn{l_stex_notation_##1 _op__cs}{##5} + } + } + \cs_if_exist:cF{l_stex_notation_##1 _op_##2_cs}{ + \tl_set:cn{l_stex_notation_##1 _op_##2_cs}{##5} + } + \cs_if_exist:cF{l_stex_notation_##1 _op__cs}{ + \tl_set:cn{l_stex_notation_##1 _op__cs}{##5} + } } } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sdefinition_start: - }{ - \l_tmpa_tl - } - } - \stex_ref_new_doc_target:n \sdefinitionid - \stex_smsmode_do: -}{ - \stex_suppress_html:n { - \str_if_empty:NF \sdefinitionname { \stex_symdecl_do:nn{}{\sdefinitionname} } } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sdefinitiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sdefinition_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sdefinition_##1_end:}} - } +} +\cs_new_protected:Npn \usestructure #1 { + \stex_get_mathstructure:n{ #1 } + \seq_clear:N \l__stex_structures_imports_seq + \clist_map_inline:Nn \l_stex_get_symbol_type_tl { + \exp_args:Ne \stex_if_module_exists:nT{\tl_to_str:n{##1}}{ + \seq_put_right:Nn \l__stex_structures_imports_seq{##1} } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sdefinition_end: - }{ - \l_tmpa_tl + } + \seq_map_inline:Nn \l__stex_structures_imports_seq { + \stex_if_do_html:T { + \hbox{\stex_annotate_invisible:nn + {shtml:usemodule=##1} {}} } - \end{stex_annotate_env} + \stex_activate_module:n {##1} } } -\cs_new_protected:Nn \__stex_statements_sdefinition_start: { - \stex_par:\noindent\titleemph{Definition\tl_if_empty:NF \sdefinitiontitle { - ~(\sdefinitiontitle) - }~} -} -\cs_new_protected:Nn \__stex_statements_sdefinition_end: {\stex_par:\medskip} -\newcommand\stexpatchdefinition[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_statements_sdefinition_start: { #2 } - \tl_set:Nn \__stex_statements_sdefinition_end: { #3 } +\stex_keys_define:nnnn{statement}{ + \str_clear:N \l_stex_key_name_str + \str_clear:N \l_stex_key_macroname_str + \clist_clear:N \l_stex_key_for_clist + \str_clear:N \l_stex_key_args_str + \tl_clear:N \l_stex_key_type_tl + \tl_clear:N \l_stex_key_def_tl + \tl_clear:N \l_stex_key_return_tl + \clist_clear:N \l_stex_key_argtypes_clist +}{ + name .str_set:N = \l_stex_key_name_str , + for .clist_set:N = \l_stex_key_for_clist , + macro .str_set:N = \l_stex_key_macroname_str , + % start .str_set:N = \l_stex_key_title_str , % TODO remove + type .tl_set:N = \l_stex_key_type_tl , + judgment .code:n = {}, + from .code:n= {}, % TODO remove + to .code:n={} % TODO remove +}{id,title,style,symargs} +\cs_new_protected:Npn \_stex_do_for_list: { + \seq_clear:N \l_stex_fors_seq + \clist_map_inline:Nn \l_stex_key_for_clist { + \exp_args:Ne\stex_get_symbol:n{\tl_to_str:n{##1}} + \seq_put_right:Nx \l_stex_fors_seq + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } +} + +\cs_new_protected:Nn \__stex_statements_setup:nn { + \str_if_empty:NF \l_stex_key_macroname_str { + \str_if_empty:NT \l_stex_key_name_str { + \str_set_eq:NN \l_stex_key_name_str \l_stex_key_macroname_str + } + } + \_stex_do_for_list: + \str_if_empty:NF \l_stex_key_name_str { + \__stex_statements_force_id: + \seq_put_right:Nx \l_stex_fors_seq { + \l_stex_current_module_str ? \l_stex_key_name_str + } + \str_set_eq:NN \l_stex_macroname_str \l_stex_key_macroname_str + \str_set:Nn \l_stex_key_role_str {#2} + \stex_symdecl_do: + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_key_macroname_str}{\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {#1}{}{}\stex_invoke_symbol: + } + \stex_if_do_html:T \_stex_symdecl_html: + } + \str_clear:N \l__stex_statements_uri_str + \str_if_empty:NTF \l_stex_key_name_str { + \stex_debug:nn{statement}{no~name} + \int_compare:nNnTF {\seq_count:N \l_stex_fors_seq} = 1 { + \str_set:Nx \l__stex_statements_uri_str {\seq_item:Nn \l_stex_fors_seq 1} + \stex_debug:nn{statement}{for:~\l__stex_statements_uri_str} }{ - \exp_after:wN \tl_set:Nn \csname __stex_statements_sdefinition_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_statements_sdefinition_#1_end:\endcsname{ #3 } - } -} -\keys_define:nn {stex / inlinedef }{ - type .str_set_x:N = \sdefinitiontype, - id .str_set_x:N = \sdefinitionid, - for .clist_set:N = \l__stex_statements_sdefinition_for_clist , - name .str_set_x:N = \sdefinitionname -} -\cs_new_protected:Nn \__stex_statements_inlinedef_args:n { - \str_clear:N \sdefinitiontype - \str_clear:N \sdefinitionid - \str_clear:N \sdefinitionname - \clist_clear:N \l__stex_statements_sdefinition_for_clist - \keys_set:nn { stex / inlinedef }{ #1 } -} -\NewDocumentCommand \inlinedef { O{} m } { - \begingroup - \__stex_statements_inlinedef_args:n{ #1 } - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - \stex_reactivate_macro:N \varbindforall - \stex_ref_new_doc_target:n \sdefinitionid - \stex_if_smsmode:TF{\stex_suppress_html:n { - \str_if_empty:NF \sdefinitionname { \stex_symdecl_do:nn{}{\sdefinitionname} } - }}{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sdefinition_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \clist_set_from_seq:NN \l__stex_statements_sdefinition_for_clist \l_tmpb_seq - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{definition}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sdefinitiontype { - \stex_annotate_invisible:nnn{typestrings}{\sdefinitiontype}{} - } - #2 - \str_if_empty:NF \sdefinitionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sdefinitionname}} - \stex_annotate_invisible:nnn{statementname}{\sdefinitionname}{} - } + \stex_debug:nn{statement}{no~for} } + }{ + \str_set:Nx \l__stex_statements_uri_str {\l_stex_current_module_str ? \l_stex_key_name_str} + \stex_debug:nn{statement}{name:~\l__stex_statements_uri_str} } - \endgroup - \stex_smsmode_do: } -\keys_define:nn {stex / sassertion }{ - type .str_set_x:N = \sassertiontype, - id .str_set_x:N = \sassertionid, - title .tl_set:N = \sassertiontitle , - for .clist_set:N = \l__stex_statements_sassertion_for_clist , - name .str_set_x:N = \sassertionname -} -\cs_new_protected:Nn \__stex_statements_sassertion_args:n { - \str_clear:N \sassertiontype - \str_clear:N \sassertionid - \str_clear:N \sassertionname - \clist_clear:N \l__stex_statements_sassertion_for_clist - \tl_clear:N \sassertiontitle - \keys_set:nn { stex / sassertion }{ #1 } +\cs_new:Nn \__stex_statements_html_keyvals:nn { + shtml:#1={}, + shtml:inline={#2}, + \seq_if_empty:NF \l_stex_fors_seq {, + shtml:fors={\seq_use:Nn \l_stex_fors_seq ,} + } + \str_if_empty:NF \l_stex_key_id_str {, + shtml:id={\stex_uri_use:N \l_stex_current_doc_uri ? \l_stex_key_id_str} + } + \clist_if_empty:NF \l_stex_key_style_clist {, + shtml:styles={\l_stex_key_style_clist} + } } +\cs_new_protected:Nn \stex_new_statement:nnn { + \stex_new_stylable_env:nnnnnnn {#1}{O{}}{ + \stex_keys_set:nn{statement}{##1} + #3 -\NewDocumentEnvironment{sassertion}{O{}}{ - \__stex_statements_sassertion_args:n{ #1 } - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_reactivate_macro:N \varbindforall - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sassertion_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } + \stex_if_smsmode:F { + \exp_args:Nne \begin{stex_annotate_env}{ + \__stex_statements_html_keyvals:nn{#1}{false} } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{assertion}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sassertiontype { - \stex_annotate_invisible:nnn{type}{\sassertiontype}{} - } - \str_if_empty:NF \sassertionname { - \stex_annotate_invisible:nnn{statementname}{\sassertionname}{} - } - \clist_set:No \l_tmpa_clist \sassertiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sassertion_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sassertion_##1_start:}} + \tl_set_eq:NN \thistitle \l_stex_key_title_tl + \str_set_eq:NN \thisname \l_stex_key_name_str + \clist_set_eq:NN \thisfor \l_stex_key_for_str + \stex_if_html_backend:TF { + \noindent + \stex_annotate:nn{shtml:statementtitle={}}{\_stex_annotate_force_break:n\l_stex_key_title_tl} } + \stex_style_apply: } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sassertion_start: - }{ - \l_tmpa_tl + \_stex_do_id: + \stex_smsmode_do: + }{ + \stex_if_smsmode:F { + \stex_if_html_backend:F \stex_style_apply: + \end{stex_annotate_env} } - } - \str_if_empty:NTF \sassertionid { - \str_if_empty:NF \sassertionname { - \stex_ref_new_doc_target:n {} + }{}{}{s} + \stex_sms_allow_env:n{s#1} + + \tl_if_empty:nF{#2}{ + \exp_after:wN \NewDocumentCommand \cs:w inline#2\cs_end: { O{} m}{ + \group_begin: + \stex_keys_set:nn{statement}{##1} + #3 + \_stex_do_id: + \stex_if_smsmode:F{ + \exp_args:Ne \stex_annotate:nn{\__stex_statements_html_keyvals:nn{#1}{true}}{ + \_stex_annotate_force_break:n{##2} + } + } + \group_end: + \stex_smsmode_do: } - } { - \stex_ref_new_doc_target:n \sassertionid + \exp_after:wN \stex_sms_allow_escape:N\cs:w inline#2\cs_end: } - \stex_smsmode_do: -}{ - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sassertiontype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sassertion_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sassertion_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sassertion_end: - }{ - \l_tmpa_tl +} + +\cs_new_protected:Nn \__stex_statements_setup_def: { + \stex_if_smsmode:F{ + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_ref_new_sym_target:n{##1} } - \end{stex_annotate_env} } + \stex_reactivate_macro:N \definiendum + \stex_reactivate_macro:N \defnotation + \stex_reactivate_macro:N \definame + \stex_reactivate_macro:N \Definame + \stex_reactivate_macro:N \varbind } -\cs_new_protected:Nn \__stex_statements_sassertion_start: { - \stex_par:\noindent\titleemph{Assertion~\tl_if_empty:NF \sassertiontitle { - (\sassertiontitle) - }~} +\cs_new_protected:Nn \__stex_statements_force_id: { + \str_if_empty:NT \l_stex_key_id_str { + \_stex_ref_new_id:n{} + \str_set_eq:NN \l_stex_key_id_str \l__stex_refs_str + } } -\cs_new_protected:Nn \__stex_statements_sassertion_end: {\stex_par:\medskip} -\newcommand\stexpatchassertion[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_statements_sassertion_start: { #2 } - \tl_set:Nn \__stex_statements_sassertion_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname __stex_statements_sassertion_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_statements_sassertion_#1_end:\endcsname{ #3 } - } -} -\keys_define:nn {stex / inlineass }{ - type .str_set_x:N = \sassertiontype, - id .str_set_x:N = \sassertionid, - for .clist_set:N = \l__stex_statements_sassertion_for_clist , - name .str_set_x:N = \sassertionname -} -\cs_new_protected:Nn \__stex_statements_inlineass_args:n { - \str_clear:N \sassertiontype - \str_clear:N \sassertionid - \str_clear:N \sassertionname - \clist_clear:N \l__stex_statements_sassertion_for_clist - \keys_set:nn { stex / inlineass }{ #1 } +\stex_new_statement:nnn{definition}{def}{ + \__stex_statements_force_id: + \__stex_statements_setup:nn{}{} + \__stex_statements_setup_def: + \stex_reactivate_macro:N \definiens } -\NewDocumentCommand \inlineass { O{} m } { - \begingroup - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_reactivate_macro:N \varbindforall - \__stex_statements_inlineass_args:n{ #1 } - \str_if_empty:NTF \sassertionid { - \str_if_empty:NF \sassertionname { - \stex_ref_new_doc_target:n {} +\stex_new_statement:nnn{assertion}{ass}{ + \__stex_statements_setup:nn{}{assertion} + \stex_if_smsmode:F{ + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_ref_new_sym_target:n{##1} } - } { - \stex_ref_new_doc_target:n \sassertionid } - - \stex_if_smsmode:TF{ - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - } + \stex_reactivate_macro:N \varbind + \stex_reactivate_macro:N \conclusion + \stex_reactivate_macro:N \premise + \stex_reactivate_macro:N \definiendum + \stex_reactivate_macro:N \defnotation + \stex_reactivate_macro:N \definame + \stex_reactivate_macro:N \Definame +} +\stex_new_statement:nnn{example}{ex}{\__stex_statements_setup:nn{}{example}} +\stex_new_statement:nnn{paragraph}{}{ + \clist_if_in:NnTF \l_stex_key_style_clist {symdoc}{ + \__stex_statements_force_id: + \__stex_statements_setup:nn{}{} + \__stex_statements_setup_def: }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sassertion_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{assertion}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sassertiontype { - \stex_annotate_invisible:nnn{typestrings}{\sassertiontype}{} - } - #2 - \str_if_empty:NF \sassertionname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sassertionname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sassertionname} - \stex_annotate_invisible:nnn{statementname}{\sassertionname}{} - } - } + \__stex_statements_setup:nn{}{} } - \endgroup - \stex_smsmode_do: } -\keys_define:nn {stex / sexample }{ - type .str_set_x:N = \exampletype, - id .str_set_x:N = \sexampleid, - title .tl_set:N = \sexampletitle, - name .str_set_x:N = \sexamplename , - for .clist_set:N = \l__stex_statements_sexample_for_clist, -} -\cs_new_protected:Nn \__stex_statements_sexample_args:n { - \str_clear:N \sexampletype - \str_clear:N \sexampleid - \str_clear:N \sexamplename - \tl_clear:N \sexampletitle - \clist_clear:N \l__stex_statements_sexample_for_clist - \keys_set:nn { stex / sexample }{ #1 } -} - -\NewDocumentEnvironment{sexample}{O{}}{ - \__stex_statements_sexample_args:n{ #1 } - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sexample_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{example}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sexampletype { - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - \str_if_empty:NF \sexamplename { - \stex_annotate_invisible:nnn{statementname}{\sexamplename}{} - } - \clist_set:No \l_tmpa_clist \sexampletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sexample_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sexample_##1_start:}} +\cs_new_protected:Nn \__stex_statements_do_defref:nn { + \stex_if_html_backend:T{\ifvmode\indent\fi} + \group_begin: + \stex_get_symbol:n{#1} + \bool_if:NTF \l_stex_allow_semantic_bool{ + \str_set:Nx\l_stex_current_symbol_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + \str_if_in:NnT \l_stex_get_symbol_name_str / { + \str_set:Nx \l_stex_get_symbol_name_str { + \exp_after:wN \_stex_split_slash: \l_stex_get_symbol_name_str + /\_stex_args_end: } } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sexample_start: - }{ - \l_tmpa_tl - } - } - \str_if_empty:NF \sexampleid { - \stex_ref_new_doc_target:n \sexampleid - } - \stex_smsmode_do: -}{ - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sexamplename}} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sexampletype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sexample_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sexample_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sexample_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} + \exp_args:No \stex_ref_new_sym_target:n \l_stex_current_symbol_str + \def\comp{\_defcomp} + \stex_annotate:nn{shtml:definiendum=\l_stex_current_symbol_str}{\comp{#2}} + }{ + \msg_error:nnxx{stex}{error/notallowed}{#1}{\l_stex_current_symbol_str} } + \group_end: } -\cs_new_protected:Nn \__stex_statements_sexample_start: { - \stex_par:\noindent\titleemph{Example~\tl_if_empty:NF \sexampletitle { - (\sexampletitle) - }~} +\NewDocumentCommand \defnotation{ m } { + \_stex_next_symbol:n { \def\comp{\_defcomp}}#1 } -\cs_new_protected:Nn \__stex_statements_sexample_end: {\stex_par:\medskip} +\stex_deactivate_macro:Nn \defnotation {definition~environments} -\newcommand\stexpatchexample[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_statements_sexample_start: { #2 } - \tl_set:Nn \__stex_statements_sexample_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname __stex_statements_sexample_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_statements_sexample_#1_end:\endcsname{ #3 } - } +\NewDocumentCommand \definiendum { O{} m m} { + \stex_keys_set:nn{symname}{ #1 } + \__stex_statements_do_defref:nn{#2}{#3} } -\keys_define:nn {stex / inlineex }{ - type .str_set_x:N = \sexampletype, - id .str_set_x:N = \sexampleid, - for .clist_set:N = \l__stex_statements_sexample_for_clist , - name .str_set_x:N = \sexamplename +\stex_deactivate_macro:Nn \definiendum {definition~environments} + +\NewDocumentCommand \definame { O{} m } { + \stex_keys_set:nn{symname}{#1} + \__stex_statements_do_defref:nn{#2}{ + \l_stex_key_pre_tl\l_stex_get_symbol_name_str\l_stex_key_post_tl + } } -\cs_new_protected:Nn \__stex_statements_inlineex_args:n { - \str_clear:N \sexampletype - \str_clear:N \sexampleid - \str_clear:N \sexamplename - \clist_clear:N \l__stex_statements_sexample_for_clist - \keys_set:nn { stex / inlineex }{ #1 } +\stex_deactivate_macro:Nn \definame {definition~environments} + +\NewDocumentCommand \Definame { O{} m } { + \stex_keys_set:nn{symname}{#1} + \__stex_statements_do_defref:nn{#2}{ + \l_stex_key_pre_tl\exp_after:wN\_stex_capitalize:n\l_stex_get_symbol_name_str\l_stex_key_post_tl + } } -\NewDocumentCommand \inlineex { O{} m } { - \begingroup - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \conclusion - \__stex_statements_inlineex_args:n{ #1 } - \str_if_empty:NF \sexampleid { - \stex_ref_new_doc_target:n \sexampleid +\stex_deactivate_macro:Nn \Definame {definition~environments} + +\NewDocumentCommand \definiens { O{} m }{ + \group_begin: + \str_clear:N \l_stex_get_symbol_name_str + \tl_if_empty:nF {#1} { + \stex_get_symbol:n { #1 } + \str_set:Nx \l__stex_statements_uri_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} } - \stex_if_smsmode:TF{ - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\examplename}} - } - }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sexample_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{example}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sexampletype { - \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} - } - #2 - \str_if_empty:NF \sexamplename { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sexamplename}} - \stex_annotate_invisible:nnn{statementname}{\sexamplename}{} - } - } + \str_if_empty:NT \l__stex_statements_uri_str { + \msg_error:nn{stex}{error/definiensfor} } - \endgroup + \stex_debug:nn{definiens}{Checking~\l__stex_statements_uri_str} + + \exp_args:No \_stex_add_definiens:nn \l__stex_statements_uri_str{#2} + + \group_end: \stex_smsmode_do: } -\keys_define:nn { stex / sparagraph} { - id .str_set_x:N = \sparagraphid , - title .tl_set:N = \l_stex_sparagraph_title_tl , - type .str_set_x:N = \sparagraphtype , - for .clist_set:N = \l__stex_statements_sparagraph_for_clist , - from .tl_set:N = \sparagraphfrom , - to .tl_set:N = \sparagraphto , - start .tl_set:N = \l_stex_sparagraph_start_tl , - name .str_set:N = \sparagraphname , - imports .tl_set:N = \l__stex_statements_sparagraph_imports_tl -} - -\cs_new_protected:Nn \stex_sparagraph_args:n { - \tl_clear:N \l_stex_sparagraph_title_tl - \tl_clear:N \sparagraphfrom - \tl_clear:N \sparagraphto - \tl_clear:N \l_stex_sparagraph_start_tl - \tl_clear:N \l__stex_statements_sparagraph_imports_tl - \str_clear:N \sparagraphid - \str_clear:N \sparagraphtype - \clist_clear:N \l__stex_statements_sparagraph_for_clist - \str_clear:N \sparagraphname - \keys_set:nn { stex / sparagraph }{ #1 } -} -\newif\if@in@omtext\@in@omtextfalse - -\NewDocumentEnvironment {sparagraph} { O{} } { - \stex_sparagraph_args:n { #1 } - \tl_if_empty:NTF \l_stex_sparagraph_start_tl { - \tl_set_eq:NN \sparagraphtitle \l_stex_sparagraph_title_tl - }{ - \tl_set_eq:NN \sparagraphtitle \l_stex_sparagraph_start_tl - } - \@in@omtexttrue - \stex_if_smsmode:F { - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{paragraph}{\seq_use:Nn \l_tmpb_seq {,}} - \str_if_empty:NF \sparagraphtype { - \stex_annotate_invisible:nnn{typestrings}{\sparagraphtype}{} - } - \str_if_empty:NF \sparagraphfrom { - \stex_annotate_invisible:nnn{from}{\sparagraphfrom}{} - } - \str_if_empty:NF \sparagraphto { - \stex_annotate_invisible:nnn{to}{\sparagraphto}{} - } - \str_if_empty:NF \sparagraphname { - \stex_annotate_invisible:nnn{statementname}{\sparagraphname}{} - } - \clist_set:No \l_tmpa_clist \sparagraphtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \sparagraphtype { - \tl_if_exist:cT {__stex_statements_sparagraph_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sparagraph_##1_start:}} - } - } - \stex_csl_to_imports:No \usemodule \l__stex_statements_sparagraph_imports_tl - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sparagraph_start: - }{ - \l_tmpa_tl - } - } - \clist_set:No \l_tmpa_clist \sparagraphtype - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}} - { - \stex_reactivate_macro:N \definiendum - \stex_reactivate_macro:N \definame - \stex_reactivate_macro:N \Definame - \stex_reactivate_macro:N \premise - \stex_reactivate_macro:N \definiens - } - \str_if_empty:NTF \sparagraphid { - \str_if_empty:NTF \sparagraphname { - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sparagraphid - } - \exp_args:NNx - \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \clist_map_inline:Nn \l__stex_statements_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \stex_ref_new_sym_target:n \l_stex_get_symbol_uri_str +\stex_deactivate_macro:Nn \definiens {definition~environments} +\stex_sms_allow_escape:N \definiens + +\cs_new_protected:Nn \_stex_add_definiens:nn { + \exp_args:Nno \stex_str_if_starts_with:nnT{#1} \l_stex_current_module_str { + \prop_map_inline:cn{c_stex_module_\l_stex_current_module_str _symbols_prop}{ + \stex_debug:nn{definiens}{#1 == \l_stex_current_module_str?##1} + \str_if_eq:noT {#1} {\l_stex_current_module_str?##1}{ + \prop_map_break:n{\_stex_add_definiens_inner:nnnnnnnn ##2} } } } - \stex_smsmode_do: - \ignorespacesandpars -}{ - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - \stex_if_smsmode:F { - \clist_set:No \l_tmpa_clist \sparagraphtype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_statements_sparagraph_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_statements_sparagraph_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_statements_sparagraph_end: - }{ - \l_tmpa_tl + \stex_if_smsmode:F{ + \stex_annotate:nn{ shtml:definiens={#1}}{ + #2 %\_stex_annotate_force_break:n{ #2 } } - \end{stex_annotate_env} } } -\cs_new_protected:Nn \__stex_statements_sparagraph_start: { - \stex_par:\noindent\tl_if_empty:NTF \l_stex_sparagraph_start_tl { - \tl_if_empty:NF \l_stex_sparagraph_title_tl { - \titleemph{\l_stex_sparagraph_title_tl}:~ - } - }{ - \titleemph{\l_stex_sparagraph_start_tl}~ - } +\cs_new_protected:Nn \_stex_add_definiens_inner:nnnnnnnn { + \stex_debug:nn{definiens}{Adding~definiens~to~\l_stex_current_module_str?#2} + \prop_gput:cnn{c_stex_module_\l_stex_current_module_str _symbols_prop} + {#2}{{#1}{#2}{#3}{#4}{defed}{#6}{#7}{#8}} } -\cs_new_protected:Nn \__stex_statements_sparagraph_end: {\stex_par:\medskip} -\newcommand\stexpatchparagraph[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_statements_sparagraph_start: { #2 } - \tl_set:Nn \__stex_statements_sparagraph_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname __stex_statements_sparagraph_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_statements_sparagraph_#1_end:\endcsname{ #3 } +\NewDocumentCommand \varbind {m} { + \clist_map_inline:nn {#1} { + \stex_get_var:n {##1} + \stex_if_do_html:T { + \stex_annotate_invisible:nn {shtml:bind=\l_stex_get_symbol_name_str}{} } + } } +\stex_deactivate_macro:Nn \varbind {definition~or~assertion~environments} -\keys_define:nn { stex / inlinepara} { - id .str_set_x:N = \sparagraphid , - type .str_set_x:N = \sparagraphtype , - for .clist_set:N = \l__stex_statements_sparagraph_for_clist , - from .tl_set:N = \sparagraphfrom , - to .tl_set:N = \sparagraphto , - name .str_set:N = \sparagraphname -} -\cs_new_protected:Nn \__stex_statements_inlinepara_args:n { - \tl_clear:N \sparagraphfrom - \tl_clear:N \sparagraphto - \str_clear:N \sparagraphid - \str_clear:N \sparagraphtype - \clist_clear:N \l__stex_statements_sparagraph_for_clist - \str_clear:N \sparagraphname - \keys_set:nn { stex / inlinepara }{ #1 } -} -\NewDocumentCommand \inlinepara { O{} m } { - \begingroup - \__stex_statements_inlinepara_args:n{ #1 } - \clist_set:No \l_tmpa_clist \sparagraphtype - \str_if_empty:NTF \sparagraphid { - \str_if_empty:NTF \sparagraphname { - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n {} - } - } { - \stex_ref_new_doc_target:n \sparagraphid +\NewDocumentCommand \conclusion { O{} m} { + \group_begin: + \str_clear:N \l_stex_get_symbol_name_str + \tl_if_empty:nF {#1} { + \stex_get_symbol:n { #1 } + \str_set:Nx \l__stex_statements_uri_str + {\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} } - \stex_if_smsmode:TF{ - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - }{ - \seq_clear:N \l_tmpb_seq - \clist_map_inline:Nn \l__stex_statements_sparagraph_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpb_seq { - \l_stex_get_symbol_uri_str - } - } - } - \ifvmode\noindent\fi - \exp_args:Nnx - \stex_annotate:nnn{paragraph}{\seq_use:Nn \l_tmpb_seq {,}}{ - \str_if_empty:NF \sparagraphtype { - \stex_annotate_invisible:nnn{typestrings}{\sparagraphtype}{} - } - \str_if_empty:NF \sparagraphfrom { - \stex_annotate_invisible:nnn{from}{\sparagraphfrom}{} - } - \str_if_empty:NF \sparagraphto { - \stex_annotate_invisible:nnn{to}{\sparagraphto}{} - } - \str_if_empty:NF \sparagraphname { - \stex_suppress_html:n{\stex_symdecl_do:nn{}{\sparagraphname}} - \stex_annotate_invisible:nnn{statementname}{\sparagraphname}{} - \stex_ref_new_sym_target:n {\l_stex_current_module_str ? \sparagraphname} - } - \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\tl_to_str:n{symdoc}}{ - \clist_map_inline:Nn \l_tmpb_seq { - \stex_ref_new_sym_target:n {##1} - } - } - #2 - } + \str_if_empty:NT \l__stex_statements_uri_str { + \msg_error:nn{stex}{error/conclusionfor} } - \endgroup - \stex_smsmode_do: + \stex_annotate:nn{ shtml:conclusion=\l__stex_statements_uri_str}{ + #2 %\_stex_annotate_force_break:n{ #2 } + } + \group_end: } +\stex_deactivate_macro:Nn \conclusion {assertion~environments} - - -%%%%%%%%%%%%% sproof.dtx %%%%%%%%%%%%% - -\keys_define:nn { stex / spf } { - id .str_set_x:N = \spfid, - for .clist_set:N = \l__stex_sproof_spf_for_clist , - from .tl_set:N = \l__stex_sproof_spf_from_tl , - proofend .tl_set:N = \l__stex_sproof_spf_proofend_tl, - type .str_set_x:N = \spftype, - title .tl_set:N = \spftitle, - continues .tl_set:N = \l__stex_sproof_spf_continues_tl, - functions .tl_set:N = \l__stex_sproof_spf_functions_tl, - term .tl_set:N = \l__stex_sproof_spf_term_tl, - method .tl_set:N = \l__stex_sproof_spf_method_tl, - hide .bool_set:N = \l__stex_sproof_spf_hide_bool -} -\cs_new_protected:Nn \__stex_sproof_spf_args:n { -\str_clear:N \spfid -\tl_clear:N \l__stex_sproof_spf_for_tl -\tl_clear:N \l__stex_sproof_spf_from_tl -\tl_set:Nn \l__stex_sproof_spf_proofend_tl {\sproof@box} -\str_clear:N \spftype -\tl_clear:N \spftitle -\tl_clear:N \l__stex_sproof_spf_continues_tl -\tl_clear:N \l__stex_sproof_spf_term_tl -\tl_clear:N \l__stex_sproof_spf_functions_tl -\tl_clear:N \l__stex_sproof_spf_method_tl - \bool_set_false:N \l__stex_sproof_spf_hide_bool -\keys_set:nn { stex / spf }{ #1 } -} -\bool_set_true:N \l__stex_sproof_inc_counter_bool -\str_set:Nn\c__stex_sproof_flow_str{inline} -\intarray_new:Nn\l__stex_sproof_counter_intarray{50} -\cs_new_protected:Npn \sproofnumber { +\NewDocumentCommand \premise {O{} m} { + \tl_if_empty:nF {#1} { + \stex_debug:nn{Here:}{Variable~#1} + \exp_args:NNx\exp_args:Nnx\vardef{v#1}{#1} + } + \stex_annotate:nn{shtml:premise={#1}}{#2} +} +\stex_deactivate_macro:Nn \premise {assertion~environments} +\stex_keys_define:nnnn{ spf }{ +\tl_clear:N \l_stex_key_for_clist +\tl_clear:N \l_stex_key_from_tl +\tl_set_eq:NN \l_stex_key_proofend_tl \__stex_proof_proof_box_tl +\tl_clear:N \l_stex_key_continues_tl +\tl_clear:N \l_stex_key_term_tl +\tl_clear:N \l_stex_key_functions_tl +\tl_clear:N \l_stex_key_method_tl + \bool_set_false:N \l_stex_key_hide_bool +}{ + for .clist_set:N = \l_stex_key_for_clist , + from .tl_set:N = \l_stex_key_from_tl , + proofend .tl_set:N = \l_stex_key_proofend_tl, + continues .tl_set:N = \l_stex_key_continues_tl, + functions .tl_set:N = \l_stex_key_functions_tl, + term .tl_set:N = \l_stex_key_term_tl, + method .tl_set:N = \l_stex_key_method_tl, + hide .bool_set:N = \l_stex_key_hide_bool +}{id,style,title} + +\bool_set_true:N \l__stex_proof_inc_counter_bool +\intarray_new:Nn\l__stex_proof_counter_intarray{50} +\cs_new_protected:Npn \__stex_proof_insert_number: { + \int_set:Nn \l_tmpa_int {1} + \bool_while_do:nn { + \int_compare_p:nNn { + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int + } > 0 + }{ + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int . + \int_incr:N \l_tmpa_int + } +} +\cs_new_protected:Nn \__stex_proof_number_as_string:N { + \str_clear:N #1 \int_set:Nn \l_tmpa_int {1} \bool_while_do:nn { \int_compare_p:nNn { - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int } > 0 }{ - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int . + \str_put_right:Nx #1 {\intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int .} \int_incr:N \l_tmpa_int } } -\cs_new_protected:Npn \__stex_sproof_inc_counter: { + +\cs_new_protected:Npn \__stex_proof_inc_counter: { \int_set:Nn \l_tmpa_int {1} \bool_while_do:nn { \int_compare_p:nNn { - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int } > 0 }{ \int_incr:N \l_tmpa_int @@ -6406,496 +7041,544 @@ \int_compare:nNnF \l_tmpa_int = 1 { \int_decr:N \l_tmpa_int } - \intarray_gset:Nnn \l__stex_sproof_counter_intarray \l_tmpa_int { - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int + 1 + \intarray_gset:Nnn \l__stex_proof_counter_intarray \l_tmpa_int { + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int + 1 } } -\cs_new_protected:Npn \__stex_sproof_add_counter: { +\cs_new_protected:Npn \__stex_proof_add_counter: { \int_set:Nn \l_tmpa_int {1} \bool_while_do:nn { \int_compare_p:nNn { - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int } > 0 }{ \int_incr:N \l_tmpa_int } - \intarray_gset:Nnn \l__stex_sproof_counter_intarray \l_tmpa_int { 1 } + \intarray_gset:Nnn \l__stex_proof_counter_intarray \l_tmpa_int { 1 } } -\cs_new_protected:Npn \__stex_sproof_remove_counter: { +\cs_new_protected:Npn \__stex_proof_remove_counter: { \int_set:Nn \l_tmpa_int {1} \bool_while_do:nn { \int_compare_p:nNn { - \intarray_item:Nn \l__stex_sproof_counter_intarray \l_tmpa_int + \intarray_item:Nn \l__stex_proof_counter_intarray \l_tmpa_int } > 0 }{ \int_incr:N \l_tmpa_int } \int_decr:N \l_tmpa_int - \intarray_gset:Nnn \l__stex_sproof_counter_intarray \l_tmpa_int { 0 } -} -\def\sproof@box{ - \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} -} -\def\sproofend{ - \tl_if_empty:NF \l__stex_sproof_spf_proofend_tl { - \hfil\null\nobreak\hfill\l__stex_sproof_spf_proofend_tl\par\smallskip - } -} -\def\spf@proofsketch@kw{Proof~Sketch} -\def\spf@proof@kw{Proof} -\def\spf@step@kw{Step} -\AddToHook{begindocument}{ - \ltx@ifpackageloaded{babel}{ - \makeatletter - \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ - \input{sproof-ngerman.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {finnish}{ - \input{sproof-finnish.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {french}{ - \input{sproof-french.ldf} - } - \clist_if_in:NnT \l_tmpa_clist {russian}{ - \input{sproof-russian.ldf} - } - \makeatother - }{} + \intarray_gset:Nnn \l__stex_proof_counter_intarray \l_tmpa_int { 0 } } -\newcommand\spfsketch[2][]{ - \begingroup - \let \premise \stex_proof_premise: - \__stex_sproof_spf_args:n{#1} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l__stex_sproof_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnx - \stex_annotate:nnn{proofsketch}{\seq_use:Nn \l_tmpa_seq {,}}{ - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \titleemph{ - \tl_if_empty:NTF \spftitle { - \spf@proofsketch@kw - }{ - \spftitle - } - }:~ - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid +\newenvironment{spfsketchenv}{}{} +\stex_new_stylable_cmd:nnnn{spfsketch}{O{} m}{\par + \begin{spfsketchenv} + \stex_keys_set:nn{spf}{#1} + \_stex_do_for_list: + \_stex_do_id: + \exp_args:Ne \stex_annotate:nn{ + shtml:proofsketch={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , } - \l_tmpa_tl #2 \sproofend } + }{ + \stex_style_apply: + #2 } - \endgroup - \stex_smsmode_do: + \end{spfsketchenv} +}{ + \noindent\emph{\spfsketchenvautorefname :}~ } - -\bool_set_false:N \l__stex_sproof_in_spfblock_bool - -\cs_new_protected:Nn \__stex_sproof_maybe_comment: { - \bool_if:NF \l__stex_sproof_in_spfblock_bool { - \par \setbox \l_tmpa_box \vbox \bgroup \everypar{\__stex_sproof_start_comment:} +\tl_set:Nn \__stex_proof_proof_box_tl { + \ltx@ifpackageloaded{amssymb}{$\square$}{ + \hbox{\vrule\vbox{\hrule width 6 pt\vskip 6pt\hrule}\vrule} } } -\cs_new_protected:Nn \__stex_sproof_maybe_comment_end: { - \bool_if:NF \l__stex_sproof_in_spfblock_bool { \egroup } -} -\cs_new_protected:Nn \__stex_sproof_start_comment: { - \csname @ @ par\endcsname\egroup\item[]\bgroup\stexcommentfont -} +\tl_set:Nn \sproofend { + \tl_if_empty:NF \l_stex_key_proofend_tl { + \hfil\null\nobreak\hfill\l_stex_key_proofend_tl\par\smallskip + } +} \cs_new_protected:Npn \stexcommentfont { \small\itshape } -\cs_new_protected:Nn \__stex_sproof_start_env:nnn { - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l__stex_sproof_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{#1}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - #3 {~\stex_annotate:nnn{spftitle}{}{#2}} - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - \begin{stex_annotate_env}{spfbody}{\bool_if:NTF \l__stex_sproof_spf_hide_bool {false}{true}} - \bool_if:NT \l__stex_sproof_spf_hide_bool{ - \stex_html_backend:F{\setbox\l_tmpa_box\vbox\bgroup} - } +\cs_new_protected:Nn \__stex_proof_start_list:n { \begin{list}{}{ \setlength\topsep{0pt} \setlength\parsep{0pt} \setlength\rightmargin{0pt} - - }\__stex_sproof_maybe_comment: + }\item[#1] } -\cs_new_protected:Nn \__stex_sproof_end_env:n { - \stex_if_smsmode:F{ - \__stex_sproof_maybe_comment_end: - \end{list} - \bool_if:NT \l__stex_sproof_spf_hide_bool{ - \stex_html_backend:F{\egroup} - } - \clist_set:No \l_tmpa_clist \spftype - #1 - \end{stex_annotate_env} - \end{stex_annotate_env} - } +\cs_new_protected:Nn \__stex_proof_end_list: { + \end{list} } -\NewDocumentEnvironment{sproof}{s O{} m}{ - \intarray_gzero:N \l__stex_sproof_counter_intarray - \intarray_gset:Nnn \l__stex_sproof_counter_intarray 1 1 - \stex_reactivate_macro:N \yield - \stex_reactivate_macro:N \eqstep - \stex_reactivate_macro:N \assumption - \stex_reactivate_macro:N \conclude - \stex_reactivate_macro:N \spfstep - \__stex_sproof_spf_args:n{#2} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid + +\cs_new_protected:Nn \__stex_proof_html: { + \stex_annotate_invisible:n{\hbox{ + \tl_if_empty:NF \l_stex_key_term_tl { + $\stex_annotate:nn{shtml:proofterm={}}{\l_stex_key_term_tl}$ } - }{ - \__stex_sproof_start_env:nnn{sproof}{#3}{ - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_sproof_sproof_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_start:}} - } - \exp_args:No \str_if_eq:nnT \c__stex_sproof_flow_str {##1} { - \tl_set:Nn \l_tmpa_tl {\use:n{}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_sproof_sproof_start: - }{ - \l_tmpa_tl + \tl_if_empty:NF \l_stex_key_method_tl { + \stex_annotate:nn{shtml:proofmethod={}}{\l_stex_key_method_tl} + } + }} +} + +\cs_new_protected:Nn \__stex_proof_html_env:n { + \exp_args:Nne \begin{stex_annotate_env}{ + shtml:#1={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , } } - } - \stex_smsmode_do: -}{\__stex_sproof_end_env:n{ - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {__stex_sproof_sproof_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{__stex_sproof_sproof_##1_end:}} + \bool_if:NT \l_stex_key_hide_bool {, + shtml:proofhide=true } } - \tl_if_empty:NTF \l_tmpa_tl { - \__stex_sproof_sproof_end: - }{ - \l_tmpa_tl + \__stex_proof_html: +} + +\bool_set_false:N \l__stex_proof_in_spfblock_bool +\cs_new_protected:Nn \__stex_proof_begin_proof:nn {\par + \intarray_gzero:N \l__stex_proof_counter_intarray + \intarray_gset:Nnn \l__stex_proof_counter_intarray 1 1 + \stex_keys_set:nn{spfsteps}{#1} + \_stex_do_for_list: + \stex_if_do_html:T { + \__stex_proof_html_env:n{proof} } -}} -\NewDocumentEnvironment{subproof}{s O{} m}{ - \__stex_sproof_spf_args:n{#2} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \__stex_sproof_start_env:nnn{subproof}{\item[\sproofnumber]\ignorespacesandpars #3}{} + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_debug:nn{definiens}{Adding~definiens~to~##1} + \_stex_add_definiens:nn {##1}{\STEXinvisible{proven}} } - \__stex_sproof_add_counter: - \stex_smsmode_do: -}{\__stex_sproof_remove_counter:\__stex_sproof_end_env:n{} - \bool_if:NT \l__stex_sproof_inc_counter_bool { - \__stex_sproof_inc_counter: + \stex_style_apply: + \_stex_do_id: + \stex_reactivate_macro:N \subproof + \stex_reactivate_macro:N \spfstep + \stex_reactivate_macro:N \conclude + \stex_reactivate_macro:N \assumption + \stex_reactivate_macro:N \eqstep + \stex_reactivate_macro:N \yield + \stex_reactivate_macro:N \spfblock + \stex_reactivate_macro:N \spfjust + \stex_annotate:nn{shtml:prooftitle={}}{#2} + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:proofbody={}} + } +} +\stex_new_stylable_env:nnnnnnn{proof}{O{} m}{ + \__stex_proof_begin_proof:nn{#1}{#2} + \bool_set_true:N\l__stex_proof_in_spfblock_bool\__stex_proof_start_list:n{} + \group_begin:\stexcommentfont +}{ + \stex_style_apply: + \stex_if_do_html:T{\end{stex_annotate_env}\end{stex_annotate_env}} +}{ + \emph{\sproofautorefname :}~ +}{ + \sproofend +}{s} +\AddToHook{env/sproof/end}{ + \bool_if:NT\l__stex_proof_in_spfblock_bool { + \group_end:\__stex_proof_end_list: } - \aftergroup\__stex_sproof_maybe_comment: } -\AddToHook{env/subproof/before}{\__stex_sproof_maybe_comment_end:} -\cs_new_protected:Nn \__stex_sproof_sproof_start: { - \par\noindent\titleemph{ - \tl_if_empty:NTF \spftype { - \spf@proof@kw +\stex_new_stylable_env:nnnnnnn{proof*}{O{}}{ + \__stex_proof_begin_proof:nn{#1}{} + \bool_set_false:N\l__stex_proof_in_spfblock_bool +}{ + \stex_style_apply: + \stex_if_do_html:T{\end{stex_annotate_env}\end{stex_annotate_env}} +}{ + \emph{Proof:}~ +}{ + \sproofend +}{s} +\str_set_eq:NN \subproofautorefname \spfstepautorefname +\stex_new_stylable_env:nnnnnnn{subproof}{s O{} m}{\par + \stex_keys_set:nn{spf}{#2} + \_stex_do_for_list: + \stex_if_do_html:T { + \__stex_proof_html_env:n{subproof} + } + \seq_map_inline:Nn \l_stex_fors_seq { + \stex_debug:nn{definiens}{Adding~definiens~to~##1} + \_stex_add_definiens:nn {##1}{\STEXinvisible{proven}} + } + + \IfBooleanTF #1 { + \stex_style_apply: + \str_if_empty:NF \l_stex_key_id_str { + \__stex_proof_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{subproof.\@currentlabel} + \_stex_do_id: + } + \bool_set_false:N \l__stex_proof_in_spfblock_bool + \stex_annotate:nn{shtml:prooftitle={}}{#3} + }{ + \bool_if:NTF \l__stex_proof_in_spfblock_bool { + \str_if_empty:NF \l_stex_key_id_str { + \__stex_proof_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{subproof.\@currentlabel} + \_stex_do_id: + } + \__stex_proof_start_list:n\__stex_proof_insert_number: + \stex_annotate:nn{shtml:prooftitle={}}{#3} + \__stex_proof_add_counter: + \stex_style_apply: }{ - \spftype + \stex_annotate:nn{shtml:prooftitle={}}{#3} + \stex_style_apply: + \_stex_do_id: } - }: + } + \stex_if_do_html:T{ + \begin{stex_annotate_env}{shtml:proofbody={}} + } + \bool_if:NT \l__stex_proof_in_spfblock_bool {\group_begin:\stexcommentfont} +}{ + \stex_style_apply: + \bool_if:NT \l__stex_proof_in_spfblock_bool \__stex_proof_inc_counter: + \stex_if_do_html:T{\end{stex_annotate_env}} + \bool_if:NT\l__stex_proof_in_spfblock_bool \__stex_proof_end_list: + \stex_if_do_html:T{\end{stex_annotate_env}} + \aftergroup \__stex_proof_inblock_restore: +}{}{}{} +\AddToHook{env/subproof/before}{ + \bool_if:NT \l__stex_proof_in_spfblock_bool \group_end: } -\cs_new_protected:Nn \__stex_sproof_sproof_end: {\sproofend} - -\newcommand\stexpatchproof[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \__stex_sproof_sproof_start: { #2 } - \tl_set:Nn \__stex_sproof_sproof_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname __stex_sproof_sproof_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname __stex_sproof_sproof_#1_end:\endcsname{ #3 } +\AddToHook{env/subproof/end}{ + \bool_if:NT\l__stex_proof_in_spfblock_bool { + \group_end:\__stex_proof_remove_counter: + %\__stex_proof_end_list: } } +\stex_deactivate_macro:Nn \subproof {sproof~environments} -\keys_define:nn { stex / spfsteps } { - id .str_set_x:N = \spfstepid, - for .clist_set:N = \l__stex_sproof_spf_for_clist , - type .str_set_x:N = \spftype, - title .tl_set:N = \spftitle, - method .tl_set:N = \l__stex_sproof_spf_method_tl, - term .tl_set:N = \l__stex_sproof_spf_term_tl +\cs_new_protected:Nn \__stex_proof_inblock_restore: { + \bool_if:NT\l__stex_proof_in_spfblock_bool { + \group_begin:\stexcommentfont + } } -\cs_new_protected:Nn \__stex_sproof_spfstep_args:n { -\str_clear:N \spfstepid -\clist_clear:N \l__stex_sproof_spf_for_clist -\str_clear:N \spftype -\tl_clear:N \l__stex_sproof_spf_method_tl -\tl_clear:N \l__stex_sproof_spf_term_tl - %\bool_set_false:N \l__stex_sproof_inc_counter_bool -\keys_set:nn { stex / spfsteps }{ #1 } + +\stex_keys_define:nnnn { spfsteps } { +\clist_clear:N \l_stex_key_for_clist + \str_clear:N \l_stex_key_name_str +\tl_clear:N \l_stex_key_method_tl +\tl_clear:N \l_stex_key_term_tl +}{ + for .clist_set:N = \l_stex_key_for_clist , + method .tl_set:N = \l_stex_key_method_tl, + term .tl_set:N = \l_stex_key_term_tl, + name .str_set_x:N = \l_stex_key_name_str + % todo: style=inline +}{id,style,title} + +\newenvironment{spfstepenv}{ + \str_set_eq:NN \spfstepenvautorefname \spfstepautorefname +}{} + +\cs_new_protected:Nn \__stex_proof_step_html:nn { + \stex_if_do_html:TF{ + \exp_args:Ne \stex_annotate:nn{ + shtml:spf#1={ + \seq_if_empty:NF \l_stex_fors_seq { + \seq_use:Nn \l_stex_fors_seq , + } + } + \str_if_empty:NF \l_stex_key_name_str {, + shtml:stepname={\l_stex_key_name_str} + } + }{ + \__stex_proof_html: + #2 + } + }{ #2 } } -\cs_new_protected:Nn \__stex_sproof_make_step_macro:Nnnnn { +\cs_new_protected:Nn \__stex_proof_make_step_macro:Nnnnn { \NewDocumentCommand #1 {s O{} +m} { - \__stex_sproof_maybe_comment_end: + \bool_if:NT \l__stex_proof_in_spfblock_bool \group_end: + \stex_keys_set:nn{spfsteps}{##2} + \str_if_empty:NF \l_stex_key_name_str { + \stex_debug:nn{Here:}{Variable~\l_stex_key_name_str} + \exp_args:NNx\exp_args:Nnx\vardef{v\l_stex_key_name_str}{\l_stex_key_name_str} + } - \__stex_sproof_spfstep_args:n{##2} - \stex_annotate:nnn{spfstep}{#2}{ - \tl_if_empty:NF \l__stex_sproof_spf_term_tl { - \stex_annotate_invisible:nnn{spfyield}{}{$\l__stex_sproof_spf_term_tl$} + \begin{spfstepenv} + \str_if_empty:NF \l_stex_key_id_str { + \__stex_proof_number_as_string:N \@currentlabel + \str_set:Nx \@currentHref{spfstep.\@currentlabel} + \_stex_do_id: } - \bool_if:NTF \l__stex_sproof_in_spfblock_bool { - #4 + + \bool_if:NTF \l__stex_proof_in_spfblock_bool { + \IfBooleanTF ##1 { + \__stex_proof_step_html:nn{#2}{##3} }{ - \item[\IfBooleanTF ##1 {}{#3}] + \__stex_proof_step_html:nn{#2}{\__stex_proof_start_list:n{#3} ##3 \__stex_proof_end_list:} + #5 } - \ignorespacesandpars ##3 + \end{spfstepenv} + \group_begin:\stexcommentfont + }{ + \__stex_proof_step_html:nn{#2}{##3} + \end{spfstepenv} } - \bool_if:NF \l__stex_sproof_in_spfblock_bool { \IfBooleanTF ##1 {}{ #5 } } - \__stex_sproof_maybe_comment: } \stex_deactivate_macro:Nn #1 {sproof~environments} } -\__stex_sproof_make_step_macro:Nnnnn \assumption {assumption} \sproofnumber {} \__stex_sproof_inc_counter: -\__stex_sproof_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {} -\__stex_sproof_make_step_macro:Nnnnn \spfstep {} \sproofnumber {} \__stex_sproof_inc_counter: +\__stex_proof_make_step_macro:Nnnnn \assumption {assumption} \__stex_proof_insert_number: {} \__stex_proof_inc_counter: +\__stex_proof_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {} +\__stex_proof_make_step_macro:Nnnnn \spfstep {step} \__stex_proof_insert_number: {} \__stex_proof_inc_counter: \NewDocumentCommand \eqstep {s m}{ - \__stex_sproof_maybe_comment_end: - \bool_if:NTF \l__stex_sproof_in_spfblock_bool { - $=$ + \bool_if:NTF \l__stex_proof_in_spfblock_bool { + \group_end: + \IfBooleanTF #1 { + \__stex_proof_step_html:nn{eqstep}{$= #2$} + }{ + \__stex_proof_step_html:nn{eqstep}{\__stex_proof_start_list:n{$=$} $#2$ \__stex_proof_end_list:} + } + \group_begin:\stexcommentfont }{ - \item[$=$] + \__stex_proof_step_html:nn{eqstep}{$= #2$} } - $\stex_annotate:nnn{spfstep}{eq}{ #2 }$ - \__stex_sproof_maybe_comment: } \stex_deactivate_macro:Nn \eqstep {sproof~environments} \NewDocumentCommand \yield {+m}{ - \stex_annotate:nnn{spfyield}{}{ #1 } + \stex_annotate:nn{shtml:proofterm={}}{ #1 } } \stex_deactivate_macro:Nn \yield {sproof~environments} \NewDocumentEnvironment{spfblock}{}{ - \item[] - \bool_set_true:N \l__stex_sproof_in_spfblock_bool + \bool_set_false:N \l__stex_proof_in_spfblock_bool }{ - \aftergroup\__stex_sproof_maybe_comment: + \aftergroup\__stex_proof_inblock_restore: } -\AddToHook{env/spfblock/before}{\__stex_sproof_maybe_comment_end:} - -\NewDocumentCommand\spfidea{O{} +m}{ - \__stex_sproof_spf_args:n{#1} - \titleemph{ - \tl_if_empty:NTF \spftype {Proof~Idea}{ - \spftype - }: - }~#2 - \sproofend +\stex_deactivate_macro:Nn \spfblock {sproof~environments} +\AddToHook{env/spfblock/before}{ + \bool_if:NT \l__stex_proof_in_spfblock_bool \group_end: } -\newcommand\spfjust[1]{ - #1 -} - -%%%%%%%%%%%%% metatheory.dtx %%%%%%%%%%%%% - -\str_const:Nn \c_stex_metatheory_ns_str {http://mathhub.info/sTeX/meta} -\begingroup -\stex_module_setup:nn{ - ns=\c_stex_metatheory_ns_str, - meta=NONE -}{Metatheory} -\stex_reactivate_macro:N \symdecl -\stex_reactivate_macro:N \notation -\stex_reactivate_macro:N \symdef -\ExplSyntaxOff -\csname stex_suppress_html:n\endcsname{ - % is-a (a:A, a \in A, a is an A, etc.) - \symdecl{isa}[args=ai] - \notation{isa}[typed,op=:]{#1 \comp{:} #2}{##1 \comp, ##2} - \notation{isa}[in]{#1 \comp\in #2}{##1 \comp, ##2} - \notation{isa}[pred]{#2\comp(#1 \comp)}{##1 \comp, ##2} - - % bind (\forall, \Pi, \lambda etc.) - \symdecl{bind}[args=Bi,assoc=pre] - \notation{bind}[depfun,prec=nobrackets,op={(\cdot)\;\to\;\cdot}]{\comp( #1 \comp{)\;\to\;} #2}{##1 \comp, ##2} - \notation{bind}[forall]{\comp\forall #1.\;#2}{##1 \comp, ##2} - \notation{bind}[Pi]{\comp\prod_{#1}#2}{##1 \comp, ##2} - - % implicit bind - \symdecl{implicitbind}[args=Bi,assoc=pre] - \notation{implicitbind}[braces,prec=nobrackets,op={\{\cdot\}_I\;\cdot}]{\comp\{ #1 \comp{\}_I\;} #2}{##1 \comp, ##2} - \notation{implicitbind}[depfun,prec=nobrackets]{\comp( #1 \comp{)\;\to_I\;} #2}{##1 \comp, ##2} - \notation{implicitbind}[Pi]{\comp\prod^I_{#1}#2}{##1\comp,##2} - - % dummy variable - \symdecl{dummyvar} - \notation{dummyvar}[underscore]{\comp\_} - \notation{dummyvar}[dot]{\comp\cdot} - \notation{dummyvar}[dash]{\comp{{\rm --}}} - - %fromto (function space, Hom-set, implication etc.) - \symdecl{fromto}[args=ai] - \notation{fromto}[xarrow]{#1 \comp\to #2}{##1 \comp\times ##2} - \notation{fromto}[arrow]{#1 \comp\to #2}{##1 \comp\to ##2} - - % mapto (lambda etc.) - %\symdecl{mapto}[args=Bi] - %\notation{mapto}[mapsto]{#1 \comp\mapsto #2}{#1 \comp, #2} - %\notation{mapto}[lambda]{\comp\lambda #1 \comp.\; #2}{#1 \comp, #2} - %\notation{mapto}[lambdau]{\comp\lambda_{#1} \comp.\; #2}{#1 \comp, #2} - - % function/operator application - \symdecl{apply}[args=ia] - \notation{apply}[prec=0;0x\infprec,parens,op=\cdot(\cdot)]{#1 \comp( #2 \comp)}{##1 \comp, ##2} - \notation{apply}[prec=0;0x\infprec,lambda]{#1 \; #2 }{##1 \; ##2} - - % collection of propositions/booleans/truth values - \symdecl{prop}[name=proposition] - \notation{prop}[prop]{\comp{{\rm prop}}} - \notation{prop}[BOOL]{\comp{{\rm BOOL}}} - - \symdecl{judgmentholds}[args=1] - \notation{judgmentholds}[vdash,op=\vdash]{\comp\vdash\; #1} - % sequences - \symdecl{seqtype}[args=1] - \notation{seqtype}[kleene]{#1^{\comp\ast}} - - \symdecl{seqexpr}[args=a] - \notation{seqexpr}[angle,prec=nobrackets]{\comp\langle #1\comp\rangle}{##1\comp,##2} - - \symdef{seqmap}[args=abi,setlike]{\comp\{#3 \comp| #2\comp\in \dobrackets{#1} \comp\}}{##1 \comp, ##2} - \symdef{seqprepend}[args=ia]{#1 \comp{::} #2}{##1 \comp, ##2} - \symdef{seqappend}[args=ai]{#1 \comp{::} #2}{##1 \comp, ##2} - \symdef{seqfoldleft}[args=iabbi]{ \comp{foldl}\dobrackets{#1,#2}\dobrackets{#3\comp,#4\comp\mapsto#5}}{##1 \comp, ##2} - \symdef{seqfoldright}[args=iabbi,op=foldr]{ \comp{foldr}\dobrackets{#1,#2}\dobrackets{#3\comp,#4\comp\mapsto#5}}{##1 \comp, ##2} - \symdef{seqhead}[args=a]{\comp{head}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqtail}[args=a]{\comp{tail}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqlast}[args=a]{\comp{last}\dobrackets{#1}}{##1 \comp, ##2} - \symdef{seqinit}[args=a]{\comp{tail}\dobrackets{#1}}{##1 \comp, ##2} - - \symdef{sequence-index}[args=2,li,prec=nobrackets]{{#1}_{#2}} - \notation{sequence-index}[ui,prec=nobrackets]{{#1}^{#2}} - - \symdef{aseqdots}[args=a,prec=nobrackets]{#1\comp{,\ellipses}}{##1\comp,##2} - \symdef{aseqfromto}[args=ai,prec=nobrackets]{#1\comp{,\ellipses,}#2}{##1\comp,##2} - \symdef{aseqfromtovia}[args=aii,prec=nobrackets]{#1\comp{,\ellipses,}#2\comp{,\ellipses,}#3}{##1\comp,##2} - - % nat literals - \symdef{natliteral}{\comp{\mathtt{Ord}}} - - % letin (``let'', local definitions, variable substitution) - \symdecl{letin}[args=bii] - \notation{letin}[let]{\comp{{\rm let}}\;#1\comp{=}#2\;\comp{{\rm in}}\;#3} - \notation{letin}[subst]{#3 \comp[ #1 \comp/ #2 \comp]} - \notation{letin}[frac]{#3 \comp[ \frac{#2}{#1} \comp]} +\newcommand\spfjust[1]{ + \stex_annotate:nn{spfjust={}}{ #1 } +} +\stex_deactivate_macro:Nn \spfjust {sproof~environments} +\group_begin: + \cs_set:Npn \__stex_modules_persist_module: {} + \cs_set:Npn \stex_check_term:n #1 {} + \cs_set:Npn \_stex_sref_do_aux:n #1 { #1 } + \bool_set_false:N \_stex_html_do_output_bool + \bool_set_false:N \c_stex_check_terms_bool + \stex_uri_resolve:Nn \l_stex_current_ns_uri {http://mathhub.info/sTeX/meta} + \stex_module_setup:n{Metatheory} + + \symdef{of~type}[args=ii,invisible]{#1} + \notation{of~type}[colon]{#1 \mathbin{\comp{:}} #2} + + \symdef{apply}[args=ia,prec=0;\infprec x\infprec]{#1\mathopen{\comp(} #2 \mathclose{\comp)}} + \notation{apply}[lambda]{#1\; \argsep{#2}{\;}} + \notation{apply}[infixop]{\argsep{#2}{\mathbin{#1}}} + \notation{apply}[infixrel]{\argsep{#2}{\mathrel{#1}}} % structures - \symdecl*{module-type}[args=1] - \notation{module-type}{\comp{\mathtt{MOD}} #1} - \symdecl{mathstruct}[name=mathematical-structure,args=a] % TODO - \notation{mathstruct}[angle,prec=nobrackets]{\comp\langle #1 \comp\rangle}{##1 \comp, ##2} - - % objects - \symdecl{object} - \notation{object}{\comp{\mathtt{OBJECT}}} + \symdef{module~type}[args=i,op=\mathtt{MOD}] + {\mathopen{\comp{\mathtt{MOD}(}}#1\mathclose{\comp{)}}} + \symdef{module~type~merge}[args=a,op=\oplus] + {\argsep{#1}{\mathbin{\comp{\oplus}}}} + \symdef{anonymous~record}[args=a] + {\mathopen{\comp{[[}}#1\mathclose{\comp{]]}}} + \symdef{record~field}[args=2]{#1\comp{.}#2} + \symdecl*{record~type} + + \symdecl{mathstruct}[name=mathematical~structure,args=a] % TODO + \notation{mathstruct}[angle,prec=nobrackets] + {\mathopen{\comp\langle} #1 \mathclose{\comp\rangle}} + \notation{mathstruct}[parens,prec=nobrackets] + {\mathopen{\comp(} #1 \mathclose{\comp)}} + % sequences + \symdef{ellipses}[ldots]{\ldots} + \symdef{sequence~expression}[comma,args=a]{#1} + \symdef{sequence~type}[args=1]{#1^{\comp\ast}} + \symdef{sequence~map}[args=ia]{ + \comp{\mathrm{map}}\mathopen{\comp{(}}#1\mathpunct{\comp{,}} + #2\mathclose{\comp{)}} + } +\iffalse + % binder (\forall, \Pi, \lambda etc.) + \symdef{pibind}[name=dependent function type,prec=nobrackets, + op=(\cdot)\;\to\;\cdot,args=Bi,assoc=pre] + {\argmap{#1}{ + \mathopen{\comp(} ##1 \mathclose{\comp{)}} + }{\mathbin{\comp{\to}}} \mathbin{\comp{\to}} #2} + \notation{pibind}[forall]{\comp\forall #1\mathpunct{\comp.} #2} + \notation{pibind}[Pi]{\mathop{\comp\prod}\c_math_subscript_token{#1}#2} + + \symdef{mapbind}[name=lambda,mapsto,prec=nobrackets,op=\mapsto,args=Bi,assoc=pre] + { #1 \mathrel{\comp\mapsto} #2} + \notation{mapbind}[lambda,prec=nobrackets,op=\lambda] + {\comp\lambda #1 \mathpunct{\comp.} #2} +\fi + \symdecl{bind}[args=Bi,assoc=pre] + \notation{bind}[depfun,prec=nobrackets,op=(\cdot)\;\to\;\cdot] + {\mathopen{\comp(} #1 \mathclose{\comp{)}\mathbin{\comp{\to}}} #2} + \notation{bind}[forall]{\comp\forall #1.\;#2} + \notation{bind}[Pi]{\mathop{\comp\prod}\c_math_subscript_token{#1}#2} + + \symdef{implicit~bind}[args=Bi,assoc=pre]{\mathopen{\comp\{} #1 \mathclose{\comp{\}\c_math_subscript_token I}} #2} + + \symdecl*{integer~literal} + \notation{integer~literal}{\mathbb Z} + + \symdecl*{ordinal} + \notation{ordinal}{\mathtt{Ord}} + + % propositions + \symdef{prop}[name=proposition]{\mathtt{Prop}} + \symdef{judgment~holds}[args=i,role=judgment]{\comp\vdash\;#1} + + % any object + \symdef{object}{\mathtt{Obj}} + + % TODO DELETE + \symdef{aseqdots}[args=a,prec=nobrackets] + {#1\comp{,\ldots}}%{##1\comp,##2} + \symdef{aseqfromto}[args=ai,prec=nobrackets] + {#1\comp{,\ldots,}#2}%{##1\comp,##2} + \symdef{aseqfromtovia}[args=aii,prec=nobrackets] + {#1\comp{,\ldots,}#2\comp{,\ldots,}#3}%{##1\comp,##2} + + \stex_close_module: + \stex_uri_add_module:NNn \l_stex_metatheory_uri \l_stex_current_ns_uri {Metatheory} + \global \let \l_stex_metatheory_uri \l_stex_metatheory_uri + \global \let \c_stex_default_metatheory \l_stex_metatheory_uri +\group_end: +\cs_new_protected:Npn \MSC #1 {} +\stex_new_stylable_cmd:nnnn{MMTinclude}{m}{ + \stex_annotate_invisible:nn{shtml:import={#1}}{} +}{} +\stex_deactivate_macro:Nn \MMTinclude {module~environments} +\stex_every_module:n {\stex_reactivate_macro:N \MMTinclude} +\NewDocumentCommand \MMTrule {m m}{ + \tl_if_empty:nTF{#2}{\seq_clear:N \l_tmpa_seq}{ + \seq_set_split:Nnn \l_tmpa_seq , {#2} + } + \int_zero:N \l_tmpa_int + \stex_annotate_invisible:n{ + $ + \stex_annotate:nn{shtml:rule={scala://#1}}{ + \_stex_annotate_force_break:n{ + \seq_if_empty:NF \l_tmpa_seq { + \seq_map_inline:Nn \l_tmpa_seq { + \int_incr:N \l_tmpa_int + \stex_annotate:nn{ + shtml:argmode=i, + shtml:arg={\int_use:N \l_tmpa_int} + }{ ##1 } + } + } + } + }$ + } } +\stex_deactivate_macro:Nn \MMTrule {module~environments} +\stex_every_module:n{\stex_reactivate_macro:N \MMTrule} +\NewDocumentEnvironment { mmtinterface } { O{} m m } { + \_stex_module_setup_top_nosig:n { #3 } + \str_set_eq:NN \l__todo_mmt_module_str \l_stex_current_module_str + \str_clear:N \l_stex_current_module_str + \stex_keys_set:nn { smodule }{ #1 } + \stex_module_setup:n{ #2 } + \str_set_eq:NN \l__todo_stex_module_str \l_stex_current_module_str + \stex_debug:nn{mmt}{Interface~\l__todo_stex_module_str^^Jfor~\l__todo_mmt_module_str} - - \ExplSyntaxOn - \stex_add_to_current_module:n{ - \def\nappli#1#2#3#4{\apply{#1}{\naseqli{#2}{#3}{#4}}} - \def\nappui#1#2#3#4{\apply{#1}{\nasequi{#2}{#3}{#4}}} - \def\livar{\csname sequence-index\endcsname[li]} - \def\uivar{\csname sequence-index\endcsname[ui]} - \def\naseqli#1#2#3{\aseqfromto{\livar{#1}{#2}}{\livar{#1}{#3}}} - \def\nasequi#1#2#3{\aseqfromto{\uivar{#1}{#2}}{\uivar{#1}{#3}}} + \stex_if_do_html:T { + \exp_args:Nne \begin{stex_annotate_env} { + shtml:theory={\l_stex_current_module_str}, + shtml:language={ \l_stex_current_language_str}, + shtml:signature={} + \tl_if_empty:NF \l_stex_metatheory_uri {, + shtml:metatheory={\stex_uri_use:N \l_stex_metatheory_uri} + } + } + \stex_annotate_invisible:n{} + \stex_annotate_invisible:nn + {shtml:import=\l__todo_mmt_module_str} {} } -\__stex_modules_end_module: -\endgroup - -%%%%%%%%%%%%% others.dtx %%%%%%%%%%%%% + \stex_module_add_code:x{ + \stex_activate_module:n{ \l__todo_mmt_module_str } + } + \stex_module_add_morphism:nonn + {}{\l__todo_mmt_module_str}{import}{} + \stex_reactivate_macro:N \mmtdef + \stex_smsmode_do: +}{ + \str_set_eq:NN \l_stex_current_module_str \l__todo_mmt_module_str + \stex_close_module: + \str_set_eq:NN \l_stex_current_module_str \l__todo_stex_module_str + \stex_close_module: + \stex_if_do_html:T { \end{stex_annotate_env} } +} +\stex_sms_allow_env:n{mmtinterface} +\NewDocumentCommand \mmtdef {m O{} m} { + \stex_keys_set:nn{symdef}{#2} + \str_set:Nx \l_stex_macroname_str { #1 } + \str_if_empty:NT \l_stex_key_name_str { + \str_set:Nx \l_stex_key_name_str { #1 } + } + \stex_symdecl_do: + + \str_set_eq:NN \l_stex_current_module_str \l__todo_mmt_module_str + \cs_set_eq:NN \l__todo_old_metagroup_cd \stex_metagroup_do_in:nn + \cs_set_protected:Npn \stex_metagroup_do_in:nn ##1 ##2 {##2} + \exp_args:Nnx \use:nn {\stex_module_add_symbol:nnnnnnnN}{ + {\l_stex_macroname_str} + {\l_stex_key_name_str} + {\int_use:N \l_stex_get_symbol_arity_int} + {\l_stex_get_symbol_args_tl} + {} + {} + {} + \stex_invoke_symbol: + } + \cs_set_eq:NN \stex_metagroup_do_in:nn \l__todo_old_metagroup_cd + \str_set_eq:NN \l_stex_current_module_str \l__todo_stex_module_str - % None -\NewDocumentCommand \MSC {m} { - % TODO + \str_set_eq:NN \l_stex_get_symbol_mod_str \l__todo_mmt_module_str + \str_set_eq:NN \l_stex_get_symbol_name_str \l_stex_key_name_str + \stex_notation_parse:n{#3} + \_stex_notation_check: + \_stex_notation_add: + \stex_if_do_html:T{ + \_stex_notation_do_html:n{\l_stex_get_symbol_mod_str ? \l_stex_get_symbol_name_str} + } + \stex_smsmode_do: } -\@ifpackageloaded{tikzinput}{ - \RequirePackage{stex-tikzinput} -}{} - -\bool_if:NT \c_stex_persist_mode_bool { - \let\__stex_notation_restore_notation_old:nnnnn - \__stex_notation_restore_notation:nnnnn - \def\__stex_notation_restore_notation_new:nnnnn#1#2#3#4#5{ - \__stex_notation_restore_notation_old:nnnnn{#1}{#2}{#3}{#4}{#5} +\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments} +\stex_sms_allow_escape:N \mmtdef +\seq_if_empty:NT \g_stex_current_file { + \seq_gset_eq:NN \g_stex_current_file \c_stex_main_file +} +\_stex_persist_read_now: +\_stex_every_file: +\cs_new_protected:Nn \__todo_newlabel:n { + \exp_args:Ne\__todo_old_newlabel:{\tl_to_str:n{#1}} +} +\AtBeginDocument{ + \iow_now:Nn \@auxout { \ExplSyntaxOn - } - \def\__stex_notation_restore_notation:nnnnn{ + \let\__todo_old_newlabel:\newlabel + \let\newlabel\__todo_newlabel:n \ExplSyntaxOff - \catcode`~10 - \__stex_notation_restore_notation_new:nnnnn - } - \input{\jobname.sms} - \let\__stex_notation_restore_notation:nnnnn - \__stex_notation_restore_notation_old:nnnnn - \prop_if_exist:NT\c_stex_mathhub_main_manifest_prop{ - \prop_get:NnN \c_stex_mathhub_main_manifest_prop {id} - \l_tmpa_str - \prop_set_eq:cN { c_stex_mathhub_\l_tmpa_str _manifest_prop } - \c_stex_mathhub_main_manifest_prop - \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str } } } - -\stex_get_document_uri: \endinput %% %% End of file `stex.sty'. diff --git a/Master/texmf-dist/tex/latex/stex/tikzinput.sty b/Master/texmf-dist/tex/latex/stex/tikzinput.sty index d8cd67217b8..aecf3a6ce09 100644 --- a/Master/texmf-dist/tex/latex/stex/tikzinput.sty +++ b/Master/texmf-dist/tex/latex/stex/tikzinput.sty @@ -9,7 +9,7 @@ %%%%%%%%%%%%% tikzinput.dtx %%%%%%%%%%%%% -\ProvidesExplPackage{tikzinput}{2022/09/14}{3.2.0}{tikzinput package} +\ProvidesExplPackage{tikzinput}{2023/03/19}{3.3.0}{tikzinput package} \RequirePackage{l3keys2e} \keys_define:nn { tikzinput } { @@ -58,13 +58,6 @@ \tikzinput [#1] {#2} \end{center} } - -\@ifpackageloaded{stex}{ - \RequirePackage{stex-tikzinput} -}{} - - - \endinput %% %% End of file `tikzinput.sty'. diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 2a5cd8ecbf6..4a09e216f89 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -3137,6 +3137,7 @@ my $core_latex = "$Master/texmf-dist/tex/latex"; 'elteikthesis' => 'latex', # requires interaction 'embedfile' => 'etex', 'emisa' => 'pdflatex-preserve-pdf', + 'emo' => 'latex', 'engpron' => 'latex -translate-file=empty.tcx', # no 8-bit 'ecclesiastic' => 'latex', # requires interaction 'emisa' => 'pdflatex-preserve-pdf', @@ -7438,13 +7439,14 @@ sub POSTstex { # install original pristine source dir so we can just remove # everything after building and not worry about individual junk files. - # Although they should all get cleaned up by runins, let's not risk it. + # Although they should all get cleaned up by runins, let's not prove it. &xsystem ("$CP -r source $DEST/source/latex/$package"); - # run the (thankfully) provided ins files. - print "POST$package - run ins files in source/ subdirs\n"; + # run the (thankfully) provided ins file. + print "POST$package - run ins file(s) in source/ subdirs\n"; &xchdir ("source"); - for my $ins (glob ("*/*.ins")) { + # as of 2023, there's only one .ins, but no harm in keeping the loop. + for my $ins (glob ("*.ins")) { my $insdir = dirname ($ins); my $insfile = basename ($ins); &xchdir ($insdir); @@ -7453,12 +7455,12 @@ sub POSTstex { SYSTEM ("$MV *.cls *.sty $texdest"); &xchdir (".."); } - &xchdir (".."); &xsystem ("rm -rf source"); print "POST$package - doc files up a level\n"; - &xsystem ("$MV Makefile Makefile.top"); - &xsystem ("$MV */* ."); + &xsystem ("echo hithere; pwd; ls -lR"); + &xsystem ("$MV Makefile Makefile.top"); + &xsystem ("$MV doc/* ."); &SYSTEM ($RMDIR_EMPTY); } |