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:
Eddie Kohler
2016-11-23 08:52:10 -05:00
parent 982e7be597
commit 6bb62b11b4
8 changed files with 65 additions and 37 deletions

View File

@@ -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