summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/math-ini.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/math-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/math-ini.mkiv215
1 files changed, 146 insertions, 69 deletions
diff --git a/Master/texmf-dist/tex/context/base/math-ini.mkiv b/Master/texmf-dist/tex/context/base/math-ini.mkiv
index 9dbadc11f01..f778afa08c5 100644
--- a/Master/texmf-dist/tex/context/base/math-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/math-ini.mkiv
@@ -29,11 +29,6 @@
\ifx\v!compact\undefined \def\v!compact{compact} \fi
-%D New:
-
-\let\startimath\Ustartmath \let\stopimath \Ustopmath
-\let\startdmath\Ustartdisplaymath \let\stopdmath \Ustopmath
-
%D We move these definitions into the format:
% test [[\char948 \ctxlua{tex.sprint(utf.char(948))}]]
@@ -41,16 +36,29 @@
\registerctxluafile{math-ini}{1.001}
\registerctxluafile{math-dim}{1.001}
+\registerctxluafile{math-act}{1.001}
\registerctxluafile{math-ent}{1.001}
\registerctxluafile{math-ext}{1.001}
\registerctxluafile{math-vfu}{1.001}
\registerctxluafile{math-map}{1.001}
\registerctxluafile{math-noa}{1.001}
+\registerctxluafile{math-tag}{1.001}
+
+\definesystemattribute[mathalphabet] [public]
+\definesystemattribute[mathsize] [public]
+\definesystemattribute[mathpunctuation][public]
+\definesystemattribute[mathgreek] [public]
+\definesystemattribute[mathalternate] [public]
+
+% experiment
-\definesystemattribute[mathalphabet] \chardef\mathalphabetattribute \dogetattributeid{mathalphabet}
-\definesystemattribute[mathsize] \chardef\mathsizeattribute \dogetattributeid{mathsize}
-\definesystemattribute[mathpunctuation] \chardef\mathpunctuationattribute \dogetattributeid{mathpunctuation}
-\definesystemattribute[mathgreek] \chardef\mathgreekattribute \dogetattributeid{mathgreek}
+% Normally this is applied to only one character.
+%
+% $ABC$ $\cal ABC$ $\mathaltcal ABC$
+
+\def\mathalternate#1{\ctxlua{mathematics.setalternate(0,"#1")}} % fam 0
+
+\def\mathaltcal{\mathalternate{cal}\cal} % ss01 in xits
% todo: only in mmode
@@ -61,9 +69,9 @@
\let\mathgreeknormal\mathgreekupright
\let\mathgreeknone \mathgreekdefault
-\def\setmathattribute#1#2{\ifmmode\ctxlua{mathematics.sync_a_both ("#1","#2")}\fi}
-\def\setmathalphabet #1{\ifmmode\ctxlua{mathematics.sync_a_name ("#1")}\fi}
-\def\setmathstyle #1{\ifmmode\ctxlua{mathematics.sync_a_style("#1")}\fi}
+\def\setmathattribute#1#2{\ifmmode\ctxlua{mathematics.syncboth ("#1","#2")}\fi}
+\def\setmathalphabet #1{\ifmmode\ctxlua{mathematics.syncname ("#1")}\fi}
+\def\setmathstyle #1{\ifmmode\ctxlua{mathematics.syncstyle("#1")}\fi}
\unexpanded\def\mr {\setmathattribute{regular}{tf}}
@@ -145,10 +153,10 @@
%D Helpers:
-\def\utfmathclass #1{\ctxlua{tex.sprint(mathematics.utfmathclass ("#1"))}}
-\def\utfmathstretch#1{\ctxlua{tex.sprint(mathematics.utfmathstretch("#1"))}}
-\def\utfmathcommand#1{\ctxlua{tex.sprint(mathematics.utfmathcommand("#1"))}}
-\def\utfmathfiller #1{\ctxlua{tex.sprint(mathematics.utfmathfiller ("#1"))}}
+\def\utfmathclass #1{\cldcontext{mathematics.utfmathclass (\!!bs#1\!!es)}}
+\def\utfmathstretch#1{\cldcontext{mathematics.utfmathstretch(\!!bs#1\!!es)}}
+\def\utfmathcommand#1{\cldcontext{mathematics.utfmathcommand(\!!bs#1\!!es)}}
+\def\utfmathfiller #1{\cldcontext{mathematics.utfmathfiller (\!!bs#1\!!es)}}
% \def\utfmathclassdefault #1#2{\ctxlua{
% tex.sprint(mathematics.utfmathclass("#1","#2"))
@@ -169,23 +177,23 @@
\def\@@mathboxcomm #1{\dontleavehmode\hbox\Ustartmath\mathsurround\zeropoint#1\Ustopmath}
\def\@@mathchoicecomm#1{[todo #1]}
-\chardef\mathordcode = 0 \let\mathordcomm \mathord
-\chardef\mathopcode = 1 \let\mathopcomm \mathop
-\chardef\mathbincode = 2 \let\mathbincomm \mathbin
-\chardef\mathrelcode = 3 \let\mathrelcomm \mathrel
-\chardef\mathopencode = 4 \let\mathopencomm \mathopen
-\chardef\mathclosecode = 5 \let\mathclosecomm \mathclose
-\chardef\mathpunctcode = 6 \let\mathpunctcomm \mathpunct
-\chardef\mathalphacode = 7 \let\mathalphacomm \firstofoneargument
-\chardef\mathinnercode = 0 \let\mathinnercomm \mathinner
-\chardef\mathnothingcode= 0 \let\mathnothingcomm \firstofoneargument
-\chardef\mathlimopcode = 1 \let\mathlimopcomm \@@mathlimopcomm
-\chardef\mathnolopcode = 1 \let\mathnolopcomm \@@mathnolopcomm
-\chardef\mathchoicecode = 0 \let\mathchoicecomm \@@mathchoicecomm
-\chardef\mathboxcode = 0 \let\mathboxcomm \@@mathboxcomm
-
-\chardef\mathaccentcode = 8
-\chardef\mathradicalcode= 9
+\setnewconstant\mathordcode 0 \let\mathordcomm \mathord
+\setnewconstant\mathopcode 1 \let\mathopcomm \mathop
+\setnewconstant\mathbincode 2 \let\mathbincomm \mathbin
+\setnewconstant\mathrelcode 3 \let\mathrelcomm \mathrel
+\setnewconstant\mathopencode 4 \let\mathopencomm \mathopen
+\setnewconstant\mathclosecode 5 \let\mathclosecomm \mathclose
+\setnewconstant\mathpunctcode 6 \let\mathpunctcomm \mathpunct
+\setnewconstant\mathalphacode 7 \let\mathalphacomm \firstofoneargument
+\setnewconstant\mathinnercode 0 \let\mathinnercomm \mathinner
+\setnewconstant\mathnothingcode 0 \let\mathnothingcomm \firstofoneargument
+\setnewconstant\mathlimopcode 1 \let\mathlimopcomm \@@mathlimopcomm
+\setnewconstant\mathnolopcode 1 \let\mathnolopcomm \@@mathnolopcomm
+\setnewconstant\mathchoicecode 0 \let\mathchoicecomm \@@mathchoicecomm
+\setnewconstant\mathboxcode 0 \let\mathboxcomm \@@mathboxcomm
+
+\setnewconstant\mathaccentcode 8
+\setnewconstant\mathradicalcode 9
\def\puremathcode#1{\the\csname math#1code\endcsname}
\def\puremathcomm#1{\csname math#1comm\endcsname}
@@ -250,10 +258,10 @@
{\normalhbox\bgroup\mf
\dowithnextbox{\flushnextbox\egroup}\normalhbox}
-\def\mbox
+\def\mbox % we cannot add \dontleavehmode ... else no \setbox0\mbox possible
{\ifmmode\normalmbox\else\normalhbox\fi}
-\def\enablembox
+\unexpanded\def\enablembox
{\appendtoks
\ifx\normalhbox\undefined\let\normalhbox\hbox\fi
\let\hbox\mbox
@@ -342,70 +350,133 @@
%D The result is as expected: the first line typesets ok, while the second
%D one triggers an error message.
+\setnewconstant\activemathcharcode "8000
+
+\newtoks\activatedmathcharacters
+
+\def\activatemathcharacter#1%
+ {\appendtoks
+ \global\mathcode#1=\activemathcharcode
+ \to \activatedmathcharacters}
+
+\def\activatemathcharacters
+ {\the\activatedmathcharacters}
+
+\setnewconstant\primeasciicode 39 % '
+
+\activatemathcharacter\circumflexasciicode
+\activatemathcharacter\underscoreasciicode
+\activatemathcharacter\ampersandasciicode
+\activatemathcharacter\primeasciicode
+
+% not used:
+%
+% \mathcode\spaceasciicode\activemathcharcode
+%
+% not used:
+%
+% \bgroup
+% \catcode\underscoreasciicode\activecatcode
+% \doglobal\appendtoks
+% \mathcode\underscoreasciicode\activemathcharcode
+% \let_\activemathunderscore
+% \to \everymathematics
+% \egroup
+%
+% plain tex legacy:
+
+\bgroup
+ \catcode\primeasciicode\activecatcode
+ \doglobal\appendtoks
+ \let'\domathprime
+ \to \everymathematics
+\egroup
+
\newtoks\everydonknuthmode
\newtoks\everynonknuthmode
-\def\nonknuthmode{\the\everynonknuthmode\let\nonknuthmode\relax}
-\def\donknuthmode{\the\everydonknuthmode}
+\newconditional \knuthmode
+
+\def\nonknuthmode
+ {\pushcatcodetable
+ \setcatcodetable\ctxcatcodes
+ \the\everynonknuthmode
+ \let\nonknuthmode\relax
+ \popcatcodetable}
-\ifdefined\normalsuber\else \def\normalsuber{_} \fi
-\ifdefined\normalsuper\else \def\normalsuper{^} \fi
-\ifdefined\normalaltab\else \def\normalaltab{&} \fi
+\def\donknuthmode
+ {\pushcatcodetable
+ \setcatcodetable\ctxcatcodes
+ \the\everydonknuthmode
+ \popcatcodetable}
\bgroup
- \catcode`_=\active
- \catcode`^=\active
- \catcode`&=\active
+ \catcode\underscoreasciicode\activecatcode
+ \catcode\circumflexasciicode\activecatcode
+ \catcode\ampersandasciicode \activecatcode
\global \everynonknuthmode {\appendtoks
- \let_\normalsuber
- \let^\normalsuper
- \let&\normalaltab
+ \let_\normalsubscript
+ \let^\normalsuperscript
+ \let&\normalmathaligntab % use \def when it's \aligntab
\to \everymathematics}
\egroup
\appendtoks
- \mathcode`_="8000
- \mathcode`^="8000
- \mathcode`&="8000
- \catcode`_=\@@other
- \catcode`^=\@@other
- \catcode`&=\@@other
+ \setfalse\knuthmode
+ \catcode\underscoreasciicode\othercatcode
+ \catcode\circumflexasciicode\othercatcode
+ \catcode\ampersandasciicode \othercatcode
\to \everynonknuthmode
\appendtoks
- \catcode`_=\@@subscript
- \catcode`^=\@@superscript
- \catcode`&=\@@alignment
+ \settrue\knuthmode
+ \catcode\underscoreasciicode\subscriptcatcode
+ \catcode\circumflexasciicode\superscriptcatcode
+ \catcode\ampersandasciicode \alignmentcatcode
\to \everydonknuthmode
\appendtoks
\startextendcatcodetable\ctxcatcodes
- \catcode`_=\@@other
- \catcode`^=\@@other
- \catcode`&=\@@other
+ \catcode\underscoreasciicode\othercatcode
+ \catcode\circumflexasciicode\othercatcode
+ \catcode\ampersandasciicode \othercatcode
\stopextendcatcodetable
\to \everynonknuthmode
\appendtoks
\startextendcatcodetable\ctxcatcodes
- \catcode`_=\@@subscript
- \catcode`^=\@@superscript
- \catcode`&=\@@alignment
+ \catcode\underscoreasciicode\subscriptcatcode
+ \catcode\circumflexasciicode\superscriptcatcode
+ \catcode\ampersandasciicode \alignmentcatcode
\stopextendcatcodetable
\to \everydonknuthmode
-%D Needed for unicode:
+% \def\prefermathcatcodes
+% {\catcode\underscoreasciicode\subscriptcatcode
+% \catcode\circumflexasciicode\superscriptcatcode
+% \catcode\ampersandasciicode \alignmentcatcode}
+
+%D Even more drastic:
-\def\nulloperator{\mathortext{\mathop{\null}}{\null}}
+\unexpanded\def\asciimode
+ {\catcodetable\txtcatcodes
+ \nonknuthmode}
-%D To be dealt with ...
+\unexpanded\def\startasciimode
+ {\pushcatcodetable
+ \catcodetable\txtcatcodes
+ \nonknuthmode}
-\mathcode`\ ="8000 % \space
-\mathcode`\'="8000 % ^\prime
-\mathcode`\_="8000 % \_
+\unexpanded\def\stopasciimode
+ {\popcatcodetable
+ \ifconditional\knuthmode\else\donknuthmode\fi}
+
+%D Needed for unicode:
+
+\def\nulloperator{\mathortext{\mathop{\emptyhbox}}{\emptyhbox}}
%D \macros
%D {setupmathematics}
@@ -428,8 +499,8 @@
\appendtoks
\doifelse{\mathematicsparameter\v!compact}\v!yes
- {\ctxlua{fonts.vf.math.optional=true}}
- {\ctxlua{fonts.vf.math.optional=false}}%
+ {\ctxlua{fonts.handlers.vf.math.optional=true}}
+ {\ctxlua{fonts.handlers.vf.math.optional=false}}%
\to \everysetupmathematics
\setupmathematics
@@ -654,4 +725,10 @@
\def\mathoptext#1{\mathop{\text{#1}}}
+% for a while:
+
+\ifnum\luatexversion>65
+ \def\Umathbotaccent{\Umathaccent bottom }
+\fi
+
\protect \endinput