mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 20:48:41 +00:00
Make supsub work with empty nucleus
Auditors: emily
This commit is contained in:
@@ -52,7 +52,10 @@ var groupToType = {
|
||||
};
|
||||
|
||||
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);
|
||||
} else if (group.type === "llap" || group.type === "rlap") {
|
||||
return getTypeOfGroup(group.value);
|
||||
|
@@ -1,3 +1,4 @@
|
||||
var buildTree = require("../buildTree");
|
||||
var parseTree = require("../parseTree");
|
||||
|
||||
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() {
|
||||
it("should not fail", function() {
|
||||
expect(function() {
|
||||
|
Reference in New Issue
Block a user