mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 12:18:39 +00:00
Support \mathop, \mathrel, \mathbin, \mathpunct, etc. class commands.
These commands set their arguments in a given TeX math class. Use the existing "op" type for \mathop (to support \limits); introduce a new "mclass" type for the other classes. Fixes #482. Tests borrowed from #485 (cbreeden).
This commit is contained in:
@@ -316,7 +316,7 @@ groupTypes.spacing = function(group) {
|
||||
return node;
|
||||
};
|
||||
|
||||
groupTypes.op = function(group) {
|
||||
groupTypes.op = function(group, options) {
|
||||
var node;
|
||||
|
||||
// TODO(emily): handle big operators using the `largeop` attribute
|
||||
@@ -325,6 +325,10 @@ groupTypes.op = function(group) {
|
||||
// This is a symbol. Just add the symbol.
|
||||
node = new mathMLTree.MathNode(
|
||||
"mo", [makeText(group.value.body, group.mode)]);
|
||||
} else if (group.value.value) {
|
||||
// This is an operator with children. Add them.
|
||||
node = new mathMLTree.MathNode(
|
||||
"mo", buildExpression(group.value.value, options));
|
||||
} else {
|
||||
// This is a text operator. Add all of the characters from the
|
||||
// operator's name.
|
||||
@@ -475,6 +479,11 @@ groupTypes.phantom = function(group, options) {
|
||||
return new mathMLTree.MathNode("mphantom", inner);
|
||||
};
|
||||
|
||||
groupTypes.mclass = function(group, options) {
|
||||
var inner = buildExpression(group.value.value, options);
|
||||
return new mathMLTree.MathNode("mstyle", inner);
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a list of nodes, builds them, and returns a list of the generated
|
||||
* MathML nodes. A little simpler than the HTML version because we don't do any
|
||||
|
Reference in New Issue
Block a user