Improve MathML for extensible arrows (#1901)

* Add padding

* Fix lint errors

* Pick up comments

* Pick up comment
This commit is contained in:
Ron Kok
2019-03-29 06:52:56 -07:00
committed by ylemkimon
parent 21f7fe85d5
commit 32b25cd5cf

View File

@@ -9,6 +9,14 @@ import * as mml from "../buildMathML";
import type {ParseNode} from "../parseNode";
// Helper function
const paddedNode = group => {
const node = new mathMLTree.MathNode("mpadded", group ? [group] : []);
node.setAttribute("width", "+0.6em");
node.setAttribute("lspace", "0.3em");
return node;
};
// Stretchy arrows with an optional argument
defineFunction({
type: "xArrow",
@@ -105,12 +113,11 @@ defineFunction({
mathmlBuilder(group, options) {
const arrowNode = stretchy.mathMLnode(group.label);
let node;
let lowerNode;
if (group.body) {
const upperNode = mml.buildGroup(group.body, options);
const upperNode = paddedNode(mml.buildGroup(group.body, options));
if (group.below) {
lowerNode = mml.buildGroup(group.below, options);
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
node = new mathMLTree.MathNode(
"munderover", [arrowNode, lowerNode, upperNode]
);
@@ -118,10 +125,13 @@ defineFunction({
node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
}
} else if (group.below) {
lowerNode = mml.buildGroup(group.below, options);
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
} else {
node = new mathMLTree.MathNode("mover", [arrowNode]);
// This should never happen.
// Parser.js throws an error if there is no argument.
node = paddedNode();
node = new mathMLTree.MathNode("mover", [arrowNode, node]);
}
return node;
},