summaryrefslogtreecommitdiff
path: root/tex/context/base/math-for.mkiv
blob: 16cab9a65875d0a0cce7081bb5c30e966482e1aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%D \module
%D   [       file=strc-mat,
%D        version=2008.10.20,
%D          title=\CONTEXT\ Structure Macros,
%D       subtitle=Math Numbering,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Structure Macros / Math Formulas}

%D This module only provides the code for defining formulas and
%D fetching parameters. The action takes place later.

\unprotect

\let\currentformula\s!unknown

\def\formulaparameter    #1{\csname\doformulaparameter{\??fm\currentformula}#1\endcsname}
\def\formulaparameterhash#1{\doformulaparameterhash   {\??fm\currentformula}#1}

\def\doformulaparameter    #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doformulaparentparameter    \csname#1\s!parent\endcsname#2\fi}
\def\doformulaparameterhash#1#2{\ifcsname#1#2\endcsname  #1\else\expandafter\doformulaparentparameterhash\csname#1\s!parent\endcsname#2\fi}

\def\detokenizedformulaparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??fm\currentformula#1\endcsname}}

\def\doformulaparentparameter    #1#2{\ifx#1\relax\s!empty\else\doformulaparameter    #1#2\fi}
\def\doformulaparentparameterhash#1#2{\ifx#1\relax        \else\doformulaparameterhash#1#2\fi}

\def\dosetformulaattributes#1#2% style color
  {\edef\fontattributehash {\formulaparameterhash#1}%
   \edef\colorattributehash{\formulaparameterhash#2}%
   \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
   \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}

\def\getformulaparameters{\getparameters[\??fm]}

%D \macros
%D   {setupformulas}

\newtoks \everysetupformulas

\unexpanded\def\setupformulas
  {\dodoubleempty\dosetupformulas}

\def\dosetupformulas[#1][#2]%
  {\ifsecondargument
     \edef\currentformula{#1}%
     \getparameters[\??fm#1][#2]%
   \else
%      \let\currentformula\v!formula % hm
     \let\currentformula\empty
     \getparameters[\??fm][#1]%
   \fi
   \the\everysetupformulas
   \let\currentformula\empty}

%D Not yet cleanup up:

%D \macros
%D   {setuptextformulas}
%D
%D This command sets up in||line math. Most features deals
%D with grid snapping and are experimental.

\newtoks \everysetuptextformulas

\unexpanded\def\setuptextformulas
  {\dosingleempty\dosetuptextformulas}

\def\dosetuptextformulas[#1]%
  {\getparameters[\??mt][#1]%
   \the\everysetuptextformulas}

\protect \endinput