summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/math-fen.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/math-fen.mkiv')
-rw-r--r--tex/context/base/mkiv/math-fen.mkiv64
1 files changed, 55 insertions, 9 deletions
diff --git a/tex/context/base/mkiv/math-fen.mkiv b/tex/context/base/mkiv/math-fen.mkiv
index 320dffeb8..a32ea410e 100644
--- a/tex/context/base/mkiv/math-fen.mkiv
+++ b/tex/context/base/mkiv/math-fen.mkiv
@@ -15,6 +15,14 @@
\unprotect
+% maybe always "method=auto" for:
+%
+% \switchtobodyfont[cambria]
+% \ruledhbox{$f(x)$}
+% \ruledhbox{\mathdelimitersmode6$f\left(x\right)$}
+% \ruledhbox{\mathdelimitersmode7$f\left(x\right)$}
+% \ruledhbox{$f\left(\frac{1}{x}\right)$}
+
% todo: mathstyle
% \definemathfence [fancybracket] [bracket] [command=yes,color=blue]
@@ -38,12 +46,14 @@
\let\setupmathfences\setupmathfence
\setupmathfences
- [\c!left=,
+ [\c!method=, % maybe always \v!auto
+ \c!left=,
\c!right=,
\c!middle=,
\c!mathstyle=,
\c!color=,
\c!command=,
+ \c!mathclass=,
\c!factor=\v!auto]
\appendtoks
@@ -61,17 +71,40 @@
{\ifx#1\empty
#2.%
\else
+ \edef\p_mathclass{\mathfenceparameter\c!mathclass}%
\edef\p_factor{\mathfenceparameter\c!factor}%
\ifx\p_factor\empty
- #2%
+ \ifx\p_mathclass\empty
+ #2%
+ \else
+ #3%
+ \s!class\p_mathclass
+ \fi
\else\ifx\p_factor\v!auto
- #2%
+ \ifx\p_mathclass\empty
+ #2%
+ \else
+ #3%
+ \s!class\p_mathclass
+ \fi
\else\ifx\p_factor\v!none
- #3\s!height\zeropoint\s!depth\zeropoint\s!axis
- #2%
+ #3%
+ \s!height\zeropoint
+ \s!depth\zeropoint
+ \ifx\p_mathclass\empty\else
+ \s!class\p_mathclass
+ \fi
+ \s!axis
+ % #2%
\else
\scratchdimen\dimexpr\p_factor\bodyfontsize/2\relax
- #3\s!height\scratchdimen\s!depth\scratchdimen\s!axis
+ #3%
+ \s!height\scratchdimen
+ \s!depth\scratchdimen
+ \ifx\p_mathclass\empty\else
+ \s!class\p_mathclass
+ \fi
+ \s!axis
\fi\fi\fi
\Udelimiter#4\fam#1\relax
\fi}
@@ -94,7 +127,7 @@
\def\math_fenced_middle
{\edef\p_middle
- {\mathfenceparameter\c!middle}%
+ {\mathfenceparameter\c!middle}%
\mskip\thinmuskip
\math_fenced_color_push
% \normalmiddle\ifx\p_middle\empty.\else\Udelimiter\plusfour\fam\p_middle\relax\fi
@@ -771,14 +804,14 @@
\unexpanded\def\stopcheckedfences
{\endgroup}
-\appendtoks
+% \appendtoks
% maybe: safeguard against overloading
%
% \let\left \math_fences_used_left
% \let\right \math_fences_used_right
% \let\middle \math_fences_used_middle
% \let\leftorright\math_fences_used_both
-\to \everymathematics
+% \to \everymathematics
\appendtoks
\ifx\currentmathfence\empty
@@ -786,6 +819,19 @@
\fi
\to \everysetupmathfence
+\newconstant\c_math_fences_delimiters_mode \c_math_fences_delimiters_mode"16 % \numexpr"02+"04+"10\relax
+
+%unexpanded\def\enableautofencemode {\mathdelimitersmode\plussix} % the shift (1) is too fragile
+\unexpanded\def\enableautofencemode {\mathdelimitersmode\c_math_fences_delimiters_mode}
+
+\unexpanded\def\disableautofencemode{\mathdelimitersmode\zerocount}
+
+\appendtoks
+ \ifx\currentmathfence\empty
+ \doifelse{\mathfenceparameter\c!method}\v!auto\enableautofencemode\disableautofencemode
+ \fi
+\to \everysetupmathfence
+
% some day default: \setupmathfences[\c!state=\v!auto]
%D The next characters were used for constructing nicer extensibles but