mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
Fix MathML output for ' and large operators with limits (#788)
Summary: (@kevinbarabash) This diff extracts MathML builder tests out into a separate file and updates them to use jest snapshot testing. It updates the output of prime ' from using identifier nodes <mi> to operator nodes <mo>. It also updates large operators with limits to use munderover instead of msupsub. I added an option to remove unnecessary mrows to buildGroup. Right now it's only used for by groupTypes.supsub. I'll see if it can be used elsewhere (everywhere?) in a follow up PR. Test Plan: - make test w/o errors - verify mathml snapshots contain the desired markup
This commit is contained in:
committed by
Erik Demaine
parent
e00738d16f
commit
fafaf85f96
@@ -2192,50 +2192,6 @@ describe("An aligned environment", function() {
|
||||
|
||||
});
|
||||
|
||||
const getMathML = function(expr, settings) {
|
||||
const usedSettings = settings ? settings : defaultSettings;
|
||||
|
||||
expect(expr).toParse(usedSettings);
|
||||
|
||||
const built = buildMathML(parseTree(expr, usedSettings), expr, usedSettings);
|
||||
|
||||
// Strip off the surrounding <span>
|
||||
return built.children[0];
|
||||
};
|
||||
|
||||
describe("A MathML builder", function() {
|
||||
it("should generate math nodes", function() {
|
||||
const node = getMathML("x^2");
|
||||
|
||||
expect(node.type).toEqual("math");
|
||||
});
|
||||
|
||||
it("should generate appropriate MathML types", function() {
|
||||
const identifier = getMathML("x").children[0].children[0];
|
||||
expect(identifier.children[0].type).toEqual("mi");
|
||||
|
||||
const number = getMathML("1").children[0].children[0];
|
||||
expect(number.children[0].type).toEqual("mn");
|
||||
|
||||
const operator = getMathML("+").children[0].children[0];
|
||||
expect(operator.children[0].type).toEqual("mo");
|
||||
|
||||
const space = getMathML("\\;").children[0].children[0];
|
||||
expect(space.children[0].type).toEqual("mspace");
|
||||
|
||||
const text = getMathML("\\text{a}").children[0].children[0];
|
||||
expect(text.children[0].type).toEqual("mtext");
|
||||
|
||||
const textop = getMathML("\\sin").children[0].children[0];
|
||||
expect(textop.children[0].type).toEqual("mi");
|
||||
});
|
||||
|
||||
it("should generate a <mphantom> node for \\phantom", function() {
|
||||
const phantom = getMathML("\\phantom{x}").children[0].children[0];
|
||||
expect(phantom.children[0].type).toEqual("mphantom");
|
||||
});
|
||||
});
|
||||
|
||||
describe("A parser that does not throw on unsupported commands", function() {
|
||||
// The parser breaks on unsupported commands unless it is explicitly
|
||||
// told not to
|
||||
|
Reference in New Issue
Block a user