diff --git a/src/buildHTML.js b/src/buildHTML.js index 5bd163fd..631f5f19 100644 --- a/src/buildHTML.js +++ b/src/buildHTML.js @@ -1640,7 +1640,7 @@ groupTypes.raisebox = function(group, options) { value: [{ type: "text", value: { - body: group.value.body, + body: group.value.value, font: "mathrm", // simulate \textrm }, }], diff --git a/src/buildMathML.js b/src/buildMathML.js index 5b27200a..c2607b13 100644 --- a/src/buildMathML.js +++ b/src/buildMathML.js @@ -604,9 +604,13 @@ groupTypes.mclass = function(group, options) { return new mathMLTree.MathNode("mstyle", inner); }; -// Transforms (translation/rotation) don't seem to have a representation -// in MathML, so just treat them like \text{...} -groupTypes.raisebox = groupTypes.text; +groupTypes.raisebox = function(group, options) { + const node = new mathMLTree.MathNode( + "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 diff --git a/src/functions.js b/src/functions.js index 4545070f..91c6a542 100644 --- a/src/functions.js +++ b/src/functions.js @@ -673,6 +673,7 @@ defineFunction(["\\raisebox"], { return { type: "raisebox", dy: amount, - body: ordargument(body), + body: body, + value: ordargument(body), }; }); diff --git a/test/__snapshots__/mathml-spec.js.snap b/test/__snapshots__/mathml-spec.js.snap index de5a4589..2b52ca14 100644 --- a/test/__snapshots__/mathml-spec.js.snap +++ b/test/__snapshots__/mathml-spec.js.snap @@ -74,6 +74,27 @@ exports[`A MathML builder should make prime operators into nodes 1`] = ` `; +exports[`A MathML builder should use for raisebox 1`] = ` + + + + + + + + b + + + + + + \\raisebox{0.25em}{b} + + + + +`; + exports[`A MathML builder should use for regular operators 1`] = ` diff --git a/test/mathml-spec.js b/test/mathml-spec.js index d9e00b91..6565c099 100644 --- a/test/mathml-spec.js +++ b/test/mathml-spec.js @@ -50,4 +50,8 @@ describe("A MathML builder", function() { it('should use for regular operators', () => { expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot(); }); + + it('should use for raisebox', () => { + expect(getMathML("\\raisebox{0.25em}{b}")).toMatchSnapshot(); + }); });