Support \bgroup and \egroup

This commit is contained in:
Martin von Gagern
2017-01-06 23:34:29 +01:00
parent 96d1e6aea7
commit e2763a3007
6 changed files with 21 additions and 0 deletions

View File

@@ -8,6 +8,13 @@ function defineMacro(name, body) {
module.exports[name] = body;
}
//////////////////////////////////////////////////////////////////////
// basics
defineMacro("\\bgroup", "{");
defineMacro("\\egroup", "}");
defineMacro("\\begingroup", "{");
defineMacro("\\endgroup", "}");
//////////////////////////////////////////////////////////////////////
// amsmath.sty

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 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

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"] || "";