diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-07 20:49:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-07 20:49:10 +0000 |
commit | ddfe3a4eaf95167482e923d4da3de2917a7dbfbb (patch) | |
tree | 0acc1bb60b37392451f5e79e00c33c487c19abcf /Master/texmf-dist/tex/latex/stex/statements | |
parent | a04ae5a947a6b06bc717719f6ad63e6de5cb5af6 (diff) |
stex (7apr16)
git-svn-id: svn://tug.org/texlive/trunk@40320 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/stex/statements')
-rw-r--r-- | Master/texmf-dist/tex/latex/stex/statements/statements.sty | 194 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/stex/statements/statements.sty.ltxml | 365 |
2 files changed, 139 insertions, 420 deletions
diff --git a/Master/texmf-dist/tex/latex/stex/statements/statements.sty b/Master/texmf-dist/tex/latex/stex/statements/statements.sty index 4c8f57560e8..d3c0e44382a 100644 --- a/Master/texmf-dist/tex/latex/stex/statements/statements.sty +++ b/Master/texmf-dist/tex/latex/stex/statements/statements.sty @@ -7,31 +7,39 @@ %% statements.dtx (with options: `package') %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{statements}[2012/01/28 v1.1 Semantic Markup for Statements] -\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}} -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{omdoc}} +\ProvidesPackage{statements}[2016/04/06 v1.2 Semantic Markup for Statements] +\newif\ifdef@index\def@indexfalse +\DeclareOption{defindex}{\def@indextrue} +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{omtext}} \ProcessOptions \RequirePackage{omtext} -\RequirePackage{modules} +\RequirePackage[base]{babel} \RequirePackage[hyperref]{ntheorem} \theoremstyle{plain} +\AfterBabelLanguage{ngerman}{\input{statements-ngerman.ldf}} \providecommand\STpresent[1]{#1} \def\define@statement@env#1{% \newenvironment{#1}[1][]{\metasetkeys{omtext}{##1}\sref@target% +\@in@omtexttrue% \ifx\omtext@display\st@flow\else% \ifx\omtext@title\@empty\begin{ST#1Env}\else\begin{ST#1Env}[\omtext@title]\fi% \ifx\sref@id\@empty\else\label{#1.\sref@id}\fi -\csname st@#1@initialize\endcsname\fi +\csname st@#1@initialize\endcsname\fi% display \ifx\sref@id\@empty\sref@label@id{here}\else% -\sref@label@id{\STpresent{\csname ST#1EnvKeyword\endcsname}~\@currentlabel}\fi} -{\csname st@#1@terminate\endcsname\ifx\omtext@display\st@flow\else\end{ST#1Env}\fi}} +\sref@label@id{\STpresent{\csname ST#1EnvKeyword\endcsname}~\@currentlabel}\fi% +\ignorespaces} +{\csname st@#1@terminate\endcsname\ifx\omtext@display\st@flow\else\end{ST#1Env}\fi% +\omtext@post@skip\@in@omtextfalse}} \newenvironment{assertion}[1][]{\metasetkeys{omtext}{#1}\sref@target% -\ifx\omtext@display\st@flow\else% +\@in@omtexttrue% +\ifx\omtext@display\st@flow\itshape\noindent\ignorespaces% +\else% display!=flow \ifx\omtext@title\@empty\begin{ST\omtext@type AssEnv}% \else\begin{ST\omtext@type AssEnv}[\omtext@title]\fi\fi% \ifx\omtext@type\@empty\sref@label@id{here}\else% -\sref@label@id{\STpresent{\csname ST\omtext@type AssEnvKeyword\endcsname}~\@currentlabel}\fi} -{\ifx\omtext@display\st@flow\else\end{ST\omtext@type AssEnv}\fi} +\sref@label@id{\STpresent{\csname ST\omtext@type AssEnvKeyword\endcsname}~\@currentlabel} +\fi}%display=flow +{\ifx\omtext@display\st@flow\else\end{ST\omtext@type AssEnv}\@in@omtextfalse\fi} \def\st@theorem@kw{Theorem} \def\st@lemma@kw{Lemma} \def\st@proposition@kw{Proposition} @@ -41,10 +49,12 @@ \def\st@postulate@kw{Postulate} \def\st@obligation@kw{Obligation} \def\st@assumption@kw{Assumption} +\def\st@rule@kw{Rule} \def\st@observation@kw{Observation} +\def\st@remark@kw{Remark} \theorembodyfont{\itshape} \theoremheaderfont{\normalfont\bfseries} -\newtheorem{STtheoremAssEnv}{\st@theorem@kw} +\newtheorem{STtheoremAssEnv}{\st@theorem@kw}[section] \newtheorem{STlemmaAssEnv}[STtheoremAssEnv]{\st@lemma@kw} \newtheorem{STpropositionAssEnv}[STtheoremAssEnv]{\st@proposition@kw} \newtheorem{STcorollaryAssEnv}[STtheoremAssEnv]{\st@corollary@kw} @@ -54,6 +64,9 @@ \newtheorem{STobligationAssEnv}[STtheoremAssEnv]{\st@obligation@kw} \newtheorem{STassumptionAssEnv}[STtheoremAssEnv]{\st@assumption@kw} \newtheorem{STobservationAssEnv}[STtheoremAssEnv]{\st@observation@kw} +\theorembodyfont{\rm} +\newtheorem{STremarkAssEnv}[STtheoremAssEnv]{\st@remark@kw} +\newtheorem{STruleAssEnv}[STtheoremAssEnv]{\st@rule@kw} \def\st@example@initialize{}\def\st@example@terminate{} \define@statement@env{example} \def\st@example@kw{Example} @@ -68,88 +81,159 @@ \addmetakey{symboldec}{functions} \addmetakey{symboldec}{role} \addmetakey*{symboldec}{title} -\addmetakey{symboldec}{name} +\addmetakey*{symboldec}{name} \addmetakey{symboldec}{subject} \addmetakey*{symboldec}{display} -\def\symboldec@type{Symbol} \newenvironment{symboldec}[1][]{\metasetkeys{symboldec}{#1}\sref@target\st@indeftrue% -\ifx\symboldec@display\st@flow\else{\stDMemph{\symboldec@type} \symboldec@name:}\fi% +\ifx\symboldec@display\st@flow\else{\noindent\stDMemph{\symdef@type} \symboldec@name:}\fi% \ifx\symboldec@title\@empty~\else~(\stDMemph{\symboldec@title})\par\fi}{} -\newcommand{\symtype}[2]{Type (#1): $#2$} +\srefaddidkey{symtype} +\addmetakey*{symtype}{system} +\addmetakey*{symtype}{for} +\newcommand\type@type{Type} +\newcommand\symtype[3][]{\metasetkeys{symtype}{#1}\sref@target% +\noindent\type@type \ifx\symtype@\@empty\else (\symtype@system)\fi #2: $#3$} +\newcommand\inlinetypedec[3][]{\metasetkeys{symtype}{#1}\sref@target{\def\thedectype{#2}#3}} +\def\st@typedec@kw{Type Declaration} +\theorembodyfont{\upshape} +\newtheorem{STtypedecEnv}[STtheoremAssEnv]{\st@typedec@kw} +\newenvironment{typedec}[2][]{\metasetkeys{omtext}{#1}\sref@target% +\def\thedectype{#2}% +\ifx\omtext@display\st@flow\else% +\ifx\omtext@title\@empty\begin{STtypedecEnv}\else\begin{STtypedecEnv}[\omtext@title]\fi% +\ifx\sref@id\@empty\else\label{typedec.\sref@id}\fi +\ifx\sref@id\@empty\sref@label@id{here}\else% +\sref@label@id{\STpresent{\csname STtypedecEnvKeyword\endcsname}~\@currentlabel}\fi% +\ignorespaces} +{\ifx\omtext@display\st@flow\else\end{STtypedecEnv}\fi\omtext@post@skip} \newif\ifst@indef\st@indeffalse \newenvironment{definition}[1][]{\metasetkeys{omtext}{#1}\sref@target\st@indeftrue% \ifx\omtext@display\st@flow\else% \ifx\omtext@title\@empty\begin{STdefinitionEnv}\else\begin{STdefinitionEnv}[\omtext@title]\fi\fi% \ifx\sref@id\@empty\sref@label@id{here}\else% -\sref@label@id{\STpresent{\csname STdefinitionEnvKeyword\endcsname}~\@currentlabel}\fi} +\sref@label@id{\STpresent{\csname STdefinitionEnvKeyword\endcsname}~\@currentlabel}\fi% +\ignorespaces} {\ifx\omtext@display\st@flow\else\end{STdefinitionEnv}\fi} \def\st@definition@kw{Definition} \theorembodyfont{\upshape} \newtheorem{STdefinitionEnv}[STtheoremAssEnv]{\st@definition@kw} -\def\notemph#1{{\bf{#1}}} +\def\notemph#1{#1} \def\st@notation@terminate{} \def\st@notation@initialize{} \define@statement@env{notation} \def\st@notation@kw{Notation} \theorembodyfont{\upshape} \newtheorem{STnotationEnv}[STtheoremAssEnv]{\st@notation@kw} -\def\st@def@target#1#2{\def\@test{#1}% +\newcommand\st@def@target[3]{\def\@symname{#1}\def\@verbname{#2}% \ifst@indef% if we are in a definition or such -\ifx\omtext@theory\@empty% if there is no theory attribute \@ifundefined{mod@id}% if we are not in a module {\PackageWarning{statements}{definiendum in unidentified module\MessageBreak \protect\definiendum, \protect\defi, \protect\defii, \protect\defiii\MessageBreak can only be referenced when called in a module with id key}}% -{\ifx\@test\@empty% -\expandafter\sref@target@ifh{sref@#2@\mod@id @target}{}\else% -\expandafter\sref@target@ifh{sref@#1@\mod@id @target}{}\fi}% -\else\expandafter\sref@target@ifh{sref@#1@\omtext@theory @target}{}\fi% -\else\PackageError{statements}% +{% now we are in a module +\edef\@@cd{\ifx\omtext@theory\@empty\mod@id\else\omtext@theory\fi}% +\edef\@@name{\ifx\@symname\@empty\@verbname\else\@symname\fi}% +\defemph{\@ifundefined{sref@\@@name @\@@cd @defined}% +{\expandafter\sref@target@ifh{sref@\@@name @\@@cd @target}{#3}}% +{#3}}% +\expandafter\gdef\csname sref@\@@name @\@@cd @defined\endcsname{yes}% +\ifmetakeys@showmeta\metakeys@show@keys{\@@cd}{name:\@@name}\fi}% +\else% st@indef +\PackageError{statements}% {definiendum outside definition context\MessageBreak \protect\definiendum, \protect\defi, \protect\defii, \protect\defiii\MessageBreak do not make sense semantically outside a definition.\MessageBreak Consider wrapping the defining phrase in a \protect\inlinedef}% -\fi} +\fi}% st@indef \newcommand\@termdef[2][]{\def\@test{#1}% \@ifundefined{mod@id}{}{\ifx\@test\@empty\def\@@name{#2}\else\def\@@name{#1}\fi% \termdef{\mod@id @\@@name}{#2}}} -\newcommand\definiendum[2][]{\st@def@target{#1}{#2}\defemph{#2}} -\newcommand{\notatiendum}[2][]{\notemph{#2}} -\newcommand{\defi}[2][]{\definiendum[#1]{#2}\omdoc@index[#1]{#2}} -\newcommand{\adefi}[3][]{\def\@test{#1}% -\ifx\@test\@empty\definiendum[#3]{#2}% -\else\definiendum[#1]{#2}\omdoc@index[#1]{#3}\fi} -\newcommand{\defii}[3][]{\st@def@target{#1}{#2-#3}\defemph{#2 #3}\@twin[#1]{#2}{#3}} -\newcommand{\adefii}[4][]{\def\@test{#1}% -\ifx\@test\@empty\definiendum[#3-#4]{#2}% -\else\definiendum[#1]{#2}\@twin[#1]{#3}{#4}\fi} -\newcommand{\defiii}[4][]{\st@def@target{#1}{#2-#3-#4}\defemph{#2 #3 #4}\@atwin[#1]{#2}{#3}{#4}} -\newcommand{\adefiii}[5][]{\def\@test{#1}% -\ifx\@test\@empty\definiendum[#3-#4-#5]{#2}% -\else\definiendum[#1]{#2}\@atwin[#1]{#3}{#4}{#5}\fi} -\newcommand{\inlineex}[2][]{\metasetkeys{omtext}{#1}\sref@target\sref@label@id{here}#2} -\newcommand{\inlinedef}[2][]{\metasetkeys{omtext}{#1}\sref@target\sref@label@id{here}\st@indeftrue #2} -\addmetakey[\mod@id]{termref}{cd} -\addmetakey{termref}{cdbase} -\addmetakey{termref}{name} -\addmetakey{termref}{role} -\def\termref@set#1#2{\def\termref@name{#2}\metasetkeys{termref}{#1}} -\newcommand{\termref}[2][]{\metasetkeys{termref}{#1}\st@termref{#2}} -\def\st@termref#1{\ifx\termref@name\@empty\def\termref@name{#1}\fi% -\ifx\termref@cdbase\@empty\mod@termref\termref@cd\termref@name{#1}% -\else\sref@href@ifh\termref@cdbase{#1}\fi} -\newcommand\atrefi[3][]{\def\@test{#1}\ifx\@test\@empty\termref[name=#3]{#2}\else\termref[cd=#1,name=#3]{#2}\fi} +\newcommand\definiendum[2][]{\st@def@target{#1}{#2}{#2}} +\newcommand\notatiendum[2][]{\notemph{#2}} +\newcommand\defi[2][]{\st@def@target{#1}{#2}{#2}\def\@phrase{#2}\@defi} +\newcommand\@defi[1][]{\ifdef@index\omdoc@indexi[#1]{\@phrase}\fi\xspace} +\newcommand\defis[2][]{\st@def@target{#1}{#2}{#2s}\def\@phrase{#2}\@defi} +\newcommand\adefi[3][]{\def\@name{#1}\def\@verb{#3}% +\st@def@target{#1}{#3}{#2}\@adefi} +\newcommand\@adefi[1][]{% +\ifdef@index% +\ifx\@name\@empty\omdoc@indexi[#1]{\@verb}% +\else\omdoc@indexi[at=\@name,#1]{\@verb}\fi% +\fi\xspace} +\newcommand\@defii[1][]{\ifdef@index\@twin[#1]{\@pone}{\@ptwo}\fi\xspace} +\newcommand\defii[3][]{\def\@pone{#2}\def\@ptwo{#3}% +\st@def@target{#1}{#2-#3}{#2 #3}\@defii} +\newcommand\defiis[3][]{\def\@pone{#2}\def\@ptwo{#3}% +\st@def@target{#1}{#2-#3}{#2 #3s}\@defii} +\newcommand\adefii[4][]{\def\@name{#1}\def\@pone{#3}\def\@ptwo{#4}% +\st@def@target{#1}{#3-#4}{#2}\@adefii} +\newcommand\@adefii[1][]{% +\ifdef@index% +\ifx\@name\@empty\@twin[#1]{\@pone}{\@ptwo}% +\else\@twin[at=\@name,#1]{\@pone}{\@ptwo}\fi% +\fi\xspace} +\newcommand\defiii[4][]{\def\@pone{#2}\def\@ptwo{#3}\def\@pthree{#4}% +\st@def@target{#1}{#2-#3-#4}{#2 #3 #4}\@defiii} +\newcommand\@defiii[1][]{\ifdef@index\@atwin[#1]{\@pone}{\@ptwo}{\@pthree}\fi\xspace} +\newcommand\defiiis[4][]{\def\@pone{#2}\def\@ptwo{#3}\def\@pthree{#4}% +\st@def@target{#1}{#2-#3-#4}{#2 #3 #4s}\@defiii} +\newcommand\adefiii[5][]{\def\@name{#1}\def\@pone{#3}\def\@ptwo{#4}\def\@pthree{#3}% +\st@def@target{#1}{#3-#4-#5}{#2}\@adefiii} +\newcommand\@adefiii[1][]{% +\ifdef@index% +\ifx\@name\@empty\@atwin[#1]{\@pone}{\@ptwo}{\@pthree}% +\else\@atwin[at=\@name,#1]{\@pone}{\@ptwo}{\@pthree}\fi% +\fi\xspace} +\newcommand\inlineex[2][]{\metasetkeys{omtext}{#1}% +\sref@target\sref@label@id{here}#2} +\newcommand\inlineass[2][]{\metasetkeys{omtext}{#1}% +\sref@target\sref@label@id{here}#2} +\newcommand\inlinedef[2][]{\metasetkeys{omtext}{#1}% +\if@in@omtext\else% we are not in an omtext or statement +\PackageError{modules}{\protect\inlinedef\space outside a statement!}% +{Try wrapping the paragraph in a\MessageBreak +\protect\begin{omtext}, \protect\begin{assertion}, \protect\begin{axiom}, ... \MessageBreak +whatever is suitable semantically}\fi% +\sref@target\sref@label@id{here}\st@indeftrue #2} +\addmetakey*{termref}{cd} +\addmetakey*{termref}{cdbase} +\addmetakey*{termref}{name} +\addmetakey*{termref}{role} +\newcommand\termref[2][]{\metasetkeys{termref}{#1}% + \ifx\termref@cd\@empty\def\termref@cd{\mod@id}\fi% + \ifx\termref@name\@empty\def\termref@name{#2}\fi% + \@ifundefined{sref@\termref@name @\termref@cd @defined} + {\ifx\termref@cdbase\@empty% external reference + \mod@termref\termref@cd\termref@name{#2}% + \else\sref@href@ifh\termref@cdbase{#2}% + \fi}% + {\sref@hlink@ifh{sref@\termref@name @\termref@cd @target}{#2}}% +} +\newcommand\atrefi[3][]{\def\@test{#1}% +\ifx\@test\@empty\termref[name=#3]{#2}\else\termref[cd=#1,name=#3]{#2}\fi} \newcommand\atrefii[4][]{\atrefi[#1]{#2}{#3-#4}} \newcommand\atrefiii[5][]{\atrefi[#1]{#2}{#3-#4-#5}} -\newcommand{\trefi}[2][]{\atrefi[#1]{#2}{#2}} -\newcommand{\trefii}[3][]{\atrefi[#1]{#2 #3}{#2-#3}} -\newcommand{\trefiii}[4][]{\atrefi[#1]{#2 #3 #4}{#2-#3-#4}} +\newcommand\trefi[2][]{\atrefi[#1]{#2}{#2}} +\newcommand\trefii[3][]{\atrefi[#1]{#2 #3}{#2-#3}} +\newcommand\trefiii[4][]{\atrefi[#1]{#2 #3 #4}{#2-#3-#4}} +\newcommand\trefis[2][]{\atrefi[#1]{#2s}{#2}} +\newcommand\trefiis[3][]{\atrefi[#1]{#2 #3s}{#2-#3}} +\newcommand\trefiiis[4][]{\atrefi[#1]{#2 #3 #4s}{#2-#3-#4}} \providecommand{\termemph}[1]{#1} \providecommand{\defemph}[1]{{\textbf{#1}}} \providecommand{\stDMemph}[1]{{\textbf{#1}}} -\newcommand{\symref}[2]{\@nameuse{mod@symref@#1}{#2}} +\newcommand\term[2][]{\def\@test{#1}% +\ifx\@test\@empty\else +\@ifundefined{module@defs@#1}{\PackageWarning{statements}% +{{\protect\term} specifies module #1 which is not in + scope\MessageBreak import it via e.g. via \protect\importmhmodule}}{} +\fi% +\PackageWarning{statements}% +{Dangling link (\protect\term) for "#2" still needs to be specified}% +\textcolor{blue}{\underline{#2}}} +\newcommand\symref[2]{\@nameuse{mod@symref@#1}{#2}} \newcommand\defin[2][]{\defi[#1]{#2}% \PackageWarning{statements}{\protect\defin\space is deprecated, use \protect\defi\space instead}} \newcommand\twindef[3][]{\defii[#1]{#2}{#3}% diff --git a/Master/texmf-dist/tex/latex/stex/statements/statements.sty.ltxml b/Master/texmf-dist/tex/latex/stex/statements/statements.sty.ltxml deleted file mode 100644 index 92d7f8d8b84..00000000000 --- a/Master/texmf-dist/tex/latex/stex/statements/statements.sty.ltxml +++ /dev/null @@ -1,365 +0,0 @@ -# -*- CPERL -*- -package LaTeXML::Package::Pool; -use strict; -use LaTeXML::Package; -RequirePackage('omtext'); -RequirePackage('modules'); -sub lowcase {my ($string) = @_; $string ? return lc(ToString($string)) : return('')}#$ -sub dashed { join('-',map($_->toString,@_));}#$ -sub makeNCName { - my ($name) = @_; - my $ncname=$name; - $ncname=~s/\s/_/g; #Spaces to underscores - $ncname="_$ncname" if $ncname!~/^(\w|_)/; #Ensure start with letter or underscore - ##More to come... - $ncname; -} -sub simple_wrapper { - #Deref if array reference - my @input; - foreach (@_) { - if (ref $_ && $_ =~ /ARRAY/ && $_ !~ /LaTeXML/) { - @input=(@input,@$_); - } else - { push (@input,$_); } - } - return '' if (!@input); - @input = map(split(/\s*,\s*/,ToString($_)),@input); - my $output=join(" ",@input); - $output=~s/(^ )|[{}]//g; #remove leading space and list separator brackets - $output||''; -} -sub hash_wrapper{ - #Deref if array reference - my @input; - foreach (@_) { - if (ref $_ && $_ =~ /ARRAY/ && $_ !~ /LaTeXML/) { - @input=(@input,@$_); - } else - { push (@input,$_); } - } - return '' if (!@input); - @input = map(split(/\s*,\s*/,ToString($_)),@input); - my $output=join(".sym #",@input); - $output=~s/(^\.sym )|[{}]//g; #remove leading space and list separator brackets - "#$output"||''; -} -DefEnvironment('{assertion} OptionalKeyVals:omtext', - "<omdoc:assertion " - . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() " - . "?&KeyVal(#1,'theory')(theory='&KeyVal(#1,'theory')')() " - . "type='&lowcase(&KeyVal(#1,'type'))'>" - . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()" - . "<omdoc:CMP>#body" - ."</omdoc:assertion>\n"); -DefEnvironment('{example} OptionalKeyVals:omtext', - "<omdoc:example " - . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() " - . "?&KeyVal(#1,'for')(for='&hash_wrapper(&KeyVal(#1,'for'))')()>" - . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()" - . "<omdoc:CMP>#body" - . "</omdoc:example>\n"); -DefEnvironment('{axiom} OptionalKeyVals:omtext', - "<omdoc:axiom " - . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')()>" - . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()" - . "<omdoc:CMP>#body" - . "</omdoc:axiom>\n"); -DefEnvironment('{symboldec} OptionalKeyVals:symboldec', - "<omdoc:symbol " - . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')" - . "(xml:id='&makeNCName(&KeyVal(#1,'name')).def.sym')" - . "name='&KeyVal(#1,'name')'>" - . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()" - . "<dc:description>#body" - ."</omdoc:symbol>\n"); -DefConstructor('\symtype{}{}', - "<omdoc:type system='#1'><ltx:Math><ltx:XMath>#2</ltx:XMath></ltx:Math></omdoc:type>"); -sub definitionBody { - my ($doc, $keyvals, %props) = @_; - my $for = $keyvals->getValue('for') if $keyvals; - my $type = $keyvals->getValue('type') if $keyvals; - my %for_attr=(); - if (ToString($for)) { - $for = ToString($for); - $for =~ s/^{(.+)}$/$1/eg; - foreach (split(/,\s*/,$for)) { - $for_attr{$_}=1; - }} - if ($props{theory}) { - my @symbols = @{$props{defs} || []}; - foreach my $symb(@symbols) { - next if $for_attr{$symb}; - $for_attr{$symb}=1; - $doc->insertElement('omdoc:symbol', undef, (name=>$symb, "xml:id"=>makeNCName("$symb.def.sym"))); - } - } - my %attrs = (); - $for = join(" ",(keys %for_attr)); - $attrs{'for'} = $for if $for; - my $id = $keyvals->getValue('id') if $keyvals; - $attrs{'xml:id'} = $id if $id; - $attrs{'type'} = $type if $type; - if ($props{theory}) { - $doc->openElement('omdoc:definition', %attrs); - } else { - $attrs{'type'}='definition'; - $doc->openElement('omdoc:omtext', %attrs); - } - my $title = $keyvals->getValue('title') if $keyvals; - if ($title) { - $doc->openElement('omdoc:metadata'); - $doc->openElement('dc:title'); - $doc->absorb($title); - $doc->closeElement('dc:title');} - $doc->openElement('omdoc:CMP'); - $doc->absorb($props{body}) if $props{body}; - $doc->maybeCloseElement('omdoc:CMP'); - if ($props{theory}) { - $doc->closeElement('omdoc:definition'); - } else { - $doc->closeElement('omdoc:omtext'); - } - return; } -DefEnvironment('{definition} OptionalKeyVals:omtext', sub{definitionBody(@_)}, - afterDigestBegin=>sub { - my ($stomach, $whatsit) = @_; - my @symbols = (); - $whatsit->setProperty(theory=>LookupValue('current_module')); - $whatsit->setProperty(defs=>\@symbols); - AssignValue('defs', \@symbols); return; }, - afterDigest => sub { AssignValue('defs', undef); return; });#$ -DefEnvironment('{notation} OptionalKeyVals:omtext', - "<omdoc:definition " - . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id').not')()" - . "?&KeyVal(#1,'for')(for='&simple_wrapper(&KeyVal(#1,'for'))')()>" - . "?&KeyVal(#1,'title')(<dc:title>&KeyVal(#1,'title')</dc:title>)()" - . "<omdoc:CMP>#body" - . "</omdoc:definition>\n"); -DefConstructor('\notatiendum OptionalKeyVals:notation {}', - "<ltx:text class='notatiendum'>#2</ltx:text>"); -DefConstructor('\definiendum [] {}', - "<omdoc:term role='definiendum' name='#name' cd='#theory'>#2</omdoc:term>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $whatsit->getArg(2) unless $name; - $whatsit->setProperty(name=>$name->toString); - push(@$addr, $name->toString) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module')); - return; });#$ -DefConstructor('\defi[]{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' name='?#1(#1)(#2)' cd='#theory'>#2</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'><omdoc:idp>#2</omdoc:idp></omdoc:ide>" - ."</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $whatsit->getArg(2) unless $name; - push(@$addr, $name->toString) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module'));#$ - return; }, - alias=>'\defi'); -DefConstructor('\adefi[]{}{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' name='?#1(#1)(#3)' cd='#theory'>#2</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'><omdoc:idp>#3</omdoc:idp></omdoc:ide>" - ."</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $whatsit->getArg(3) unless $name; - push(@$addr, $name->toString) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module'));#$ - return; }, - alias=>'\adefi'); -DefConstructor('\defii[]{}{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' name='?#1(#1)(&dashed(#2,#3))' cd='#theory'>" - . "#2 #3" - . "</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'>" - . "<omdoc:idp>#2</omdoc:idp>" - . "<omdoc:idp>#3</omdoc:idp>" - . "</omdoc:ide>" - ."</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; -my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $name->toString if $name; - $name = $whatsit->getArg(2)->toString.'-'.$whatsit->getArg(3)->toString unless $name; - push(@$addr, $name) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module')); - return; }, - alias=>'\defii');#$ -DefConstructor('\adefii[]{}{}{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' name='?#1(#1)(&dashed(#3,#4))' cd='#theory'>" - . "#2" - . "</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'>" - . "<omdoc:idp>#3</omdoc:idp>" - . "<omdoc:idp>#4</omdoc:idp>" - . "</omdoc:ide>" - ."</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $name->toString if $name; - $name = $whatsit->getArg(3)->toString.'-'.$whatsit->getArg(4)->toString unless $name; - push(@$addr, $name) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module')); - return; }, - alias=>'\defii');#$ -DefConstructor('\defiii[]{}{}{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' cd='#theory' name='?#1(#1)(&dashed(#2,#3,#4))'>#2 #3 #4</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'>" - . "<omdoc:idp>#2</omdoc:idp>" - . "<omdoc:idp>#3</omdoc:idp>" - . "<omdoc:idp>#4</omdoc:idp>" - . "</omdoc:ide>" - . "</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $name->toString if $name; - $name = $whatsit->getArg(2)->toString.'-'.$whatsit->getArg(3)->toString.'-'.$whatsit->getArg(4)->toString unless $name; - push(@$addr, $name) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module')); - return; }, - alias=>'\defiii'); -DefConstructor('\adefiii[]{}{}{}{}', - "<omdoc:idx>" - . "<omdoc:idt>" - . "<omdoc:term role='definiendum' cd='#theory' name='?#1(#1)(&dashed(#3,#4,#5))'>#2</omdoc:term>" - . "</omdoc:idt>" - . "<omdoc:ide index='default'>" - . "<omdoc:idp>#3</omdoc:idp>" - . "<omdoc:idp>#4</omdoc:idp>" - . "<omdoc:idp>#5</omdoc:idp>" - . "</omdoc:ide>" - . "</omdoc:idx>", - afterDigest => sub { - my ($stomach, $whatsit) = @_; - my $addr = LookupValue('defs'); - my $name = $whatsit->getArg(1); - $name = $name->toString if $name; - $name = $whatsit->getArg(3)->toString.'-'.$whatsit->getArg(4)->toString.'-'.$whatsit->getArg(5)->toString unless $name; - push(@$addr, $name) if ($addr and $name); - $whatsit->setProperty(theory=>LookupValue('current_module')); - return; }, - alias=>'\defiii'); -DefConstructor('\inlineex OptionalKeyVals:omtext {}', - "<ltx:text class='example'>#2</ltx:text>"); -DefConstructor('\inlinedef OptionalKeyVals:omtext {}', sub { - my ($document, $keyvals, $body, %props) = @_; - my $for = $keyvals->getValue('for') if $keyvals; - my %for_attr=(); - if (ToString($for)) { - $for = ToString($for); - $for =~ s/^{(.+)}$/$1/eg; - foreach (split(/,\s*/,$for)) { - $for_attr{$_}=1; - }} - my @symbols = @{$props{defs} || []}; - #Prepare for symbol insertion -insert before the parent of the closest ancestor CMP element - my $original_node = $document->getNode; - my $xc = XML::LibXML::XPathContext->new( $original_node ); - $xc->registerNs('omdoc', 'http://omdoc.org/ns'); - my ($statement_ancestor) = $xc->findnodes('./ancestor::omdoc:CMP/..'); - foreach my $symb(@symbols) { - next if $for_attr{$symb}; - $for_attr{$symb}=1; - my $symbolnode = XML::LibXML::Element->new('symbol'); - $symbolnode->setAttribute(name=>$symb); - $symbolnode->setAttribute("xml:id"=>makeNCName("$symb.def.sym")); - $statement_ancestor->parentNode->insertBefore($symbolnode,$statement_ancestor); - } - #Restore the insertion point - $document->setNode($original_node); - my %attrs = (); - $for = join(" ",(keys %for_attr)); - $attrs{'for'} = $for if $for; - my $id = $keyvals->getValue('id') if $keyvals; - $attrs{'xml:id'} = $id if $id; -$attrs{'class'} = 'inlinedef'; - $document->openElement('ltx:text',%attrs); - $document->absorb($body); -$document->closeElement('ltx:text'); }, - #Prepare 'defs' hooks for \defi and \definiendum symbol names - beforeDigest=>sub { - my @symbols = (); - AssignValue('defs', \@symbols); return; }, - #Adopt collected names as 'defs' property, remove hooks - afterDigest=>sub { - my ($stomach, $whatsit) = @_; - my $defsref = LookupValue('defs'); - my @defs = @$defsref; - $whatsit->setProperty('defs',\@defs); - AssignValue('defs',undef); - return; }); -DefConstructor('\termref OptionalKeyVals:termref {}', - "<omdoc:term " - . "?&KeyVal(#1,'cdbase')(cdbase='&KeyVal(#1,'cdbase')')() " - . "cd='?&KeyVal(#1,'cd')(&KeyVal(#1,'cd'))(#module)' " - . "name='&KeyVal(#1,'name')'>" - . "#2" - ."</omdoc:term>", - afterDigest=>sub{$_[1]->setProperty(module=>LookupValue('current_module'))}); -RawTeX(' -\newcommand\atrefi[3][]{\def\@test{#1}\ifx\@test\@empty\termref[name=#3]{#2}\else\termref[cd=#1,name=#3]{#2}\fi} -\newcommand\atrefii[4][]{\atrefi[#1]{#2}{#3-#4}} -\newcommand\atrefiii[5][]{\atrefi[#1]{#2}{#3-#4-#5}} -\newcommand{\trefi}[2][]{\atrefi[#1]{#2}{#2}} -\newcommand{\trefii}[3][]{\atrefi[#1]{#2 #3}{#2-#3}} -\newcommand{\trefiii}[4][]{\atrefi[#1]{#2 #3 #4}{#2-#3-#4}} -'); -DefConstructor('\symref{}{}', - "<omdoc:term cd='&LookupValue('symdef.#1.cd')' name='&LookupValue('symdef.#1.name')'>" - . "#2" - ."</omdoc:term>"); -Tag('omdoc:assertion',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:definition',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:example',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:requation',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:axiom',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:symbol',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:type',afterOpen=>\&numberIt,afterClose=>\&locateIt); -Tag('omdoc:term',afterOpen=>\&numberIt,afterClose=>\&locateIt); -RawTeX(' -\newcommand\defin[2][]{\defi[#1]{#2}% -\PackageWarning{statements}{\protect\defin\space is deprecated, use \protect\defi\space instead}} -\newcommand\twindef[3][]{\defii[#1]{#2}{#3}% -\PackageWarning{statements}{\protect\twindef\space is deprecated, use \protect\defii\space instead}} -\newcommand\atwindef[4][]{\defiii[#1]{#2}{#3}{#4}% -\PackageWarning{statements}{\protect\atwindef\space is deprecated, use \protect\defiii\space instead}} -\newcommand\definalt[3][]{\adefi[#1]{#2}{#3}% -\PackageWarning{statements}{\protect\definalt\space is deprecated, use \protect\adefi\space instead}} -\newcommand\twindefalt[4][]{\adefii[#1]{#2}{#3}{#4}% -\PackageWarning{statements}{\protect\twindefalt\space is deprecated, use \protect\adefii\space instead}} -\newcommand\atwindefalt[5][]{\adefiii[#1]{#2}{#3}{#4}{#5}% -\PackageWarning{statements}{\protect\atwindefalt\space is deprecated, use \protect\adefiii\space instead}} -\newcommand\twinref[3][]{\trefii[#1]{#2}{#3}% -\PackageWarning{statements}{\protect\twinref\space is deprecated, use \protect\trefii\space instead}} -\newcommand\atwinref[4][]{\atrefiii[#1]{#2}{#3}{#4}% -\PackageWarning{statements}{\protect\atwindef\space is deprecated, use \protect\trefiii\space instead}} -'); -1; |