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 /Master/texmf-dist/tex | |
parent | 552c2f99479d2f8c84a188cc03d22adad630de0e (diff) |
stex (21mar23)
git-svn-id: svn://tug.org/texlive/trunk@66640 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
37 files changed, 7931 insertions, 7435 deletions
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'. |