Make supsub work with empty nucleus
Auditors: emily
This commit is contained in:
parent
f58f582aa5
commit
944b55a6b0
|
@ -52,7 +52,10 @@ var groupToType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var getTypeOfGroup = function(group) {
|
var getTypeOfGroup = function(group) {
|
||||||
if (group.type === "supsub") {
|
if (group == null) {
|
||||||
|
// Like when typesetting $^3$
|
||||||
|
return groupToType.ord;
|
||||||
|
} else if (group.type === "supsub") {
|
||||||
return getTypeOfGroup(group.value.base);
|
return getTypeOfGroup(group.value.base);
|
||||||
} else if (group.type === "llap" || group.type === "rlap") {
|
} else if (group.type === "llap" || group.type === "rlap") {
|
||||||
return getTypeOfGroup(group.value);
|
return getTypeOfGroup(group.value);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
var buildTree = require("../buildTree");
|
||||||
var parseTree = require("../parseTree");
|
var parseTree = require("../parseTree");
|
||||||
|
|
||||||
describe("A parser", function() {
|
describe("A parser", function() {
|
||||||
|
@ -286,6 +287,26 @@ describe("A subscript and superscript parser", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("A subscript and superscript tree-builder", function() {
|
||||||
|
it("should not fail when there is no nucleus", function() {
|
||||||
|
expect(function() {
|
||||||
|
buildTree(parseTree("^3"));
|
||||||
|
}).not.toThrow();
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
buildTree(parseTree("_2"));
|
||||||
|
}).not.toThrow();
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
buildTree(parseTree("^3_2"));
|
||||||
|
}).not.toThrow();
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
buildTree(parseTree("_2^3"));
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("A group parser", function() {
|
describe("A group parser", function() {
|
||||||
it("should not fail", function() {
|
it("should not fail", function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user