diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/x-newmml.tex')
-rw-r--r-- | Master/texmf-dist/tex/context/base/x-newmml.tex | 352 |
1 files changed, 230 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/context/base/x-newmml.tex b/Master/texmf-dist/tex/context/base/x-newmml.tex index 803190ee44d..f4847eeb94d 100644 --- a/Master/texmf-dist/tex/context/base/x-newmml.tex +++ b/Master/texmf-dist/tex/context/base/x-newmml.tex @@ -13,7 +13,14 @@ %D Remark: from now on this is a module and no longer an xtag %D filter. In due time it will replace the older renderer (which -%D we will keep around for sentimental reasons). +%D we will keep around for sentimental reasons). This variant has +%D no namespace support yet, but eventually we will use a \MKIV\ +%D version. + +\ifx\inlinemathematics\undefined + \def\inlinemathematics {\dontleavehmode\mathematics} % already in kernel + \long\def\inlinemath #1{\dontleavehmode\relax\ifmmode#1\else $#1$\fi} +\fi % \defineXMLentity[x000AF]{\normalorfiller{x}\hrulefill} % CHECK FOR: \xmlrent @@ -77,7 +84,7 @@ %D The second implementation expanded the whole math sequence %D into an internal \TEX\ representation. This is a rather clean %D and fast process. Filtering and testing takes place by -%D redefining teh internal representation macros. +%D redefining the internal representation macros. %D %D The third implementation may look a bit more messy in some %D respects. This is because in \TEX\ it's not that trivial to @@ -131,13 +138,6 @@ {\startsavingXMLelements} {\stopsavingXMLelements} -% already defined -% -% \defineXMLnestedenvironmentsave -% [xmlstack] -% {} -% {\pushXMLnameonstack} - \stopXMLmapping %D Auxiliary MathML macros: (to be generalized) @@ -439,16 +439,17 @@ [csymbol] [encoding=text, definitionURL=] - {} + {\doifsomething{\XMLop{definitionURL}}{\directsetup{mmc:csymbol:apply}}} \startsetups mmc:csymbol:apply \begingroup \startsavingXMLelements \rawXMLstacktext\plusone % still on stack, no check, just attr test \stopsavingXMLelements - % http://www.publisherswhodontcareaboutcosts.com/SomeName - \doifsetupselse{mmc:csymbol:\XMLpar{csymbol}{definitionURL}{}} { - \expanded{\endgroup\noexpand\directsetup{mmc:csymbol:\XMLpar{csymbol}{definitionURL}{}}} + % http://www.publishers.com/SomeName + \lowercasestring\XMLpar{csymbol}{definitionURL}{}\to\mmcSymbolURL + \doifsetupselse{mmc:csymbol:} {\mmcSymbolURL} { + \expanded{\endgroup\noexpand\directsetup{mmc:csymbol:\mmcSymbolURL}} } { % SomeName (fallback) \splitfilename{\XMLpar{csymbol}{definitionURL}{}} @@ -469,7 +470,7 @@ %D <dmath><apply><cn>1.23</cn></apply></dmath> %D \stopXMLdata %D -%D \setupMMLappearance[cn] [alternative=b] +%D \type{\setupMMLappearance[cn] [alternative=b]} %D %D \startXMLdata %D <imath><apply><cn>1.23</cn></apply></imath> @@ -540,7 +541,7 @@ \def\MMLccartesian#1% {\def\MMLcsep{+}#1\getXMLentity{imaginaryi}} -% float will be obsolete, an is replace by e-notation +% float will be obsolete, and is replace by e-notation \def\MMLcfloat#1% {\doifelse\@@MMLfloatsymbol\v!no @@ -784,6 +785,7 @@ \XMLfirstnamed{bvar} \fi \getXMLentity{mapsto} + \MMLcreset \XMLfirstnamed{apply,reln,ci,cn} } \endgroup @@ -803,6 +805,7 @@ \startsetups mmc:lambda:simple:stop \stopsavingXMLelements + \MMLcreset % new \XMLfirstnamed{apply} \endgroup \stopsetups @@ -839,7 +842,13 @@ \setupMMLappearance[piece][\c!separator=] -\def\MMLcPIECEseparator{\doif\@@MMLpieceseparator\v!yes,} +\def\setMMLcPIECEseparator + {\processaction + [\@@MMLpieceseparator] + [ \v!yes=>\def\theMMLpieceseparator{,\@col@amp@}, + \v!no=>\let\theMMLpieceseparator\@col@amp@, + \s!default=>\let\theMMLpieceseparator\@col@amp@, + \s!unknown=>\def\theMMLpieceseparator{\,\,\hbox{\@@MMLpieceseparator}\,\,}]} \defineXMLargument[piecewise] {\cases} @@ -855,12 +864,13 @@ \startsetups mmc:piece:start \startsavingXMLelements + \setMMLcPIECEseparator \stopsetups \startsetups mmc:piece:stop \stopsavingXMLelements \edef\ascii{\getXMLstackdata\plusone} - \@EA\XMLRtoks\@EA{\ascii\MMLcPIECEseparator\@col@amp@} + \@EA\XMLRtoks\@EA{\ascii\theMMLpieceseparator} \edef\ascii{\getXMLstackdata\plustwo} \@EA\appendtoks\@EA\mathematics\@EA{\ascii}\to\XMLRtoks \the\XMLRtoks\crcr @@ -878,19 +888,25 @@ \defineXMLcommand [factorial] {\getXMLstackdata\plustwo !} -\defineXMLcommand [divide] {\directsetup{mmc:divide}} +\defineXMLcommand [divide] [\MMLargumentprefix] [] {\directsetup{mmc:divide}} % brr not nested -\setupMMLappearance [divide] [\c!level=\!!maxcard] +\setupMMLappearance [divide] [\c!level=\!!maxcard,\c!alternative=\v!a] \startsetups mmc:divide - \increment\MMLcDIVIDElevel - \ifnum\MMLcDIVIDElevel>\@@MMLdividelevel\space - \getXMLstackdata\plustwo/\getXMLstackdata\plusthree - \else - \MMLcreset - \frac{\MMLcreset\getXMLstackdata\plustwo}{\MMLcreset\getXMLstackdata\plusthree}% - \fi - \decrement\MMLcDIVIDElevel + \startusingMMLarguments + \increment\MMLcDIVIDElevel + \doifelse \@@MMLdividealternative\v!b { + \getXMLstackdata\plustwo/\getXMLstackdata\plusthree + } { + \ifnum\MMLcDIVIDElevel>\@@MMLdividelevel\space + \getXMLstackdata\plustwo/\getXMLstackdata\plusthree + \else + \MMLcreset + \frac{\MMLcreset\getXMLstackdata\plustwo}{\MMLcreset\getXMLstackdata\plusthree}% + \fi + } + \decrement\MMLcDIVIDElevel + \stopusingMMLarguments \stopsetups % min max @@ -909,9 +925,10 @@ % minus plus -\defineXMLcommand [minus] {\directsetup{mmc:minus}} -\defineXMLcommand [plus] {\directsetup{mmc:plus}} +\defineXMLcommand [minus] {\directsetup{mmc:minus}} +\defineXMLcommand [plus] [\MMLargumentprefix] [] {\directsetup{mmc:plus}} +\setupMMLappearance [plus] [\c!alternative=\v!a] % b = no sign -> 3 1/4 \setupMMLappearance [sign] [\c!reduction=\v!yes] \startsetups mmc:minus @@ -929,49 +946,60 @@ \stopsetups \startsetups mmc:plus - \doifelse \@@MMLsignreduction \v!yes { - \setMMLcreset{fn,plus,minus,\MMLcfunctionlist,\MMLcconstructlist}% was plus/, minus/ - \doifelse{\getXMLstackname\plustwo} {apply} { - % branch needed, else (a-b) + (c-d) goes wrong - % reset check in case of (-x) + 37 - \begingroup - \dodoifelseMMCfunctioninapply \plustwo {minus} { - \ifnum\XMLstacklevel>\plustwo - \endgroup - \else + \startusingMMLarguments + \doifelse \@@MMLsignreduction \v!yes { + \setMMLcreset{fn,plus,minus,\MMLcfunctionlist,\MMLcconstructlist}% was plus/, minus/ + \doifelse{\getXMLstackname\plustwo} {apply} { + % branch needed, else (a-b) + (c-d) goes wrong + % reset check in case of (-x) + 37 + \begingroup + \dodoifelseMMCfunctioninapply \plustwo {minus} { + \ifnum\XMLstacklevel>\plustwo + \endgroup + \else + \endgroup + \MMLcreset + \fi + } { \endgroup - \MMLcreset - \fi + } + \doifelse \@@MMLplusalternative \v!b { + \getXMLstackdata\plustwo \, + } { + \flushXMLstackwith\plustwo + + } + } { - \endgroup - } - \flushXMLstackwith\plustwo + - } { - \flushXMLstackwith\plustwo { - \doifelse {\getXMLstackname\recurselevel} {apply} { - \begingroup - \dodoifelseMMCfunctioninapply \recurselevel {minus} { - \ifnum\XMLstacklevel>\plustwo +\fi + \flushXMLstackwith\plustwo { + \doifelse {\getXMLstackname\recurselevel} {apply} { + \begingroup + \dodoifelseMMCfunctioninapply \recurselevel {minus} { + \ifnum\XMLstacklevel>\plustwo +\fi + } { + \doifelse \@@MMLplusalternative \v!b { + \, % maybe 2 1/3 + } { + + + } + } + \endgroup + \MMLcreset } { + } - \endgroup - \MMLcreset - } { - + } } + } { + \ifcase\XMLstacklevel + \or + % self + \or + +\getXMLstackdata\plustwo + \else + \flushXMLstackwith\plustwo+ + \fi } - } { - \ifcase\XMLstacklevel - \or - % self - \or - +\getXMLstackdata\plustwo - \else - \flushXMLstackwith\plustwo+ - \fi - } + \stopusingMMLarguments \stopsetups % power @@ -1127,20 +1155,22 @@ % relations -\defineXMLcommand [eq] {\MMLcrelation=} -\defineXMLcommand [neq] {\MMLcrelation\neq} -\defineXMLcommand [gt] {\MMLcrelation>} -\defineXMLcommand [lt] {\MMLcrelation<} -\defineXMLcommand [geq] {\MMLcrelation\geq} -\defineXMLcommand [leq] {\MMLcrelation\leq} -\defineXMLcommand [equivalent] {\MMLcrelation\equiv} -\defineXMLcommand [approx] {\MMLcrelation\approx} -\defineXMLcommand [factorof] {\MMLcrelation\mid} +\defineXMLcommand [eq] [\MMLargumentprefix] [\c!align=] {\MMLcrelation=} +\defineXMLcommand [neq] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\neq} +\defineXMLcommand [gt] [\MMLargumentprefix] [\c!align=] {\MMLcrelation>} +\defineXMLcommand [lt] [\MMLargumentprefix] [\c!align=] {\MMLcrelation<} +\defineXMLcommand [geq] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\geq} +\defineXMLcommand [leq] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\leq} +\defineXMLcommand [equivalent] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\equiv} +\defineXMLcommand [approx] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\approx} +\defineXMLcommand [factorof] [\MMLargumentprefix] [\c!align=] {\MMLcrelation\mid} \setupMMLappearance[relation][\c!align=\v!no] \def\MMLcrelation - {\MMLcreset + {\startusingMMLarguments + \MMLcreset + \edef\@@MMLrelationalign{\executeifdefined{\MMLargumentprefix\c!align}\@@MMLrelationalign}% \processaction [\@@MMLrelationalign] [\v!last=>\let\next\lastMMLcrelation , @@ -1153,9 +1183,10 @@ \next} \def\noMMLcrelation#1% - {\flushXMLstackwith\plustwo{#1}} + {\flushXMLstackwith\plustwo{#1} + \stopusingMMLarguments} -\def\lastMMLcrelation#1% +\def\lastMMLcrelation#1% weird, probably bugged {\XMLRtoks\emptytoks \dostepwiserecurse\plustwo\XMLstacklevel\plusone {\appendetoks\noexpand\getXMLstackdata{\recurselevel}\to\XMLRtoks @@ -1164,19 +1195,23 @@ \else\ifnum\recurselevel=\numexpr\XMLstacklevel-1\relax \appendtoks\@col@amp@#1\to\XMLRtoks \fi\fi}% - \eqalign{\the\XMLRtoks\crcr}} + \eqalign{\the\XMLRtoks\crcr}% + \stopusingMMLarguments} \def\firstMMLcrelation#1% {\collectXMLstackrows\plusthree{\crcr\@col@amp@#1}% - \eqalign{\getXMLstackdata\plustwo\@col@amp@#1\the\XMLRtoks}} + \eqalign{\getXMLstackdata\plustwo\@col@amp@#1\the\XMLRtoks}% + \stopusingMMLarguments} \def\leftMMLcrelation#1% {\collectXMLstackrows\plustwo{\@col@amp@#1\crcr}% - \eqalign{\the\XMLRtoks}} + \eqalign{\the\XMLRtoks}% + \stopusingMMLarguments} \def\rightMMLcrelation#1% {\collectXMLstackrows\plustwo{\crcr#1{}\@col@amp@}% - \eqalign{\@col@amp@\the\XMLRtoks\crcr}} + \eqalign{\@col@amp@\the\XMLRtoks\crcr}% + \stopusingMMLarguments} \defineXMLcommand [becomes] {\MMLcrelation{:=}} @@ -1280,40 +1315,64 @@ % <math><apply><apply><diff/><bvar><ci>x</ci></bvar><degree>2</degree><ci>f</ci></apply><ci>a</ci></apply></math> % \stopXMLdata +% d^y/dx^2 +% +% \startXMLdata +% <math><apply><diff/> +% <bvar><ci>x</ci><cn type="integer">2</cn></bvar> +% <lambda><bvar><ci>x</ci></bvar><ci>y</ci></lambda> +% </apply></math> +% \stopXMLdata + \startsetups mmc:diff \MMLcreset \doifelse\@@MMLdiffalternative\v!a { - \XMLdoifonstackelse{bvar} { - \frac { - \XMLdoifonstackelse{degree} { - \collectXMLnamedstack{degree}\empty + \XMLdoifonstackelse{lambda} { + % a special case (mathadore/openmath) + \begingroup + \defineXMLsave[ci] + \defineXMLsave[cn] + \defineXMLprocess[lambda] + \defineXMLprocess[bvar] + \frac { + d^{\XMLfirstnamed{bvar}\XMLflush{cn}}{\XMLfirstnamed{lambda}\XMLflush{ci}} } { - \collectXMLnamedstacknamed{bvar}{degree}+ + d{\XMLfirstnamed{bvar}\XMLflush{ci}}^{\XMLfirstnamed{bvar}\XMLflush{cn}} } - \mfunction{\getXMLentity{mathematicald}} - ^{\the\XMLRtoks} - \doif\@@MMLdifflocation\v!top { - \XMLdoifonstackelse{ci} { - \XMLfirstnamed{ci} + \endgroup + } { + \XMLdoifonstackelse{bvar} { + \frac { + \XMLdoifonstackelse{degree} { + \collectXMLnamedstack{degree}\empty } { - \MMLcreset\XMLfirstnamed{apply} + \collectXMLnamedstacknamed{bvar}{degree}+ + } + \mfunction{\getXMLentity{mathematicald}} + ^{\the\XMLRtoks} + \doif\@@MMLdifflocation\v!top { + \XMLdoifonstackelse{ci} { + \XMLfirstnamed{ci} + } { + \MMLcreset\XMLfirstnamed{apply} + } } + } { + \mfunction{\getXMLentity{mathematicald}} + \begingroup + \defineXMLsave[degree] + \XMLfirstnamed{bvar} + \doifXMLdata{degree} { + ^{\XMLflush{degree}} + } + \endgroup + } + \doifnot\@@MMLdifflocation\v!top { + \left(\MMLcreset\XMLfirstnamed{apply,ci}\right) } } { - \mfunction{\getXMLentity{mathematicald}} - \begingroup - \defineXMLsave[degree] - \XMLfirstnamed{bvar} - \doifXMLdata{degree} { - ^{\XMLflush{degree}} - } - \endgroup + \flushXMLstackfrom\plustwo^\prime } - \doifnot\@@MMLdifflocation\v!top { - \left(\MMLcreset\XMLfirstnamed{apply,ci}\right) - } - } { - \flushXMLstackfrom\plustwo^\prime } } { \MMLcreset @@ -1402,8 +1461,30 @@ \defineXMLcommand [laplacian] {\getXMLentity {laplacian}\directsetup{mmc:donamedfunction}} \defineXMLcommand [ident] {\getXMLentity {identity}\directsetup{mmc:donamedfunction}} -\defineXMLcommand [domain] {\getXMLentity {domain}\directsetup{mmc:donamedfunction}} -\defineXMLcommand [codomain] {\getXMLentity {codomain}\directsetup{mmc:donamedfunction}} +% \defineXMLcommand [domain] {\getXMLentity {domain}\directsetup{mmc:donamedfunction}} +% \defineXMLcommand [codomain] {\getXMLentity {codomain}\directsetup{mmc:donamedfunction}} + +\defineXMLcommand[domain] {\directsetup{mmc:domain:action}} +\defineXMLcommand[codomain]{\directsetup{mmc:codomain:action}} + +\setupMMLappearance[domain] [symbol=] +\setupMMLappearance[codomain][symbol=] + +\startsetups mmc:domain:action + \doifelsenothing\@@MMLdomainsymbol { + \getXMLentity{domain}\directsetup{mmc:donamedfunction} + } { + \@@MMLdomainsymbol_{\flushXMLstackfrom\plustwo} + } +\stopsetups +\startsetups mmc:codomain:action + \doifelsenothing\@@MMLcodomainsymbol { + \getXMLentity{codomain}\directsetup{mmc:donamedfunction} + } { + \@@MMLcodomainsymbol_{\flushXMLstackfrom\plustwo} + } +\stopsetups + \startsetups mmc:donamedfunction % \left( @@ -1535,7 +1616,11 @@ \XMLfirstnamed{lowlimit} } } - \XMLfirstnamed{apply} + \begingroup + \MMLcreset + \directsetup{mmc:lambda:simple}% a bit of open math conversion mess + \XMLfirstnamed{apply,lambda}% lambda needed for openmath + \endgroup \stopsetups \defineXMLcommand [tendsto] [type=default] {\directsetup{mmc:tendsto}} @@ -2220,11 +2305,11 @@ \endgroup \stopsetups -\def\doMMLfiller#1% +\def\doMMLfiller#1% bugged {\pushmacro\doMMLfiller \let\doMMLfiller\gobbleoneargument \gdef\dodoMMLfiller{\disablefiller\mathematics{#1}}% - \setbox\scratchbox=\hbox + \hbox {\def\normalorfiller##1##2% {\gdef\dodoMMLfiller{\enablefiller#1}% \let\normalorfiller\gobbletwoarguments}% @@ -2342,7 +2427,7 @@ \ifdim\wd\scratchbox=\zeropoint \edef\MMLpunit{#1em}% \else - \edef\ascii{#1}\convertcommand\ascii\to\ascii + \edefconvertedargument\ascii{#1}% \convertasciiafter\doifinstringelse{em}{\ascii}{\edef\MMLpunit{#1}}{% \convertasciiafter\doifinstringelse{ex}{\ascii}{\edef\MMLpunit{#1}}{% \convertasciiafter\doifinstringelse{pt}{\ascii}{\edef\MMLpunit{#1}}{% @@ -2360,7 +2445,7 @@ \ifdim\wd\scratchbox=\zeropoint \edef\MMLpunit{#1em}% \else - \edef\ascii{#1}\convertcommand\ascii\to\ascii + \edefconvertedargument\ascii{#1}% \convertasciiafter\doifinstringelse{em}{\ascii}{\edef\MMLpunit{#1}}{% \convertasciiafter\doifinstringelse{ex}{\ascii}{\edef\MMLpunit{#1}}{% \convertasciiafter\doifinstringelse{pt}{\ascii}{\edef\MMLpunit{#1}}{% @@ -2451,6 +2536,11 @@ \let\MMLdoL\donothing \let\MMLdoR\donothing +\startsetups mmc:apply:start + \begingroup + \startsavingXMLelements +\stopsetups + \startsetups mmc:apply:stop \stopsavingXMLelements \MMLmathinner { @@ -2472,9 +2562,11 @@ \doifelse {\getXMLstackname\plusone} {apply} { % <apply> <apply> ... </apply> <ci> .. </ci> </apply> \doifelseMMCfunctioninapply \plusone {plus,minus} { +% [a] % yet incomplete and rather untested % <apply> <apply> <minus/> <tan/> <cos/> </apply> <ci>x</ci> </apply> } { +% [b] \MMLcreset } \MMLdoL @@ -2487,17 +2579,21 @@ \MMLdoR } { \doifelse {\getXMLstackname\plusone} {fn} { +% [c] % \MMLdoL/R are to be taken care of in the next setup \directsetup{mmc:fn:apply} } { \doifelse {\getXMLstackname\plusone} {csymbol} { % \MMLdoL/R are to be taken care of in the next setup +% [d] \directsetup{mmc:csymbol:apply} } { \doifelse {\getXMLstackname\plusone} {ci} { +% [e] % \MMLdoL/R are to be taken care of in the next setup \directsetup{mmc:ci:apply} } { +% [f] \MMLdoL \getXMLstackdata\plusone \MMLdoR @@ -2520,43 +2616,55 @@ \doifelse {\getXMLstackname\plusone} {ci} { \flattenXMLcontent{\getXMLstackdata\plusone} \doifsetupselse{mmc:fn:\flattenedXMLcontent} { -% \MMLdoL/MMLdoR to be handled in plugin + % \MMLdoL/MMLdoR to be handled in plugin \global\defXMLstackdata\XMLfnoperator\plusone \expanded{\endgroup\noexpand\directsetup{mmc:fn:\flattenedXMLcontent}} } { \endgroup \MMLcreset -\MMLdoL + \MMLdoL \getXMLstackdata\plusone \ifnum\XMLstacklevel>\plusone \getXMLentity{NegThinSpace} \left(\MMLcreset\flushXMLstackwith\plustwo{\MMLseparator,}\right) \fi -\MMLdoR + \MMLdoR } } { \endgroup \MMLcreset -\MMLdoL + \MMLdoL \getXMLstackdata\plusone -\MMLdoR + \MMLdoR } \stopsetups \startsetups mmc:csymbol:apply \begingroup - \startsavingXMLelements - \rawXMLstacktext\plusone % still on stack, no check, just attr test - \stopsavingXMLelements + \defineXMLsave[csymbol][definitionURL=,encoding=] + \rawXMLstackdata\plusone % was text % still on stack, no check, just attr test % \MMLdoL/MMLdoR to be handled in plugin - \doifsetupselse{mmc:csymbol:\XMLpar{csymbol}{definitionURL}{}} { - \expanded{\endgroup\noexpand\directsetup{mmc:csymbol:\XMLpar{csymbol}{definitionURL}{}}} + \lowercasestring\XMLpar{csymbol}{definitionURL}{}\to\mmcSymbolURL + \doifsetupselse{mmc:csymbol:\mmcSymbolURL} { + \expanded{\endgroup\noexpand\directsetup{mmc:csymbol:\mmcSymbolURL}} } { \endgroup - \XMLval{mmc:cs}{\XMLop{encoding}}{\firstofoneargument} + %\XMLval{mmc:cs}{\XMLop{encoding}}{\firstofoneargument}% fails when no content + \XMLval{mmc:cs}{\XMLop{encoding}}{} } \stopsetups +\defineXMLsingular + [csymbol] + [encoding=text, + definitionURL=] + {\directsetup{mmc:csymbol:apply:singular}} + +\startsetups mmc:csymbol:apply:singular + \lowercasestring\XMLpar{csymbol}{definitionURL}{}\to\mmcSymbolURL + \directsetup{mmc:csymbol:\mmcSymbolURL} +\stopsetups + \startsetups mmc:ci:apply \getXMLstackdata\plusone \ifnum\XMLstacklevel>\plusone |