Use mpadded for \raisebox MathML (#876)

* Use mpadded for \raisebox MathML

* Add MathML snapshot
This commit is contained in:
Ron Kok
2017-09-13 18:29:09 -07:00
committed by Kevin Barabash
parent dbc5a74ebd
commit a358c5a94c
5 changed files with 35 additions and 5 deletions

View File

@@ -1640,7 +1640,7 @@ groupTypes.raisebox = function(group, options) {
value: [{ value: [{
type: "text", type: "text",
value: { value: {
body: group.value.body, body: group.value.value,
font: "mathrm", // simulate \textrm font: "mathrm", // simulate \textrm
}, },
}], }],

View File

@@ -604,9 +604,13 @@ groupTypes.mclass = function(group, options) {
return new mathMLTree.MathNode("mstyle", inner); return new mathMLTree.MathNode("mstyle", inner);
}; };
// Transforms (translation/rotation) don't seem to have a representation groupTypes.raisebox = function(group, options) {
// in MathML, so just treat them like \text{...} const node = new mathMLTree.MathNode(
groupTypes.raisebox = groupTypes.text; "mpadded", [buildGroup(group.value.body, options)]);
const dy = group.value.dy.value.number + group.value.dy.value.unit;
node.setAttribute("voffset", dy);
return node;
};
/** /**
* Takes a list of nodes, builds them, and returns a list of the generated * Takes a list of nodes, builds them, and returns a list of the generated

View File

@@ -673,6 +673,7 @@ defineFunction(["\\raisebox"], {
return { return {
type: "raisebox", type: "raisebox",
dy: amount, dy: amount,
body: ordargument(body), body: body,
value: ordargument(body),
}; };
}); });

View File

@@ -74,6 +74,27 @@ exports[`A MathML builder should make prime operators into <mo> nodes 1`] = `
`; `;
exports[`A MathML builder should use <mpadded> for raisebox 1`] = `
<math>
<semantics>
<mrow>
<mpadded voffset="0.25em">
<mrow>
<mtext>
b
</mtext>
</mrow>
</mpadded>
</mrow>
<annotation encoding="application/x-tex">
\\raisebox{0.25em}{b}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <msupsub> for regular operators 1`] = ` exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
<math> <math>

View File

@@ -50,4 +50,8 @@ describe("A MathML builder", function() {
it('should use <msupsub> for regular operators', () => { it('should use <msupsub> for regular operators', () => {
expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot(); expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot();
}); });
it('should use <mpadded> for raisebox', () => {
expect(getMathML("\\raisebox{0.25em}{b}")).toMatchSnapshot();
});
}); });