Merge pull request #605 from gagern/overset

Builtin macros, macro arguments, \overset and \underset
This commit is contained in:
Kevin Barabash
2017-04-15 20:39:01 -04:00
committed by GitHub
12 changed files with 131 additions and 3 deletions

View File

@@ -2011,6 +2011,13 @@ describe("A macro expander", function() {
"\\bar": "a",
});
});
it("should expand the \overset macro as expected", function() {
expect("\\overset?=").toParseLike("\\mathop{=}\\limits^{?}");
expect("\\overset{x=y}{\sqrt{ab}}")
.toParseLike("\\mathop{\sqrt{ab}}\\limits^{x=y}");
expect("\\overset {?} =").toParseLike("\\mathop{=}\\limits^{?}");
});
});
describe("A parser taking String objects", function() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -26,5 +26,8 @@ for (var key in dict) {
}
});
itm.query = querystring.stringify(query);
if (itm.macros) {
itm.query += "&" + querystring.stringify(itm.macros);
}
}
module.exports = dict;

View File

@@ -74,6 +74,11 @@ Exponents: a^{a^a_a}_{a^a_a}
FractionTest: \dfrac{a}{b}\frac{a}{b}\tfrac{a}{b}\;-\dfrac12\;1\tfrac12\;{1 \atop 2}
Functions: \sin\cos\tan\ln\log
GreekLetters: \alpha\beta\gamma\omega
GroupMacros:
macros:
\startExp: e^\bgroup
\endExp: \egroup
tex: \startExp a+b\endExp
KaTeX: \KaTeX
Kern:
tex: \frac{a\kern{1em}b}{c}a\kern{1em}b\kern{1ex}c\kern{-0.25em}d
@@ -128,6 +133,13 @@ OpLimits: |
{\sin_2^2 \lim_2^2 \int_2^2 \sum_2^2}
{\displaystyle \lim_2^2 \int_2^2 \intop_2^2 \sum_2^2}
OverUnderline: x\underline{x}\underline{\underline{x}}\underline{x_{x_{x_x}}}\underline{x^{x^{x^x}}}\overline{x}\overline{x}\overline{x^{x^{x^x}}} \blue{\overline{\underline{x}}\underline{\overline{x}}}
OverUnderset: |
\begin{array}{l}
x\overset?=1\\
{\displaystyle\lim_{t\underset{>0}\to0}}\\
a+b+c+d\overset{b+c=0}\longrightarrow a+d\\
\overset { x = y } { \sqrt { a b } }
\end{array}
Phantom: \dfrac{1+\phantom{x^{\blue{2}}} = x}{1+x^{\blue{2}} = x}
PrimeSpacing: f'+f_2'+f^{f'}
PrimeSuper: x'^2+x'''^2+x'^2_3+x_3'^2

View File

@@ -47,6 +47,12 @@
if (query["errorColor"]) {
settings.errorColor = query["errorColor"];
}
var macros = {};
var macroRegex = /(?:^\?|&)(?:\\|%5[Cc])([A-Za-z]+)=([^&]*)/g;
while ((match = macroRegex.exec(window.location.search)) !== null) {
settings.macros = macros;
macros["\\" + match[1]] = decodeURIComponent(match[2]);
}
katex.render(query["tex"], mathNode, settings);
document.getElementById("pre").innerHTML = query["pre"] || "";